From e03d986455952f0a6fb0c73c78d44ba90f63ac39 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:24:34 +0100 Subject: [PATCH 1/7] Add composer normalize --- composer.json | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 9adab22..4e03098 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,12 @@ { "name": "php-http/httplug", "description": "HTTPlug, the HTTP client abstraction for PHP", - "license": "MIT", - "keywords": ["http", "client"], + "keywords": [ + "http", + "client" + ], "homepage": "http://httplug.io", + "license": "MIT", "authors": [ { "name": "Eric GELOEN", @@ -11,18 +14,25 @@ }, { "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "require": { "php": "^7.0", - "psr/http-message": "^1.0", + "php-http/promise": "^1.0", "psr/http-client": "^1.0", - "php-http/promise": "^1.0" + "psr/http-message": "^1.0" }, "require-dev": { - "phpspec/phpspec": "^4.3.4|^5.0|^6.0", - "friends-of-phpspec/phpspec-code-coverage" : "^4.1" + "ergebnis/composer-normalize": "^2.1", + "friends-of-phpspec/phpspec-code-coverage": "^4.1", + "phpspec/phpspec": "^4.3.4 || ^5.0 || ^6.0" + }, + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } }, "autoload": { "psr-4": { @@ -32,10 +42,5 @@ "scripts": { "test": "vendor/bin/phpspec run", "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" - }, - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } } } From efb32e146a3ef85b696c9b26eacbd973eeb43a19 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:28:24 +0100 Subject: [PATCH 2/7] Add phpstan config --- .gitattributes | 30 +++++++++++++++--------------- phpstan-baseline.neon | 22 ++++++++++++++++++++++ phpstan.neon.dist | 7 +++++++ 3 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes index c47225a..84790d1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,15 @@ -.editorconfig export-ignore -.gitattributes export-ignore -/.github/ export-ignore -.gitignore export-ignore -/.php_cs export-ignore -/.scrutinizer.yml export-ignore -/.styleci.yml export-ignore -/.travis.yml export-ignore -/behat.yml.dist export-ignore -/features/ export-ignore -/phpspec.ci.yml export-ignore -/phpspec.yml.dist export-ignore -/phpunit.xml.dist export-ignore -/spec/ export-ignore -/tests/ export-ignore +.editorconfig export-ignore +.gitattributes export-ignore +/.github/ export-ignore +.gitignore export-ignore +/.php_cs export-ignore +/.scrutinizer.yml export-ignore +/.styleci.yml export-ignore +/.travis.yml export-ignore +/phpspec.ci.yml export-ignore +/phpspec.yml.dist export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore +/spec/ export-ignore +/tests/ export-ignore diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..d45d0a4 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,22 @@ +parameters: + ignoreErrors: + - + message: "#^Method Http\\\\Client\\\\Exception\\\\HttpException\\:\\:create\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Exception/HttpException.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/Exception/HttpException.php + + - + message: "#^Method Http\\\\Client\\\\Exception\\\\NetworkException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Exception/NetworkException.php + + - + message: "#^Method Http\\\\Client\\\\Exception\\\\RequestException\\:\\:setRequest\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Exception/RequestException.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..6f8227f --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: max + paths: + - src From 1779860d91e46ec9e2ee4dbb687029024cafe7e5 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:34:19 +0100 Subject: [PATCH 3/7] Improve PHP-CS-Fixer --- .gitattributes | 2 +- .gitignore | 3 ++- .php_cs | 13 ------------- .php_cs.dist | 16 ++++++++++++++++ 4 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 .php_cs create mode 100644 .php_cs.dist diff --git a/.gitattributes b/.gitattributes index 84790d1..60aab89 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,7 @@ .gitattributes export-ignore /.github/ export-ignore .gitignore export-ignore -/.php_cs export-ignore +/.php_cs.dist export-ignore /.scrutinizer.yml export-ignore /.styleci.yml export-ignore /.travis.yml export-ignore diff --git a/.gitignore b/.gitignore index 16b4a20..1029e28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/behat.yml +.php_cs +.php_cs.cache /build/ /composer.lock /phpspec.yml diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 23ba165..0000000 --- a/.php_cs +++ /dev/null @@ -1,13 +0,0 @@ -setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__.'/src') + ->name('*.php') + ) +; + +return $config; From 679ae8538883636fee806a21fde0b8d1c0799987 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:36:27 +0100 Subject: [PATCH 4/7] Run PHP CS fixer --- src/Exception/HttpException.php | 5 +---- src/Exception/NetworkException.php | 6 ++---- src/Exception/RequestException.php | 6 ++---- src/HttpAsyncClient.php | 2 +- src/Promise/HttpFulfilledPromise.php | 3 --- src/Promise/HttpRejectedPromise.php | 3 --- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/Exception/HttpException.php b/src/Exception/HttpException.php index 38337b5..6c2a007 100644 --- a/src/Exception/HttpException.php +++ b/src/Exception/HttpException.php @@ -20,10 +20,7 @@ class HttpException extends RequestException protected $response; /** - * @param string $message - * @param RequestInterface $request - * @param ResponseInterface $response - * @param \Exception|null $previous + * @param string $message */ public function __construct( $message, diff --git a/src/Exception/NetworkException.php b/src/Exception/NetworkException.php index d52a356..9b4f1e8 100644 --- a/src/Exception/NetworkException.php +++ b/src/Exception/NetworkException.php @@ -2,8 +2,8 @@ namespace Http\Client\Exception; -use Psr\Http\Message\RequestInterface; use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException; +use Psr\Http\Message\RequestInterface; /** * Thrown when the request cannot be completed because of network issues. @@ -17,9 +17,7 @@ class NetworkException extends TransferException implements PsrNetworkException use RequestAwareTrait; /** - * @param string $message - * @param RequestInterface $request - * @param \Exception|null $previous + * @param string $message */ public function __construct($message, RequestInterface $request, \Exception $previous = null) { diff --git a/src/Exception/RequestException.php b/src/Exception/RequestException.php index b548335..f6c60ce 100644 --- a/src/Exception/RequestException.php +++ b/src/Exception/RequestException.php @@ -2,8 +2,8 @@ namespace Http\Client\Exception; -use Psr\Http\Message\RequestInterface; use Psr\Http\Client\RequestExceptionInterface as PsrRequestException; +use Psr\Http\Message\RequestInterface; /** * Exception for when a request failed, providing access to the failed request. @@ -18,9 +18,7 @@ class RequestException extends TransferException implements PsrRequestException use RequestAwareTrait; /** - * @param string $message - * @param RequestInterface $request - * @param \Exception|null $previous + * @param string $message */ public function __construct($message, RequestInterface $request, \Exception $previous = null) { diff --git a/src/HttpAsyncClient.php b/src/HttpAsyncClient.php index bc9d5ee..c3b9d61 100644 --- a/src/HttpAsyncClient.php +++ b/src/HttpAsyncClient.php @@ -17,7 +17,7 @@ interface HttpAsyncClient * * Exceptions related to processing the request are available from the returned Promise. * - * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception. + * @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception * * @throws \Exception If processing the request is impossible (eg. bad configuration). */ diff --git a/src/Promise/HttpFulfilledPromise.php b/src/Promise/HttpFulfilledPromise.php index 6779e44..1ad32cd 100644 --- a/src/Promise/HttpFulfilledPromise.php +++ b/src/Promise/HttpFulfilledPromise.php @@ -13,9 +13,6 @@ final class HttpFulfilledPromise implements Promise */ private $response; - /** - * @param ResponseInterface $response - */ public function __construct(ResponseInterface $response) { $this->response = $response; diff --git a/src/Promise/HttpRejectedPromise.php b/src/Promise/HttpRejectedPromise.php index bfb0738..8af97de 100644 --- a/src/Promise/HttpRejectedPromise.php +++ b/src/Promise/HttpRejectedPromise.php @@ -12,9 +12,6 @@ final class HttpRejectedPromise implements Promise */ private $exception; - /** - * @param Exception $exception - */ public function __construct(Exception $exception) { $this->exception = $exception; From 3db435a2935d1989a0ccda2e2c410039ab5c39aa Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:39:41 +0100 Subject: [PATCH 5/7] Add github actions --- .github/workflows/.editorconfig | 2 ++ .github/workflows/checks.yml | 37 +++++++++++++++++++++ .github/workflows/ci.yml | 57 +++++++++++++++++++++++++++++++++ .github/workflows/static.yml | 34 ++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 .github/workflows/.editorconfig create mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/static.yml diff --git a/.github/workflows/.editorconfig b/.github/workflows/.editorconfig new file mode 100644 index 0000000..7bd3346 --- /dev/null +++ b/.github/workflows/.editorconfig @@ -0,0 +1,2 @@ +[*.yml] +indent_size = 2 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..48ffa14 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,37 @@ +name: Checks + +on: + push: + branches: + - master + pull_request: + +jobs: + composer-normalize: + name: Composer Normalize + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Install + uses: docker://composer + with: + args: install + + - name: Normalize + uses: docker://composer + with: + args: composer normalize --dry-run + + roave-bc-check: + name: Roave BC Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Roave BC Check + uses: docker://nyholm/roave-bc-check-ga diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..40fb626 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + build-lowest-version: + name: Build lowest version + runs-on: ubuntu-latest + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@1.6.2 + with: + php-version: '7.0' + coverage: xdebug + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Checkout code + uses: actions/checkout@v1 + + - name: Download dependencies + run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest + + - name: Run tests + run: composer test-ci + + build: + name: Build + runs-on: ubuntu-latest + strategy: + max-parallel: 10 + matrix: + php: ['7.0', '7.1', '7.2', '7.3', '7.4'] + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@1.6.2 + with: + php-version: ${{ matrix.php }} + + - name: Setup Problem Matchers for PHPUnit + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Checkout code + uses: actions/checkout@v1 + + - name: Download dependencies + run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest + + - name: Run tests + run: composer test diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..9d15468 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,34 @@ +name: Static analysis + +on: + push: + branches: + - master + pull_request: + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: PHPStan + uses: docker://oskarstark/phpstan-ga + with: + args: analyze --no-progress + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff-format udiff From 6351a430e6c79336c6fe9a84cd130ff68109a19b Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:43:21 +0100 Subject: [PATCH 6/7] Remove composer normalize from dependencies --- .github/workflows/checks.yml | 5 +++++ composer.json | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 48ffa14..90cca07 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,6 +20,11 @@ jobs: with: args: install + - name: Require normalize + uses: docker://composer + with: + args: require --dev ergebnis/composer-normalize + - name: Normalize uses: docker://composer with: diff --git a/composer.json b/composer.json index 4e03098..b1bc671 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ "psr/http-message": "^1.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.1", "friends-of-phpspec/phpspec-code-coverage": "^4.1", "phpspec/phpspec": "^4.3.4 || ^5.0 || ^6.0" }, From 826ab5a9c37b22a00f153b68a11052e8c4a885b9 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Mon, 30 Dec 2019 14:51:24 +0100 Subject: [PATCH 7/7] Disable coverage for now --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40fb626..3a68135 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,6 @@ jobs: uses: shivammathur/setup-php@1.6.2 with: php-version: '7.0' - coverage: xdebug - name: Setup Problem Matchers for PHPUnit run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" @@ -28,7 +27,7 @@ jobs: run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest - name: Run tests - run: composer test-ci + run: composer test build: name: Build