mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
Updating workflows and add psalm (#741)
* Updating workflows and add psalm * Normalize composer * Fixed CS
This commit is contained in:
parent
d8ae00d23c
commit
12ed8aae43
16
.github/main.workflow
vendored
16
.github/main.workflow
vendored
@ -1,16 +0,0 @@
|
||||
workflow "Main" {
|
||||
on = "push"
|
||||
resolves = ["Roave BC Check", "PHPStan"]
|
||||
}
|
||||
|
||||
action "Roave BC Check" {
|
||||
uses = "docker://nyholm/roave-bc-check-ga"
|
||||
secrets = ["GITHUB_TOKEN"]
|
||||
args = ""
|
||||
}
|
||||
|
||||
action "PHPStan" {
|
||||
uses = "docker://oskarstark/phpstan-ga"
|
||||
secrets = ["GITHUB_TOKEN"]
|
||||
args = "analyse"
|
||||
}
|
70
.github/workflows/php.yml
vendored
70
.github/workflows/php.yml
vendored
@ -1,50 +1,54 @@
|
||||
name: PHP Composer
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'master', '2.x' ]
|
||||
pull_request:
|
||||
branches: [ 'master', '2.x' ]
|
||||
push: ~
|
||||
pull_request: ~
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
php:
|
||||
strategy:
|
||||
matrix:
|
||||
# https://github.com/marketplace/actions/setup-php-action#github-hosted-runners
|
||||
operating-system: [ 'ubuntu-latest' ]
|
||||
php-versions: [ '7.3', '7.4', '8.0' ]
|
||||
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
runs-on: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: none
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit, phpstan
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
- name: PHP Unit Tests
|
||||
run: vendor/bin/phpunit
|
||||
|
||||
- name: PHP Unit Tests
|
||||
run: composer test
|
||||
lowest:
|
||||
name: Lowest deps
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@2.9.0
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: pcov
|
||||
|
||||
- name: PHP Stan
|
||||
if: matrix.php-versions == '7.3'
|
||||
run: |
|
||||
phpstan --version
|
||||
phpstan analyse
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Scrunitizer CI
|
||||
if: matrix.php-versions == '7.3'
|
||||
run: |
|
||||
wget https://scrutinizer-ci.com/ocular.phar
|
||||
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml
|
||||
- name: Download dependencies
|
||||
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable --prefer-lowest
|
||||
|
||||
- name: Run tests
|
||||
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
|
||||
|
||||
- name: Scrunitizer CI
|
||||
run: |
|
||||
wget https://scrutinizer-ci.com/ocular.phar
|
||||
php ocular.phar code-coverage:upload --format=php-clover coverage.xml
|
||||
|
88
.github/workflows/static.yml
vendored
Normal file
88
.github/workflows/static.yml
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
name: Static analysis
|
||||
|
||||
on:
|
||||
pull_request: ~
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
phpstan:
|
||||
name: PHPStan
|
||||
runs-on: Ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@2.9.0
|
||||
with:
|
||||
php-version: '7.4'
|
||||
coverage: none
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Download dependencies
|
||||
run: composer update --no-interaction --prefer-dist
|
||||
|
||||
- name: PHPStan
|
||||
uses: docker://oskarstark/phpstan-ga:0.12.70
|
||||
with:
|
||||
entrypoint: /composer/vendor/bin/phpstan
|
||||
args: analyze --no-progress
|
||||
|
||||
php-cs-fixer:
|
||||
name: PHP-CS-Fixer
|
||||
runs-on: Ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: PHP-CS-Fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga:2.18.2
|
||||
with:
|
||||
args: --dry-run --diff-format udiff
|
||||
|
||||
psalm:
|
||||
name: Psalm
|
||||
runs-on: Ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Psalm
|
||||
uses: docker://vimeo/psalm-github-actions:4.4.1
|
||||
with:
|
||||
args: --no-progress --show-info=false --stats
|
||||
|
||||
roave-bc-check:
|
||||
name: Roave BC Check
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Roave BC Check
|
||||
uses: docker://nyholm/roave-bc-check-ga
|
||||
|
||||
composer-normalize:
|
||||
name: Composer Normalize
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@2.9.0
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
tools: composer-normalize
|
||||
|
||||
- name: Validate composer.json
|
||||
run: composer validate
|
||||
|
||||
- name: Normalize composer.json
|
||||
run: composer-normalize --dry-run
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@ phpunit.phar
|
||||
phpunit.xml
|
||||
modd.conf
|
||||
.phpunit.result.cache
|
||||
.php_cs.cache
|
||||
.phpunit.result.cache
|
||||
|
@ -1,19 +1,35 @@
|
||||
{
|
||||
"name": "mailgun/mailgun-php",
|
||||
"description": "The Mailgun SDK provides methods for all API functions.",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Travis Swientek",
|
||||
"email": "travis@mailgunhq.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"psr/http-client": "^1.0.1",
|
||||
"php-http/multipart-stream-builder": "^1.1.2",
|
||||
"php-http/client-common": "^2.2.1",
|
||||
"php-http/discovery": "^1.9.1",
|
||||
"php-http/multipart-stream-builder": "^1.1.2",
|
||||
"psr/http-client": "^1.0.1",
|
||||
"webmozart/assert": "^1.9.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"php-http/guzzle7-adapter": "^0.1.1",
|
||||
"nyholm/nsa": "^1.2.1",
|
||||
"nyholm/psr7": "^1.3.1",
|
||||
"nyholm/nsa": "^1.2.1"
|
||||
"php-http/guzzle7-adapter": "^0.1.1",
|
||||
"phpunit/phpunit": "^9.3"
|
||||
},
|
||||
"suggest": {
|
||||
"guzzlehttp/psr7": "PSR-7 message implementation that also provides common utility methods",
|
||||
"php-http/curl-client": "cURL client for PHP-HTTP"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@ -24,25 +40,5 @@
|
||||
"psr-4": {
|
||||
"Mailgun\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"php-http/curl-client": "cURL client for PHP-HTTP",
|
||||
"guzzlehttp/psr7": "PSR-7 message implementation that also provides common utility methods"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Travis Swientek",
|
||||
"email": "travis@mailgunhq.com"
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpunit",
|
||||
"test-coverage": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
88
psalm.baseline.xml
Normal file
88
psalm.baseline.xml
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
|
||||
<file src="src/Api/Domain.php">
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$params</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
<RedundantCondition occurrences="5">
|
||||
<code>boolean</code>
|
||||
<code>boolean</code>
|
||||
<code>nullOrString</code>
|
||||
<code>stringNotEmpty</code>
|
||||
<code>stringNotEmpty</code>
|
||||
</RedundantCondition>
|
||||
<TypeDoesNotContainNull occurrences="1">
|
||||
<code>nullOrString</code>
|
||||
</TypeDoesNotContainNull>
|
||||
</file>
|
||||
<file src="src/Api/HttpApi.php">
|
||||
<ParamNameMismatch occurrences="1">
|
||||
<code>$class</code>
|
||||
</ParamNameMismatch>
|
||||
</file>
|
||||
<file src="src/Api/Ip.php">
|
||||
<RedundantCondition occurrences="1">
|
||||
<code>boolean</code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="src/Api/MailingList.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$this->hydrator</code>
|
||||
</PossiblyNullArgument>
|
||||
<RedundantCondition occurrences="1">
|
||||
<code>isArray</code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="src/Api/MailingList/Member.php">
|
||||
<RedundantCondition occurrences="2">
|
||||
<code>isArray</code>
|
||||
<code>isArray</code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="src/Api/Message.php">
|
||||
<RedundantCondition occurrences="3">
|
||||
<code>nullOrIsArray</code>
|
||||
<code>string</code>
|
||||
<code>string</code>
|
||||
</RedundantCondition>
|
||||
<TypeDoesNotContainNull occurrences="1">
|
||||
<code>nullOrIsArray</code>
|
||||
</TypeDoesNotContainNull>
|
||||
</file>
|
||||
<file src="src/Api/Pagination.php">
|
||||
<PossiblyNullArgument occurrences="4">
|
||||
<code>$response->getFirstUrl()</code>
|
||||
<code>$response->getLastUrl()</code>
|
||||
<code>$response->getNextUrl()</code>
|
||||
<code>$response->getPreviousUrl()</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Api/Route.php">
|
||||
<RedundantCondition occurrences="1">
|
||||
<code>isArray</code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="src/Api/Suppression/Complaint.php">
|
||||
<PossiblyUndefinedVariable occurrences="1">
|
||||
<code>$params</code>
|
||||
</PossiblyUndefinedVariable>
|
||||
</file>
|
||||
<file src="src/Assert.php">
|
||||
<MissingImmutableAnnotation occurrences="1">
|
||||
<code>protected static function reportInvalidArgument($message)</code>
|
||||
</MissingImmutableAnnotation>
|
||||
</file>
|
||||
<file src="src/HttpClient/Plugin/HistoryTrait.php">
|
||||
<UnrecognizedStatement occurrences="1"/>
|
||||
</file>
|
||||
<file src="src/Mailgun.php">
|
||||
<PossiblyNullArgument occurrences="1">
|
||||
<code>$this->apiKey</code>
|
||||
</PossiblyNullArgument>
|
||||
</file>
|
||||
<file src="src/Message/BatchMessage.php">
|
||||
<PossiblyUndefinedMethod occurrences="1">
|
||||
<code>getId</code>
|
||||
</PossiblyUndefinedMethod>
|
||||
</file>
|
||||
</files>
|
16
psalm.xml
Normal file
16
psalm.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="3"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
errorBaseline="psalm.baseline.xml"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
@ -92,7 +92,7 @@ abstract class HttpApi
|
||||
case 402:
|
||||
throw HttpClientException::requestFailed($response);
|
||||
case 403:
|
||||
throw HttpClientException::forbidden($response);
|
||||
throw HttpClientException::forbidden($response);
|
||||
case 404:
|
||||
throw HttpClientException::notFound($response);
|
||||
case 413:
|
||||
|
@ -19,7 +19,7 @@ class UnsubscribeTest extends BaseModelTest
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_gets_empty_list_of_tags_by_default()
|
||||
public function itGetsEmptyListOfTagsByDefault()
|
||||
{
|
||||
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net']);
|
||||
$this->assertEquals([], $unsubscribe->getTags());
|
||||
@ -28,7 +28,7 @@ class UnsubscribeTest extends BaseModelTest
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_gets_tags()
|
||||
public function itGetsTags()
|
||||
{
|
||||
$tags = ['tag1', 'tag2'];
|
||||
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net', 'tags' => $tags]);
|
||||
|
Loading…
Reference in New Issue
Block a user