diff --git a/.gitattributes b/.gitattributes index 0a004a9..1fd8ce1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ -.editorconfig export-ignore +.editorconfig export-ignore .gitattributes export-ignore /.github/ export-ignore .gitignore export-ignore diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e2753b5..3a3dfee 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,24 +15,16 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install - uses: docker://composer - with: - args: install + - name: Composer normalize + uses: docker://ergebnis/composer-normalize-action - - name: Normalize - uses: docker://composer - with: - args: composer normalize --dry-run - - # Disabled until https://github.com/Roave/BackwardCompatibilityCheck/issues/37 is resolved - # roave-bc-check: - # name: Roave BC Check - # runs-on: ubuntu-latest + roave-bc-check: + name: Roave BC Check + runs-on: ubuntu-latest - # steps: - # - name: Checkout code - # uses: actions/checkout@v2 + steps: + - name: Checkout code + uses: actions/checkout@v2 - # - name: Roave BC Check - # uses: docker://nyholm/roave-bc-check-ga + - name: Roave BC Check + uses: docker://nyholm/roave-bc-check-ga diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a77b98d..08a1fbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,60 +2,78 @@ name: CI on: push: - branches: - - master pull_request: jobs: - build-lowest-version: - name: Build lowest version + latest: + name: PHP ${{ matrix.php }} Latest runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.1', '7.2', '7.3', '7.4', '8.0'] steps: - - name: Set up PHP - uses: shivammathur/setup-php@1.7.0 - with: - php-version: '7.1' - coverage: xdebug - extensions: mbstring - tools: prestissimo - - - name: Setup Problem Matchers for PHPUnit - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Checkout code uses: actions/checkout@v2 - - name: Download dependencies - run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest --prefer-lowest + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer + coverage: none - - name: Run tests - run: composer test-ci + - name: Install dependencies + run: composer update --prefer-dist --no-interaction --no-progress - build: - name: Build + - name: Execute tests + run: composer test + + lowest: + name: PHP ${{ matrix.php }} Lowest runs-on: ubuntu-latest strategy: - max-parallel: 10 matrix: php: ['7.1', '7.2', '7.3', '7.4'] steps: - - name: Set up PHP - uses: shivammathur/setup-php@1.7.0 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: mbstring - tools: prestissimo + tools: composer + coverage: none + + - name: Install dependencies + run: | + composer require "sebastian/comparator:^3.0.2" --no-interaction --no-update + composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress - - name: Setup Problem Matchers for PHPUnit - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Execute tests + run: composer test + + coverage: + name: Code Coverage + runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Download dependencies - run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --no-suggest + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + tools: composer + coverage: xdebug + + - name: Install dependencies + run: | + composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-progress - - name: Run tests - run: composer test + - name: Execute tests + run: composer test-ci diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index aa264e1..b2f69cf 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -17,6 +17,8 @@ jobs: - name: PHPStan uses: docker://oskarstark/phpstan-ga + env: + REQUIRE_DEV: true with: args: analyze --no-progress diff --git a/composer.json b/composer.json index 013cfe7..9a60d8f 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ } ], "require": { - "php": "^7.1", - "clue/stream-filter": "^1.4.1", + "php": "^7.1 || ^8.0", + "clue/stream-filter": "^1.5", "php-http/message-factory": "^1.0.2", "psr/http-message": "^1.0" }, @@ -25,12 +25,9 @@ }, "require-dev": { "ext-zlib": "*", - "akeneo/phpspec-skip-example-extension": "^1.0", - "coduo/phpspec-data-provider-extension": "^1.0", - "ergebnis/composer-normalize": "^2.1", + "ergebnis/composer-normalize": "^2.6", "guzzlehttp/psr7": "^1.0", - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4", + "phpspec/phpspec": "^5.1 || ^6.3", "slim/slim": "^3.0", "zendframework/zend-diactoros": "^1.0" }, diff --git a/phpspec.ci.yml b/phpspec.ci.yml index a4a288f..5f8a626 100644 --- a/phpspec.ci.yml +++ b/phpspec.ci.yml @@ -4,9 +4,8 @@ suites: psr4_prefix: Http\Message formatter.name: pretty extensions: - - PhpSpec\Extension\CodeCoverageExtension - - Coduo\PhpSpec\DataProvider\DataProviderExtension - - Akeneo\SkipExampleExtension + FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: ~ code_coverage: format: clover output: build/coverage.xml +runner.maintainers.errors.level: 16383 diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 56d3c89..785cf0e 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -3,6 +3,4 @@ suites: namespace: Http\Message psr4_prefix: Http\Message formatter.name: pretty -extensions: - - Coduo\PhpSpec\DataProvider\DataProviderExtension - - Akeneo\SkipExampleExtension +runner.maintainers.errors.level: 16383 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c5e0ce2..9c95e48 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -130,11 +130,6 @@ parameters: count: 1 path: src/CookieJar.php - - - message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:count\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/CookieJar.php - - message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:getIterator\\(\\) return type has no value type specified in iterable type Traversable\\\\.$#" count: 1 @@ -145,61 +140,16 @@ parameters: count: 1 path: src/CookieUtil.php - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:getSize\\(\\) has no return typehint specified\\.$#" - count: 2 - path: src/Encoding/FilteredStream.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:isSeekable\\(\\) has no return typehint specified\\.$#" - count: 2 - path: src/Encoding/FilteredStream.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:seek\\(\\) has no return typehint specified\\.$#" - count: 2 - path: src/Encoding/FilteredStream.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#" - count: 2 - path: src/Encoding/FilteredStream.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:fill\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/Encoding/FilteredStream.php - - message: "#^Method Http\\\\Message\\\\Encoding\\\\ChunkStream\\:\\:fill\\(\\) has no return typehint specified\\.$#" count: 1 path: src/Encoding/ChunkStream.php - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has no return typehint specified\\.$#" - count: 1 - path: src/Encoding/Filter/Chunk.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$closing with no typehint specified\\.$#" - count: 1 - path: src/Encoding/Filter/Chunk.php - - message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$consumed with no typehint specified\\.$#" count: 1 path: src/Encoding/Filter/Chunk.php - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$in with no typehint specified\\.$#" - count: 1 - path: src/Encoding/Filter/Chunk.php - - - - message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$out with no typehint specified\\.$#" - count: 1 - path: src/Encoding/Filter/Chunk.php - - message: "#^Access to an undefined property Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:\\$stream\\.$#" count: 2 @@ -220,6 +170,21 @@ parameters: count: 1 path: src/Encoding/Filter/Chunk.php + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:fill\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/FilteredStream.php + + - + message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:seek\\(\\) has no return typehint specified\\.$#" + count: 1 + path: src/Encoding/FilteredStream.php + - message: "#^Method Http\\\\Message\\\\MessageFactory\\\\DiactorosMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#" count: 1 diff --git a/spec/CookieJarSpec.php b/spec/CookieJarSpec.php index 29afee4..f528395 100644 --- a/spec/CookieJarSpec.php +++ b/spec/CookieJarSpec.php @@ -161,7 +161,7 @@ function it_clears_cookies() $this->count()->shouldReturn(0); } - public function getMatchers() + public function getMatchers(): array { return [ 'beAnArrayOfInstance' => function ($subject, $instance) { diff --git a/spec/CookieSpec.php b/spec/CookieSpec.php index 3de69f3..c4e0c01 100644 --- a/spec/CookieSpec.php +++ b/spec/CookieSpec.php @@ -25,17 +25,20 @@ function it_has_a_name() /** * @dataProvider invalidCharacterExamples */ - function it_throws_an_exception_when_the_name_contains_invalid_character($name, $shouldThrow) + function it_throws_an_exception_when_the_name_contains_invalid_character() { - $this->beConstructedWith($name); + foreach (self::invalidCharacterExamples() as $example) { + $this->beConstructedWith($example[0]); - if ($shouldThrow) { - $expectation = $this->shouldThrow('InvalidArgumentException'); - } else { - $expectation = $this->shouldNotThrow('InvalidArgumentException'); + if ($example[1]) { + $expectation = $this->shouldThrow('InvalidArgumentException'); + } else { + $expectation = $this->shouldNotThrow('InvalidArgumentException'); + } + + $expectation->duringInstantiation(); } - $expectation->duringInstantiation(); } function it_throws_an_expection_when_name_is_empty() @@ -51,20 +54,19 @@ function it_has_a_value() $this->hasValue()->shouldReturn(true); } - /** - * @dataProvider invalidCharacterExamples - */ - function it_throws_an_exception_when_the_value_contains_invalid_character($value, $shouldThrow) + function it_throws_an_exception_when_the_value_contains_invalid_character() { - $this->beConstructedWith('name', $value); + foreach (self::invalidCharacterExamples() as $example) { + $this->beConstructedWith('name', $example[0]); - if ($shouldThrow) { - $expectation = $this->shouldThrow('InvalidArgumentException'); - } else { - $expectation = $this->shouldNotThrow('InvalidArgumentException'); - } + if ($example[1]) { + $expectation = $this->shouldThrow('InvalidArgumentException'); + } else { + $expectation = $this->shouldNotThrow('InvalidArgumentException'); + } - $expectation->duringInstantiation(); + $expectation->duringInstantiation(); + } } function it_accepts_a_value() @@ -75,18 +77,17 @@ function it_accepts_a_value() $cookie->getValue()->shouldReturn('value2'); } - /** - * @dataProvider invalidCharacterExamples - */ - function it_throws_an_exception_when_the_new_value_contains_invalid_character($value, $shouldThrow) + function it_throws_an_exception_when_the_new_value_contains_invalid_character() { - if ($shouldThrow) { - $expectation = $this->shouldThrow('InvalidArgumentException'); - } else { - $expectation = $this->shouldNotThrow('InvalidArgumentException'); - } + foreach (self::invalidCharacterExamples() as $example) { + if ($example[1]) { + $expectation = $this->shouldThrow('InvalidArgumentException'); + } else { + $expectation = $this->shouldNotThrow('InvalidArgumentException'); + } - $expectation->duringWithValue($value); + $expectation->duringWithValue($example[0]); + } } function it_has_a_max_age_time() @@ -270,7 +271,7 @@ function it_can_be_constructed_without_max_age_validation() * * @return array */ - public function invalidCharacterExamples() + private static function invalidCharacterExamples() { return [ ['a', false], diff --git a/spec/CookieUtilSpec.php b/spec/CookieUtilSpec.php index f2fac15..6c831c1 100644 --- a/spec/CookieUtilSpec.php +++ b/spec/CookieUtilSpec.php @@ -7,70 +7,151 @@ class CookieUtilSpec extends ObjectBehavior { - /** - * @dataProvider getCookieStrings - */ - function it_parses_cookie_date_string($cookieDateString, $expectedString) + function it_parses_cookie_date_string_1() { - $this->beConstructedThrough('parseDate', [$cookieDateString]); - $this->shouldHaveType('\DateTime'); - $this->format('l, d-M-Y H:i:s O')->shouldReturn($expectedString); + $this->testCookieParse('Friday, 31 Jul 20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_2() + { + $this->testCookieParse('Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_3() + { + $this->testCookieParse('Fri, 31-Jul-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_4() + { + $this->testCookieParse('Fri, 31 Jul 2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_5() + { + $this->testCookieParse('Fri, 31-07-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_6() + { + $this->testCookieParse('Fri, 31-07-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_7() + { + $this->testCookieParse('Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_8() + { + $this->testCookieParse('Fri Jul 31 08:49:37 2020', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_9() + { + $this->testCookieParse('Friday July 31st 2020, 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'); + } + + function it_parses_cookie_date_string_10() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('Wed, 09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 +0000'); + } + + function it_parses_cookie_date_string_11() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('Wed, 09 Jun 2021 22:18:14 GMT', 'Wednesday, 09-Jun-2021 22:18:14 +0000'); + } + + function it_parses_cookie_date_string_12() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('Tue, 18 Oct 2011 07:42:42.123 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'); + } + + function it_parses_cookie_date_string_13() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('18 Oct 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'); } - /** - * @dataProvider getInvalidCookieDateStrings - */ - function it_throws_an_exception_if_cookie_date_string_is_unparseable($cookieDateString) + function it_parses_cookie_date_string_14() { - $this->beConstructedThrough('parseDate', [$cookieDateString]); + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('8 Oct 2011 7:42:42 GMT', 'Saturday, 08-Oct-2011 07:42:42 +0000'); + } + + function it_parses_cookie_date_string_15() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('8 Oct 2011 7:2:42 GMT', 'Saturday, 08-Oct-2011 07:02:42 +0000'); + } + + function it_parses_cookie_date_string_16() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('Oct 18 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'); + } + + function it_parses_cookie_date_string_17() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)', 'Tuesday, 18-Oct-2011 07:05:03 +0000'); + } + + function it_parses_cookie_date_string_18() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 +0000'); + } + + function it_parses_cookie_date_string_19() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('01 Jan 1970 00:00:00 GMT', 'Thursday, 01-Jan-1970 00:00:00 +0000'); + } + + function it_parses_cookie_date_string_20() + { + // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 + $this->testCookieParse('01 Jan 1601 00:00:00 GMT', 'Monday, 01-Jan-1601 00:00:00 +0000'); + } + + function it_parses_cookie_date_string_21() + { + // implicit year + $this->testCookieParse('10 Feb 81 13:00:00 GMT', 'Tuesday, 10-Feb-1981 13:00:00 +0000'); + } + + function it_parses_cookie_date_string_22() + { + // dashes + $this->testCookieParse('Thu, 17-Apr-2014 02:12:29 GMT', 'Thursday, 17-Apr-2014 02:12:29 +0000'); + } + + function it_parses_cookie_date_string_23() + { + // dashes and UTC + $this->testCookieParse('Thu, 17-Apr-2014 02:12:29 UTC', 'Thursday, 17-Apr-2014 02:12:29 +0000'); + } + + function it_throws_an_exception_if_cookie_date_string_is_unparseable_1() + { + $this->beConstructedThrough('parseDate', ['Flursday July 31st 2020, 08:49:37 GMT']); $this->shouldThrow('Http\Message\Exception\UnexpectedValueException'); } - /** - * Provides examples for valid cookie date string. - * - * @return array - */ - public function getCookieStrings() - { - return [ - ['Friday, 31 Jul 20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Fri, 31-Jul-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Fri, 31 Jul 2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Fri, 31-07-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Fri, 31-07-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Fri Jul 31 08:49:37 2020', 'Friday, 31-Jul-2020 08:49:37 +0000'], - ['Friday July 31st 2020, 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 +0000'], - // https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52 - ['Wed, 09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 +0000'], - ['Wed, 09 Jun 2021 22:18:14 GMT', 'Wednesday, 09-Jun-2021 22:18:14 +0000'], - ['Tue, 18 Oct 2011 07:42:42.123 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'], - ['18 Oct 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'], - ['8 Oct 2011 7:42:42 GMT', 'Saturday, 08-Oct-2011 07:42:42 +0000'], - ['8 Oct 2011 7:2:42 GMT', 'Saturday, 08-Oct-2011 07:02:42 +0000'], - ['Oct 18 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 +0000'], - ['Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)', 'Tuesday, 18-Oct-2011 07:05:03 +0000'], - ['09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 +0000'], - ['01 Jan 1970 00:00:00 GMT', 'Thursday, 01-Jan-1970 00:00:00 +0000'], - ['01 Jan 1601 00:00:00 GMT', 'Monday, 01-Jan-1601 00:00:00 +0000'], - ['10 Feb 81 13:00:00 GMT', 'Tuesday, 10-Feb-1981 13:00:00 +0000'], // implicit year - ['Thu, 17-Apr-2014 02:12:29 GMT', 'Thursday, 17-Apr-2014 02:12:29 +0000'], // dashes - ['Thu, 17-Apr-2014 02:12:29 UTC', 'Thursday, 17-Apr-2014 02:12:29 +0000'], // dashes and UTC - ]; - } - - /** - * Provides examples for invalid cookie date string. - * - * @return array - */ - public function getInvalidCookieDateStrings() - { - return [ - ['Flursday July 31st 2020, 08:49:37 GMT'], - ['99 Jix 3038 48:86:72 ZMT'], - ]; + function it_throws_an_exception_if_cookie_date_string_is_unparseable_2() + { + $this->beConstructedThrough('parseDate', ['99 Jix 3038 48:86:72 ZMT']); + $this->shouldThrow('Http\Message\Exception\UnexpectedValueException'); + } + + private function testCookieParse(string $input, string $output) + { + $this->beConstructedThrough('parseDate', [$input]); + $this->shouldHaveType('\DateTime'); + $this->format('l, d-M-Y H:i:s O')->shouldReturn($output); } } diff --git a/spec/Decorator/MessageDecoratorSpec.php b/spec/Decorator/MessageDecoratorSpec.php index 53f79ec..e9d0fe9 100644 --- a/spec/Decorator/MessageDecoratorSpec.php +++ b/spec/Decorator/MessageDecoratorSpec.php @@ -121,7 +121,7 @@ function it_accepts_a_body(MessageInterface $message, MessageInterface $newMessa $new->getMessage()->shouldReturn($newMessage); } - function getMatchers() + function getMatchers(): array { return [ 'useTrait' => function ($subject, $trait) { diff --git a/spec/Decorator/RequestDecoratorSpec.php b/spec/Decorator/RequestDecoratorSpec.php index 776cb94..efe4648 100644 --- a/spec/Decorator/RequestDecoratorSpec.php +++ b/spec/Decorator/RequestDecoratorSpec.php @@ -87,7 +87,7 @@ function it_accepts_an_uri(RequestInterface $request, RequestInterface $newReque $new->getMessage()->shouldReturn($newRequest); } - function getMatchers() + function getMatchers(): array { return [ 'useTrait' => function ($subject, $trait) { diff --git a/spec/Decorator/ResponseDecoratorSpec.php b/spec/Decorator/ResponseDecoratorSpec.php index 7fdd61c..587a86a 100644 --- a/spec/Decorator/ResponseDecoratorSpec.php +++ b/spec/Decorator/ResponseDecoratorSpec.php @@ -63,7 +63,7 @@ function it_has_a_reason_phrase(ResponseInterface $response) $this->getReasonPhrase()->shouldReturn('OK'); } - function getMatchers() + function getMatchers(): array { return [ 'useTrait' => function ($subject, $trait) { diff --git a/spec/Decorator/StreamDecoratorSpec.php b/spec/Decorator/StreamDecoratorSpec.php index 055e385..7dbcaf5 100644 --- a/spec/Decorator/StreamDecoratorSpec.php +++ b/spec/Decorator/StreamDecoratorSpec.php @@ -133,7 +133,7 @@ function it_returns_metadata_of_the_stream(StreamInterface $stream) $this->getMetadata('key2')->shouldReturn(null); } - function getMatchers() + function getMatchers(): array { return [ 'useTrait' => function ($subject, $trait) { diff --git a/spec/Encoding/ChunkStreamSpec.php b/spec/Encoding/ChunkStreamSpec.php index 68a078e..35b68a7 100644 --- a/spec/Encoding/ChunkStreamSpec.php +++ b/spec/Encoding/ChunkStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class ChunkStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/CompressStreamSpec.php b/spec/Encoding/CompressStreamSpec.php index 04efda6..ad58b1f 100644 --- a/spec/Encoding/CompressStreamSpec.php +++ b/spec/Encoding/CompressStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class CompressStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/DechunkStreamSpec.php b/spec/Encoding/DechunkStreamSpec.php index 3616d1b..2ef2aa2 100644 --- a/spec/Encoding/DechunkStreamSpec.php +++ b/spec/Encoding/DechunkStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class DechunkStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/DecompressStreamSpec.php b/spec/Encoding/DecompressStreamSpec.php index baafad0..78a5923 100644 --- a/spec/Encoding/DecompressStreamSpec.php +++ b/spec/Encoding/DecompressStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class DecompressStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/FilteredStreamStubSpec.php b/spec/Encoding/FilteredStreamStubSpec.php index 6e6692e..7e3f3f6 100644 --- a/spec/Encoding/FilteredStreamStubSpec.php +++ b/spec/Encoding/FilteredStreamStubSpec.php @@ -12,14 +12,22 @@ function it_throws_during_instantiation_with_invalid_read_filter_options(StreamI { $this->beAnInstanceOf('spec\Http\Message\Encoding\FilteredStreamStub'); $this->beConstructedWith($stream, 'foo'); - $this->shouldThrow('RuntimeException')->duringInstantiation(); + if (\PHP_MAJOR_VERSION < 8) { + $this->shouldThrow('RuntimeException')->duringInstantiation(); + } else { + $this->shouldThrow('PhpSpec\Exception\Example\ErrorException')->duringInstantiation(); + } } function it_throws_during_instantiation_with_invalid_write_filter_options(StreamInterface $stream) { $this->beAnInstanceOf('spec\Http\Message\Encoding\FilteredStreamStub'); $this->beConstructedWith($stream, null, 'foo'); - $this->shouldThrow('RuntimeException')->duringInstantiation(); + if (\PHP_MAJOR_VERSION < 8) { + $this->shouldThrow('RuntimeException')->duringInstantiation(); + } else { + $this->shouldThrow('PhpSpec\Exception\Example\ErrorException')->duringInstantiation(); + } } function let(StreamInterface $stream) diff --git a/spec/Encoding/GzipDecodeStreamSpec.php b/spec/Encoding/GzipDecodeStreamSpec.php index 17b8dea..e2bbee2 100644 --- a/spec/Encoding/GzipDecodeStreamSpec.php +++ b/spec/Encoding/GzipDecodeStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class GzipDecodeStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/GzipEncodeStreamSpec.php b/spec/Encoding/GzipEncodeStreamSpec.php index 2037be5..e750606 100644 --- a/spec/Encoding/GzipEncodeStreamSpec.php +++ b/spec/Encoding/GzipEncodeStreamSpec.php @@ -3,7 +3,6 @@ namespace spec\Http\Message\Encoding; use Psr\Http\Message\StreamInterface; -use PhpSpec\Exception\Example\SkippingException; use PhpSpec\ObjectBehavior; class GzipEncodeStreamSpec extends ObjectBehavior diff --git a/spec/Encoding/ZlibStreamBehavior.php b/spec/Encoding/ZlibStreamBehavior.php index bcd8311..6f1d298 100644 --- a/spec/Encoding/ZlibStreamBehavior.php +++ b/spec/Encoding/ZlibStreamBehavior.php @@ -2,9 +2,6 @@ namespace spec\Http\Message\Encoding { - use Psr\Http\Message\StreamInterface; - use PhpSpec\Exception\Example\SkippingException; - trait ZlibStreamBehavior { function it_throws_an_exception_when_zlib_is_not_enabled() diff --git a/spec/StreamFactory/StreamFactoryBehavior.php b/spec/StreamFactory/StreamFactoryBehavior.php index f78a1c6..05447d8 100644 --- a/spec/StreamFactory/StreamFactoryBehavior.php +++ b/spec/StreamFactory/StreamFactoryBehavior.php @@ -56,7 +56,7 @@ function it_does_not_rewind_existing_resource() ->shouldHaveContent('def'); } - public function getMatchers() + public function getMatchers(): array { return [ 'haveContent' => function (StreamInterface $subject, $key) {