diff --git a/.gitattributes b/.gitattributes index c47225a..60aab89 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.dist 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/.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..90cca07 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,42 @@ +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: Require normalize + uses: docker://composer + with: + args: require --dev ergebnis/composer-normalize + + - 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..3a68135 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +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' + + - 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 + + 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 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; diff --git a/composer.json b/composer.json index 9adab22..b1bc671 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,24 @@ }, { "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" + "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 +41,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" - } } } 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 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;