From 9cc8c3f1dc9d7d400d810e24ae9e244677b63cd7 Mon Sep 17 00:00:00 2001 From: Edoardo Tenani Date: Wed, 23 Aug 2017 16:48:40 +0200 Subject: [PATCH 001/204] correctly get curl info options --- src/VCR/Util/CurlHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 52c5172f3..773da559a 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -112,7 +112,7 @@ public static function getCurlOptionFromResponse(Response $response, $option = 0 $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; default: - $info = $response->getCurlInfo($option); + $info = $response->getCurlInfo(self::$curlInfoList[$option]); break; } From 5a51a036558acd89c88b7a914cf96a469946221e Mon Sep 17 00:00:00 2001 From: Edoardo Tenani Date: Wed, 23 Aug 2017 17:09:41 +0200 Subject: [PATCH 002/204] record curl infos in response --- src/VCR/Response.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/VCR/Response.php b/src/VCR/Response.php index cd110fe9b..69e5ad3ad 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -65,7 +65,8 @@ public function toArray() array( 'status' => $this->status, 'headers' => $this->getHeaders(), - 'body' => $body + 'body' => $body, + 'curl_info' => $this->curlInfo, ) ); } @@ -94,7 +95,8 @@ public static function fromArray(array $response) return new static( isset($response['status']) ? $response['status'] : 200, isset($response['headers']) ? $response['headers'] : array(), - $body + $body, + isset($response['curl_info']) ? $response['curl_info'] : array() ); } From 4e607fa1daa5c2bf89eb465b7de3df13cfef940f Mon Sep 17 00:00:00 2001 From: Edoardo Tenani Date: Tue, 29 Aug 2017 17:05:10 +0200 Subject: [PATCH 003/204] test restore curl info from storage --- tests/VCR/ResponseTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index da8127c99..b461b9d6d 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -120,6 +120,15 @@ public function testGetCurlInfo() $this->assertEquals($curlOptions, $response->getCurlInfo()); } + public function testRestoreCurlInfoFromArray() + { + $expectedCurlOptions = array('option' => 'value'); + $response = new Response(200, array(), null, $expectedCurlOptions); + $restoredResponse = Response::fromArray($response->toArray()); + + $this->assertEquals($expectedCurlOptions, $response->getCurlInfo()); + } + public function testToArray() { $expectedArray = array( @@ -131,7 +140,10 @@ public function testToArray() 'headers' => array( 'host' => 'example.com' ), - 'body' => 'Test response' + 'body' => 'Test response', + 'curl_info' => [ + 'content_type' => 'text/html' + ] ); $response = Response::fromArray($expectedArray); From 018ce65a41d0babb9d79e2ccb882589ab941e00e Mon Sep 17 00:00:00 2001 From: Edoardo Tenani Date: Wed, 18 Oct 2017 18:09:39 +0200 Subject: [PATCH 004/204] fix array short syntax, unsupported on php 5.3 --- tests/VCR/ResponseTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index b461b9d6d..e5605031a 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -141,9 +141,9 @@ public function testToArray() 'host' => 'example.com' ), 'body' => 'Test response', - 'curl_info' => [ + 'curl_info' => array( 'content_type' => 'text/html' - ] + ) ); $response = Response::fromArray($expectedArray); From 054dc5a6e729b15e8fd2068928ce97db2574e42d Mon Sep 17 00:00:00 2001 From: Renato Mendes Figueiredo Date: Wed, 18 Oct 2017 21:10:39 +0200 Subject: [PATCH 005/204] Updating curl test to have a representative curl_info --- tests/fixtures/unittest_curl_test | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/fixtures/unittest_curl_test b/tests/fixtures/unittest_curl_test index 9203eff64..1b7524452 100644 --- a/tests/fixtures/unittest_curl_test +++ b/tests/fixtures/unittest_curl_test @@ -11,11 +11,33 @@ headers: Location: 'http://www.google.com/' Content-Type: 'text/html; charset=UTF-8' - Date: 'Mon, 13 May 2013 08:15:58 GMT' - Expires: 'Wed, 12 Jun 2013 08:15:58 GMT' + Date: 'Wed, 18 Oct 2017 18:59:08 GMT' + Expires: 'Wed, 17 Nov 2017 18:59:08 GMT' Cache-Control: 'public, max-age=2592000' Server: gws Content-Length: '219' X-XSS-Protection: '1; mode=block' X-Frame-Options: SAMEORIGIN body: "This is a curl test dummy." + curl_info: + url: 'http://google.com/' + content_type: 'text/html; charset=UTF-8' + http_code: 301 + header_size: 249 + request_size: 49 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.194497 + namelookup_time: 0.132455 + connect_time: 0.164555 + pretransfer_time: 0.164586 + size_upload: !!float 0 + size_download: !!float 268 + speed_download: !!float 1377 + speed_upload: !!float 0 + download_content_length: !!float 268 + upload_content_length: !!float -1 + starttransfer_time: 0.194476 + certinfo: { } + primary_port: 80 From db3dd28eeb39a2a939c268500ec8794e37137625 Mon Sep 17 00:00:00 2001 From: Valdo Romao Date: Fri, 19 Oct 2018 12:35:12 +0200 Subject: [PATCH 006/204] Disabled opcache when intercepting file --- src/VCR/Util/StreamProcessor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 89756cf13..06cdadbb6 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -72,6 +72,7 @@ public function __construct(Configuration $configuration = null) public function intercept() { if (!$this->isIntercepting) { + ini_set('opcache.enable', 0); stream_wrapper_unregister(self::PROTOCOL); $this->isIntercepting = stream_wrapper_register(self::PROTOCOL, __CLASS__); } From 62f62ec84e4cdd87c71a0aa9aa04c64ad90d9b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 19 Oct 2018 16:40:02 +0200 Subject: [PATCH 007/204] Adding failing test for Opcache --- .travis.yml | 6 ++ tests/integration/apache/README.md | 3 + tests/integration/apache/composer.json | 6 ++ .../integration/apache/expected_cassette.yaml | 21 +++++++ tests/integration/apache/phpunit.xml | 13 +++++ tests/integration/apache/startApache.sh | 3 + tests/integration/apache/test/OpcacheTest.php | 55 +++++++++++++++++++ tests/integration/apache/www/.gitignore | 1 + .../integration/apache/www/performRequest.php | 7 +++ .../apache/www/performRequestWithPhpVcr.php | 11 ++++ tests/integration/apache/www/target.html | 1 + 11 files changed, 127 insertions(+) create mode 100644 tests/integration/apache/README.md create mode 100644 tests/integration/apache/composer.json create mode 100644 tests/integration/apache/expected_cassette.yaml create mode 100644 tests/integration/apache/phpunit.xml create mode 100755 tests/integration/apache/startApache.sh create mode 100644 tests/integration/apache/test/OpcacheTest.php create mode 100644 tests/integration/apache/www/.gitignore create mode 100644 tests/integration/apache/www/performRequest.php create mode 100644 tests/integration/apache/www/performRequestWithPhpVcr.php create mode 100644 tests/integration/apache/www/target.html diff --git a/.travis.yml b/.travis.yml index 06f543c1e..53a9087e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,12 @@ matrix: php: 7.1 - env: TEST_DIR=. PHP_CS_FIXER=true php: 7.2 + - env: TEST_DIR=tests/integration/apache + php: 7.2 + dist: trusty + sudo: required + services: + - docker - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 - env: TEST_DIR=tests/integration/guzzle/4 diff --git a/tests/integration/apache/README.md b/tests/integration/apache/README.md new file mode 100644 index 000000000..378ef3309 --- /dev/null +++ b/tests/integration/apache/README.md @@ -0,0 +1,3 @@ +The apache integration test is here to test that Opcache does not have side-effects on PHP-VCR. + +Especially, it tests that PHP-VCR is able to instrument a file that was previously loaded in cache via Opcache. \ No newline at end of file diff --git a/tests/integration/apache/composer.json b/tests/integration/apache/composer.json new file mode 100644 index 000000000..a31c4a30f --- /dev/null +++ b/tests/integration/apache/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "ext-curl": "*", + "phpunit/phpunit": "^7.4" + } +} diff --git a/tests/integration/apache/expected_cassette.yaml b/tests/integration/apache/expected_cassette.yaml new file mode 100644 index 000000000..a1a76b3b9 --- /dev/null +++ b/tests/integration/apache/expected_cassette.yaml @@ -0,0 +1,21 @@ + +- + request: + method: GET + url: 'http://localhost/tests/integration/apache/www/target.html' + headers: + Host: localhost + response: + status: + http_version: '1.1' + code: '200' + message: OK + headers: + Date: 'Fri, 19 Oct 2018 14:13:53 GMT' + Server: 'Apache/2.4.25 (Debian)' + Last-Modified: 'Fri, 19 Oct 2018 13:54:38 GMT' + ETag: '"6-578953e8e6867"' + Accept-Ranges: bytes + Content-Length: '6' + Content-Type: text/html + body: foobar diff --git a/tests/integration/apache/phpunit.xml b/tests/integration/apache/phpunit.xml new file mode 100644 index 000000000..6a1d11132 --- /dev/null +++ b/tests/integration/apache/phpunit.xml @@ -0,0 +1,13 @@ + + + + + ./test + + + + diff --git a/tests/integration/apache/startApache.sh b/tests/integration/apache/startApache.sh new file mode 100755 index 000000000..6d273ab41 --- /dev/null +++ b/tests/integration/apache/startApache.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker run --rm --name apache-web-server -p 8080:80 -v "$PWD/../../../":/var/www/html thecodingmachine/php:7.2-v1-apache diff --git a/tests/integration/apache/test/OpcacheTest.php b/tests/integration/apache/test/OpcacheTest.php new file mode 100644 index 000000000..090800dec --- /dev/null +++ b/tests/integration/apache/test/OpcacheTest.php @@ -0,0 +1,55 @@ +fail('Failed to start Apache server'); + } + + // Step 3: Let's perform 2 requests: one that performs a direct cURL request and THEN, one that goes through PHP-VCR + file_get_contents('http://localhost:8080/tests/integration/apache/www/performRequest.php'); + file_get_contents('http://localhost:8080/tests/integration/apache/www/performRequestWithPhpVcr.php'); + + // Step 4: cleanup + passthru('docker stop apache-web-server'); + + // Step 5: verify that the cassette contains what we want. + $cassette = file_get_contents('www/vcr.yaml'); + $this->assertContains('http://localhost/tests/integration/apache/www/target.html', $cassette); + } +} diff --git a/tests/integration/apache/www/.gitignore b/tests/integration/apache/www/.gitignore new file mode 100644 index 000000000..16f1ee2a0 --- /dev/null +++ b/tests/integration/apache/www/.gitignore @@ -0,0 +1 @@ +vcr.yaml \ No newline at end of file diff --git a/tests/integration/apache/www/performRequest.php b/tests/integration/apache/www/performRequest.php new file mode 100644 index 000000000..a5dcd1f7d --- /dev/null +++ b/tests/integration/apache/www/performRequest.php @@ -0,0 +1,7 @@ +setCassettePath(__DIR__); +VCR::insertCassette('vcr.yaml'); + +require_once 'performRequest.php'; diff --git a/tests/integration/apache/www/target.html b/tests/integration/apache/www/target.html new file mode 100644 index 000000000..f6ea04951 --- /dev/null +++ b/tests/integration/apache/www/target.html @@ -0,0 +1 @@ +foobar \ No newline at end of file From 7d4c26c575ca5734fc0475473cf604528f2abfbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 22 Oct 2018 17:39:59 +0200 Subject: [PATCH 008/204] Adding failing unit test on cURL errors --- tests/VCR/Util/HttpClientTest.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index e78c7167b..17509173d 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -2,18 +2,17 @@ namespace VCR\Util; -use VCR\Response; use VCR\Request; class HttpClientTest extends \PHPUnit_Framework_TestCase { - public function testCreateHttpClient() + public function testHttpClientOnError() { - $this->assertInstanceOf('\VCR\Util\HttpClient', new HttpClient()); - } + $httpClient = new HttpClient(); + // Request on a closed port + $request = new Request('GET', 'http://localhost:9934'); - public function testCreateHttpClientWithMock() - { - $this->assertInstanceOf('\VCR\Util\HttpClient', new HttpClient()); + $this->expectException('VCR\\VCRException'); + $httpClient->send($request); } } From 9f8b60c03350189560babbcabdd321422b0aa63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 22 Oct 2018 18:01:38 +0200 Subject: [PATCH 009/204] Adding PHPStan to CI build --- .travis.yml | 3 ++- composer.json | 3 ++- phpstan.neon | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index 06f543c1e..c6498b768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: php: 7.1 - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" php: 7.1 - - env: TEST_DIR=. PHP_CS_FIXER=true + - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true php: 7.2 - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 @@ -49,6 +49,7 @@ install: script: - $PHPUNIT_BIN --coverage-clover=coverage.clover - if [ "${PHP_CS_FIXER}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php ./php-cs-fixer-v2.phar fix --dry-run --diff $TRAVIS_BUILD_DIR; fi + - if [ "${PHPSTAN}" = "true" ]; then composer require --dev phpstan/phpstan ^0.10 && composer phpstan; fi after_success: - wget https://scrutinizer-ci.com/ocular.phar diff --git a/composer.json b/composer.json index 52544d2ca..a32566807 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "scripts": { "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", - "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs" + "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", + "phpstan": "phpstan analyse src -c phpstan.neon --level=0 --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..716959083 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +#parameters: +# ignoreErrors: +#includes: +# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon From 8e725b509fdaee2a5c4a905e05e6149b10075eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 23 Oct 2018 16:36:57 +0200 Subject: [PATCH 010/204] Fixing PHPStan level 0 issues --- phpstan.neon | 5 +++-- src/VCR/CodeTransform/AbstractCodeTransform.php | 2 +- src/VCR/Request.php | 2 +- src/VCR/Util/CurlHelper.php | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 716959083..e0ae64682 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ -#parameters: -# ignoreErrors: +parameters: + ignoreErrors: + - "#Call to an undefined static method SoapClient::__construct\\(\\)#" #includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 934367c42..b841d3737 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -7,7 +7,7 @@ * * @package VCR\CodeTransform */ -abstract class AbstractCodeTransform extends \PHP_User_Filter +abstract class AbstractCodeTransform extends \php_user_filter { const NAME = 'vcr_abstract_filter'; diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 5aa02655a..6e85064ba 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -53,7 +53,7 @@ public function __construct($method, $url, array $headers = array()) * with specified request matcher callbacks. * * @param Request $request Request to check if it matches the current one. - * @param \callable[] $requestMatchers Request matcher callbacks. + * @param callable[] $requestMatchers Request matcher callbacks. * * @throws \BadFunctionCallException If one of the specified request matchers is not callable. * @return boolean True if specified request matches the current one. diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 118893a87..799985fd1 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -17,7 +17,6 @@ class CurlHelper //"certinfo"? CURLINFO_HTTP_CODE => 'http_code', CURLINFO_EFFECTIVE_URL => 'url', - CURLINFO_FILETIME => 'filetime', CURLINFO_TOTAL_TIME => 'total_time', CURLINFO_NAMELOOKUP_TIME => 'namelookup_time', CURLINFO_CONNECT_TIME => 'connect_time', From 3535833db91ae0bb57ba9c345778ad8287c5cbcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 23 Oct 2018 17:31:03 +0200 Subject: [PATCH 011/204] Adding failing integration test for wrong URL with SoapClient --- .../src/VCR/Example/ExampleSoapClient.php | 6 ++++ .../VCR/Example/ExampleSoapClientTest.php | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php index 429b8b143..204c7d1c7 100644 --- a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php +++ b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php @@ -18,4 +18,10 @@ public function call($number = 12) return trim((string) $response->NumberToWordsResult); } + + public function callBadUrl() + { + // The port is not open. This leads to an error + $client = new \SoapClient('http://localhost:9945', array('soap_version' => SOAP_1_2)); + } } diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index b699c8df7..902b2c68b 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -3,6 +3,7 @@ namespace VCR\Example; use org\bovigo\vfs\vfsStream; +use SoapFault; /** * Converts temperature units from webservicex @@ -16,6 +17,10 @@ public function setUp() // Configure virtual filesystem. vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); + + // Trigger autoload of assertions (broken after VCR is enabled... + $this->assertNotNull(1); + $this->assertTrue(true); } public function testCallDirectly() @@ -37,6 +42,34 @@ public function testCallDirectlyEqualsIntercepted() $this->assertEquals($this->callSoap(), $this->callSoapIntercepted()); } + /** + * This test performs a SOAP request on a buggy WSDL. + * It checks that the non instrumented code and the instrumented code return the same exception. + */ + public function testCallSoapWithError() + { + $nonInstrumentedException = null; + try { + $soapClient = new ExampleSoapClient(); + $soapClient->callBadUrl(); + } catch (SoapFault $e) { + $nonInstrumentedException = $e; + } + $this->assertNotNull($nonInstrumentedException); + $catched = false; + \VCR\VCR::turnOn(); + \VCR\VCR::insertCassette('test-cassette.yml'); + try { + $soapClient = new ExampleSoapClient(); + $soapClient->callBadUrl(); + } catch (SoapFault $e) { + $catched = true; + $this->assertEquals($e->getMessage(), $nonInstrumentedException->getMessage()); + } + $this->assertTrue($catched); + \VCR\VCR::turnOff(); + } + protected function callSoap() { $soapClient = new ExampleSoapClient(); From 1ae0d09d5ec2894519cfde015b6578c1c04bdda4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 23 Oct 2018 18:42:03 +0200 Subject: [PATCH 012/204] Adding failing integration test with ConnectException. cURL error is not forwarded correctly. --- tests/integration/guzzle/6/test/ErrorTest.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/integration/guzzle/6/test/ErrorTest.php diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php new file mode 100644 index 000000000..6a3d03b0c --- /dev/null +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -0,0 +1,51 @@ +setCassettePath(vfsStream::url('testDir')); + } + + public function testConnectException() + { + $nonInstrumentedException = null; + try { + $client = new Client(); + $client->get(self::TEST_GET_URL); + } catch (ConnectException $e) { + $nonInstrumentedException = $e; + } + $this->assertNotNull($nonInstrumentedException); + $catched = false; + \VCR\VCR::turnOn(); + \VCR\VCR::insertCassette('test-cassette.yml'); + try { + $client = new Client(); + $client->get(self::TEST_GET_URL); + } catch (ConnectException $e) { + $catched = true; + $this->assertEquals($e->getMessage(), $nonInstrumentedException->getMessage()); + } + $this->assertTrue($catched); + \VCR\VCR::turnOff(); + } + + protected function assertValidGETResponse($info) + { + } +} From 8f5635505a2dfe712cd915442985c2cb8c7a5789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 23 Oct 2018 19:20:45 +0200 Subject: [PATCH 013/204] Forwarding cURL errors from HttpClient to SoapClient and CurlHook --- .travis.yml | 2 +- src/VCR/CodeTransform/CurlCodeTransform.php | 4 +- src/VCR/LibraryHooks/CurlHook.php | 78 +++++++++++++++++---- src/VCR/LibraryHooks/StreamWrapperHook.php | 10 ++- src/VCR/Util/CurlException.php | 29 ++++++++ src/VCR/Util/HttpClient.php | 8 ++- src/VCR/Videorecorder.php | 20 ++++-- tests/VCR/Util/HttpClientTest.php | 2 +- 8 files changed, 127 insertions(+), 26 deletions(-) create mode 100644 src/VCR/Util/CurlException.php diff --git a/.travis.yml b/.travis.yml index 06f543c1e..046453c87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ matrix: - env: TEST_DIR=tests/integration/guzzle/6 php: 5.6 - env: TEST_DIR=tests/integration/soap - php: 5.6 + php: 7.2 before_install: - composer self-update diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index b6af88e83..0c50101ee 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -16,7 +16,9 @@ class CurlCodeTransform extends AbstractCodeTransform '/(?|\w_)\\\?curl_multi_remove_handle\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', '/(?|\w_)\\\?curl_multi_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_exec(', '/(?|\w_)\\\?curl_multi_info_read\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', - '/(?|\w_)\\\?curl_reset\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_reset(' + '/(?|\w_)\\\?curl_reset\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_reset(', + '/(?|\w_)\\\?curl_error\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_error(', + '/(?|\w_)\\\?curl_errno\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_errno(' ); /** diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 283b17f63..4af5487a5 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -6,6 +6,7 @@ use VCR\Request; use VCR\Response; use VCR\CodeTransform\AbstractCodeTransform; +use VCR\Util\CurlException; use VCR\Util\CurlHelper; use VCR\Util\StreamProcessor; use VCR\Util\TextUtil; @@ -50,6 +51,11 @@ class CurlHook implements LibraryHook */ protected static $multiExecLastChs = array(); + /** + * @var CurlException[] Last cURL error, as a CurlException. + */ + protected static $lastErrors = array(); + /** * @var AbstractCodeTransform */ @@ -197,17 +203,22 @@ public static function curlReset($curlHandle) */ public static function curlExec($curlHandle) { - $request = self::$requests[(int) $curlHandle]; - CurlHelper::validateCurlPOSTBody($request, $curlHandle); + try { + $request = self::$requests[(int) $curlHandle]; + CurlHelper::validateCurlPOSTBody($request, $curlHandle); - $requestCallback = self::$requestCallback; - self::$responses[(int) $curlHandle] = $requestCallback($request); + $requestCallback = self::$requestCallback; + self::$responses[(int) $curlHandle] = $requestCallback($request); - return CurlHelper::handleOutput( - self::$responses[(int) $curlHandle], - self::$curlOptions[(int) $curlHandle], - $curlHandle - ); + return CurlHelper::handleOutput( + self::$responses[(int) $curlHandle], + self::$curlOptions[(int) $curlHandle], + $curlHandle + ); + } catch (CurlException $e) { + self::$lastErrors[(int) $curlHandle] = $e; + return false; + } } /** @@ -296,10 +307,16 @@ public static function curlMultiInfoRead() */ public static function curlGetinfo($curlHandle, $option = 0) { - return CurlHelper::getCurlOptionFromResponse( - self::$responses[(int) $curlHandle], - $option - ); + if (isset(self::$responses[(int) $curlHandle])) { + return CurlHelper::getCurlOptionFromResponse( + self::$responses[(int) $curlHandle], + $option + ); + } elseif (isset(self::$lastErrors[(int) $curlHandle])) { + return self::$lastErrors[(int) $curlHandle]->getInfo(); + } else { + throw new \RuntimeException('Unexpected error, could not find curl_getinfo in response or errors'); + } } /** @@ -336,4 +353,39 @@ public static function curlSetoptArray($curlHandle, $options) } } } + + /** + * Return a string containing the last error for the current session + * + * @link https://php.net/manual/en/function.curl-error.php + * @param resource $curlHandle + * + * @return string the error message or '' (the empty string) if no + * error occurred. + */ + public static function curlError($curlHandle) + { + if (isset(self::$lastErrors[(int) $curlHandle])) { + return self::$lastErrors[(int) $curlHandle]->getMessage(); + } + return ''; + } + + /** + * Return the last error number + * + * @link https://php.net/manual/en/function.curl-errno.php + * + * @param resource $curlHandle + * + * @return int the error number or 0 (zero) if no error + * occurred. + */ + public static function curlErrno($curlHandle) + { + if (isset(self::$lastErrors[(int) $curlHandle])) { + return self::$lastErrors[(int) $curlHandle]->getCode(); + } + return 0; + } } diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index e6fb6d427..16cad704b 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -5,6 +5,7 @@ use VCR\Request; use VCR\Response; use VCR\Util\Assertion; +use VCR\Util\CurlException; use VCR\Util\HttpUtil; use VCR\Util\StreamHelper; @@ -90,9 +91,12 @@ public function stream_open($path, $mode, $options, &$opened_path) $request = StreamHelper::createRequestFromStreamContext($this->context, $path); $requestCallback = self::$requestCallback; - $this->response = $requestCallback($request); - - return true; + try { + $this->response = $requestCallback($request); + return true; + } catch (CurlException $e) { + return false; + } } /** diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php new file mode 100644 index 000000000..f9674b9c9 --- /dev/null +++ b/src/VCR/Util/CurlException.php @@ -0,0 +1,29 @@ +info = curl_getinfo($ch); + return $e; + } + + /** + * Returns the curl_info array. + * + * @return array + */ + public function getInfo() + { + return $this->info; + } +} diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index ca981cb19..770c6a7e5 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -16,6 +16,8 @@ class HttpClient * @param Request $request HTTP Request to send. * * @return Response Response for specified request. + * + * @throws CurlException In case of cURL error */ public function send(Request $request) { @@ -32,7 +34,11 @@ public function send(Request $request) curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_HEADER, true); - list($status, $headers, $body) = HttpUtil::parseResponse(curl_exec($ch)); + $result = curl_exec($ch); + if ($result === false) { + throw CurlException::create($ch); + } + list($status, $headers, $body) = HttpUtil::parseResponse($result); return new Response( HttpUtil::parseStatus($status), diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 7e0b3f2d7..94a48ff18 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -248,12 +248,20 @@ public function handleRequest(Request $request) $this->disableLibraryHooks(); - $this->dispatch(VCREvents::VCR_BEFORE_HTTP_REQUEST, new BeforeHttpRequestEvent($request)); - $response = $this->client->send($request); - $this->dispatch(VCREvents::VCR_AFTER_HTTP_REQUEST, new AfterHttpRequestEvent($request, $response)); - - $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); - $this->cassette->record($request, $response); + try { + $this->dispatch(VCREvents::VCR_BEFORE_HTTP_REQUEST, new BeforeHttpRequestEvent($request)); + $response = $this->client->send($request); + $this->dispatch(VCREvents::VCR_AFTER_HTTP_REQUEST, new AfterHttpRequestEvent($request, $response)); + + $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); + $this->cassette->record($request, $response); + } catch (\Exception $e) { + $this->enableLibraryHooks(); + throw $e; + } catch (\Throwable $e) { + $this->enableLibraryHooks(); + throw $e; + } $this->enableLibraryHooks(); return $response; diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index 17509173d..f3a85a205 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -12,7 +12,7 @@ public function testHttpClientOnError() // Request on a closed port $request = new Request('GET', 'http://localhost:9934'); - $this->expectException('VCR\\VCRException'); + $this->setExpectedException('VCR\\Util\\CurlException'); $httpClient->send($request); } } From 69bea33155e92625ae81473a13dcd8b34d3ff202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 26 Oct 2018 14:31:59 +0200 Subject: [PATCH 014/204] Stepping up minimum PHP version to 7.2 --- .travis.yml | 41 +- composer.json | 6 +- composer.lock | 1267 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 1191 insertions(+), 123 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6498b768..879422982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,41 +1,27 @@ language: php -dist: precise +dist: trusty matrix: fast_finish: true include: - - env: TEST_DIR=. - php: 5.3 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 5.3 - - env: TEST_DIR=. - php: 5.4 - - env: TEST_DIR=. - php: 5.5 - - env: TEST_DIR=. - php: 5.6 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 5.6 - - env: TEST_DIR=. - php: 7.0 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.0 - - env: TEST_DIR=. - php: 7.1 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.1 - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true php: 7.2 + - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" + php: 7.2 + - env: TEST_DIR=. + php: 7.3 - env: TEST_DIR=tests/integration/guzzle/3 - php: 5.6 - - env: TEST_DIR=tests/integration/guzzle/4 - php: 5.6 + php: 7.2 +# Guzzle 4 is not compatible with PHP >= 7.1 due to an error in the code that was only fixed in Guzzle 5. +# See: https://github.com/guzzle/guzzle/pull/1393 +# - env: TEST_DIR=tests/integration/guzzle/4 +# php: 7.2 - env: TEST_DIR=tests/integration/guzzle/5 - php: 5.6 + php: 7.2 - env: TEST_DIR=tests/integration/guzzle/6 - php: 5.6 + php: 7.2 - env: TEST_DIR=tests/integration/soap - php: 5.6 + php: 7.2 before_install: - composer self-update @@ -62,4 +48,5 @@ cache: - tests/integration/guzzle/4/vendor - tests/integration/guzzle/5/vendor - tests/integration/guzzle/6/vendor + - tests/integration/soap/vendor - $HOME/.composer/cache diff --git a/composer.json b/composer.json index a32566807..5465527c1 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ ], "require": { + "php": ">=7.2", "ext-curl": "*", "beberlei/assert": "^2.0", "symfony/yaml": "~2.1|^3.0|^4.0", @@ -26,9 +27,10 @@ "require-dev": { "phpunit/phpunit": "^4.8|^5.0", - "sebastian/version": "^1.0.3|^2.0", + "sebastian/comparator": "^1.2.4", "mikey179/vfsStream": "^1.2", - "lapistano/proxy-object": "dev-master#d7184a479f502d5a0f96d0bae73566dbb498da8f" + "lapistano/proxy-object": "dev-master#d7184a479f502d5a0f96d0bae73566dbb498da8f", + "phpstan/phpstan": "^0.10.5" }, "autoload": { diff --git a/composer.lock b/composer.lock index 0941b4bfe..2ab2cf885 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "e7620447991c15ab183fd84a2b8dfde2", + "content-hash": "a02ecf31e56df3052f290dc8b81b7486", "packages": [ { "name": "beberlei/assert", - "version": "v2.7.8", + "version": "v2.9.6", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "be6aa40e3f2d2f0766f159409ab9a80c8db6ca23" + "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/be6aa40e3f2d2f0766f159409ab9a80c8db6ca23", - "reference": "be6aa40e3f2d2f0766f159409ab9a80c8db6ca23", + "url": "https://api.github.com/repos/beberlei/assert/zipball/ec9e4cf0b63890edce844ee3922e2b95a526e936", + "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.1.1", - "phpunit/phpunit": "^4|^5" + "phpunit/phpunit": "^4.8.35|^5.7" }, "type": "library", "autoload": { @@ -59,20 +59,20 @@ "assertion", "validation" ], - "time": "2017-10-20T15:59:40+00:00" + "time": "2018-06-11T17:15:25+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.0.0", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "6223fb2b68e7059e8d5843c0103999a84e7275cf" + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/6223fb2b68e7059e8d5843c0103999a84e7275cf", - "reference": "6223fb2b68e7059e8d5843c0103999a84e7275cf", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", "shasum": "" }, "require": { @@ -95,7 +95,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -122,24 +122,83 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-09T17:30:28+00:00" + "time": "2018-07-26T09:10:45+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.0", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04" + "reference": "367e689b2fdc19965be435337b50bc8adf2746c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b3d0c9c11be3831b84825967dc6b52b5a7b84e04", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04", + "url": "https://api.github.com/repos/symfony/yaml/zipball/367e689b2fdc19965be435337b50bc8adf2746c9", + "reference": "367e689b2fdc19965be435337b50bc8adf2746c9", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" @@ -153,7 +212,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -180,38 +239,82 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" + "time": "2018-10-02T16:36:10+00:00" } ], "packages-dev": [ + { + "name": "composer/xdebug-handler", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-08-31T19:07:57+00:00" + }, { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -236,7 +339,58 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "jean85/pretty-package-versions", + "version": "1.2", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48", + "shasum": "" + }, + "require": { + "ocramius/package-versions": "^1.2.0", + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A wrapper for ocramius/package-versions to get pretty versions strings", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "time": "2018-06-13T13:22:40+00:00" }, { "name": "lapistano/proxy-object", @@ -326,54 +480,634 @@ "role": "Developer" } ], - "description": "Virtual file system to mock the real file system in unit tests.", - "homepage": "http://vfs.bovigo.org/", - "time": "2017-08-01T08:02:14+00:00" + "description": "Virtual file system to mock the real file system in unit tests.", + "homepage": "http://vfs.bovigo.org/", + "time": "2017-08-01T08:02:14+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2018-06-11T23:09:50+00:00" + }, + { + "name": "nette/bootstrap", + "version": "v2.4.6", + "source": { + "type": "git", + "url": "https://github.com/nette/bootstrap.git", + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543", + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543", + "shasum": "" + }, + "require": { + "nette/di": "~2.4.7", + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "latte/latte": "~2.2", + "nette/application": "~2.3", + "nette/caching": "~2.3", + "nette/database": "~2.3", + "nette/forms": "~2.3", + "nette/http": "~2.4.0", + "nette/mail": "~2.3", + "nette/robot-loader": "^2.4.2 || ^3.0", + "nette/safe-stream": "~2.2", + "nette/security": "~2.3", + "nette/tester": "~2.0", + "tracy/tracy": "^2.4.1" + }, + "suggest": { + "nette/robot-loader": "to use Configurator::createRobotLoader()", + "tracy/tracy": "to use Configurator::enableTracy()" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", + "homepage": "https://nette.org", + "keywords": [ + "bootstrapping", + "configurator", + "nette" + ], + "time": "2018-05-17T12:52:20+00:00" + }, + { + "name": "nette/di", + "version": "v2.4.14", + "source": { + "type": "git", + "url": "https://github.com/nette/di.git", + "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a", + "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/neon": "^2.3.3 || ~3.0.0", + "nette/php-generator": "^2.6.1 || ~3.0.0", + "nette/utils": "^2.4.3 || ~3.0.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/bootstrap": "<2.4", + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", + "homepage": "https://nette.org", + "keywords": [ + "compiled", + "di", + "dic", + "factory", + "ioc", + "nette", + "static" + ], + "time": "2018-09-17T15:47:40+00:00" + }, + { + "name": "nette/finder", + "version": "v2.4.2", + "source": { + "type": "git", + "url": "https://github.com/nette/finder.git", + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", + "shasum": "" + }, + "require": { + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🔍 Nette Finder: find files and directories with an intuitive API.", + "homepage": "https://nette.org", + "keywords": [ + "filesystem", + "glob", + "iterator", + "nette" + ], + "time": "2018-06-28T11:49:23+00:00" + }, + { + "name": "nette/neon", + "version": "v2.4.3", + "source": { + "type": "git", + "url": "https://github.com/nette/neon.git", + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "shasum": "" + }, + "require": { + "ext-iconv": "*", + "ext-json": "*", + "php": ">=5.6.0" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🍸 Nette NEON: encodes and decodes NEON file format.", + "homepage": "http://ne-on.org", + "keywords": [ + "export", + "import", + "neon", + "nette", + "yaml" + ], + "time": "2018-03-21T12:12:21+00:00" + }, + { + "name": "nette/php-generator", + "version": "v3.0.5", + "source": { + "type": "git", + "url": "https://github.com/nette/php-generator.git", + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "shasum": "" + }, + "require": { + "nette/utils": "^2.4.2 || ~3.0.0", + "php": ">=7.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", + "homepage": "https://nette.org", + "keywords": [ + "code", + "nette", + "php", + "scaffolding" + ], + "time": "2018-08-09T14:32:27+00:00" + }, + { + "name": "nette/robot-loader", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/nette/robot-loader.git", + "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/fc76c70e740b10f091e502b2e393d0be912f38d4", + "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "nette/finder": "^2.3 || ^3.0", + "nette/utils": "^2.4 || ^3.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "^2.0", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "homepage": "https://nette.org", + "keywords": [ + "autoload", + "class", + "interface", + "nette", + "trait" + ], + "time": "2018-08-13T14:19:06+00:00" + }, + { + "name": "nette/utils", + "version": "v2.5.3", + "source": { + "type": "git", + "url": "https://github.com/nette/utils.git", + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce", + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" + }, + "require-dev": { + "nette/tester": "~2.0", + "tracy/tracy": "^2.3" + }, + "suggest": { + "ext-gd": "to use Image", + "ext-iconv": "to use Strings::webalize() and toAscii()", + "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-json": "to use Nette\\Utils\\Json", + "ext-mbstring": "to use Strings::lower() etc...", + "ext-xml": "to use Strings::length() etc. when mbstring is not available" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/loader.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "homepage": "https://nette.org", + "keywords": [ + "array", + "core", + "datetime", + "images", + "json", + "nette", + "paginator", + "password", + "slugify", + "string", + "unicode", + "utf-8", + "utility", + "validation" + ], + "time": "2018-09-18T10:22:16+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.1.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/d0230c5c77a7e3cfa69446febf340978540958c0", + "reference": "d0230c5c77a7e3cfa69446febf340978540958c0", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2018-10-10T09:24:14+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.7.0", + "name": "ocramius/package-versions", + "version": "1.3.0", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "url": "https://github.com/Ocramius/PackageVersions.git", + "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f", + "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "composer-plugin-api": "^1.0.0", + "php": "^7.1.0" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "composer/composer": "^1.6.3", + "ext-zip": "*", + "infection/infection": "^0.7.1", + "phpunit/phpunit": "^7.0.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "2.0.x-dev" + } }, - "type": "library", "autoload": { "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] + "PackageVersions\\": "src/PackageVersions" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } ], - "time": "2017-10-19T19:58:43+00:00" + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "time": "2018-02-05T13:05:30+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -431,29 +1165,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.1.1", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/reflection-common": "^1.0.0", "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -472,7 +1212,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-30T18:51:59+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -523,33 +1263,33 @@ }, { "name": "phpspec/prophecy", - "version": "v1.7.2", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -582,7 +1322,122 @@ "spy", "stub" ], - "time": "2017-09-04T11:05:03+00:00" + "time": "2018-08-05T17:53:17+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "ed3223362174b8067729930439e139794e9e514a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ed3223362174b8067729930439e139794e9e514a", + "reference": "ed3223362174b8067729930439e139794e9e514a", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "require-dev": { + "consistence/coding-standard": "^2.0.0", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/phpstan": "^0.10@dev", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^3.3.0", + "symfony/process": "^3.4 || ^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "time": "2018-06-20T17:48:01+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "0.10.5", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "shasum": "" + }, + "require": { + "composer/xdebug-handler": "^1.3.0", + "jean85/pretty-package-versions": "^1.0.3", + "nette/bootstrap": "^2.4 || ^3.0", + "nette/di": "^2.4.7 || ^3.0", + "nette/robot-loader": "^3.0.1", + "nette/utils": "^2.4.5 || ^3.0", + "nikic/php-parser": "^4.0.2", + "php": "~7.1", + "phpstan/phpdoc-parser": "^0.3", + "symfony/console": "~3.2 || ~4.0", + "symfony/finder": "~3.2 || ~4.0" + }, + "require-dev": { + "brianium/paratest": "^2.0", + "consistence/coding-standard": "^3.5", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "ext-gd": "*", + "ext-intl": "*", + "ext-mysqli": "*", + "ext-zip": "*", + "jakub-onderka/php-parallel-lint": "^1.0", + "localheinz/composer-normalize": "~0.9.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-deprecation-rules": "^0.10.2", + "phpstan/phpstan-php-parser": "^0.10", + "phpstan/phpstan-phpunit": "^0.10", + "phpstan/phpstan-strict-rules": "^0.10", + "phpunit/phpunit": "^7.0", + "slevomat/coding-standard": "^4.7.2" + }, + "bin": [ + "bin/phpstan" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": [ + "src/", + "build/PHPStan" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2018-10-20T17:24:55+00:00" }, { "name": "phpunit/php-code-coverage", @@ -649,16 +1504,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -692,7 +1547,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -786,16 +1641,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { @@ -831,20 +1686,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-08-20T05:47:52+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.23", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/78532d5269d984660080d8e0f4c99c5c2ea65ffe", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -868,8 +1723,8 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" @@ -913,7 +1768,7 @@ "testing", "xunit" ], - "time": "2017-10-15T06:13:55+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -974,6 +1829,53 @@ ], "time": "2017-06-30T09:13:00+00:00" }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1487,18 +2389,194 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/console", + "version": "v4.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/dc7122fe5f6113cfaba3b3de575d31112c9aa60b", + "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" + }, + "suggest": { + "psr/log-implementation": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2018-10-03T08:15:46+00:00" + }, + { + "name": "symfony/finder", + "version": "v4.1.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/1f17195b44543017a9c9b2d437c670627e96ad06", + "reference": "1f17195b44543017a9c9b2d437c670627e96ad06", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2018-10-03T08:47:56+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-08-06T14:22:27+00:00" + }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { @@ -1535,7 +2613,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], @@ -1546,6 +2624,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { + "php": ">=7.2", "ext-curl": "*" }, "platform-dev": [] From 4d78bd2f2b53cd004b168d3c90d856ee9f060d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Sat, 27 Oct 2018 17:18:55 +0200 Subject: [PATCH 015/204] Upgrading to PHPUnit 7 --- README.md | 4 +- composer.json | 4 +- composer.lock | 580 ++++++++++-------- tests/VCR/CassetteTest.php | 5 +- .../AbstractCodeTransformTest.php | 4 +- .../CodeTransform/CurlCodeTransformTest.php | 16 +- .../CodeTransform/SoapCodeTransformTest.php | 16 +- tests/VCR/ConfigurationTest.php | 20 +- tests/VCR/Event/AfterHttpRequestEventTest.php | 3 +- tests/VCR/Event/AfterPlaybackEventTest.php | 3 +- .../VCR/Event/BeforeHttpRequestEventTest.php | 3 +- tests/VCR/Event/BeforePlaybackEventTest.php | 3 +- tests/VCR/Event/BeforeRecordEventTest.php | 3 +- tests/VCR/LibraryHooks/CurlHookTest.php | 19 +- tests/VCR/LibraryHooks/SoapHookTest.php | 3 +- .../LibraryHooks/StreamWrapperHookTest.php | 3 +- tests/VCR/RequestMatcherTest.php | 4 +- tests/VCR/RequestTest.php | 6 +- tests/VCR/ResponseTest.php | 4 +- tests/VCR/Storage/AbstractStorageTest.php | 5 +- tests/VCR/Storage/BlackholeTest.php | 4 +- tests/VCR/Storage/JsonTest.php | 3 +- tests/VCR/Storage/YamlTest.php | 3 +- tests/VCR/Util/CurlHelperTest.php | 5 +- tests/VCR/Util/HttpClientTest.php | 3 +- tests/VCR/Util/HttpUtilTest.php | 4 +- tests/VCR/Util/SoapClientTest.php | 24 +- tests/VCR/Util/StreamHelperTest.php | 3 +- tests/VCR/Util/StreamProcessorTest.php | 15 +- tests/VCR/Util/TextUtilTest.php | 4 +- tests/VCR/VCRFactoryTest.php | 3 +- tests/VCR/VCRTest.php | 17 +- tests/VCR/VideorecorderTest.php | 64 +- tests/integration/guzzle/3/composer.lock | 51 +- tests/integration/guzzle/3/phpunit.xml | 2 +- tests/integration/guzzle/4/composer.lock | 14 +- tests/integration/guzzle/5/composer.lock | 66 +- tests/integration/guzzle/5/phpunit.xml | 2 +- tests/integration/guzzle/6/phpunit.xml | 2 +- tests/integration/guzzle/6/test/AsyncTest.php | 3 +- .../VCR/Example/ExampleHttpClientTest.php | 3 +- tests/integration/soap/phpunit.xml | 2 +- .../VCR/Example/ExampleSoapClientTest.php | 3 +- 43 files changed, 584 insertions(+), 424 deletions(-) diff --git a/README.md b/README.md index 75b060ce2..228ea03b4 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Disclaimer: Doing this in PHP is not as easy as in programming languages which s Using static method calls: ``` php -class VCRTest extends \PHPUnit_Framework_TestCase +class VCRTest extends TestCase { public function testShouldInterceptStreamWrapper() { @@ -68,7 +68,7 @@ class VCRTest extends \PHPUnit_Framework_TestCase You can use annotations in PHPUnit by using [phpunit-testlistener-vcr](https://github.com/php-vcr/phpunit-testlistener-vcr): ``` php -class VCRTest extends \PHPUnit_Framework_TestCase +class VCRTest extends TestCase { /** * @vcr unittest_annotation_test diff --git a/composer.json b/composer.json index 5465527c1..9bbeaf89c 100644 --- a/composer.json +++ b/composer.json @@ -26,10 +26,8 @@ }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.0", - "sebastian/comparator": "^1.2.4", + "phpunit/phpunit": "^7.4.3", "mikey179/vfsStream": "^1.2", - "lapistano/proxy-object": "dev-master#d7184a479f502d5a0f96d0bae73566dbb498da8f", "phpstan/phpstan": "^0.10.5" }, diff --git a/composer.lock b/composer.lock index 2ab2cf885..b805fc2b9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a02ecf31e56df3052f290dc8b81b7486", + "content-hash": "1354b1a85494d7a07315f638d1921a27", "packages": [ { "name": "beberlei/assert", @@ -392,52 +392,6 @@ ], "time": "2018-06-13T13:22:40+00:00" }, - { - "name": "lapistano/proxy-object", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/lapistano/proxy-object.git", - "reference": "d7184a479f502d5a0f96d0bae73566dbb498da8f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lapistano/proxy-object/zipball/d7184a479f502d5a0f96d0bae73566dbb498da8f", - "reference": "d7184a479f502d5a0f96d0bae73566dbb498da8f", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "@stable" - }, - "type": "library", - "autoload": { - "psr-0": { - "lapistano\\ProxyObject": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache 2.0" - ], - "authors": [ - { - "name": "Bastian Feder", - "email": "lapis@bastian-feder.de", - "homepage": "http://blog.bastian-feder.de" - } - ], - "description": "A library that makes it much easier to generate a proxy of your system under test (SUT)", - "homepage": "http://www.github.com/lapistano/proxy-object", - "keywords": [ - "phpunit", - "proxy-object", - "testing" - ], - "time": "2015-06-24T09:27:33+00:00" - }, { "name": "mikey179/vfsStream", "version": "v1.6.5", @@ -1109,6 +1063,108 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "time": "2018-02-05T13:05:30+00:00" }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -1441,40 +1497,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.8", + "version": "6.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4d3ae9b21a7d7e440bd0cf65565533117976859f", + "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "^1.3", - "phpunit/php-text-template": "^1.2", - "phpunit/php-token-stream": "^1.4.2 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-xdebug": "^2.5.1" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -1489,7 +1545,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1500,29 +1556,32 @@ "testing", "xunit" ], - "time": "2017-04-02T07:44:40+00:00" + "time": "2018-10-23T05:59:32+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1537,7 +1596,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1547,7 +1606,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -1592,28 +1651,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1628,7 +1687,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1637,33 +1696,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2018-02-01T13:07:23+00:00" }, { "name": "phpunit/php-token-stream", - "version": "2.0.2", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "791198a2c6254db10131eecfe8c06670700904db" + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", - "reference": "791198a2c6254db10131eecfe8c06670700904db", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.2.4" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1686,55 +1745,57 @@ "keywords": [ "tokenizer" ], - "time": "2017-11-27T05:48:46+00:00" + "time": "2018-02-01T13:16:43+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.27", + "version": "7.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" + "reference": "c151651fb6ed264038d486ea262e243af72e5e64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", - "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c151651fb6ed264038d486ea262e243af72e5e64", + "reference": "c151651fb6ed264038d486ea262e243af72e5e64", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.4", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "^1.2.4", - "sebastian/diff": "^1.4.3", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.1", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "^1.0.6|^2.0.1", - "symfony/yaml": "~2.1|~3.0|~4.0" + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.0", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" + "phpunit/phpunit-mock-objects": "*" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -1742,7 +1803,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "7.4-dev" } }, "autoload": { @@ -1768,66 +1829,7 @@ "testing", "xunit" ], - "time": "2018-02-01T05:50:59+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", - "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", - "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2017-06-30T09:13:00+00:00" + "time": "2018-10-23T05:57:41+00:00" }, { "name": "psr/log", @@ -1923,30 +1925,30 @@ }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1977,38 +1979,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.3", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "reference": "366541b989927187c4ca70490a35615d3fef2dce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", + "reference": "366541b989927187c4ca70490a35615d3fef2dce", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2033,34 +2036,37 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2018-06-10T07:54:39+00:00" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2085,34 +2091,34 @@ "environment", "hhvm" ], - "time": "2016-11-26T07:53:53+00:00" + "time": "2017-07-01T08:51:00+00:00" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -2152,27 +2158,27 @@ "export", "exporter" ], - "time": "2016-11-19T08:54:04+00:00" + "time": "2017-04-03T13:19:02+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -2180,7 +2186,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2203,33 +2209,34 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "2.0.1", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2249,32 +2256,77 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-02-18T15:18:39+00:00" + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" }, { "name": "sebastian/recursion-context", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -2302,29 +2354,29 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19T07:33:16+00:00" + "time": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2344,7 +2396,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -2565,6 +2617,46 @@ ], "time": "2018-08-06T14:22:27+00:00" }, + { + "name": "theseer/tokenizer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07T12:08:54+00:00" + }, { "name": "webmozart/assert", "version": "1.3.0", @@ -2618,9 +2710,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "lapistano/proxy-object": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index 8e740def7..18f30ebc6 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -3,11 +3,12 @@ namespace VCR; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test integration of PHPVCR with PHPUnit. */ -class CassetteTest extends \PHPUnit_Framework_TestCase +class CassetteTest extends TestCase { /** @@ -23,7 +24,7 @@ public function setUp() public function testInvalidCassetteName() { - $this->setExpectedException('\VCR\VCRException', 'Cassette name must be a string, array given.'); + $this->expectException(VCRException::class, 'Cassette name must be a string, array given.'); new Cassette(array(), new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); } diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 330d5bc30..4c1b829c5 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -2,7 +2,9 @@ namespace VCR\CodeTransform; -class AbstractCodeTransformTest extends \PHPUnit_framework_TestCase +use PHPUnit\Framework\TestCase; + +class AbstractCodeTransformTest extends TestCase { protected function getFilter(array $methods = array()) { diff --git a/tests/VCR/CodeTransform/CurlCodeTransformTest.php b/tests/VCR/CodeTransform/CurlCodeTransformTest.php index 295c6cd7c..426ccd457 100644 --- a/tests/VCR/CodeTransform/CurlCodeTransformTest.php +++ b/tests/VCR/CodeTransform/CurlCodeTransformTest.php @@ -3,20 +3,24 @@ namespace VCR\CodeTransform; use lapistano\ProxyObject\ProxyBuilder; +use PHPUnit\Framework\TestCase; -class CurlCodeTransformTest extends \PHPUnit_Framework_TestCase +class CurlCodeTransformTest extends TestCase { /** * @dataProvider codeSnippetProvider */ public function testTransformCode($expected, $code) { - $proxy = new ProxyBuilder('\VCR\CodeTransform\CurlCodeTransform'); - $filter = $proxy - ->setMethods(array('transformCode')) - ->getProxy(); + $codeTransform = new class extends CurlCodeTransform { + // A proxy to access the protected transformCode method. + public function publicTransformCode(string $code): string + { + return $this->transformCode($code); + } + }; - $this->assertEquals($expected, $filter->transformCode($code)); + $this->assertEquals($expected, $codeTransform->publicTransformCode($code)); } public function codeSnippetProvider() diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/VCR/CodeTransform/SoapCodeTransformTest.php index 259ee851f..f0ac0f0d9 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/VCR/CodeTransform/SoapCodeTransformTest.php @@ -3,20 +3,24 @@ namespace VCR\CodeTransform; use lapistano\ProxyObject\ProxyBuilder; +use PHPUnit\Framework\TestCase; -class SoapCodeTransformTest extends \PHPUnit_Framework_TestCase +class SoapCodeTransformTest extends TestCase { /** * @dataProvider codeSnippetProvider */ public function testTransformCode($expected, $code) { - $proxy = new ProxyBuilder('\VCR\CodeTransform\SoapCodeTransform'); - $filter = $proxy - ->setMethods(array('transformCode')) - ->getProxy(); + $codeTransform = new class extends SoapCodeTransform { + // A proxy to access the protected transformCode method. + public function publicTransformCode(string $code): string + { + return $this->transformCode($code); + } + }; - $this->assertEquals($expected, $filter->transformCode($code)); + $this->assertEquals($expected, $codeTransform->publicTransformCode($code)); } public function codeSnippetProvider() diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index 6f06b6baf..d2bf8fc1d 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -2,10 +2,12 @@ namespace VCR; +use PHPUnit\Framework\TestCase; + /** * */ -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends TestCase { /** * @var Configuration @@ -19,8 +21,8 @@ public function setUp() public function testSetCassettePathThrowsErrorOnInvalidPath() { - $this->setExpectedException( - 'VCR\VCRException', + $this->expectException( + VCRException::class, "Cassette path 'invalid_path' is not a directory. Please either " . 'create it or set a different cassette path using ' . "\\VCR\\VCR::configure()->setCassettePath('directory')." @@ -64,7 +66,7 @@ public function testEnableSingleLibraryHook() public function testEnableLibraryHooksFailsWithWrongHookName() { - $this->setExpectedException('InvalidArgumentException', "Library hooks don't exist: non_existing"); + $this->expectException('InvalidArgumentException', "Library hooks don't exist: non_existing"); $this->config->enableLibraryHooks(array('non_existing')); } @@ -82,13 +84,13 @@ public function testEnableRequestMatchers() public function testEnableRequestMatchersFailsWithNoExistingName() { - $this->setExpectedException('InvalidArgumentException', "Request matchers don't exist: wrong, name"); + $this->expectException('InvalidArgumentException', "Request matchers don't exist: wrong, name"); $this->config->enableRequestMatchers(array('wrong', 'name')); } public function testAddRequestMatcherFailsWithNoName() { - $this->setExpectedException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''"); + $this->expectException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''"); $expected = function ($first, $second) { return true; }; @@ -97,7 +99,7 @@ public function testAddRequestMatcherFailsWithNoName() public function testAddRequestMatcherFailsWithWrongCallback() { - $this->setExpectedException('VCR\VCRException', "Request matcher 'example' is not callable."); + $this->expectException('VCR\VCRException', "Request matcher 'example' is not callable."); $this->config->addRequestMatcher('example', array()); } @@ -129,7 +131,7 @@ public function availableStorageProvider() public function testSetStorageInvalidName() { - $this->setExpectedException('VCR\VCRException', "Storage 'Does not exist' not available."); + $this->expectException('VCR\VCRException', "Storage 'Does not exist' not available."); $this->config->setStorage('Does not exist'); } @@ -161,7 +163,7 @@ public function testBlacklist() public function testSetModeInvalidName() { - $this->setExpectedException('VCR\VCRException', "Mode 'invalid' does not exist."); + $this->expectException('VCR\VCRException', "Mode 'invalid' does not exist."); $this->config->setMode('invalid'); } } diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/VCR/Event/AfterHttpRequestEventTest.php index 2987c9109..151164bca 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/VCR/Event/AfterHttpRequestEventTest.php @@ -2,10 +2,11 @@ namespace VCR\Event; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Response; -class AfterHttpRequestEventTest extends \PHPUnit_Framework_TestCase +class AfterHttpRequestEventTest extends TestCase { /** * @var AfterHttpRequestEvent diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index da665d7a1..aa8b865e0 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -2,13 +2,14 @@ namespace VCR\Event; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Cassette; use VCR\Configuration; use VCR\Storage; use VCR\Response; -class AfterPlaybackEventTest extends \PHPUnit_Framework_TestCase +class AfterPlaybackEventTest extends TestCase { /** * @var AfterPlaybackEvent diff --git a/tests/VCR/Event/BeforeHttpRequestEventTest.php b/tests/VCR/Event/BeforeHttpRequestEventTest.php index b3479f66e..94363129a 100644 --- a/tests/VCR/Event/BeforeHttpRequestEventTest.php +++ b/tests/VCR/Event/BeforeHttpRequestEventTest.php @@ -2,9 +2,10 @@ namespace VCR\Event; +use PHPUnit\Framework\TestCase; use VCR\Request; -class BeforeHttpRequestEventTest extends \PHPUnit_Framework_TestCase +class BeforeHttpRequestEventTest extends TestCase { /** * @var BeforeHttpRequestEvent diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/VCR/Event/BeforePlaybackEventTest.php index 969a752ef..fddbea780 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/VCR/Event/BeforePlaybackEventTest.php @@ -2,12 +2,13 @@ namespace VCR\Event; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Cassette; use VCR\Configuration; use VCR\Storage; -class BeforePlaybackEventTest extends \PHPUnit_Framework_TestCase +class BeforePlaybackEventTest extends TestCase { /** * @var BeforePlaybackEvent diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index d61d998d3..f3d9e1800 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -2,13 +2,14 @@ namespace VCR\Event; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Cassette; use VCR\Configuration; use VCR\Storage; use VCR\Response; -class BeforeRecordEventTest extends \PHPUnit_Framework_TestCase +class BeforeRecordEventTest extends TestCase { /** * @var BeforeRecordEvent diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 8e08c4d7a..65beea8c4 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -2,6 +2,7 @@ namespace VCR\LibraryHooks; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Response; use VCR\Configuration; @@ -11,7 +12,7 @@ /** * Test if intercepting http/https using curl works. */ -class CurlHookTest extends \PHPUnit_Framework_TestCase +class CurlHookTest extends TestCase { public $expected = 'example response body'; /** @@ -71,10 +72,10 @@ public function testShouldNotInterceptCallWhenNotEnabled() */ public function testShouldNotInterceptCallWhenDisabled() { - $testClass = $this; + $intercepted = false; $this->curlHook->enable( - function () use ($testClass) { - $testClass->fail('This request should not have been intercepted.'); + function () use (&$intercepted) { + $intercepted = true; } ); $this->curlHook->disable(); @@ -84,6 +85,7 @@ function () use ($testClass) { curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); curl_close($curlHandle); + $this->assertFalse($intercepted, 'This request should not have been intercepted.'); } public function testShouldWriteFileOnFileDownload() @@ -250,12 +252,18 @@ public function testShouldReturnCurlInfoAllKeys() $this->curlHook->disable(); } + /** + * @doesNotPerformAssertions + */ public function testShouldNotThrowErrorWhenDisabledTwice() { $this->curlHook->disable(); $this->curlHook->disable(); } + /** + * @doesNotPerformAssertions + */ public function testShouldNotThrowErrorWhenEnabledTwice() { $this->curlHook->enable($this->getTestCallback()); @@ -314,6 +322,9 @@ function (Request $request) use ($testClass, &$callCount) { $this->assertFalse($afterLastInfo, 'Multi info called the last time should return false.'); } + /** + * @doesNotPerformAssertions + */ public function testShouldNotInterceptMultiCallWhenDisabled() { $testClass = $this; diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index 638ab3b3b..33738be47 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -2,6 +2,7 @@ namespace VCR\LibraryHooks; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Response; use VCR\Configuration; @@ -11,7 +12,7 @@ /** * Test if intercepting http/https using soap works. */ -class SoapHookTest extends \PHPUnit_Framework_TestCase +class SoapHookTest extends TestCase { const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index e253d1be8..650a8a1bb 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -2,13 +2,14 @@ namespace VCR\LibraryHooks; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Response; /** * Test if intercepting http/https using stream wrapper works. */ -class StreamWrapperHookTest extends \PHPUnit_Framework_TestCase +class StreamWrapperHookTest extends TestCase { public function testEnable() { diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index 1d8430b85..9793ed5b5 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -2,7 +2,9 @@ namespace VCR; -class RequestMatcherTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class RequestMatcherTest extends TestCase { public function testMatchingMethod() { diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 3a8379ef6..9425dd400 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -2,10 +2,12 @@ namespace VCR; +use PHPUnit\Framework\TestCase; + /** * Test integration of PHPVCR with PHPUnit. */ -class RequestTest extends \PHPUnit_Framework_TestCase +class RequestTest extends TestCase { /** * @var \VCR\Request @@ -59,7 +61,7 @@ public function testDoesntMatch() public function testMatchesThrowsExceptionIfMatcherNotFound() { $request = new Request('POST', 'http://example.com', array('User-Agent' => 'Unit-Test')); - $this->setExpectedException( + $this->expectException( '\BadFunctionCallException', "Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n" ); diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index 90dbe0803..28b8ded53 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -2,10 +2,12 @@ namespace VCR; +use PHPUnit\Framework\TestCase; + /** * Test VCRs response object. */ -class ResponseTest extends \PHPUnit_Framework_TestCase +class ResponseTest extends TestCase { public function testGetHeaders() { diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index f9b1d4102..eb090994a 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -3,11 +3,12 @@ namespace VCR\Storage; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test integration of PHPVCR with PHPUnit. */ -class AbstractStorageTest extends \PHPUnit_Framework_TestCase +class AbstractStorageTest extends TestCase { protected $handle; protected $filePath; @@ -27,7 +28,7 @@ public function testFilePathCreated() public function testRootNotExisting() { - $this->setExpectedException('\VCR\VCRException', "Cassette path 'vfs://test/foo' is not existing or not a directory"); + $this->expectException('\VCR\VCRException', "Cassette path 'vfs://test/foo' is not existing or not a directory"); vfsStream::setup('test'); new TestStorage(vfsStream::url('test/foo'), 'file'); diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index 336b7f63e..3aba13119 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -2,7 +2,9 @@ namespace VCR\Storage; -class BlackholeTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class BlackholeTest extends TestCase { protected $storage; diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 4d63bc84a..464d10663 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -3,11 +3,12 @@ namespace VCR\Storage; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test integration of PHPVCR with PHPUnit. */ -class JsonTest extends \PHPUnit_Framework_TestCase +class JsonTest extends TestCase { protected $handle; protected $filePath; diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index a4bcc3463..4e8261e67 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -3,11 +3,12 @@ namespace VCR\Storage; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test integration of PHPVCR with PHPUnit. */ -class YamlTest extends \PHPUnit_Framework_TestCase +class YamlTest extends TestCase { public function setUp() { diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 3f2fac7f0..4eb16a66f 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -3,10 +3,11 @@ namespace VCR\Util; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; use VCR\Request; use VCR\Response; -class CurlHelperTest extends \PHPUnit_Framework_TestCase +class CurlHelperTest extends TestCase { /** * @dataProvider getHttpMethodsProvider() @@ -160,7 +161,7 @@ public function testSetCurlOptionReadFunctionToNull() public function testSetCurlOptionReadFunctionMissingSize() { - $this->setExpectedException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); + $this->expectException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $request = new Request('POST', 'example.com'); $callback = function ($curlHandle, $fileHandle, $size) { diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index e78c7167b..6356ac5ed 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -2,10 +2,11 @@ namespace VCR\Util; +use PHPUnit\Framework\TestCase; use VCR\Response; use VCR\Request; -class HttpClientTest extends \PHPUnit_Framework_TestCase +class HttpClientTest extends TestCase { public function testCreateHttpClient() { diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index debb2c70e..52efc1b9c 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -2,7 +2,9 @@ namespace VCR\Util; -class HttpUtilTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class HttpUtilTest extends TestCase { public function testParseResponseBasic() { diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index b99d783f5..3d5f247d4 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -3,10 +3,12 @@ namespace VCR\Util; use lapistano\ProxyObject\ProxyBuilder; +use PHPUnit\Framework\TestCase; +use VCR\LibraryHooks\SoapHook; use VCR\VCRException; use VCR\Util\SoapClient; -class SoapClientTest extends \PHPUnit_Framework_TestCase +class SoapClientTest extends TestCase { const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; const ACTION = 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP'; @@ -118,26 +120,26 @@ public function testDoRequestExpectingException() $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); - $this->setExpectedException($exception); + $this->expectException($exception); $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2); } public function testLibraryHook() { - $client = new SoapClient(self::WSDL); - - $proxy = new ProxyBuilder('\VCR\Util\SoapClient'); - $client = $proxy - ->disableOriginalConstructor() - ->setMethods(array('getLibraryHook')) - ->getProxy(); + $client = new class(self::WSDL) extends SoapClient { + // A proxy to access the protected getLibraryHook method. + public function publicGetLibraryHook(): SoapHook + { + return $this->getLibraryHook(); + } + }; - $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->getLibraryHook()); + $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->publicGetLibraryHook()); $client->setLibraryHook($this->getLibraryHookMock(true)); - $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->getLibraryHook()); + $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->publicGetLibraryHook()); } public function testGetLastWhateverBeforeRequest() diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index 8686a74c4..d236adab1 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -2,9 +2,10 @@ namespace VCR\Util; +use PHPUnit\Framework\TestCase; use VCR\Request; -class StreamHelperTest extends \PHPUnit_Framework_TestCase +class StreamHelperTest extends TestCase { public function streamContexts() { diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index d76e9ce17..fc3f2d5ec 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -2,7 +2,10 @@ namespace VCR\Util; -class StreamProcessorTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\Error\Warning; + +class StreamProcessorTest extends TestCase { /** @@ -85,6 +88,9 @@ public function testStreamOpenShouldNotFailOnNonExistingFile($fileMode) restore_error_handler(); } + /** + * @doesNotPerformAssertions + */ public function testUrlStatSuccessfully() { $test = $this; @@ -98,15 +104,16 @@ public function testUrlStatSuccessfully() restore_error_handler(); } - /** - * @expectedException PHPUnit_Framework_Error_Warning - */ public function testUrlStatFileNotFound() { $processor = new StreamProcessor(); + $this->expectException(Warning::class); $processor->url_stat('file_not_found', 0); } + /** + * @doesNotPerformAssertions + */ public function testQuietUrlStatFileNotFoundToBeQuiet() { $processor = new StreamProcessor(); diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/VCR/Util/TextUtilTest.php index 694b20bc3..428aaa329 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/VCR/Util/TextUtilTest.php @@ -2,10 +2,12 @@ namespace VCR\Util; +use PHPUnit\Framework\TestCase; + /** * Tests TextUtil methods. */ -class TextUtilTest extends \PHPUnit_Framework_TestCase +class TextUtilTest extends TestCase { /** * @dataProvider curlMethodsProvider diff --git a/tests/VCR/VCRFactoryTest.php b/tests/VCR/VCRFactoryTest.php index 967bb6b20..fb0125cd8 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/VCR/VCRFactoryTest.php @@ -3,11 +3,12 @@ namespace VCR; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test instance creation. */ -class VCRFactoryTest extends \PHPUnit_Framework_TestCase +class VCRFactoryTest extends TestCase { /** * @dataProvider instanceProvider diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 9d63c35a7..077f62306 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -2,13 +2,14 @@ namespace VCR; +use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\Event; use org\bovigo\vfs\vfsStream; /** * Test integration of PHPVCR with PHPUnit. */ -class VCRTest extends \PHPUnit_Framework_TestCase +class VCRTest extends TestCase { public static function setupBeforeClass() { @@ -18,7 +19,7 @@ public static function setupBeforeClass() public function testUseStaticCallsNotInitialized() { VCR::configure()->enableLibraryHooks(array('stream_wrapper')); - $this->setExpectedException( + $this->expectException( 'VCR\VCRException', 'Please turn on VCR before inserting a cassette, use: VCR::turnOn()' ); @@ -76,6 +77,9 @@ public function testShouldInterceptSoapLibrary() VCR::turnOff(); } + /** + * @doesNotPerformAssertions + */ public function testShouldNotInterceptCallsToDevUrandom() { if ('\\' === DIRECTORY_SEPARATOR) { @@ -96,7 +100,7 @@ public function testShouldNotInterceptCallsToDevUrandom() public function testShouldThrowExceptionIfNoCassettePresent() { - $this->setExpectedException( + $this->expectException( 'BadMethodCallException', 'Invalid http request. No cassette inserted. Please make sure to insert ' . "a cassette in your unit test using VCR::insertCassette('name');" @@ -109,7 +113,8 @@ public function testShouldThrowExceptionIfNoCassettePresent() VCR::turnOff(); } - public function testInsertMultipleCassettes() + // Useless test: already tested in VideorecorderTest::testInsertCassetteEjectExisting + /*public function testInsertMultipleCassettes() { $this->configureVirtualCassette(); @@ -117,14 +122,14 @@ public function testInsertMultipleCassettes() VCR::insertCassette('unittest_cassette1'); VCR::insertCassette('unittest_cassette2'); // TODO: Check of cassette was changed - } + }*/ public function testDoesNotBlockThrowingExceptions() { $this->configureVirtualCassette(); VCR::turnOn(); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); VCR::insertCassette('unittest_cassette1'); throw new \InvalidArgumentException('test'); } diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 6ab030443..f66c1ee25 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -4,11 +4,12 @@ use lapistano\ProxyObject\ProxyBuilder; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Test Videorecorder. */ -class VideorecorderTest extends \PHPUnit_Framework_TestCase +class VideorecorderTest extends TestCase { public function testCreateVideorecorder() { @@ -47,20 +48,21 @@ public function testHandleRequestRecordsRequestWhenModeIsNewRecords() $configuration->enableLibraryHooks(array()); $configuration->setMode('new_episodes'); - $proxy = new ProxyBuilder('\VCR\Videorecorder'); - $videorecorder = $proxy - ->setConstructorArgs(array($configuration, $client, VCRFactory::getInstance())) - ->setProperties(array('cassette', 'client')) - ->getProxy(); - $videorecorder->client = $client; - $videorecorder->cassette = $this->getCassetteMock($request, $response); + $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { + public function setCassette(Cassette $cassette): void + { + $this->cassette = $cassette; + } + }; + + $videorecorder->setCassette($this->getCassetteMock($request, $response)); $this->assertEquals($response, $videorecorder->handleRequest($request)); } public function testHandleRequestThrowsExceptionWhenModeIsNone() { - $this->setExpectedException( + $this->expectException( 'LogicException', "The request does not match a previously recorded request and the 'mode' is set to 'none'. " . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." @@ -73,14 +75,14 @@ public function testHandleRequestThrowsExceptionWhenModeIsNone() $configuration->enableLibraryHooks(array()); $configuration->setMode('none'); - $proxy = new ProxyBuilder('\VCR\Videorecorder'); - $videorecorder = $proxy - ->setConstructorArgs(array($configuration, $client, VCRFactory::getInstance())) - ->setProperties(array('cassette', 'client')) - ->getProxy(); - $videorecorder->client = $client; + $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { + public function setCassette(Cassette $cassette): void + { + $this->cassette = $cassette; + } + }; - $videorecorder->cassette = $this->getCassetteMock($request, $response, 'none'); + $videorecorder->setCassette($this->getCassetteMock($request, $response, 'none')); $videorecorder->handleRequest($request); } @@ -94,21 +96,21 @@ public function testHandleRequestRecordsRequestWhenModeIsOnceAndCassetteIsNew() $configuration->enableLibraryHooks(array()); $configuration->setMode('once'); - $proxy = new ProxyBuilder('\VCR\Videorecorder'); - $videorecorder = $proxy - ->setConstructorArgs(array($configuration, $client, VCRFactory::getInstance())) - ->setProperties(array('cassette', 'client')) - ->getProxy(); - $videorecorder->client = $client; + $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { + public function setCassette(Cassette $cassette): void + { + $this->cassette = $cassette; + } + }; - $videorecorder->cassette = $this->getCassetteMock($request, $response, 'once', true); + $videorecorder->setCassette($this->getCassetteMock($request, $response, 'once', true)); $this->assertEquals($response, $videorecorder->handleRequest($request)); } public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld() { - $this->setExpectedException( + $this->expectException( 'LogicException', "The request does not match a previously recorded request and the 'mode' is set to 'once'. " . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." @@ -121,14 +123,14 @@ public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld() $configuration->enableLibraryHooks(array()); $configuration->setMode('once'); - $proxy = new ProxyBuilder('\VCR\Videorecorder'); - $videorecorder = $proxy - ->setConstructorArgs(array($configuration, $client, VCRFactory::getInstance())) - ->setProperties(array('cassette', 'client')) - ->getProxy(); - $videorecorder->client = $client; + $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { + public function setCassette(Cassette $cassette): void + { + $this->cassette = $cassette; + } + }; - $videorecorder->cassette = $this->getCassetteMock($request, $response, 'once', false); + $videorecorder->setCassette($this->getCassetteMock($request, $response, 'once', false)); $videorecorder->handleRequest($request); } diff --git a/tests/integration/guzzle/3/composer.lock b/tests/integration/guzzle/3/composer.lock index e3ba8eda3..1416af9d7 100644 --- a/tests/integration/guzzle/3/composer.lock +++ b/tests/integration/guzzle/3/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "68366044f967cdb769d600d4f2977188", + "content-hash": "8573d0718749797c92bc6d384e04eaff", "packages": [ { "name": "guzzlehttp/guzzle", @@ -96,32 +96,34 @@ "rest", "web service" ], - "time": "2014-01-28 22:29:15" + "time": "2014-01-28T22:29:15+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.1", - "target-dir": "Symfony/Component/EventDispatcher", + "version": "v4.1.6", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/720fe9bca893df7ad1b4546649473b5afddf0216", - "reference": "720fe9bca893df7ad1b4546649473b5afddf0216", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1.3" + }, + "conflict": { + "symfony/dependency-injection": "<3.4" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/stopwatch": "~2.2" + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/expression-language": "~3.4|~4.0", + "symfony/stopwatch": "~3.4|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -130,31 +132,34 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "4.1-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2014-12-02 20:19:20" + "homepage": "https://symfony.com", + "time": "2018-07-26T09:10:45+00:00" } ], "packages-dev": [], diff --git a/tests/integration/guzzle/3/phpunit.xml b/tests/integration/guzzle/3/phpunit.xml index 30e6c463b..2d6304580 100644 --- a/tests/integration/guzzle/3/phpunit.xml +++ b/tests/integration/guzzle/3/phpunit.xml @@ -6,7 +6,7 @@ > - + ../test diff --git a/tests/integration/guzzle/4/composer.lock b/tests/integration/guzzle/4/composer.lock index 7aa5d2e09..b4582dc3d 100644 --- a/tests/integration/guzzle/4/composer.lock +++ b/tests/integration/guzzle/4/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e500b5a216f42ba9ab567e0e9034749f", + "content-hash": "dd5aa4e5d110b03429e712f90ca10a0b", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "4.2.3", + "version": "4.2.4", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "66fd916e9f9130bc22c51450476823391cb2f67c" + "reference": "13a8e5acff26b0a87d353042170b48976da004a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd916e9f9130bc22c51450476823391cb2f67c", - "reference": "66fd916e9f9130bc22c51450476823391cb2f67c", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/13a8e5acff26b0a87d353042170b48976da004a1", + "reference": "13a8e5acff26b0a87d353042170b48976da004a1", "shasum": "" }, "require": { @@ -69,7 +69,7 @@ "rest", "web service" ], - "time": "2014-10-05 19:29:14" + "time": "2016-07-15T17:44:18+00:00" }, { "name": "guzzlehttp/streams", @@ -122,7 +122,7 @@ "Guzzle", "stream" ], - "time": "2014-08-17 21:15:53" + "time": "2014-08-17T21:15:53+00:00" } ], "packages-dev": [], diff --git a/tests/integration/guzzle/5/composer.lock b/tests/integration/guzzle/5/composer.lock index 1ecd2825d..1690aa89f 100644 --- a/tests/integration/guzzle/5/composer.lock +++ b/tests/integration/guzzle/5/composer.lock @@ -1,40 +1,35 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "3dc2ee230cecf4c3dd15b49672e806db", + "content-hash": "a426abfa60297f7ecc0e43c351699bf4", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "5.1.0", + "version": "5.3.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "f1085bb4e023766a66b7b051914ec73bdf7202b5" + "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f1085bb4e023766a66b7b051914ec73bdf7202b5", - "reference": "f1085bb4e023766a66b7b051914ec73bdf7202b5", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/93bbdb30d59be6cd9839495306c65f2907370eb9", + "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9", "shasum": "" }, "require": { - "guzzlehttp/ringphp": "~1.0", - "php": ">=5.4.0" + "guzzlehttp/ringphp": "^1.1", + "php": ">=5.4.0", + "react/promise": "^2.2" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" + "phpunit/phpunit": "^4.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "GuzzleHttp\\": "src/" @@ -62,20 +57,20 @@ "rest", "web service" ], - "time": "2014-12-19 20:27:15" + "time": "2018-07-31T13:33:10+00:00" }, { "name": "guzzlehttp/ringphp", - "version": "1.0.5", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/guzzle/RingPHP.git", - "reference": "a903f51b692427318bc813217c0e6505287e79a4" + "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a903f51b692427318bc813217c0e6505287e79a4", - "reference": "a903f51b692427318bc813217c0e6505287e79a4", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/5e2a174052995663dd68e6b5ad838afd47dd615b", + "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b", "shasum": "" }, "require": { @@ -93,7 +88,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -112,7 +107,8 @@ "homepage": "https://github.com/mtdowling" } ], - "time": "2014-12-11 05:50:32" + "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", + "time": "2018-07-31T13:22:33+00:00" }, { "name": "guzzlehttp/streams", @@ -162,31 +158,29 @@ "Guzzle", "stream" ], - "time": "2014-10-12 19:18:40" + "time": "2014-10-12T19:18:40+00:00" }, { "name": "react/promise", - "version": "v2.2.0", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef" + "reference": "f4edc2581617431aea50430749db55cc3fc031b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/365fcee430dfa4ace1fbc75737ca60ceea7eeeef", - "reference": "365fcee430dfa4ace1fbc75737ca60ceea7eeeef", + "url": "https://api.github.com/repos/reactphp/promise/zipball/f4edc2581617431aea50430749db55cc3fc031b3", + "reference": "f4edc2581617431aea50430749db55cc3fc031b3", "shasum": "" }, "require": { "php": ">=5.4.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } + "require-dev": { + "phpunit/phpunit": "~4.8" }, + "type": "library", "autoload": { "psr-4": { "React\\Promise\\": "src/" @@ -202,11 +196,15 @@ "authors": [ { "name": "Jan Sorgalla", - "email": "jsorgalla@googlemail.com" + "email": "jsorgalla@gmail.com" } ], "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "time": "2014-12-30 13:32:42" + "keywords": [ + "promise", + "promises" + ], + "time": "2018-06-13T15:59:06+00:00" } ], "packages-dev": [], diff --git a/tests/integration/guzzle/5/phpunit.xml b/tests/integration/guzzle/5/phpunit.xml index 30e6c463b..f27d64587 100644 --- a/tests/integration/guzzle/5/phpunit.xml +++ b/tests/integration/guzzle/5/phpunit.xml @@ -6,7 +6,7 @@ > - + ../test diff --git a/tests/integration/guzzle/6/phpunit.xml b/tests/integration/guzzle/6/phpunit.xml index 312b9f174..d680e9228 100644 --- a/tests/integration/guzzle/6/phpunit.xml +++ b/tests/integration/guzzle/6/phpunit.xml @@ -6,7 +6,7 @@ > - + ../test test diff --git a/tests/integration/guzzle/6/test/AsyncTest.php b/tests/integration/guzzle/6/test/AsyncTest.php index 1344fb040..c71c4859c 100644 --- a/tests/integration/guzzle/6/test/AsyncTest.php +++ b/tests/integration/guzzle/6/test/AsyncTest.php @@ -4,11 +4,12 @@ use GuzzleHttp\Client; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Tests example request. */ -class AsyncTest extends \PHPUnit_Framework_TestCase +class AsyncTest extends TestCase { const TEST_GET_URL = 'https://api.chew.pro/trbmb'; const TEST_GET_URL_2 = 'https://api.chew.pro/trbmb?foo=42'; diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index 4f6ac8875..14ca5a161 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -3,11 +3,12 @@ namespace VCR\Example; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Tests example request. */ -class ExampleHttpClientTest extends \PHPUnit_Framework_TestCase +class ExampleHttpClientTest extends TestCase { const TEST_GET_URL = 'https://api.chew.pro/trbmb'; const TEST_POST_URL = 'https://httpbin.org/post'; diff --git a/tests/integration/soap/phpunit.xml b/tests/integration/soap/phpunit.xml index e952df760..bfc5d44e7 100644 --- a/tests/integration/soap/phpunit.xml +++ b/tests/integration/soap/phpunit.xml @@ -6,7 +6,7 @@ > - + ./test diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index b699c8df7..0d2c6e9d4 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -3,13 +3,14 @@ namespace VCR\Example; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; /** * Converts temperature units from webservicex * * @link http://www.webservicex.net/New/Home/ServiceDetail/31 */ -class ExampleSoapClientTest extends \PHPUnit_Framework_TestCase +class ExampleSoapClientTest extends TestCase { public function setUp() { From 084a955f553d244187021d6fac46e73cf6bc6486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 08:04:44 +0100 Subject: [PATCH 016/204] Removing non existent constant. --- composer.json | 2 +- src/VCR/Util/StreamProcessor.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 9bbeaf89c..904519782 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=0 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=1 --no-progress -vvv" }, "authors": [ diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 89756cf13..dc794b731 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -496,8 +496,9 @@ public function stream_set_option($option, $arg1, $arg2) return stream_set_write_buffer($this->resource, $arg1); case STREAM_OPTION_READ_BUFFER: return stream_set_read_buffer($this->resource, $arg1); - case STREAM_OPTION_CHUNK_SIZE: - return stream_set_chunk_size($this->resource, $arg1); + // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 + /*case STREAM_OPTION_CHUNK_SIZE: + return stream_set_chunk_size($this->resource, $arg1);*/ } } From c97f1bb2bcb9348cad7ffb9fb09c7582c4a1856f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 08:18:06 +0100 Subject: [PATCH 017/204] Fixing PHP-Doc annotation syntax (and reaching PHPStan level 2) --- composer.json | 2 +- phpstan.neon | 2 ++ src/VCR/LibraryHooks/LibraryHook.php | 2 +- src/VCR/Request.php | 26 +++++++++++++------------- src/VCR/Util/HttpUtil.php | 8 ++++---- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 904519782..f677e83df 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=1 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=2 --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon index e0ae64682..598c1a2ad 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,7 @@ parameters: ignoreErrors: - "#Call to an undefined static method SoapClient::__construct\\(\\)#" + - "#Access to an undefined property object::\\$data\\.#" + - "#Access to an undefined property object::\\$datalen\\.#" #includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon diff --git a/src/VCR/LibraryHooks/LibraryHook.php b/src/VCR/LibraryHooks/LibraryHook.php index c98dec937..8e059936f 100644 --- a/src/VCR/LibraryHooks/LibraryHook.php +++ b/src/VCR/LibraryHooks/LibraryHook.php @@ -21,7 +21,7 @@ interface LibraryHook * Enables library hook which means that all of this library * http interactions are intercepted. * - * @param \Closure Callback which will be called when a request is intercepted. + * @param \Closure $requestCallback Callback which will be called when a request is intercepted. * @throws \VCR\VCRException When specified callback is not callable. * @return void */ diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 6e85064ba..30ec047b1 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -16,7 +16,7 @@ class Request */ protected $url; /** - * @var array + * @var array */ protected $headers = array(); /** @@ -158,7 +158,7 @@ public function getMethod() } /** - * @return array + * @return array */ public function getHeaders() { @@ -166,8 +166,8 @@ public function getHeaders() } /** - * @param $key - * @return mixed + * @param string $key + * @return string */ public function getHeader($key) { @@ -175,7 +175,7 @@ public function getHeader($key) } /** - * @param $key + * @param string $key * @return boolean */ public function hasHeader($key) @@ -246,7 +246,7 @@ public function getCurlOptions() } /** - * @param $key + * @param string $key * @return mixed */ public function getCurlOption($key) @@ -312,8 +312,8 @@ public function setCurlOptions(array $curlOptions) } /** - * @param $key - * @param $value + * @param string $key + * @param string $value */ public function setHeader($key, $value) { @@ -321,7 +321,7 @@ public function setHeader($key, $value) } /** - * @param $key + * @param string $key */ public function removeHeader($key) { @@ -329,8 +329,8 @@ public function removeHeader($key) } /** - * @param $key - * @param $value + * @param string $key + * @param mixed $value */ public function setPostField($key, $value) { @@ -338,8 +338,8 @@ public function setPostField($key, $value) } /** - * @param $key - * @param $value + * @param string $key + * @param mixed $value */ public function setCurlOption($key, $value) { diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index c1e8d613d..236aeb650 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -9,10 +9,10 @@ class HttpUtil /** * Returns key value pairs of response headers. * - * @param array $headers List of headers. Example: ['Content-Type: text/html', '...'] - * @return array Key/value pairs of headers, e.g. ['Content-Type' => 'text/html'] + * @param string[] $headers List of headers. Example: ['Content-Type: text/html', '...'] + * @return array Key/value pairs of headers, e.g. ['Content-Type' => 'text/html'] */ - public static function parseHeaders(array $headers) + public static function parseHeaders(array $headers): array { $headerGroups = array(); $headerList = array(); @@ -79,7 +79,7 @@ public static function parseResponse($response) /** * Returns an array of arrays for specified raw header string. * - * @param string $header + * @param string $rawHeader * @return array */ public static function parseRawHeader($rawHeader) From 765678fddb2ed46d5c9fe69db3e54db3a4649b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 08:29:23 +0100 Subject: [PATCH 018/204] Fixing StreamProcessor returns (true on success, false on failure) --- src/VCR/Util/StreamProcessor.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index dc794b731..8965b4545 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -493,13 +493,16 @@ public function stream_set_option($option, $arg1, $arg2) case STREAM_OPTION_READ_TIMEOUT: return stream_set_timeout($this->resource, $arg1, $arg2); case STREAM_OPTION_WRITE_BUFFER: - return stream_set_write_buffer($this->resource, $arg1); + // stream_set_write_buffer returns 0 in case of success + return stream_set_write_buffer($this->resource, $arg1) === 0; case STREAM_OPTION_READ_BUFFER: - return stream_set_read_buffer($this->resource, $arg1); + // stream_set_read_buffer returns 0 in case of success + return stream_set_read_buffer($this->resource, $arg1) === 0; // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 /*case STREAM_OPTION_CHUNK_SIZE: return stream_set_chunk_size($this->resource, $arg1);*/ } + return false; } /** From 0b7fa41824146e2a99f83a5bee8e1d8c594182c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 08:30:19 +0100 Subject: [PATCH 019/204] Adding nullable type hints in PHPDoc for explicitly nullable properties / return types. PHPStan level 3 reached. --- composer.json | 2 +- src/VCR/LibraryHooks/CurlHook.php | 2 +- src/VCR/LibraryHooks/SoapHook.php | 2 +- src/VCR/LibraryHooks/StreamWrapperHook.php | 2 +- src/VCR/Response.php | 2 +- src/VCR/Util/StreamProcessor.php | 2 +- src/VCR/Videorecorder.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index f677e83df..17b69ccdd 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=2 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=3 --no-progress -vvv" }, "authors": [ diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 283b17f63..a30e734f9 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -16,7 +16,7 @@ class CurlHook implements LibraryHook { /** - * @var \Closure Callback which will be executed when a request is intercepted. + * @var \Closure|null Callback which will be executed when a request is intercepted. */ protected static $requestCallback; diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 18e402810..60d990bfb 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -14,7 +14,7 @@ class SoapHook implements LibraryHook { /** - * @var callable + * @var callable|null */ private static $requestCallback; diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index e6fb6d427..0906c3884 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -14,7 +14,7 @@ class StreamWrapperHook implements LibraryHook { /** - * @var \Closure Callback which will be executed when a request is intercepted. + * @var \Closure|null Callback which will be executed when a request is intercepted. */ protected static $requestCallback; diff --git a/src/VCR/Response.php b/src/VCR/Response.php index cd110fe9b..5f3918a6e 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -107,7 +107,7 @@ public function getBody() } /** - * @return array + * @return array|null */ public function getCurlInfo($option = null) { diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 8965b4545..ac9408386 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -293,7 +293,7 @@ public function stream_tell() * @param string $path The file path or URL to stat. * @param integer $flags Holds additional flags set by the streams API. * - * @return integer Should return as many elements as stat() does. + * @return array|false Should return as many elements as stat() does. */ public function url_stat($path, $flags) { diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 7e0b3f2d7..0fad3defe 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -45,7 +45,7 @@ class Videorecorder protected $factory; /** - * @var Cassette Cassette on which to store requests and responses. + * @var Cassette|null Cassette on which to store requests and responses. */ protected $cassette; From 57229f68a1db6fcf59ee62bf4e7f1bd958205c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 09:21:29 +0100 Subject: [PATCH 020/204] Adding nullable type hints on nullable properties --- src/VCR/Configuration.php | 6 +++--- src/VCR/Exceptions/InvalidHostException.php | 10 ++++++++++ src/VCR/Storage/AbstractStorage.php | 2 +- src/VCR/Videorecorder.php | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/VCR/Exceptions/InvalidHostException.php diff --git a/src/VCR/Configuration.php b/src/VCR/Configuration.php index a80a44edb..a24cfb3a4 100644 --- a/src/VCR/Configuration.php +++ b/src/VCR/Configuration.php @@ -25,7 +25,7 @@ class Configuration * A value of null means all hooks are enabled. * * @see \VCR\LibraryHooks\LibraryHook - * @var array List of enabled LibraryHook names. + * @var array|null List of enabled LibraryHook names. */ private $enabledLibraryHooks; @@ -207,7 +207,7 @@ public function setCassettePath($cassettePath) */ public function getLibraryHooks() { - if (is_null($this->enabledLibraryHooks)) { + if ($this->enabledLibraryHooks === null) { return array_values($this->availableLibraryHooks); } @@ -255,7 +255,7 @@ public function getStorage() */ public function getRequestMatchers() { - if (is_null($this->enabledRequestMatchers)) { + if ($this->enabledRequestMatchers === null) { return array_values($this->availableRequestMatchers); } diff --git a/src/VCR/Exceptions/InvalidHostException.php b/src/VCR/Exceptions/InvalidHostException.php new file mode 100644 index 000000000..a42da507d --- /dev/null +++ b/src/VCR/Exceptions/InvalidHostException.php @@ -0,0 +1,10 @@ + Date: Mon, 29 Oct 2018 09:23:45 +0100 Subject: [PATCH 021/204] More robust headers implementation. Headers now MUST be strings (no null value allowed in header). Added HOST check in Request. --- src/VCR/Exceptions/InvalidHostException.php | 8 +++-- src/VCR/Request.php | 19 ++++++++---- tests/VCR/Util/CurlHelperTest.php | 33 +++++++++++++-------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/VCR/Exceptions/InvalidHostException.php b/src/VCR/Exceptions/InvalidHostException.php index a42da507d..1b583b429 100644 --- a/src/VCR/Exceptions/InvalidHostException.php +++ b/src/VCR/Exceptions/InvalidHostException.php @@ -3,8 +3,12 @@ namespace VCR\Exceptions; +use InvalidArgumentException; -class InvalidHostException +class InvalidHostException extends InvalidArgumentException { - + public static function create(?string $url): self + { + return new self(sprintf('Could not read host from URL "%s". Please check the URL syntax.', $url)); + } } \ No newline at end of file diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 30ec047b1..f44638876 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -2,6 +2,9 @@ namespace VCR; +use function sprintf; +use VCR\Exceptions\InvalidHostException; + /** * Encapsulates a HTTP request. */ @@ -20,7 +23,7 @@ class Request */ protected $headers = array(); /** - * @var string + * @var string|null */ protected $body; /** @@ -127,18 +130,18 @@ public static function fromArray(array $request) } /** - * @param string $url + * @param string|null $url */ public function setUrl($url) { $this->url = $url; - if ($this->hasHeader('Host') === false || $this->getHeader('Host') === null) { + if ($url !== null && $this->hasHeader('Host') === false) { $this->setHeader('Host', $this->getHost()); } } /** - * @return string + * @return string|null */ public function getBody() { @@ -214,6 +217,10 @@ public function getHost() { $host = parse_url($this->getUrl(), PHP_URL_HOST); + if ($host === null) { + throw InvalidHostException::create($this->getUrl()); + } + if ($port = parse_url($this->getUrl(), PHP_URL_PORT)) { $host .= ':' . $port; } @@ -285,7 +292,7 @@ public function setPostFiles(array $post_files) } /** - * @param string $body + * @param string|null $body */ public function setBody($body) { @@ -315,7 +322,7 @@ public function setCurlOptions(array $curlOptions) * @param string $key * @param string $value */ - public function setHeader($key, $value) + public function setHeader(string $key, string $value) { $this->headers[$key] = $value; } diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 4eb16a66f..66816a3f7 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -4,6 +4,7 @@ use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Exceptions\InvalidHostException; use VCR\Request; use VCR\Response; @@ -14,7 +15,7 @@ class CurlHelperTest extends TestCase */ public function testSetCurlOptionMethods($method) { - $request = new Request($method, 'example.com'); + $request = new Request($method, 'http://example.com'); $headers = array('Host: example.com'); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); @@ -43,7 +44,7 @@ public function getHttpMethodsProvider() public function testSetCurlOptionOnRequestPostFieldsQueryString() { - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $payload = 'para1=val1¶2=val2'; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -53,7 +54,7 @@ public function testSetCurlOptionOnRequestPostFieldsQueryString() public function testSetCurlOptionOnRequestPostFieldsArray() { - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $payload = array('some' => 'test'); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -64,7 +65,7 @@ public function testSetCurlOptionOnRequestPostFieldsArray() public function testSetCurlOptionOnRequestPostFieldsString() { - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $payload = json_encode(array('some' => 'test')); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -74,7 +75,7 @@ public function testSetCurlOptionOnRequestPostFieldsString() public function testSetCurlOptionOnRequestPostFieldsEmptyString() { - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $payload = ''; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -86,7 +87,7 @@ public function testSetCurlOptionOnRequestPostFieldsEmptyString() public function testSetCurlOptionOnRequestSetSingleHeader() { - $request = new Request('GET', 'example.com'); + $request = new Request('GET', 'http://example.com'); $headers = array('Host: example.com'); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); @@ -96,7 +97,7 @@ public function testSetCurlOptionOnRequestSetSingleHeader() public function testSetCurlOptionOnRequestSetSingleHeaderTwice() { - $request = new Request('GET', 'example.com'); + $request = new Request('GET', 'http://example.com'); $headers = array('Host: example.com'); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); @@ -107,7 +108,7 @@ public function testSetCurlOptionOnRequestSetSingleHeaderTwice() public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() { - $request = new Request('GET', 'example.com'); + $request = new Request('GET', 'http://example.com'); $headers = array( 'Host: example.com', 'Content-Type: application/json', @@ -125,7 +126,7 @@ public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() { - $request = new Request('GET', 'example.com'); + $request = new Request('GET', 'http://example.com'); $headers = array( 'Host: example.com', 'Content-Type: application/json', @@ -142,7 +143,7 @@ public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() { - $request = new Request('GET', 'example.com'); + $request = new Request('GET', 'http://example.com'); $payload = json_encode(array('some' => 'test')); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -152,17 +153,23 @@ public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() public function testSetCurlOptionReadFunctionToNull() { - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, null, curl_init()); $this->assertNull($request->getCurlOption(CURLOPT_READFUNCTION)); } + public function testInvalidHostException() + { + $this->expectException(InvalidHostException::class, 'URL must be valid.'); + new Request('POST', 'example.com'); + } + public function testSetCurlOptionReadFunctionMissingSize() { $this->expectException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $callback = function ($curlHandle, $fileHandle, $size) { }; @@ -174,7 +181,7 @@ public function testSetCurlOptionReadFunctionMissingSize() public function testSetCurlOptionReadFunction() { $expected = 'test body'; - $request = new Request('POST', 'example.com'); + $request = new Request('POST', 'http://example.com'); $test = $this; $callback = function ($curlHandle, $fileHandle, $size) use ($test, $expected) { From c63ea358705180969c8f2674850f80b7868385d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 09:24:00 +0100 Subject: [PATCH 022/204] Upgrading to PHPStan level 4. --- composer.json | 2 +- phpstan.neon | 2 ++ src/VCR/Exceptions/InvalidHostException.php | 3 +-- src/VCR/Request.php | 2 +- src/VCR/Util/CurlHelper.php | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 17b69ccdd..c1668d705 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=3 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=4 --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon index 598c1a2ad..5add13672 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,7 @@ parameters: - "#Call to an undefined static method SoapClient::__construct\\(\\)#" - "#Access to an undefined property object::\\$data\\.#" - "#Access to an undefined property object::\\$datalen\\.#" + # Cast to string is necessary to work around a PHP bug. See SoapClient::__doRequest + - "#Casting to string something that's already string\\.#" #includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon diff --git a/src/VCR/Exceptions/InvalidHostException.php b/src/VCR/Exceptions/InvalidHostException.php index 1b583b429..8faa1f240 100644 --- a/src/VCR/Exceptions/InvalidHostException.php +++ b/src/VCR/Exceptions/InvalidHostException.php @@ -1,6 +1,5 @@ setHeader($headerParts[0], $headerParts[1]); } From e9eff96d7638c6b8549cb7a9f91b642baabca3a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 09:54:14 +0100 Subject: [PATCH 023/204] Adding casts for parameters (int to bool...) Reaching PHPStan level 5. --- composer.json | 2 +- src/VCR/Request.php | 4 ++-- src/VCR/Util/StreamProcessor.php | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index c1668d705..b74339b35 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=4 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=5 --no-progress -vvv" }, "authors": [ diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 655f877a9..a383436b4 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -253,7 +253,7 @@ public function getCurlOptions() } /** - * @param string $key + * @param int $key * @return mixed */ public function getCurlOption($key) @@ -345,7 +345,7 @@ public function setPostField($key, $value) } /** - * @param string $key + * @param int $key * @param mixed $value */ public function setCurlOption($key, $value) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index ac9408386..f75c30549 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -179,9 +179,9 @@ public function stream_open($path, $mode, $options, &$openedPath) $this->restore(); if (isset($this->context)) { - $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH, $this->context); + $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH), $this->context); } else { - $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH); + $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH)); } if ($options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { @@ -390,9 +390,9 @@ public function mkdir($path, $mode, $options) { $this->restore(); if (isset($this->context)) { - $result = mkdir($path, $mode, $options, $this->context); + $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE), $this->context); } else { - $result = mkdir($path, $mode, $options); + $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE)); } $this->intercept(); @@ -489,7 +489,7 @@ public function stream_set_option($option, $arg1, $arg2) { switch ($option) { case STREAM_OPTION_BLOCKING: - return stream_set_blocking($this->resource, $arg1); + return stream_set_blocking($this->resource, (bool) $arg1); case STREAM_OPTION_READ_TIMEOUT: return stream_set_timeout($this->resource, $arg1, $arg2); case STREAM_OPTION_WRITE_BUFFER: From 1f788e8b170d4b3b03ad6831906263ea729d6682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:21:56 +0100 Subject: [PATCH 024/204] Adding additional check to be sure the cassette was successfully opened. --- src/VCR/Storage/AbstractStorage.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index d6b9c5d3e..c37b9979c 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -76,7 +76,11 @@ public function __construct($cassettePath, $cassetteName, $defaultContent = '[]' Assertion::file($this->filePath, "Specified path '{$this->filePath}' is not a file."); Assertion::readable($this->filePath, "Specified file '{$this->filePath}' must be readable."); - $this->handle = fopen($this->filePath, 'r+'); + $handle = fopen($this->filePath, 'r+'); + + Assertion::isResource($handle); + + $this->handle = $handle; } /** From cede95ee3ddfc8f257cdf6363319b2379d6e6977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:26:05 +0100 Subject: [PATCH 025/204] Asserting that curl_init did succeed --- src/VCR/Util/HttpClient.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 770c6a7e5..9fbce6a0d 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -22,6 +22,9 @@ class HttpClient public function send(Request $request) { $ch = curl_init($request->getUrl()); + + Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'"); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); if (!is_null($request->getBody())) { From 8e6530acdd0330e17cb0db048db76616f79c682b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:28:37 +0100 Subject: [PATCH 026/204] Reaching PHPStan level 6 Tweaked some PHPDoc statements. Added some ignore in PHPStan where assertions are already ensuring safety. --- phpstan.neon | 11 ++++++++++- src/VCR/LibraryHooks/CurlHook.php | 10 ++++++---- src/VCR/Util/StreamProcessor.php | 14 +++++++------- tests/VCR/Util/HttpClientTest.php | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 5add13672..4ad0ec780 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,5 +5,14 @@ parameters: - "#Access to an undefined property object::\\$datalen\\.#" # Cast to string is necessary to work around a PHP bug. See SoapClient::__doRequest - "#Casting to string something that's already string\\.#" -#includes: + - "#Parameter \\#1 \\$function of function call_user_func_array expects callable, array.* given#" + # Working around a PHPStan bug that does not detect a non falsy value in Yaml::readNextRecord + - "#Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given#" + - "#Parameter \\#1 \\$string of function strlen expects string, string\\|false given#" + # PHPStan cannot detect that curl_exec will return a string and not true (because of the CURLOPT_RETURNTRANSFER option. In HttpClient::send + - '#Parameter .* \\$response of static method VCR\\\\Util\\\\HttpUtil::parseResponse\\(\\) expects string, string\\|true given.#' + # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus + - '#Parameter .* \\$str of function substr expects string, string\\|false given.#' +includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index e4f18eb71..db28def08 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -132,7 +132,7 @@ public function isEnabled() /** * Calls the intercepted curl method if library hook is disabled, otherwise the real one. * - * @param string $method cURL method to call, example: curl_info() + * @param callable&string $method cURL method to call, example: curl_info() * @param array $args cURL arguments for this function. * * @return mixed cURL function return type. @@ -166,13 +166,15 @@ public static function __callStatic($method, $args) * @link http://www.php.net/manual/en/function.curl-init.php * @param string $url (Optional) url. * - * @return resource cURL handle. + * @return resource|false cURL handle. */ public static function curlInit($url = null) { $curlHandle = \curl_init($url); - self::$requests[(int) $curlHandle] = new Request('GET', $url); - self::$curlOptions[(int) $curlHandle] = array(); + if ($curlHandle !== false) { + self::$requests[(int) $curlHandle] = new Request('GET', $url); + self::$curlOptions[(int) $curlHandle] = array(); + } return $curlHandle; } diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index f75c30549..5d5037b4c 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -38,7 +38,7 @@ class StreamProcessor protected static $codeTransformers = array(); /** - * @var resource Resource for the currently opened file. + * @var resource|false Resource for the currently opened file. */ protected $resource; @@ -236,8 +236,8 @@ public function stream_flush() * @link http://www.php.net/manual/en/streamwrapper.stream-read.php * @param int $count How many bytes of data from the current position should be returned. * - * @return string If there are less than count bytes available, return as many as are available. - * If no more data is available, return either FALSE or an empty string. + * @return string|false If there are less than count bytes available, return as many as are available. + * If no more data is available, return either FALSE or an empty string. */ public function stream_read($count) { @@ -264,7 +264,7 @@ public function stream_seek($offset, $whence = SEEK_SET) * * @link http://www.php.net/manual/en/streamwrapper.stream-stat.php * - * @return array See stat(). + * @return array|false See stat(). */ public function stream_stat() { @@ -278,7 +278,7 @@ public function stream_stat() * * @link http://www.php.net/manual/en/streamwrapper.stream-tell.php * - * @return integer Should return the current position of the stream. + * @return integer|false Should return the current position of the stream. */ public function stream_tell() { @@ -451,7 +451,7 @@ public function rmdir($path) * * @param integer $cast_as Can be STREAM_CAST_FOR_SELECT when stream_select() is calling stream_cast() or * STREAM_CAST_AS_STREAM when stream_cast() is called for other uses. - * @return resource Should return the underlying stream resource used by the wrapper, or FALSE. + * @return resource|false Should return the underlying stream resource used by the wrapper, or FALSE. */ public function stream_cast($cast_as) { @@ -513,7 +513,7 @@ public function stream_set_option($option, $arg1, $arg2) * * @param string $data Should be stored into the underlying stream. * - * @return int + * @return int|false */ public function stream_write($data) { diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index 577b9e2c1..f4570cfd9 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -14,7 +14,7 @@ public function testHttpClientOnError() // Request on a closed port $request = new Request('GET', 'http://localhost:9934'); - $this->setExpectedException('VCR\\Util\\CurlException'); + $this->expectException(CurlException::class); $httpClient->send($request); } } From bd2a5ed308a83ef28e5a9efbdebfaadd2d4200a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:29:13 +0100 Subject: [PATCH 027/204] Adding beberlei assertion PHPStan plugin (needed to improve the impact of Assertions on types) --- composer.json | 5 +++-- composer.lock | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index b74339b35..3b22825d4 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=5 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=6 --no-progress -vvv" }, "authors": [ @@ -28,7 +28,8 @@ "require-dev": { "phpunit/phpunit": "^7.4.3", "mikey179/vfsStream": "^1.2", - "phpstan/phpstan": "^0.10.5" + "phpstan/phpstan": "^0.10.5", + "phpstan/phpstan-beberlei-assert": "^0.10.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index b805fc2b9..1947a836b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "1354b1a85494d7a07315f638d1921a27", + "content-hash": "372c55d1526a601af19752af85c33075", "packages": [ { "name": "beberlei/assert", @@ -1495,6 +1495,54 @@ "description": "PHPStan - PHP Static Analysis Tool", "time": "2018-10-20T17:24:55+00:00" }, + { + "name": "phpstan/phpstan-beberlei-assert", + "version": "0.10", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-beberlei-assert.git", + "reference": "612836107af207a89974758ad1cb6ea0430d18a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-beberlei-assert/zipball/612836107af207a89974758ad1cb6ea0430d18a6", + "reference": "612836107af207a89974758ad1cb6ea0430d18a6", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.0", + "php": "~7.1", + "phpstan/phpstan": "^0.10" + }, + "require-dev": { + "beberlei/assert": "^2.9.5", + "consistence/coding-standard": "^3.0.1", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "phing/phing": "^2.16.0", + "phpstan/phpstan-phpunit": "^0.10", + "phpstan/phpstan-strict-rules": "^0.10", + "phpunit/phpunit": "^7.1.3", + "slevomat/coding-standard": "^4.5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan beberlei/assert extension", + "time": "2018-06-23T17:18:41+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "6.1.3", From 5bf26c0f2370b1faeea55616bb0a4119cb8f0097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:29:41 +0100 Subject: [PATCH 028/204] Removing invalid XML from PHPUnit file --- phpunit.xml.dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0a5ff319b..a2faf7ba9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -17,9 +17,6 @@ - - ./vendor - src From d3dd0bff6e28a62349ddb19cf2e6771539e11e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:37:27 +0100 Subject: [PATCH 029/204] Allowing beberlei/assert to go up to v3. Increasing minimum version to have support for Assertion::isResource. --- composer.json | 2 +- composer.lock | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 3b22825d4..574e12ed3 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=7.2", "ext-curl": "*", - "beberlei/assert": "^2.0", + "beberlei/assert": "^2.7.11 | ^3.0", "symfony/yaml": "~2.1|^3.0|^4.0", "symfony/event-dispatcher": "^2.4|^3.0|^4.0" }, diff --git a/composer.lock b/composer.lock index 1947a836b..6b46465ac 100644 --- a/composer.lock +++ b/composer.lock @@ -4,29 +4,29 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "372c55d1526a601af19752af85c33075", + "content-hash": "50945719a3b7ff757067b1548befdc0f", "packages": [ { "name": "beberlei/assert", - "version": "v2.9.6", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936" + "reference": "e4f4a40a8739e1151d40fd1ed754a3ed37e1f522" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/ec9e4cf0b63890edce844ee3922e2b95a526e936", - "reference": "ec9e4cf0b63890edce844ee3922e2b95a526e936", + "url": "https://api.github.com/repos/beberlei/assert/zipball/e4f4a40a8739e1151d40fd1ed754a3ed37e1f522", + "reference": "e4f4a40a8739e1151d40fd1ed754a3ed37e1f522", "shasum": "" }, "require": { - "ext-mbstring": "*", - "php": ">=5.3" + "php": "^7" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.1.1", - "phpunit/phpunit": "^4.8.35|^5.7" + "friendsofphp/php-cs-fixer": "*", + "phpstan/phpstan-shim": "*", + "phpunit/phpunit": "*" }, "type": "library", "autoload": { @@ -59,7 +59,7 @@ "assertion", "validation" ], - "time": "2018-06-11T17:15:25+00:00" + "time": "2018-10-29T11:13:48+00:00" }, { "name": "symfony/event-dispatcher", From 87bed2512ffe787dde2abd1cee097f8e268cb7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 20:39:58 +0100 Subject: [PATCH 030/204] Fixing PHPUnit test It was not migrated to PHPUnit 7 yet because it was merged after the migration. --- .travis.yml | 2 +- tests/integration/guzzle/6/test/ErrorTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 879422982..03c88b9e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ cache: directories: - vendor - tests/integration/guzzle/3/vendor - - tests/integration/guzzle/4/vendor +# - tests/integration/guzzle/4/vendor - tests/integration/guzzle/5/vendor - tests/integration/guzzle/6/vendor - tests/integration/soap/vendor diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php index 6a3d03b0c..6e21b61cb 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -6,12 +6,13 @@ use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ConnectException; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; use VCR\Util\CurlException; /** * Tests behaviour when an error occurs. */ -class ErrorTest extends \PHPUnit_Framework_TestCase +class ErrorTest extends TestCase { const TEST_GET_URL = 'http://localhost:9959'; From 707ddd665407548c8ca4037fc428f4900861ba7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 29 Oct 2018 21:12:09 +0100 Subject: [PATCH 031/204] Reaching PHPStan level 7 \o/ --- composer.json | 2 +- phpstan.neon | 2 ++ src/VCR/LibraryHooks/CurlHook.php | 1 + src/VCR/LibraryHooks/SoapHook.php | 1 + src/VCR/LibraryHooks/StreamWrapperHook.php | 1 + src/VCR/Request.php | 26 ++++++++++++++-------- src/VCR/Response.php | 6 ++--- src/VCR/Storage/AbstractStorage.php | 2 +- src/VCR/Util/SoapClient.php | 2 +- src/VCR/Util/StreamProcessor.php | 2 +- tests/VCR/ResponseTest.php | 10 ++++----- 11 files changed, 34 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 574e12ed3..f5f22449b 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=6 --no-progress -vvv" + "phpstan": "phpstan analyse src -c phpstan.neon --level=7 --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon index 4ad0ec780..8dcea95bd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,6 +13,8 @@ parameters: - '#Parameter .* \\$response of static method VCR\\\\Util\\\\HttpUtil::parseResponse\\(\\) expects string, string\\|true given.#' # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - '#Parameter .* \\$str of function substr expects string, string\\|false given.#' + # It turns out that curl_init DOES accept null as first parameter, even if it is not documented. + - '#Parameter .* $url of function curl_init expects string, string\\|null given.#' includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index db28def08..d5a5526d4 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -210,6 +210,7 @@ public static function curlExec($curlHandle) CurlHelper::validateCurlPOSTBody($request, $curlHandle); $requestCallback = self::$requestCallback; + Assertion::isCallable($requestCallback); self::$responses[(int) $curlHandle] = $requestCallback($request); return CurlHelper::handleOutput( diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 60d990bfb..1a8d0678d 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -92,6 +92,7 @@ public function doRequest($request, $location, $action, $version, $one_way = 0, /* @var \VCR\Response $response */ $requestCallback = self::$requestCallback; + Assertion::isCallable($requestCallback); $response = $requestCallback($vcrRequest); return $response->getBody(); diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index 29092074d..b26ce79a3 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -91,6 +91,7 @@ public function stream_open($path, $mode, $options, &$opened_path) $request = StreamHelper::createRequestFromStreamContext($this->context, $path); $requestCallback = self::$requestCallback; + Assertion::isCallable($requestCallback); try { $this->response = $requestCallback($request); return true; diff --git a/src/VCR/Request.php b/src/VCR/Request.php index a383436b4..7a4d34f81 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -2,6 +2,7 @@ namespace VCR; +use Assert\Assertion; use function sprintf; use VCR\Exceptions\InvalidHostException; @@ -15,7 +16,7 @@ class Request */ protected $method; /** - * @var string + * @var string|null */ protected $url; /** @@ -203,7 +204,7 @@ public function getPostFiles() } /** - * @return string + * @return string|null */ public function getUrl() { @@ -211,17 +212,20 @@ public function getUrl() } /** - * @return mixed + * @return string */ public function getHost() { - $host = parse_url($this->getUrl(), PHP_URL_HOST); + $url = $this->getUrl(); + Assertion::string($url); + + $host = parse_url($url, PHP_URL_HOST); if ($host === null) { throw InvalidHostException::create($this->getUrl()); } - if ($port = parse_url($this->getUrl(), PHP_URL_PORT)) { + if ($port = parse_url($url, PHP_URL_PORT)) { $host .= ':' . $port; } @@ -229,19 +233,23 @@ public function getHost() } /** - * @return mixed + * @return string */ public function getPath() { - return parse_url($this->getUrl(), PHP_URL_PATH); + $url = $this->getUrl(); + Assertion::string($url); + return parse_url($url, PHP_URL_PATH); } /** - * @return mixed + * @return string */ public function getQuery() { - return parse_url($this->getUrl(), PHP_URL_QUERY); + $url = $this->getUrl(); + Assertion::string($url); + return parse_url($url, PHP_URL_QUERY); } /** diff --git a/src/VCR/Response.php b/src/VCR/Response.php index 5f3918a6e..6456b3bf6 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -22,7 +22,7 @@ class Response */ protected $headers = array(); /** - * @var string + * @var string|null */ protected $body; /** @@ -35,7 +35,7 @@ class Response /** * @param string|array $status * @param array $headers - * @param string $body + * @param string|null $body * @param array $curlInfo */ public function __construct($status, array $headers = array(), $body = null, array $curlInfo = array()) @@ -103,7 +103,7 @@ public static function fromArray(array $response) */ public function getBody() { - return $this->body; + return $this->body ?: ''; } /** diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index c37b9979c..df13037a8 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -86,7 +86,7 @@ public function __construct($cassettePath, $cassetteName, $defaultContent = '[]' /** * Returns the current record. * - * @return array Parsed current record. + * @return array|null Parsed current record. */ public function current() { diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index 3be9aab76..c1c367f53 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -44,7 +44,7 @@ public function __construct($wsdl, $options = array()) * @param integer $version The SOAP version. * @param integer $one_way If one_way is set to 1, this method returns nothing. * Use this where a response is not expected. - * @return string The XML SOAP response. + * @return string|null The XML SOAP response (or null if $one_way is set). */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 5d5037b4c..8f2c19bd9 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -555,7 +555,7 @@ public function unlink($path) public function stream_metadata($path, $option, $value) { $this->restore(); - $result = null; + $result = false; switch ($option) { case STREAM_META_TOUCH: diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index 28b8ded53..a354ec908 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -47,13 +47,13 @@ public function testGetBody() $response = Response::fromArray(array('body' => $expectedBody)); - $this->assertEquals($expectedBody, $response->getBody(true)); + $this->assertEquals($expectedBody, $response->getBody()); } public function testGetBodyNoneDefined() { $response = Response::fromArray(array()); - $this->assertNull($response->getBody(true)); + $this->assertEmpty($response->getBody()); } public function testRestoreBodyFromArray() @@ -62,7 +62,7 @@ public function testRestoreBodyFromArray() $response = new Response(200, array(), $body); $restoredResponse = Response::fromArray($response->toArray()); - $this->assertEquals($body, $restoredResponse->getBody(true)); + $this->assertEquals($body, $restoredResponse->getBody()); } public function testBase64EncodeCompressedBody() @@ -83,7 +83,7 @@ public function testBase64DecodeCompressedBody() ); $response = Response::fromArray($responseArray); - $this->assertEquals($body, $response->getBody(true)); + $this->assertEquals($body, $response->getBody()); } public function testRestoreCompressedBody() @@ -92,7 +92,7 @@ public function testRestoreCompressedBody() $response = new Response(200, array('Content-Type' => 'application/x-gzip'), $body); $restoredResponse = Response::fromArray($response->toArray()); - $this->assertEquals($body, $restoredResponse->getBody(true)); + $this->assertEquals($body, $restoredResponse->getBody()); } public function testGetStatus() From 33458d525c448431ee8c7f9d96cffec2d08412b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 30 Oct 2018 11:18:19 +0100 Subject: [PATCH 032/204] Adding PHP 7.1+ types --- composer.json | 3 +- composer.lock | 58 ++++++++++++-- phpstan.neon | 4 +- src/VCR/Cassette.php | 18 ++--- src/VCR/Configuration.php | 51 ++++++------- src/VCR/Event/AfterHttpRequestEvent.php | 4 +- src/VCR/Event/AfterPlaybackEvent.php | 6 +- src/VCR/Event/BeforeHttpRequestEvent.php | 2 +- src/VCR/Event/BeforePlaybackEvent.php | 4 +- src/VCR/Event/BeforeRecordEvent.php | 6 +- src/VCR/LibraryHooks/CurlHook.php | 36 ++++----- src/VCR/LibraryHooks/LibraryHook.php | 6 +- src/VCR/LibraryHooks/SoapHook.php | 11 ++- src/VCR/LibraryHooks/StreamWrapperHook.php | 28 +++---- src/VCR/Request.php | 88 +++++++++++----------- src/VCR/RequestMatcher.php | 14 ++-- src/VCR/Response.php | 40 +++++----- src/VCR/Storage/AbstractStorage.php | 4 +- src/VCR/Storage/Blackhole.php | 4 +- src/VCR/Storage/Json.php | 6 +- src/VCR/Storage/Storage.php | 6 +- src/VCR/Storage/Yaml.php | 4 +- src/VCR/Util/CurlException.php | 6 +- src/VCR/Util/CurlHelper.php | 15 ++-- src/VCR/Util/HttpClient.php | 2 +- src/VCR/Util/HttpUtil.php | 22 +++--- src/VCR/Util/SoapClient.php | 15 +++- src/VCR/Util/StreamHelper.php | 7 +- src/VCR/Util/StreamProcessor.php | 60 +++++++-------- src/VCR/Util/TextUtil.php | 2 +- src/VCR/VCR.php | 7 +- src/VCR/VCRFactory.php | 33 ++++---- src/VCR/Videorecorder.php | 22 +++--- tests/VCR/CassetteTest.php | 6 -- tests/VCR/ConfigurationTest.php | 6 -- tests/VCR/RequestTest.php | 33 ++++++++ tests/VCR/Storage/AbstractStorageTest.php | 2 +- tests/VCR/VideorecorderTest.php | 5 +- 38 files changed, 368 insertions(+), 278 deletions(-) diff --git a/composer.json b/composer.json index f5f22449b..6616722d8 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "phpunit/phpunit": "^7.4.3", "mikey179/vfsStream": "^1.2", "phpstan/phpstan": "^0.10.5", - "phpstan/phpstan-beberlei-assert": "^0.10.0" + "phpstan/phpstan-beberlei-assert": "^0.10.0", + "thecodingmachine/phpstan-strict-rules": "^0.10.6" }, "autoload": { diff --git a/composer.lock b/composer.lock index 6b46465ac..22cdc4b36 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "50945719a3b7ff757067b1548befdc0f", + "content-hash": "63c3bc1d8732d38581a36c56b227b2d7", "packages": [ { "name": "beberlei/assert", @@ -1748,16 +1748,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", "shasum": "" }, "require": { @@ -1793,7 +1793,7 @@ "keywords": [ "tokenizer" ], - "time": "2018-02-01T13:16:43+00:00" + "time": "2018-10-30T05:52:18+00:00" }, { "name": "phpunit/phpunit", @@ -2665,6 +2665,52 @@ ], "time": "2018-08-06T14:22:27+00:00" }, + { + "name": "thecodingmachine/phpstan-strict-rules", + "version": "v0.10.7", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/phpstan-strict-rules.git", + "reference": "bf15df9169b3909ad5eb3b7825b70e793c8b4520" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thecodingmachine/phpstan-strict-rules/zipball/bf15df9169b3909ad5eb3b7825b70e793c8b4520", + "reference": "bf15df9169b3909ad5eb3b7825b70e793c8b4520", + "shasum": "" + }, + "require": { + "php": "^7.1", + "phpstan/phpstan": "^0.10" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.10-dev" + } + }, + "autoload": { + "psr-4": { + "TheCodingMachine\\PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Négrier", + "email": "d.negrier@thecodingmachine.com" + } + ], + "description": "A set of additional rules for PHPStan based on best practices followed at TheCodingMachine", + "time": "2018-10-30T10:43:52+00:00" + }, { "name": "theseer/tokenizer", "version": "1.1.0", diff --git a/phpstan.neon b/phpstan.neon index 8dcea95bd..f4ab09b3c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -16,5 +16,5 @@ parameters: # It turns out that curl_init DOES accept null as first parameter, even if it is not documented. - '#Parameter .* $url of function curl_init expects string, string\\|null given.#' includes: -# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - - vendor/phpstan/phpstan-beberlei-assert/extension.neon + - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 0d0237c46..2e43117ac 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -38,10 +38,8 @@ class Cassette * @param Storage $storage Storage to use for requests and responses. * @throws \VCR\VCRException If cassette name is in an invalid format. */ - public function __construct($name, Configuration $config, Storage $storage) + public function __construct(string $name, Configuration $config, Storage $storage) { - Assertion::string($name, 'Cassette name must be a string, ' . \gettype($name) . ' given.'); - $this->name = $name; $this->config = $config; $this->storage = $storage; @@ -54,7 +52,7 @@ public function __construct($name, Configuration $config, Storage $storage) * * @return boolean True if a response was recorded for specified request. */ - public function hasResponse(Request $request) + public function hasResponse(Request $request): bool { return $this->playback($request) !== null; } @@ -66,7 +64,7 @@ public function hasResponse(Request $request) * * @return Response|null Response for specified request. */ - public function playback(Request $request) + public function playback(Request $request): ?Response { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); @@ -86,7 +84,7 @@ public function playback(Request $request) * * @return void */ - public function record(Request $request, Response $response) + public function record(Request $request, Response $response): void { if ($this->hasResponse($request)) { return; @@ -105,7 +103,7 @@ public function record(Request $request, Response $response) * * @return string Current cassette name. */ - public function getName() + public function getName(): string { return $this->name; } @@ -115,7 +113,7 @@ public function getName() * * @return boolean */ - public function isNew() + public function isNew(): bool { return $this->storage->isNew(); } @@ -123,9 +121,9 @@ public function isNew() /** * Returns a list of callbacks to configured request matchers. * - * @return array List of callbacks to configured request matchers. + * @return callable[] List of callbacks to configured request matchers. */ - protected function getRequestMatchers() + protected function getRequestMatchers(): array { return $this->config->getRequestMatchers(); } diff --git a/src/VCR/Configuration.php b/src/VCR/Configuration.php index a24cfb3a4..e7c702c7f 100644 --- a/src/VCR/Configuration.php +++ b/src/VCR/Configuration.php @@ -86,7 +86,7 @@ class Configuration * The RequestMatcher callback takes two Request objects and * returns true if they match or false otherwise. * - * @var array List of RequestMatcher names and callbacks. + * @var array List of RequestMatcher names and callbacks. */ private $availableRequestMatchers = array( 'method' => array('VCR\RequestMatcher', 'matchMethod'), @@ -106,7 +106,7 @@ class Configuration * all files (which are not blacklisted) are being considered for * code transformation. * - * @var array A whitelist is a list of paths. + * @var string[] A whitelist is a list of paths. */ private $whiteList = array(); @@ -116,7 +116,7 @@ class Configuration * Files in this path are left as is. Blacklisting PHP-VCRs own paths is necessary * to avoid infinite loops. * - * @var array A blacklist is a list of paths. + * @var string[] A blacklist is a list of paths. */ private $blackList = array('src/VCR/LibraryHooks/', 'src/VCR/Util/SoapClient', 'tests/VCR/Filter'); @@ -146,9 +146,9 @@ class Configuration /** * Returns the current blacklist. * - * @return array + * @return string[] */ - public function getBlackList() + public function getBlackList(): array { return $this->blackList; } @@ -160,7 +160,7 @@ public function getBlackList() * * @return Configuration */ - public function setBlackList($paths) + public function setBlackList($paths): self { $paths = (is_array($paths)) ? $paths : array($paths); @@ -174,7 +174,7 @@ public function setBlackList($paths) * * @return string Path to where cassettes are stored. */ - public function getCassettePath() + public function getCassettePath(): string { $this->assertValidCassettePath($this->cassettePath); @@ -189,7 +189,7 @@ public function getCassettePath() * @return Configuration * @throws VCRException If provided cassette path is invalid. */ - public function setCassettePath($cassettePath) + public function setCassettePath(string $cassettePath): self { $this->assertValidCassettePath($cassettePath); $this->cassettePath = $cassettePath; @@ -205,7 +205,7 @@ public function setCassettePath($cassettePath) * * @return string[] List of LibraryHook class names. */ - public function getLibraryHooks() + public function getLibraryHooks(): array { if ($this->enabledLibraryHooks === null) { return array_values($this->availableLibraryHooks); @@ -224,7 +224,7 @@ public function getLibraryHooks() * @return Configuration * @throws \InvalidArgumentException If a specified library hook doesn't exist. */ - public function enableLibraryHooks($hooks) + public function enableLibraryHooks($hooks): self { $hooks = is_array($hooks) ? $hooks : array($hooks); $invalidHooks = array_diff($hooks, array_keys($this->availableLibraryHooks)); @@ -243,7 +243,7 @@ public function enableLibraryHooks($hooks) * * @return string Class name of the storage to use. */ - public function getStorage() + public function getStorage(): string { return $this->availableStorages[$this->enabledStorage]; } @@ -251,9 +251,9 @@ public function getStorage() /** * Returns a list of enabled RequestMatcher callbacks. * - * @return array List of enabled RequestMatcher callbacks. + * @return callable[] List of enabled RequestMatcher callbacks. */ - public function getRequestMatchers() + public function getRequestMatchers(): array { if ($this->enabledRequestMatchers === null) { return array_values($this->availableRequestMatchers); @@ -274,10 +274,9 @@ public function getRequestMatchers() * @return Configuration * @throws VCRException If specified parameters are invalid. */ - public function addRequestMatcher($name, $callback) + public function addRequestMatcher(string $name, callable $callback): self { - Assertion::minLength($name, 1, "A request matchers name must be at least one character long. Found '{$name}'"); - Assertion::isCallable($callback, "Request matcher '{$name}' is not callable."); + Assertion::minLength($name, 1, "A request matchers name must be at least one character long. Found ''"); $this->availableRequestMatchers[$name] = $callback; return $this; @@ -286,13 +285,13 @@ public function addRequestMatcher($name, $callback) /** * Enables specified RequestMatchers by its name. * - * @param array $matchers List of RequestMatcher names to enable. + * @param string[] $matchers List of RequestMatcher names to enable. * * @return Configuration * * @throws \InvalidArgumentException If a specified request matcher does not exist. */ - public function enableRequestMatchers(array $matchers) + public function enableRequestMatchers(array $matchers): self { $invalidMatchers = array_diff($matchers, array_keys($this->availableRequestMatchers)); if ($invalidMatchers) { @@ -308,10 +307,10 @@ public function enableRequestMatchers(array $matchers) * * @param string $storageName Name of the storage to enable. * - * @return $this + * @return self * @throws VCRException If a invalid storage name is given. */ - public function setStorage($storageName) + public function setStorage(string $storageName): self { Assertion::keyExists($this->availableStorages, $storageName, "Storage '{$storageName}' not available."); $this->enabledStorage = $storageName; @@ -322,9 +321,9 @@ public function setStorage($storageName) /** * Returns a list of whitelisted paths. * - * @return array + * @return string[] */ - public function getWhiteList() + public function getWhiteList(): array { return $this->whiteList; } @@ -336,7 +335,7 @@ public function getWhiteList() * * @return Configuration */ - public function setWhiteList($paths) + public function setWhiteList($paths): Configuration { $paths = (is_array($paths)) ? $paths : array($paths); @@ -350,7 +349,7 @@ public function setWhiteList($paths) * * @return string */ - public function getMode() + public function getMode(): string { return $this->mode; } @@ -362,7 +361,7 @@ public function getMode() * * @return Configuration */ - public function setMode($mode) + public function setMode(string $mode): Configuration { Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist."); $this->mode = $mode; @@ -376,7 +375,7 @@ public function setMode($mode) * @param string $cassettePath Path to a cassette. * @throws VCRException If cassette path is invalid. */ - private function assertValidCassettePath($cassettePath) + private function assertValidCassettePath(string $cassettePath): void { Assertion::directory( $cassettePath, diff --git a/src/VCR/Event/AfterHttpRequestEvent.php b/src/VCR/Event/AfterHttpRequestEvent.php index de810594b..9d8d0e0f5 100644 --- a/src/VCR/Event/AfterHttpRequestEvent.php +++ b/src/VCR/Event/AfterHttpRequestEvent.php @@ -31,7 +31,7 @@ public function __construct(Request $request, Response $response) /** * @return Request */ - public function getRequest() + public function getRequest(): Request { return $this->request; } @@ -39,7 +39,7 @@ public function getRequest() /** * @return Response */ - public function getResponse() + public function getResponse(): Response { return $this->response; } diff --git a/src/VCR/Event/AfterPlaybackEvent.php b/src/VCR/Event/AfterPlaybackEvent.php index c15b456c8..26f7d7f4c 100644 --- a/src/VCR/Event/AfterPlaybackEvent.php +++ b/src/VCR/Event/AfterPlaybackEvent.php @@ -39,7 +39,7 @@ public function __construct(Request $request, Response $response, Cassette $cass /** * @return Request */ - public function getRequest() + public function getRequest(): Request { return $this->request; } @@ -47,7 +47,7 @@ public function getRequest() /** * @return Response */ - public function getResponse() + public function getResponse(): Response { return $this->response; } @@ -55,7 +55,7 @@ public function getResponse() /** * @return Cassette */ - public function getCassette() + public function getCassette(): Cassette { return $this->cassette; } diff --git a/src/VCR/Event/BeforeHttpRequestEvent.php b/src/VCR/Event/BeforeHttpRequestEvent.php index 0bf1211d6..aaa365af6 100644 --- a/src/VCR/Event/BeforeHttpRequestEvent.php +++ b/src/VCR/Event/BeforeHttpRequestEvent.php @@ -23,7 +23,7 @@ public function __construct(Request $request) /** * @return Request */ - public function getRequest() + public function getRequest(): Request { return $this->request; } diff --git a/src/VCR/Event/BeforePlaybackEvent.php b/src/VCR/Event/BeforePlaybackEvent.php index 2c9dd5512..e37d56542 100644 --- a/src/VCR/Event/BeforePlaybackEvent.php +++ b/src/VCR/Event/BeforePlaybackEvent.php @@ -30,7 +30,7 @@ public function __construct(Request $request, Cassette $cassette) /** * @return Request */ - public function getRequest() + public function getRequest(): Request { return $this->request; } @@ -38,7 +38,7 @@ public function getRequest() /** * @return Cassette */ - public function getCassette() + public function getCassette(): Cassette { return $this->cassette; } diff --git a/src/VCR/Event/BeforeRecordEvent.php b/src/VCR/Event/BeforeRecordEvent.php index 5751c0454..bc969f0af 100644 --- a/src/VCR/Event/BeforeRecordEvent.php +++ b/src/VCR/Event/BeforeRecordEvent.php @@ -39,7 +39,7 @@ public function __construct(Request $request, Response $response, Cassette $cass /** * @return Request */ - public function getRequest() + public function getRequest(): Request { return $this->request; } @@ -47,7 +47,7 @@ public function getRequest() /** * @return Response */ - public function getResponse() + public function getResponse(): Response { return $this->response; } @@ -55,7 +55,7 @@ public function getResponse() /** * @return Cassette */ - public function getCassette() + public function getCassette(): Cassette { return $this->cassette; } diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index d5a5526d4..5d63c1175 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -90,7 +90,7 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces /** * @inheritDoc */ - public function enable(\Closure $requestCallback) + public function enable(\Closure $requestCallback): void { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); @@ -110,7 +110,7 @@ public function enable(\Closure $requestCallback) /** * @inheritDoc */ - public function disable() + public function disable(): void { if (static::$status == self::DISABLED) { return; @@ -124,7 +124,7 @@ public function disable() /** * @inheritDoc */ - public function isEnabled() + public function isEnabled(): bool { return self::$status == self::ENABLED; } @@ -133,11 +133,11 @@ public function isEnabled() * Calls the intercepted curl method if library hook is disabled, otherwise the real one. * * @param callable&string $method cURL method to call, example: curl_info() - * @param array $args cURL arguments for this function. + * @param array $args cURL arguments for this function. * * @return mixed cURL function return type. */ - public static function __callStatic($method, $args) + public static function __callStatic($method, array $args) { // Call original when disabled if (static::$status == self::DISABLED) { @@ -164,11 +164,11 @@ public static function __callStatic($method, $args) * Initialize a cURL session. * * @link http://www.php.net/manual/en/function.curl-init.php - * @param string $url (Optional) url. + * @param string|null $url (Optional) url. * * @return resource|false cURL handle. */ - public static function curlInit($url = null) + public static function curlInit(?string $url = null) { $curlHandle = \curl_init($url); if ($curlHandle !== false) { @@ -185,7 +185,7 @@ public static function curlInit($url = null) * @link http://www.php.net/manual/en/function.curl-reset.php * @param resource $curlHandle A cURL handle returned by curl_init(). */ - public static function curlReset($curlHandle) + public static function curlReset($curlHandle): void { \curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); @@ -231,7 +231,7 @@ public static function curlExec($curlHandle) * @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). * @param resource $curlHandle A cURL handle returned by curl_init(). */ - public static function curlMultiAddHandle($multiHandle, $curlHandle) + public static function curlMultiAddHandle($multiHandle, $curlHandle): void { if (!isset(self::$multiHandles[(int) $multiHandle])) { self::$multiHandles[(int) $multiHandle] = array(); @@ -247,7 +247,7 @@ public static function curlMultiAddHandle($multiHandle, $curlHandle) * @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). * @param resource $curlHandle A cURL handle returned by curl_init(). */ - public static function curlMultiRemoveHandle($multiHandle, $curlHandle) + public static function curlMultiRemoveHandle($multiHandle, $curlHandle): void { if (isset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle])) { unset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle]); @@ -263,7 +263,7 @@ public static function curlMultiRemoveHandle($multiHandle, $curlHandle) * * @return integer A cURL code defined in the cURL Predefined Constants. */ - public static function curlMultiExec($multiHandle, &$stillRunning) + public static function curlMultiExec($multiHandle, ?int &$stillRunning): int { if (isset(self::$multiHandles[(int) $multiHandle])) { foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { @@ -308,7 +308,7 @@ public static function curlMultiInfoRead() * * @return mixed */ - public static function curlGetinfo($curlHandle, $option = 0) + public static function curlGetinfo($curlHandle, int $option = 0) { if (isset(self::$responses[(int) $curlHandle])) { return CurlHelper::getCurlOptionFromResponse( @@ -332,7 +332,7 @@ public static function curlGetinfo($curlHandle, $option = 0) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public static function curlSetopt($curlHandle, $option, $value) + public static function curlSetopt($curlHandle, int $option, $value): bool { CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value, $curlHandle); @@ -345,10 +345,10 @@ public static function curlSetopt($curlHandle, $option, $value) * Set multiple options for a cURL transfer. * * @link http://www.php.net/manual/en/function.curl-setopt-array.php - * @param resource $curlHandle A cURL handle returned by curl_init(). - * @param array $options An array specifying which options to set and their values. + * @param resource $curlHandle A cURL handle returned by curl_init(). + * @param array $options An array specifying which options to set and their values. */ - public static function curlSetoptArray($curlHandle, $options) + public static function curlSetoptArray($curlHandle, array $options): void { if (is_array($options)) { foreach ($options as $option => $value) { @@ -366,7 +366,7 @@ public static function curlSetoptArray($curlHandle, $options) * @return string the error message or '' (the empty string) if no * error occurred. */ - public static function curlError($curlHandle) + public static function curlError($curlHandle): string { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getMessage(); @@ -384,7 +384,7 @@ public static function curlError($curlHandle) * @return int the error number or 0 (zero) if no error * occurred. */ - public static function curlErrno($curlHandle) + public static function curlErrno($curlHandle): int { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getCode(); diff --git a/src/VCR/LibraryHooks/LibraryHook.php b/src/VCR/LibraryHooks/LibraryHook.php index 8e059936f..9282602ad 100644 --- a/src/VCR/LibraryHooks/LibraryHook.php +++ b/src/VCR/LibraryHooks/LibraryHook.php @@ -25,7 +25,7 @@ interface LibraryHook * @throws \VCR\VCRException When specified callback is not callable. * @return void */ - public function enable(\Closure $requestCallback); + public function enable(\Closure $requestCallback): void; /** * Disables library hook, so no http interactions of @@ -33,12 +33,12 @@ public function enable(\Closure $requestCallback); * * @return void */ - public function disable(); + public function disable(): void; /** * Returns true if library hook is enabled, false otherwise. * * @return boolean True if library hook is enabled, false otherwise. */ - public function isEnabled(); + public function isEnabled(): bool; } diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 1a8d0678d..9a3470f2b 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -61,12 +61,11 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces * @param string $action * @param integer $version * @param int $one_way - * - * @throws \VCR\VCRException It this method is called although VCR is disabled. + * @param array $options * * @return string SOAP response. */ - public function doRequest($request, $location, $action, $version, $one_way = 0, $options = array()) + public function doRequest(string $request, string $location, string $action, int $version, int $one_way = 0, array $options = array()): string { if ($this->status === self::DISABLED) { throw new VCRException('Hook must be enabled.', VCRException::LIBRARY_HOOK_DISABLED); @@ -101,7 +100,7 @@ public function doRequest($request, $location, $action, $version, $one_way = 0, /** * @inheritDoc */ - public function enable(\Closure $requestCallback) + public function enable(\Closure $requestCallback): void { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; @@ -120,7 +119,7 @@ public function enable(\Closure $requestCallback) /** * @inheritDoc */ - public function disable() + public function disable(): void { if (!$this->isEnabled()) { return; @@ -134,7 +133,7 @@ public function disable() /** * @inheritDoc */ - public function isEnabled() + public function isEnabled(): bool { return $this->status == self::ENABLED; } diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index b26ce79a3..e5ea7eb2d 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -42,7 +42,7 @@ class StreamWrapperHook implements LibraryHook /** * @inheritDoc */ - public function enable(\Closure $requestCallback) + public function enable(\Closure $requestCallback): void { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; @@ -58,7 +58,7 @@ public function enable(\Closure $requestCallback) /** * @inheritDoc */ - public function disable() + public function disable(): void { self::$requestCallback = null; stream_wrapper_restore('http'); @@ -70,7 +70,7 @@ public function disable() /** * @inheritDoc */ - public function isEnabled() + public function isEnabled(): bool { return $this->status == self::ENABLED; } @@ -86,7 +86,7 @@ public function isEnabled() * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_open($path, $mode, $options, &$opened_path) + public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { $request = StreamHelper::createRequestFromStreamContext($this->context, $path); @@ -109,7 +109,7 @@ public function stream_open($path, $mode, $options, &$opened_path) * @return string If there are less than count bytes available, return as many as are available. * If no more data is available, return either FALSE or an empty string. */ - public function stream_read($count) + public function stream_read(int $count): string { $ret = substr($this->response->getBody(), $this->position, $count); $this->position += strlen($ret); @@ -127,7 +127,7 @@ public function stream_read($count) * * @return int */ - public function stream_write($data) + public function stream_write(string $data): int { throw new \BadMethodCallException('No writing possible'); } @@ -141,7 +141,7 @@ public function stream_write($data) * * @return integer Should return the current position of the stream. */ - public function stream_tell() + public function stream_tell(): int { return $this->position; } @@ -154,7 +154,7 @@ public function stream_tell() * @return boolean Should return TRUE if the read/write position is at the end of the stream * and if no more data is available to be read, or FALSE otherwise. */ - public function stream_eof() + public function stream_eof(): bool { return $this->position >= strlen($this->response->getBody()); } @@ -164,9 +164,9 @@ public function stream_eof() * * @link http://www.php.net/manual/en/streamwrapper.stream-stat.php * - * @return array See stat(). + * @return array See stat(). */ - public function stream_stat() + public function stream_stat(): array { return array(); } @@ -176,10 +176,10 @@ public function stream_stat() * * @link http://www.php.net/manual/en/streamwrapper.url-stat.php * - * @return array See stat(). + * @return array See stat(). */ - public function url_stat($path, $flags) + public function url_stat(string $path, int $flags): array { return array(); } @@ -194,7 +194,7 @@ public function url_stat($path, $flags) * SEEK_END - Set position to end-of-file plus offset. * @return boolean Return TRUE if the position was updated, FALSE otherwise. */ - public function stream_seek($offset, $whence) + public function stream_seek(int $offset, int $whence): bool { switch ($whence) { case SEEK_SET: @@ -232,7 +232,7 @@ public function stream_seek($offset, $whence) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_metadata($path, $option, $var) + public function stream_metadata(string $path, int $option, $var): bool { return false; } diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 7a4d34f81..a6104c446 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -28,24 +28,24 @@ class Request */ protected $body; /** - * @var array + * @var array> */ protected $postFiles = array(); /** - * @var array + * @var array $post_fields */ protected $postFields = array(); /** - * @var array + * @var array */ protected $curlOptions = array(); /** * @param string $method * @param string|null $url - * @param array $headers + * @param array $headers */ - public function __construct($method, $url, array $headers = array()) + public function __construct(string $method, ?string $url, array $headers = array()) { $this->method = $method; $this->headers = $headers; @@ -62,7 +62,7 @@ public function __construct($method, $url, array $headers = array()) * @throws \BadFunctionCallException If one of the specified request matchers is not callable. * @return boolean True if specified request matches the current one. */ - public function matches(Request $request, array $requestMatchers) + public function matches(Request $request, array $requestMatchers): bool { foreach ($requestMatchers as $matcher) { if (!is_callable($matcher)) { @@ -82,9 +82,9 @@ public function matches(Request $request, array $requestMatchers) /** * Returns an array representation of this request. * - * @return array Array representation of this request. + * @return array Array representation of this request. */ - public function toArray() + public function toArray(): array { return array_filter( array( @@ -101,11 +101,12 @@ public function toArray() /** * Creates a new Request from a specified array. * - * @param array $request Request represented as an array. + * @param array $request Request represented as an array. Allowed keys: "method", "url", "headers", + * "post_fields", "post_files", "body" * * @return Request A new Request from specified array. */ - public static function fromArray(array $request) + public static function fromArray(array $request): Request { $requestObject = new Request( $request['method'], @@ -133,7 +134,7 @@ public static function fromArray(array $request) /** * @param string|null $url */ - public function setUrl($url) + public function setUrl(?string $url): void { $this->url = $url; if ($url !== null && $this->hasHeader('Host') === false) { @@ -144,7 +145,7 @@ public function setUrl($url) /** * @return string|null */ - public function getBody() + public function getBody(): ?string { return $this->body; } @@ -152,7 +153,7 @@ public function getBody() /** * @return string */ - public function getMethod() + public function getMethod(): string { if ($this->getCurlOption(CURLOPT_CUSTOMREQUEST) !== null) { return $this->getCurlOption(CURLOPT_CUSTOMREQUEST); @@ -164,7 +165,7 @@ public function getMethod() /** * @return array */ - public function getHeaders() + public function getHeaders(): array { return $this->headers; } @@ -173,7 +174,7 @@ public function getHeaders() * @param string $key * @return string */ - public function getHeader($key) + public function getHeader(string $key): string { return $this->headers[$key]; } @@ -182,23 +183,23 @@ public function getHeader($key) * @param string $key * @return boolean */ - public function hasHeader($key) + public function hasHeader(string $key): bool { return array_key_exists($key, $this->headers); } /** - * @return array + * @return array */ - public function getPostFields() + public function getPostFields(): array { return $this->postFields; } /** - * @return array + * @return array> */ - public function getPostFiles() + public function getPostFiles(): array { return $this->postFiles; } @@ -206,7 +207,7 @@ public function getPostFiles() /** * @return string|null */ - public function getUrl() + public function getUrl(): ?string { return $this->url; } @@ -214,7 +215,7 @@ public function getUrl() /** * @return string */ - public function getHost() + public function getHost(): string { $url = $this->getUrl(); Assertion::string($url); @@ -235,7 +236,7 @@ public function getHost() /** * @return string */ - public function getPath() + public function getPath(): ?string { $url = $this->getUrl(); Assertion::string($url); @@ -243,9 +244,9 @@ public function getPath() } /** - * @return string + * @return string|null */ - public function getQuery() + public function getQuery(): ?string { $url = $this->getUrl(); Assertion::string($url); @@ -253,9 +254,9 @@ public function getQuery() } /** - * @return array + * @return array */ - public function getCurlOptions() + public function getCurlOptions(): array { return $this->curlOptions; } @@ -264,7 +265,7 @@ public function getCurlOptions() * @param int $key * @return mixed */ - public function getCurlOption($key) + public function getCurlOption(int $key) { if (empty($this->curlOptions[$key])) { return null; @@ -278,23 +279,23 @@ public function getCurlOption($key) * * @param string $method HTTP request method like GET, POST, PUT, ... */ - public function setMethod($method) + public function setMethod(string $method): void { $this->method = strtoupper($method); } /** - * @param array $post_fields + * @param array $post_fields */ - public function setPostFields(array $post_fields) + public function setPostFields(array $post_fields): void { $this->postFields = $post_fields; } /** - * @param array $post_files + * @param array> $post_files */ - public function setPostFiles(array $post_files) + public function setPostFiles(array $post_files): void { $this->postFiles = $post_files; } @@ -302,7 +303,7 @@ public function setPostFiles(array $post_files) /** * @param string|null $body */ - public function setBody($body) + public function setBody(?string $body): void { $this->body = $body; } @@ -313,15 +314,15 @@ public function setBody($body) * @param string $username Username. * @param string $password Password. */ - public function setAuthorization($username, $password) + public function setAuthorization(string $username, string $password): void { $this->setHeader('Authorization', 'Basic ' . base64_encode($username . ':' . $password)); } /** - * @param array $curlOptions + * @param array $curlOptions */ - public function setCurlOptions(array $curlOptions) + public function setCurlOptions(array $curlOptions): void { $this->curlOptions = $curlOptions; } @@ -330,7 +331,7 @@ public function setCurlOptions(array $curlOptions) * @param string $key * @param string $value */ - public function setHeader(string $key, string $value) + public function setHeader(string $key, string $value): void { $this->headers[$key] = $value; } @@ -338,7 +339,7 @@ public function setHeader(string $key, string $value) /** * @param string $key */ - public function removeHeader($key) + public function removeHeader(string $key): void { unset($this->headers[$key]); } @@ -347,7 +348,7 @@ public function removeHeader($key) * @param string $key * @param mixed $value */ - public function setPostField($key, $value) + public function setPostField(string $key, $value): void { $this->postFields[$key] = $value; } @@ -356,12 +357,15 @@ public function setPostField($key, $value) * @param int $key * @param mixed $value */ - public function setCurlOption($key, $value) + public function setCurlOption(int $key, $value): void { $this->curlOptions[$key] = $value; } - public function addPostFile(array $file) + /** + * @param array $file An array with the keys "fieldName", "contentType", "filename" and "postname" + */ + public function addPostFile(array $file): void { $this->postFiles[] = $file; } diff --git a/src/VCR/RequestMatcher.php b/src/VCR/RequestMatcher.php index a89e950cf..fdcd8f6c7 100644 --- a/src/VCR/RequestMatcher.php +++ b/src/VCR/RequestMatcher.php @@ -15,7 +15,7 @@ class RequestMatcher * * @return boolean True if the method of both specified requests match. */ - public static function matchMethod(Request $first, Request $second) + public static function matchMethod(Request $first, Request $second): bool { return $first->getMethod() == $second->getMethod(); } @@ -28,7 +28,7 @@ public static function matchMethod(Request $first, Request $second) * * @return boolean True if the url of both specified requests match. */ - public static function matchUrl(Request $first, Request $second) + public static function matchUrl(Request $first, Request $second): bool { return $first->getPath() === $second->getPath(); } @@ -41,7 +41,7 @@ public static function matchUrl(Request $first, Request $second) * * @return boolean True if the host of both specified requests match. */ - public static function matchHost(Request $first, Request $second) + public static function matchHost(Request $first, Request $second): bool { return $first->getHost() === $second->getHost(); } @@ -54,7 +54,7 @@ public static function matchHost(Request $first, Request $second) * * @return boolean True if the headers of both specified requests match. */ - public static function matchHeaders(Request $first, Request $second) + public static function matchHeaders(Request $first, Request $second): bool { // Use array_filter to ignore headers which are null. @@ -69,7 +69,7 @@ public static function matchHeaders(Request $first, Request $second) * * @return boolean True if the body of both specified requests match. */ - public static function matchBody(Request $first, Request $second) + public static function matchBody(Request $first, Request $second): bool { return $first->getBody() === $second->getBody(); } @@ -82,7 +82,7 @@ public static function matchBody(Request $first, Request $second) * * @return boolean True if the post fields of both specified requests match. */ - public static function matchPostFields(Request $first, Request $second) + public static function matchPostFields(Request $first, Request $second): bool { return $first->getPostFields() === $second->getPostFields(); } @@ -95,7 +95,7 @@ public static function matchPostFields(Request $first, Request $second) * * @return boolean True if the query string of both specified requests match. */ - public static function matchQueryString(Request $first, Request $second) + public static function matchQueryString(Request $first, Request $second): bool { return $first->getQuery() === $second->getQuery(); } diff --git a/src/VCR/Response.php b/src/VCR/Response.php index e88c860ba..fa3d32142 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -2,6 +2,7 @@ namespace VCR; +use function var_dump; use VCR\Util\Assertion; /** @@ -18,7 +19,7 @@ class Response ); /** - * @var array + * @var array */ protected $headers = array(); /** @@ -26,7 +27,7 @@ class Response */ protected $body; /** - * @var array + * @var array */ protected $curlInfo = array(); @@ -34,11 +35,11 @@ class Response /** * @param string|array $status - * @param array $headers + * @param array $headers * @param string|null $body - * @param array $curlInfo + * @param array $curlInfo */ - public function __construct($status, array $headers = array(), $body = null, array $curlInfo = array()) + public function __construct($status, array $headers = array(), ?string $body = null, array $curlInfo = array()) { $this->setStatus($status); $this->headers = $headers; @@ -49,9 +50,9 @@ public function __construct($status, array $headers = array(), $body = null, arr /** * Returns an array representation of this Response. * - * @return array Array representation of this Request. + * @return array Array representation of this Request. */ - public function toArray() + public function toArray(): array { $body = $this->getBody(); // Base64 encode when binary @@ -74,10 +75,10 @@ public function toArray() /** * Creates a new Response from a specified array. * - * @param array $response Array representation of a Response. + * @param array $response Array representation of a Response. * @return Response A new Response from a specified array */ - public static function fromArray(array $response) + public static function fromArray(array $response): Response { $body = isset($response['body']) ? $response['body'] : null; @@ -103,20 +104,19 @@ public static function fromArray(array $response) /** * @return string */ - public function getBody() + public function getBody(): string { return $this->body ?: ''; } /** - * @return array|null + * @return array|mixed|null */ - public function getCurlInfo($option = null) + public function getCurlInfo(?string $option = null) { if (empty($option)) { return $this->curlInfo; } - if (!isset($this->curlInfo[$option])) { return null; } @@ -125,9 +125,9 @@ public function getCurlInfo($option = null) } /** - * @return array + * @return array */ - public function getHeaders() + public function getHeaders(): array { return $this->headers; } @@ -135,17 +135,17 @@ public function getHeaders() /** * @return string */ - public function getStatusCode() + public function getStatusCode(): string { return $this->status['code']; } - public function getContentType() + public function getContentType(): ?string { return $this->getHeader('Content-Type'); } - public function getHeader($key) + public function getHeader(string $key): ?string { if (!isset($this->headers[$key])) { return null; @@ -165,7 +165,7 @@ public function getHttpVersion() /** * @return string */ - public function getStatusMessage() + public function getStatusMessage(): string { return $this->status['message']; } @@ -173,7 +173,7 @@ public function getStatusMessage() /** * @param string|array $status */ - protected function setStatus($status) + protected function setStatus($status): void { if (is_array($status)) { $this->status = $status; diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index df13037a8..3611ce2a3 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -58,7 +58,7 @@ abstract class AbstractStorage implements Storage * @param string $cassetteName Path to the cassette file, relative to the path. * @param string $defaultContent Default data for this cassette if its not existing */ - public function __construct($cassettePath, $cassetteName, $defaultContent = '[]') + public function __construct(string $cassettePath, string $cassetteName, string $defaultContent = '[]') { Assertion::directory($cassettePath, "Cassette path '{$cassettePath}' is not existing or not a directory"); @@ -108,7 +108,7 @@ public function key() * * @return boolean TRUE if created, FALSE if not */ - public function isNew() + public function isNew(): bool { return $this->isNew; } diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index e50012751..b7daf2520 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -10,14 +10,14 @@ class Blackhole implements Storage /** * {@inheritDoc} */ - public function storeRecording(array $recording) + public function storeRecording(array $recording): void { } /** * {@inheritDoc} */ - public function isNew() + public function isNew(): bool { return true; } diff --git a/src/VCR/Storage/Json.php b/src/VCR/Storage/Json.php index af7b371ab..7c9002546 100644 --- a/src/VCR/Storage/Json.php +++ b/src/VCR/Storage/Json.php @@ -15,7 +15,7 @@ class Json extends AbstractStorage /** * @inheritDoc */ - public function storeRecording(array $recording) + public function storeRecording(array $recording): void { fseek($this->handle, -1, SEEK_END); if (ftell($this->handle) > 2) { @@ -35,7 +35,7 @@ public function storeRecording(array $recording) * * @return void */ - public function next() + public function next(): void { $this->current = json_decode($this->readNextRecord(), true); ++$this->position; @@ -46,7 +46,7 @@ public function next() * * @return string Next record in raw format. */ - protected function readNextRecord() + protected function readNextRecord(): string { $depth = 0; $isInRecord = false; diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index f9699b68b..e9469fef7 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -13,15 +13,15 @@ interface Storage extends \Iterator /** * Stores an array of data. * - * @param array $recording Array to store in storage. + * @param array> $recording Array to store in storage. * @return void */ - public function storeRecording(array $recording); + public function storeRecording(array $recording): void; /** * Returns true if the file did not exist and had to be created. * * @return boolean TRUE if created, FALSE if not */ - public function isNew(); + public function isNew(): bool; } diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index 2fc798834..bd698dc67 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -43,7 +43,7 @@ public function __construct($cassettePath, $cassetteName, Parser $parser = null, /** * @inheritDoc */ - public function storeRecording(array $recording) + public function storeRecording(array $recording): void { fseek($this->handle, -1, SEEK_END); fwrite($this->handle, "\n" . $this->yamlDumper->dump(array($recording), 4)); @@ -67,7 +67,7 @@ public function next() * * @return string Next record in raw format. */ - private function readNextRecord() + private function readNextRecord(): string { if ($this->isEOF) { $this->isValidPosition = false; diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php index f9674b9c9..aab7ca1fc 100644 --- a/src/VCR/Util/CurlException.php +++ b/src/VCR/Util/CurlException.php @@ -10,7 +10,7 @@ class CurlException extends \Exception * @param resource $ch The cURL handler * @return CurlException */ - public static function create($ch) + public static function create($ch): self { $e = new CurlException(curl_error($ch), curl_errno($ch)); $e->info = curl_getinfo($ch); @@ -20,9 +20,9 @@ public static function create($ch) /** * Returns the curl_info array. * - * @return array + * @return array */ - public function getInfo() + public function getInfo(): array { return $this->info; } diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 53df7baaa..09346bd1e 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -46,13 +46,13 @@ class CurlHelper * * The response header might be passed to a custom function. * - * @param Response $response Response which contains the response body. - * @param array $curlOptions cURL options which are not stored within the Response. - * @param resource $ch cURL handle to add headers if needed. + * @param Response $response Response which contains the response body. + * @param array $curlOptions cURL options which are not stored within the Response. + * @param resource $ch cURL handle to add headers if needed. * * @return null|string */ - public static function handleOutput(Response $response, array $curlOptions, $ch) + public static function handleOutput(Response $response, array $curlOptions, $ch): ?string { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) { @@ -81,6 +81,7 @@ public static function handleOutput(Response $response, array $curlOptions, $ch) } else { echo $body; } + return null; } /** @@ -92,7 +93,7 @@ public static function handleOutput(Response $response, array $curlOptions, $ch) * @throws \BadMethodCallException * @return mixed Value of the cURL option. */ - public static function getCurlOptionFromResponse(Response $response, $option = 0) + public static function getCurlOptionFromResponse(Response $response, int $option = 0) { switch ($option) { case 0: // 0 == array of all curl options @@ -132,7 +133,7 @@ public static function getCurlOptionFromResponse(Response $response, $option = 0 * @param mixed $value Value of the cURL option. * @param resource $curlHandle cURL handle where this option is set on (optional). */ - public static function setCurlOptionOnRequest(Request $request, $option, $value, $curlHandle = null) + public static function setCurlOptionOnRequest(Request $request, int $option, $value, $curlHandle = null): void { switch ($option) { case CURLOPT_URL: @@ -194,7 +195,7 @@ public static function setCurlOptionOnRequest(Request $request, $option, $value, * @param Request $request Request to set cURL option to. * @param resource $curlHandle cURL handle associated with the request. */ - public static function validateCurlPOSTBody(Request $request, $curlHandle = null) + public static function validateCurlPOSTBody(Request $request, $curlHandle = null): void { $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION); if (is_null($readFunction)) { diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 9fbce6a0d..f88e11933 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -19,7 +19,7 @@ class HttpClient * * @throws CurlException In case of cURL error */ - public function send(Request $request) + public function send(Request $request): Response { $ch = curl_init($request->getUrl()); diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 236aeb650..5296fea4a 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -38,9 +38,9 @@ public static function parseHeaders(array $headers): array * Returns http_version, code and message from a HTTP status line. * * @param string $status HTTP status line, e.g. HTTP/1.1 200 OK - * @return array Parsed 'http_version', 'code' and 'message'. + * @return array Parsed 'http_version', 'code' and 'message'. */ - public static function parseStatus($status) + public static function parseStatus(string $status): array { Assertion::startsWith( $status, @@ -61,9 +61,9 @@ public static function parseStatus($status) * Returns status, headers and body from a HTTP response string. * * @param string $response Response including header and body. - * @return array Status, headers and body as strings. + * @return array Status, headers and body as strings. */ - public static function parseResponse($response) + public static function parseResponse(string $response): array { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); @@ -80,9 +80,9 @@ public static function parseResponse($response) * Returns an array of arrays for specified raw header string. * * @param string $rawHeader - * @return array + * @return array */ - public static function parseRawHeader($rawHeader) + public static function parseRawHeader(string $rawHeader): array { return explode("\r\n", trim($rawHeader)); } @@ -90,10 +90,10 @@ public static function parseRawHeader($rawHeader) /** * Returns a list of headers from a key/value paired array. * - * @param array $headers Headers as key/value pairs. - * @return array List of headers ['Content-Type: text/html', '...']. + * @param array $headers Headers as key/value pairs. + * @return string[] List of headers ['Content-Type: text/html', '...']. */ - public static function formatHeadersForCurl(array $headers) + public static function formatHeadersForCurl(array $headers): array { $curlHeaders = array(); @@ -110,7 +110,7 @@ public static function formatHeadersForCurl(array $headers) * @param Response $response * @return string HTTP status line. */ - public static function formatAsStatusString(Response $response) + public static function formatAsStatusString(Response $response): string { return 'HTTP/' . $response->getHttpVersion() . ' ' . $response->getStatusCode() @@ -123,7 +123,7 @@ public static function formatAsStatusString(Response $response) * @param Response $response * @return string HTTP status line. */ - public static function formatAsStatusWithHeadersString(Response $response) + public static function formatAsStatusWithHeadersString(Response $response): string { $headers = self::formatHeadersForCurl($response->getHeaders()); array_unshift($headers, self::formatAsStatusString($response)); diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index c1c367f53..44c6e644d 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -15,6 +15,9 @@ class SoapClient extends \SoapClient */ protected $soapHook; + /** + * @var array + */ protected $options = array(); /** @@ -27,7 +30,11 @@ class SoapClient extends \SoapClient */ protected $request; - public function __construct($wsdl, $options = array()) + /** + * @param mixed $wsdl + * @param array $options + */ + public function __construct($wsdl, array $options = array()) { $this->options = $options; parent::__construct($wsdl, $options); @@ -85,7 +92,7 @@ public function __getLastResponse() * * @param SoapHook $hook SOAP library hook to use when intercepting SOAP requests. */ - public function setLibraryHook(SoapHook $hook) + public function setLibraryHook(SoapHook $hook): void { $this->soapHook = $hook; } @@ -102,7 +109,7 @@ public function setLibraryHook(SoapHook $hook) * Use this where a response is not expected. * @return string The XML SOAP response. */ - protected function realDoRequest($request, $location, $action, $version, $one_way = 0) + protected function realDoRequest(string $request, string $location, string $action, int $version, int $one_way = 0): string { return parent::__doRequest($request, $location, $action, $version, $one_way); } @@ -114,7 +121,7 @@ protected function realDoRequest($request, $location, $action, $version, $one_wa * * @return SoapHook SOAP library hook. */ - protected function getLibraryHook() + protected function getLibraryHook(): SoapHook { if (empty($this->soapHook)) { $this->soapHook = VCRFactory::get('VCR\LibraryHooks\SoapHook'); diff --git a/src/VCR/Util/StreamHelper.php b/src/VCR/Util/StreamHelper.php index 79e6c80ee..b3bc26d57 100644 --- a/src/VCR/Util/StreamHelper.php +++ b/src/VCR/Util/StreamHelper.php @@ -21,7 +21,7 @@ class StreamHelper * * @return Request */ - public static function createRequestFromStreamContext($context, $path, Request $existing = null) + public static function createRequestFromStreamContext($context, string $path, Request $existing = null): Request { $http = self::getHttpOptionsFromContext($context); $request = $existing; @@ -67,9 +67,10 @@ public static function createRequestFromStreamContext($context, $path, Request $ * Returns HTTP options from current stream context. * * @see http://php.net/manual/en/context.http.php - * @return array HTTP options. + * @param resource|null $context + * @return array HTTP options. */ - protected static function getHttpOptionsFromContext($context) + protected static function getHttpOptionsFromContext($context): array { if (!$context) { return array(); diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 8f2c19bd9..4c756f2b9 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -69,7 +69,7 @@ public function __construct(Configuration $configuration = null) * * @return void */ - public function intercept() + public function intercept(): void { if (!$this->isIntercepting) { stream_wrapper_unregister(self::PROTOCOL); @@ -82,7 +82,7 @@ public function intercept() * * @return void */ - public function restore() + public function restore(): void { stream_wrapper_restore(self::PROTOCOL); } @@ -94,7 +94,7 @@ public function restore() * * @return bool True if the specified url is whitelisted, false otherwise. */ - protected function isWhitelisted($uri) + protected function isWhitelisted(string $uri): bool { $whiteList = static::$configuration->getWhiteList(); @@ -120,7 +120,7 @@ protected function isWhitelisted($uri) * * @return bool True if the provided url is blacklisted, false otherwise. */ - protected function isBlacklisted($uri) + protected function isBlacklisted(string $uri): bool { $uri = $this->normalizePath($uri); @@ -140,7 +140,7 @@ protected function isBlacklisted($uri) * * @return bool */ - protected function isPhpFile($uri) + protected function isPhpFile(string $uri): bool { return pathinfo($uri, PATHINFO_EXTENSION) === 'php'; } @@ -151,7 +151,7 @@ protected function isPhpFile($uri) * * @return bool */ - protected function shouldProcess($uri) + protected function shouldProcess(string $uri): bool { return $this->isWhitelisted($uri) && !$this->isBlacklisted($uri) && $this->isPhpFile($uri); } @@ -169,7 +169,7 @@ protected function shouldProcess($uri) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_open($path, $mode, $options, &$openedPath) + public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool { // file_exists catches paths like /dev/urandom that are missed by is_file. if ('r' === substr($mode, 0, 1) && !file_exists($path)) { @@ -200,7 +200,7 @@ public function stream_open($path, $mode, $options, &$openedPath) * * @return boolean */ - public function stream_close() + public function stream_close(): bool { return fclose($this->resource); } @@ -213,7 +213,7 @@ public function stream_close() * @return boolean Should return TRUE if the read/write position is at the end of the stream * and if no more data is available to be read, or FALSE otherwise. */ - public function stream_eof() + public function stream_eof(): bool { return feof($this->resource); } @@ -225,7 +225,7 @@ public function stream_eof() * * @return boolean */ - public function stream_flush() + public function stream_flush(): bool { return fflush($this->resource); } @@ -239,7 +239,7 @@ public function stream_flush() * @return string|false If there are less than count bytes available, return as many as are available. * If no more data is available, return either FALSE or an empty string. */ - public function stream_read($count) + public function stream_read(int $count) { return fread($this->resource, $count); } @@ -254,7 +254,7 @@ public function stream_read($count) * SEEK_END - Set position to end-of-file plus offset. * @return boolean Return TRUE if the position was updated, FALSE otherwise. */ - public function stream_seek($offset, $whence = SEEK_SET) + public function stream_seek(int $offset, int $whence = SEEK_SET): bool { return fseek($this->resource, $offset, $whence) === 0; } @@ -295,7 +295,7 @@ public function stream_tell() * * @return array|false Should return as many elements as stat() does. */ - public function url_stat($path, $flags) + public function url_stat(string $path, int $flags) { $this->restore(); if ($flags & STREAM_URL_STAT_QUIET) { @@ -320,7 +320,7 @@ public function url_stat($path, $flags) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function dir_closedir() + public function dir_closedir(): bool { closedir($this->resource); @@ -336,7 +336,7 @@ public function dir_closedir() * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function dir_opendir($path) + public function dir_opendir(string $path): bool { $this->restore(); if (isset($this->context)) { @@ -368,7 +368,7 @@ public function dir_readdir() * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function dir_rewinddir() + public function dir_rewinddir(): bool { rewinddir($this->resource); @@ -386,7 +386,7 @@ public function dir_rewinddir() * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function mkdir($path, $mode, $options) + public function mkdir(string $path, int $mode, int $options): bool { $this->restore(); if (isset($this->context)) { @@ -409,7 +409,7 @@ public function mkdir($path, $mode, $options) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function rename($path_from, $path_to) + public function rename(string $path_from, string $path_to): bool { $this->restore(); if (isset($this->context)) { @@ -431,7 +431,7 @@ public function rename($path_from, $path_to) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function rmdir($path) + public function rmdir(string $path): bool { $this->restore(); if (isset($this->context)) { @@ -453,7 +453,7 @@ public function rmdir($path) * STREAM_CAST_AS_STREAM when stream_cast() is called for other uses. * @return resource|false Should return the underlying stream resource used by the wrapper, or FALSE. */ - public function stream_cast($cast_as) + public function stream_cast(int $cast_as) { return $this->resource; } @@ -467,7 +467,7 @@ public function stream_cast($cast_as) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_lock($operation) + public function stream_lock(int $operation): bool { $operation = ($operation === 0 ? LOCK_EX : $operation); return flock($this->resource, $operation); @@ -485,7 +485,7 @@ public function stream_lock($operation) * @return boolean Returns TRUE on success or FALSE on failure. If option is not implemented, * FALSE should be returned. */ - public function stream_set_option($option, $arg1, $arg2) + public function stream_set_option(int $option, int $arg1, int $arg2): bool { switch ($option) { case STREAM_OPTION_BLOCKING: @@ -515,7 +515,7 @@ public function stream_set_option($option, $arg1, $arg2) * * @return int|false */ - public function stream_write($data) + public function stream_write(string $data) { return fwrite($this->resource, $data); } @@ -529,7 +529,7 @@ public function stream_write($data) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function unlink($path) + public function unlink(string $path): bool { $this->restore(); if (isset($this->context)) { @@ -552,7 +552,7 @@ public function unlink($path) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_metadata($path, $option, $value) + public function stream_metadata(string $path, int $option, $value): bool { $this->restore(); $result = false; @@ -591,7 +591,7 @@ public function stream_metadata($path, $option, $value) * * @return boolean Returns TRUE on success or FALSE on failure. */ - public function stream_truncate($new_size) + public function stream_truncate(int $new_size): bool { return ftruncate($this->resource, $new_size); } @@ -603,7 +603,7 @@ public function stream_truncate($new_size) * * @return void */ - public function appendCodeTransformer(AbstractCodeTransform $codeTransformer) + public function appendCodeTransformer(AbstractCodeTransform $codeTransformer): void { static::$codeTransformers[$codeTransformer::NAME] = $codeTransformer; } @@ -615,7 +615,7 @@ public function appendCodeTransformer(AbstractCodeTransform $codeTransformer) * * @return void */ - public function detachCodeTransformer(AbstractCodeTransform $codeTransformer) + public function detachCodeTransformer(AbstractCodeTransform $codeTransformer): void { if (!empty(static::$codeTransformers[$codeTransformer::NAME])) { unset(static::$codeTransformers[$codeTransformer::NAME]); @@ -627,7 +627,7 @@ public function detachCodeTransformer(AbstractCodeTransform $codeTransformer) * * @param resource $stream */ - protected function appendFiltersToStream($stream) + protected function appendFiltersToStream($stream): void { foreach (static::$codeTransformers as $codeTransformer) { stream_filter_append($stream, $codeTransformer::NAME, STREAM_FILTER_READ); @@ -641,7 +641,7 @@ protected function appendFiltersToStream($stream) * * @return string */ - private function normalizePath($path) + private function normalizePath(string $path): string { if (DIRECTORY_SEPARATOR !== '/') { return str_replace(DIRECTORY_SEPARATOR, '/', $path); diff --git a/src/VCR/Util/TextUtil.php b/src/VCR/Util/TextUtil.php index 449016f15..12a3fa7e3 100644 --- a/src/VCR/Util/TextUtil.php +++ b/src/VCR/Util/TextUtil.php @@ -16,7 +16,7 @@ class TextUtil * * @return string Lowercase camelcased version of specified text. */ - public static function underscoreToLowerCamelcase($underscore) + public static function underscoreToLowerCamelcase(string $underscore): string { return lcfirst( str_replace( diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index f1d2c8bc8..17be2072d 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -28,7 +28,12 @@ class VCR */ const MODE_NONE = 'none'; - public static function __callStatic($method, $parameters) + /** + * @param string $method + * @param mixed[] $parameters + * @return mixed + */ + public static function __callStatic(string $method, array $parameters) { $instance = VCRFactory::get('VCR\Videorecorder'); diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index 2c173d5d4..dc62d9551 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -2,6 +2,11 @@ namespace VCR; +use VCR\LibraryHooks\CurlHook; +use VCR\LibraryHooks\SoapHook; +use VCR\Storage\AbstractStorage; +use VCR\Util\StreamProcessor; + class VCRFactory { /** @@ -18,7 +23,7 @@ class VCRFactory * * @param Configuration $config */ - protected function __construct($config = null) + protected function __construct(Configuration $config = null) { $this->config = $config ?: $this->getOrCreate('VCR\Configuration'); } @@ -26,7 +31,7 @@ protected function __construct($config = null) /** * @return Videorecorder */ - protected function createVCRVideorecorder() + protected function createVCRVideorecorder(): Videorecorder { return new Videorecorder( $this->config, @@ -38,14 +43,14 @@ protected function createVCRVideorecorder() /** * Provides an instance of the StreamProcessor. * - * @return \VCR\Util\StreamProcessor + * @return StreamProcessor */ - protected function createVCRUtilStreamProcessor() + protected function createVCRUtilStreamProcessor(): StreamProcessor { - return new Util\StreamProcessor($this->config); + return new StreamProcessor($this->config); } - protected function createStorage($cassetteName) + protected function createStorage(string $cassetteName): AbstractStorage { $dsn = $this->config->getCassettePath(); $class = $this->config->getStorage(); @@ -53,7 +58,7 @@ protected function createStorage($cassetteName) return new $class($dsn, $cassetteName); } - protected function createVCRLibraryHooksSoapHook() + protected function createVCRLibraryHooksSoapHook(): SoapHook { return new LibraryHooks\SoapHook( $this->getOrCreate('VCR\CodeTransform\SoapCodeTransform'), @@ -61,7 +66,7 @@ protected function createVCRLibraryHooksSoapHook() ); } - protected function createVCRLibraryHooksCurlHook() + protected function createVCRLibraryHooksCurlHook(): CurlHook { return new LibraryHooks\CurlHook( $this->getOrCreate('VCR\CodeTransform\CurlCodeTransform'), @@ -76,7 +81,7 @@ protected function createVCRLibraryHooksCurlHook() * * @return VCRFactory */ - public static function getInstance(Configuration $config = null) + public static function getInstance(Configuration $config = null): self { if (!self::$instance) { self::$instance = new self($config); @@ -89,11 +94,11 @@ public static function getInstance(Configuration $config = null) * Returns an instance for specified class name and parameters. * * @param string $className Class name to get a instance for. - * @param array $params Constructor arguments for this class. + * @param mixed[] $params Constructor arguments for this class. * * @return mixed An instance for specified class name and parameters. */ - public static function get($className, $params = array()) + public static function get(string $className, array $params = array()) { return self::getInstance()->getOrCreate($className, $params); } @@ -102,11 +107,11 @@ public static function get($className, $params = array()) * Returns an instance for specified classname and parameters. * * @param string $className Class name to get a instance for. - * @param array $params Constructor arguments for this class. + * @param mixed[] $params Constructor arguments for this class. * * @return mixed */ - public function getOrCreate($className, $params = array()) + public function getOrCreate(string $className, array $params = array()) { $key = $className . join('-', $params); @@ -135,7 +140,7 @@ public function getOrCreate($className, $params = array()) * * @return string */ - protected function getMethodName($className) + protected function getMethodName(string $className): string { return 'create' . str_replace('\\', '', $className); } diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 08a20b9e2..458f3c703 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -76,7 +76,7 @@ public function __construct(Configuration $config, HttpClient $client, VCRFactor /** * @param EventDispatcherInterface $dispatcher */ - public function setEventDispatcher(EventDispatcherInterface $dispatcher) + public function setEventDispatcher(EventDispatcherInterface $dispatcher): void { $this->eventDispatcher = $dispatcher; } @@ -84,7 +84,7 @@ public function setEventDispatcher(EventDispatcherInterface $dispatcher) /** * @return EventDispatcherInterface */ - public function getEventDispatcher() + public function getEventDispatcher(): EventDispatcherInterface { if (!$this->eventDispatcher) { $this->eventDispatcher = new EventDispatcher(); @@ -99,7 +99,7 @@ public function getEventDispatcher() * @param Event $event The event to pass to the event handlers/listeners. * @return Event */ - private function dispatch($eventName, Event $event = null) + private function dispatch(string $eventName, Event $event = null): Event { return $this->getEventDispatcher()->dispatch($eventName, $event); } @@ -113,7 +113,7 @@ private function dispatch($eventName, Event $event = null) * * @return void */ - public function turnOn() + public function turnOn(): void { if ($this->isOn) { $this->turnOff(); @@ -132,7 +132,7 @@ public function turnOn() * * @return void */ - public function turnOff() + public function turnOff(): void { if ($this->isOn) { $this->disableLibraryHooks(); @@ -150,7 +150,7 @@ public function turnOff() * * @return void */ - public function eject() + public function eject(): void { Assertion::true($this->isOn, 'Please turn on VCR before ejecting a cassette, use: VCR::turnOn().'); $this->cassette = null; @@ -166,7 +166,7 @@ public function eject() * @return void * @throws VCRException If videorecorder is turned off when inserting a cassette. */ - public function insertCassette($cassetteName) + public function insertCassette(string $cassetteName): void { Assertion::true($this->isOn, 'Please turn on VCR before inserting a cassette, use: VCR::turnOn().'); @@ -187,7 +187,7 @@ public function insertCassette($cassetteName) * * @return Configuration Configuration for this videorecorder. */ - public function configure() + public function configure(): Configuration { return $this->config; } @@ -207,7 +207,7 @@ public function configure() * @throws \LogicException If the mode is set to none or once and * the cassette did not have a matching response. */ - public function handleRequest(Request $request) + public function handleRequest(Request $request): Response { if ($this->cassette === null) { throw new \BadMethodCallException( @@ -274,7 +274,7 @@ public function handleRequest(Request $request) * * @return void */ - protected function disableLibraryHooks() + protected function disableLibraryHooks(): void { foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); @@ -289,7 +289,7 @@ protected function disableLibraryHooks() * * @return void */ - protected function enableLibraryHooks() + protected function enableLibraryHooks(): void { $self = $this; foreach ($this->config->getLibraryHooks() as $hookClass) { diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index 18f30ebc6..5372ddb96 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -22,12 +22,6 @@ public function setUp() $this->cassette = new Cassette('test', new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); } - public function testInvalidCassetteName() - { - $this->expectException(VCRException::class, 'Cassette name must be a string, array given.'); - new Cassette(array(), new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); - } - public function testGetName() { $this->assertEquals('test', $this->cassette->getName()); diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index d2bf8fc1d..fb052a654 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -97,12 +97,6 @@ public function testAddRequestMatcherFailsWithNoName() $this->config->addRequestMatcher('', $expected); } - public function testAddRequestMatcherFailsWithWrongCallback() - { - $this->expectException('VCR\VCRException', "Request matcher 'example' is not callable."); - $this->config->addRequestMatcher('example', array()); - } - public function testAddRequestMatchers() { $expected = function () { diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 9425dd400..7b76ce0c4 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -2,6 +2,7 @@ namespace VCR; +use const CURLOPT_CUSTOMREQUEST; use PHPUnit\Framework\TestCase; /** @@ -142,6 +143,29 @@ public function testStorePostFile() ); } + public function testSetPostFiles() + { + $file = array( + 'fieldName' => 'field_name', + 'contentType' => 'application/octet-stream', + 'filename' => 'tests/fixtures/unittest_curl_test', + 'postname' => 'unittest_curl_test', + ); + $this->request->setPostFiles([$file]); + $this->assertEquals( + array( + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => array( + 'User-Agent' => 'Unit-Test', + 'Host' => 'example.com', + ), + 'post_files' => array($file), + ), + $this->request->toArray() + ); + } + public function testRestorePostFiles() { $file = array( @@ -249,4 +273,13 @@ public function testCurlCustomRequestOverridesMethod() $this->assertEquals('PUT', $postRequest->getMethod()); $this->assertEquals('POST', $getRequest->getMethod()); } + + public function testSetCurlOptions() + { + $getRequest = new Request('GET', 'http://example.com'); + $getRequest->setCurlOptions([ + CURLOPT_CUSTOMREQUEST => 'PUT' + ]); + $this->assertEquals('PUT', $getRequest->getCurlOption(CURLOPT_CUSTOMREQUEST)); + } } diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index eb090994a..bae4904ef 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -39,7 +39,7 @@ class TestStorage extends AbstractStorage { private $recording; - public function storeRecording(array $recording) + public function storeRecording(array $recording): void { $this->recording = $recording; } diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index f66c1ee25..bb7b334a6 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -151,13 +151,16 @@ protected function getCassetteMock($request, $response, $mode = VCR::MODE_NEW_EP { $cassette = $this->getMockBuilder('\VCR\Cassette') ->disableOriginalConstructor() - ->setMethods(array('record', 'playback', 'isNew')) + ->setMethods(array('record', 'playback', 'isNew', 'getName')) ->getMock(); $cassette ->expects($this->once()) ->method('playback') ->with($request) ->will($this->returnValue(null)); + $cassette + ->method('getName') + ->will($this->returnValue('foobar')); if (VCR::MODE_NEW_EPISODES === $mode || VCR::MODE_ONCE === $mode && $isNew === true) { $cassette From c6437030a0b78c76df8b31225da65cf92ae0681b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 31 Oct 2018 20:21:14 +0100 Subject: [PATCH 033/204] Fixed AbstractCodeTransform registration. AbstractCodeTransform was actually misbehaving if several instances of the same XxxCodeTransform were to be created. Indeed, a wrapper can be registered, but not unregistered. If 2 instances of CurlCodeTransform were to be created, the registration of the wrapper would be attempted twice. The second one would fail and try again but the wrapper is already registered. This PR registers only if the stream is indeed not already registered. --- .../CodeTransform/AbstractCodeTransform.php | 24 +++++++------------ src/VCR/CodeTransform/CurlCodeTransform.php | 8 +++++-- src/VCR/CodeTransform/SoapCodeTransform.php | 8 +++++-- .../AbstractCodeTransformTest.php | 4 ++-- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index b841d3737..e430271c8 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -2,6 +2,10 @@ namespace VCR\CodeTransform; +use function in_array; +use function stream_get_filters; +use VCR\Util\Assertion; + /** * A stream wrapper filter to transform code. * @@ -11,25 +15,15 @@ abstract class AbstractCodeTransform extends \php_user_filter { const NAME = 'vcr_abstract_filter'; - /** - * Flag to signalize the current filter is registered. - * - * @var bool - */ - protected $isRegistered = false; - /** * Attaches the current filter to a stream. - * - * @return bool true on success or false on failure. */ - public function register() + public function register(): void { - if (!$this->isRegistered) { - $this->isRegistered = stream_filter_register(static::NAME, get_called_class()); + if (!in_array(static::NAME, stream_get_filters(), true)) { + $isRegistered = stream_filter_register(static::NAME, get_called_class()); + Assertion::true($isRegistered, sprintf('Failed registering stream filter "%s" on stream "%s"', get_called_class(), static::NAME)); } - - return $this->isRegistered; } /** @@ -62,5 +56,5 @@ public function filter($in, $out, &$consumed, $closing) * * @return string */ - abstract protected function transformCode($code); + abstract protected function transformCode(string $code): string; } diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index 0c50101ee..87a7a208e 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -2,6 +2,8 @@ namespace VCR\CodeTransform; +use VCR\Util\Assertion; + class CurlCodeTransform extends AbstractCodeTransform { const NAME = 'vcr_curl'; @@ -24,8 +26,10 @@ class CurlCodeTransform extends AbstractCodeTransform /** * @inheritdoc */ - protected function transformCode($code) + protected function transformCode(string $code): string { - return preg_replace(array_keys(self::$patterns), array_values(self::$patterns), $code); + $transformedCode = preg_replace(array_keys(self::$patterns), array_values(self::$patterns), $code); + Assertion::string($transformedCode); + return $transformedCode; } } diff --git a/src/VCR/CodeTransform/SoapCodeTransform.php b/src/VCR/CodeTransform/SoapCodeTransform.php index 6c192b041..a89d96a24 100644 --- a/src/VCR/CodeTransform/SoapCodeTransform.php +++ b/src/VCR/CodeTransform/SoapCodeTransform.php @@ -2,6 +2,8 @@ namespace VCR\CodeTransform; +use VCR\Util\Assertion; + class SoapCodeTransform extends AbstractCodeTransform { const NAME = 'vcr_soap'; @@ -19,8 +21,10 @@ class SoapCodeTransform extends AbstractCodeTransform /** * @inheritdoc */ - protected function transformCode($code) + protected function transformCode(string $code): string { - return preg_replace(self::$patterns, self::$replacements, $code); + $transformedCode = preg_replace(self::$patterns, self::$replacements, $code); + Assertion::string($transformedCode); + return $transformedCode; } } diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 4c1b829c5..3cfe0b23a 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -33,10 +33,10 @@ public function testRegisterAlreadyRegistered() $filter = $this->getFilter(); $filter->register(); - $this->assertAttributeSame(true, 'isRegistered', $filter, 'First attempt to register failed.'); + $this->assertContains(AbstractCodeTransform::NAME, stream_get_filters(), 'First attempt to register failed.'); $filter->register(); - $this->assertAttributeSame(true, 'isRegistered', $filter, 'Second attempt to register failed.'); + $this->assertContains(AbstractCodeTransform::NAME, stream_get_filters(), 'Second attempt to register failed.'); } } From e5ac2e6cd0f53963d3da678de30653d13f678dc5 Mon Sep 17 00:00:00 2001 From: Valdo Romao Date: Fri, 9 Nov 2018 17:16:32 +0100 Subject: [PATCH 034/204] Added SoapOperation request matcher + unit tests --- src/VCR/Configuration.php | 15 +++--- src/VCR/RequestMatcher.php | 82 +++++++++++++++++++++----------- tests/VCR/RequestMatcherTest.php | 34 +++++++++++++ 3 files changed, 96 insertions(+), 35 deletions(-) diff --git a/src/VCR/Configuration.php b/src/VCR/Configuration.php index e7c702c7f..cdea5fffd 100644 --- a/src/VCR/Configuration.php +++ b/src/VCR/Configuration.php @@ -89,13 +89,14 @@ class Configuration * @var array List of RequestMatcher names and callbacks. */ private $availableRequestMatchers = array( - 'method' => array('VCR\RequestMatcher', 'matchMethod'), - 'url' => array('VCR\RequestMatcher', 'matchUrl'), - 'host' => array('VCR\RequestMatcher', 'matchHost'), - 'headers' => array('VCR\RequestMatcher', 'matchHeaders'), - 'body' => array('VCR\RequestMatcher', 'matchBody'), - 'post_fields' => array('VCR\RequestMatcher', 'matchPostFields'), - 'query_string' => array('VCR\RequestMatcher', 'matchQueryString'), + 'method' => array(RequestMatcher::class, 'matchMethod'), + 'url' => array(RequestMatcher::class, 'matchUrl'), + 'host' => array(RequestMatcher::class, 'matchHost'), + 'headers' => array(RequestMatcher::class, 'matchHeaders'), + 'body' => array(RequestMatcher::class, 'matchBody'), + 'post_fields' => array(RequestMatcher::class, 'matchPostFields'), + 'query_string' => array(RequestMatcher::class, 'matchQueryString'), + 'soap_operation' => array(RequestMatcher::class, 'matchSoapOperation'), ); /** diff --git a/src/VCR/RequestMatcher.php b/src/VCR/RequestMatcher.php index fdcd8f6c7..9ecbcb9a2 100644 --- a/src/VCR/RequestMatcher.php +++ b/src/VCR/RequestMatcher.php @@ -10,93 +10,119 @@ class RequestMatcher /** * Returns true if the method of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the method of both specified requests match. */ - public static function matchMethod(Request $first, Request $second): bool + public static function matchMethod(Request $storedRequest, Request $request): bool { - return $first->getMethod() == $second->getMethod(); + return $storedRequest->getMethod() == $request->getMethod(); } /** * Returns true if the url of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the url of both specified requests match. */ - public static function matchUrl(Request $first, Request $second): bool + public static function matchUrl(Request $storedRequest, Request $request): bool { - return $first->getPath() === $second->getPath(); + return $storedRequest->getPath() === $request->getPath(); } /** * Returns true if the host of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the host of both specified requests match. */ - public static function matchHost(Request $first, Request $second): bool + public static function matchHost(Request $storedRequest, Request $request): bool { - return $first->getHost() === $second->getHost(); + return $storedRequest->getHost() === $request->getHost(); } /** * Returns true if the headers of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the headers of both specified requests match. */ - public static function matchHeaders(Request $first, Request $second): bool + public static function matchHeaders(Request $storedRequest, Request $request): bool { // Use array_filter to ignore headers which are null. - return array_filter($first->getHeaders()) === array_filter($second->getHeaders()); + return array_filter($storedRequest->getHeaders()) === array_filter($request->getHeaders()); } /** * Returns true if the body of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the body of both specified requests match. */ - public static function matchBody(Request $first, Request $second): bool + public static function matchBody(Request $storedRequest, Request $request): bool { - return $first->getBody() === $second->getBody(); + return $storedRequest->getBody() === $request->getBody(); } /** * Returns true if the post fields of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the post fields of both specified requests match. */ - public static function matchPostFields(Request $first, Request $second): bool + public static function matchPostFields(Request $storedRequest, Request $request): bool { - return $first->getPostFields() === $second->getPostFields(); + return $storedRequest->getPostFields() === $request->getPostFields(); } /** * Returns true if the query string of both specified requests match. * - * @param Request $first First request to match. - * @param Request $second Second request to match. + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. * * @return boolean True if the query string of both specified requests match. */ - public static function matchQueryString(Request $first, Request $second): bool + public static function matchQueryString(Request $storedRequest, Request $request): bool { - return $first->getQuery() === $second->getQuery(); + return $storedRequest->getQuery() === $request->getQuery(); + } + + /** + * Returns true if the SOAP operation of both specified requests match, or if the request is not a SOAP request. + * + * @param Request $storedRequest First request to match, coming from the cassette. + * @param Request $request Second request to match, the request performed by the user. + * + * @return boolean True if the query string of both specified requests match. + */ + public static function matchSoapOperation(Request $storedRequest, Request $request): bool + { + $soapOperationRequest = preg_match('/<(.*?)>/m', $request->getBody(), $matches); + if (empty($matches)) { + // The request is not a SOAP request + return true; + } + $operationRequest = $matches[1]; + $soapOperationStoredRequest = preg_match('/<(.*?)>/m', $storedRequest->getBody(), $matches); + if (empty($matches)) { + // The stored request is not a SOAP request + return false; + } + $operationStoredRequest = $matches[1]; + + return $operationRequest === $operationStoredRequest; } } diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index 9793ed5b5..5c7c7af48 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -136,4 +136,38 @@ public function testMatchingBody() $this->assertFalse(RequestMatcher::matchBody($first, $second), 'Bodies are different.'); } + + public function testMatchingSoapOperation() + { + $storedRequest = Request::fromArray([ + 'method' => 'POST', + 'url' => 'http://example.com', + 'headers' => array(), + 'body' => "\n45000\n" + ]); + + $request = Request::fromArray([ + 'method' => 'POST', + 'url' => 'http://example.com', + 'headers' => array(), + 'body' => "\n75008\n" + ]); + $this->assertTrue(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operations are the same'); + + $request = Request::fromArray([ + 'method' => 'POST', + 'url' => 'http://example.com', + 'headers' => array(), + 'body' => "\n75008\n" + ]); + $this->assertFalse(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operations are different'); + + $request = Request::fromArray([ + 'method' => 'POST', + 'url' => 'http://example.com', + 'headers' => array(), + 'body' => "{}" + ]); + $this->assertTrue(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operation is not SOAP message'); + } } From 57339eff979ac161c295c94ec9b66fb1539863a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 13 Nov 2018 10:17:38 +0100 Subject: [PATCH 035/204] Fixing type hinting on createStorage Was typehinted on the AbstractStorage class instead of the Storage interface. --- src/VCR/VCRFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index dc62d9551..3f1077659 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -4,7 +4,7 @@ use VCR\LibraryHooks\CurlHook; use VCR\LibraryHooks\SoapHook; -use VCR\Storage\AbstractStorage; +use VCR\Storage\Storage; use VCR\Util\StreamProcessor; class VCRFactory @@ -50,7 +50,7 @@ protected function createVCRUtilStreamProcessor(): StreamProcessor return new StreamProcessor($this->config); } - protected function createStorage(string $cassetteName): AbstractStorage + protected function createStorage(string $cassetteName): Storage { $dsn = $this->config->getCassettePath(); $class = $this->config->getStorage(); From 6b2944e8bf1a0c01c046cab7e8c0c5785035266f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 13 Nov 2018 10:18:08 +0100 Subject: [PATCH 036/204] Using "finally" statement now that PHP-VCR has a PHP 7+ requirement --- src/VCR/Videorecorder.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 458f3c703..eeebaab92 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -255,14 +255,9 @@ public function handleRequest(Request $request): Response $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); $this->cassette->record($request, $response); - } catch (\Exception $e) { + } finally { $this->enableLibraryHooks(); - throw $e; - } catch (\Throwable $e) { - $this->enableLibraryHooks(); - throw $e; } - $this->enableLibraryHooks(); return $response; } From cd48ec879d91d55bf98e017093acdd6b517d0040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 13 Nov 2018 10:29:07 +0100 Subject: [PATCH 037/204] Update tests/VCR/RequestMatcherTest.php Co-Authored-By: ValdoTR --- tests/VCR/RequestMatcherTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index 5c7c7af48..a16649aa1 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -166,7 +166,7 @@ public function testMatchingSoapOperation() 'method' => 'POST', 'url' => 'http://example.com', 'headers' => array(), - 'body' => "{}" + 'body' => '{}' ]); $this->assertTrue(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operation is not SOAP message'); } From 0d5fe385981805761ff372e2d7f8ff63f79b153b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 6 Aug 2019 09:24:23 +0200 Subject: [PATCH 038/204] Adding PHP7.4snapshot to Travis (with allowed failure) --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9d2f97d10..7a61684a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ matrix: php: 7.2 - env: TEST_DIR=. php: 7.3 + - env: TEST_DIR=. + php: 7.4snapshot - env: TEST_DIR=tests/integration/apache php: 7.2 dist: trusty @@ -28,6 +30,8 @@ matrix: php: 7.2 - env: TEST_DIR=tests/integration/soap php: 7.2 + allow_failures: + - php: 7.4snapshot before_install: - composer self-update From 6de021a605192ba38361b6613a410e9e60c29dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 6 Aug 2019 09:32:22 +0200 Subject: [PATCH 039/204] Applying CS fix with newest version of PHP-CS-Fixer --- tests/VCR/RequestTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 7b76ce0c4..29e020972 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -245,9 +245,9 @@ public function testGetHostReturnsBothHostAndPort() public function testDoNotOverwriteHostHeader() { $this->request = new Request( - 'GET', - 'http://example.com', - array('User-Agent' => 'Unit-Test', 'Host' => 'www.example.com') + 'GET', + 'http://example.com', + array('User-Agent' => 'Unit-Test', 'Host' => 'www.example.com') ); $this->assertEquals( From 51a27ecf6ccad2e58609083a648165d91f1c0b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 6 Aug 2019 09:39:38 +0200 Subject: [PATCH 040/204] Fixing PHPStan new issues following dependencies upgrade --- composer.lock | 853 +++++++++++++++++++++++++------------- phpstan.neon | 2 + src/VCR/Videorecorder.php | 5 +- 3 files changed, 579 insertions(+), 281 deletions(-) diff --git a/composer.lock b/composer.lock index 22cdc4b36..cd484247a 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "63c3bc1d8732d38581a36c56b227b2d7", "packages": [ { "name": "beberlei/assert", - "version": "v3.1.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "e4f4a40a8739e1151d40fd1ed754a3ed37e1f522" + "reference": "ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/e4f4a40a8739e1151d40fd1ed754a3ed37e1f522", - "reference": "e4f4a40a8739e1151d40fd1ed754a3ed37e1f522", + "url": "https://api.github.com/repos/beberlei/assert/zipball/ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7", + "reference": "ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "*", "phpstan/phpstan-shim": "*", - "phpunit/phpunit": "*" + "phpunit/phpunit": ">=6.0.0 <8" }, "type": "library", "autoload": { @@ -44,13 +44,13 @@ "authors": [ { "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de", - "role": "Lead Developer" + "role": "Lead Developer", + "email": "kontakt@beberlei.de" }, { "name": "Richard Quadling", - "email": "rquadling@gmail.com", - "role": "Collaborator" + "role": "Collaborator", + "email": "rquadling@gmail.com" } ], "description": "Thin assertion library for input validation in business models.", @@ -59,33 +59,40 @@ "assertion", "validation" ], - "time": "2018-10-29T11:13:48+00:00" + "time": "2019-05-28T15:18:28+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.1.6", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" + "reference": "212b020949331b6531250584531363844b34a94e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/212b020949331b6531250584531363844b34a94e", + "reference": "212b020949331b6531250584531363844b34a94e", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" }, "conflict": { "symfony/dependency-injection": "<3.4" }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "1.1" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/expression-language": "~3.4|~4.0", + "symfony/http-foundation": "^3.4|^4.0", + "symfony/service-contracts": "^1.1", "symfony/stopwatch": "~3.4|~4.0" }, "suggest": { @@ -95,7 +102,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -122,20 +129,78 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2018-07-26T09:10:45+00:00" + "time": "2019-06-27T06:42:14+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "c61766f4440ca687de1084a5c00b08e167a2575c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c61766f4440ca687de1084a5c00b08e167a2575c", + "reference": "c61766f4440ca687de1084a5c00b08e167a2575c", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/event-dispatcher": "", + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-06-20T06:46:26+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.9.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "82ebae02209c21113908c229e9883c419720738a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", "shasum": "" }, "require": { @@ -147,7 +212,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -180,20 +245,20 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/yaml", - "version": "v4.1.6", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "367e689b2fdc19965be435337b50bc8adf2746c9" + "reference": "34d29c2acd1ad65688f58452fd48a46bd996d5a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/367e689b2fdc19965be435337b50bc8adf2746c9", - "reference": "367e689b2fdc19965be435337b50bc8adf2746c9", + "url": "https://api.github.com/repos/symfony/yaml/zipball/34d29c2acd1ad65688f58452fd48a46bd996d5a6", + "reference": "34d29c2acd1ad65688f58452fd48a46bd996d5a6", "shasum": "" }, "require": { @@ -212,7 +277,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -239,22 +304,22 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-10-02T16:36:10+00:00" + "time": "2019-07-24T14:47:54+00:00" } ], "packages-dev": [ { "name": "composer/xdebug-handler", - "version": "1.3.0", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c" + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/b8e9745fb9b06ea6664d8872c4505fb16df4611c", - "reference": "b8e9745fb9b06ea6664d8872c4505fb16df4611c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", "shasum": "" }, "require": { @@ -285,31 +350,33 @@ "Xdebug", "performance" ], - "time": "2018-08-31T19:07:57+00:00" + "time": "2019-05-27T17:52:04+00:00" }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -334,12 +401,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "jean85/pretty-package-versions", @@ -393,24 +460,24 @@ "time": "2018-06-13T13:22:40+00:00" }, { - "name": "mikey179/vfsStream", - "version": "v1.6.5", + "name": "mikey179/vfsstream", + "version": "v1.6.7", "source": { "type": "git", - "url": "https://github.com/mikey179/vfsStream.git", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" + "url": "https://github.com/bovigo/vfsStream.git", + "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", + "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "~4.5" + "phpunit/phpunit": "^4.5|^5.0" }, "type": "library", "extra": { @@ -430,26 +497,26 @@ "authors": [ { "name": "Frank Kleine", - "homepage": "http://frankkleine.de/", - "role": "Developer" + "role": "Developer", + "homepage": "http://frankkleine.de/" } ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2017-08-01T08:02:14+00:00" + "time": "2019-08-01T01:38:37+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.8.1", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", "shasum": "" }, "require": { @@ -484,43 +551,40 @@ "object", "object graph" ], - "time": "2018-06-11T23:09:50+00:00" + "time": "2019-04-07T13:18:21+00:00" }, { "name": "nette/bootstrap", - "version": "v2.4.6", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/bootstrap.git", - "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543" + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543", - "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", + "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", "shasum": "" }, "require": { - "nette/di": "~2.4.7", - "nette/utils": "~2.4", - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "nette/di": "^3.0", + "nette/utils": "^3.0", + "php": ">=7.1" }, "require-dev": { - "latte/latte": "~2.2", - "nette/application": "~2.3", - "nette/caching": "~2.3", - "nette/database": "~2.3", - "nette/forms": "~2.3", - "nette/http": "~2.4.0", - "nette/mail": "~2.3", - "nette/robot-loader": "^2.4.2 || ^3.0", - "nette/safe-stream": "~2.2", - "nette/security": "~2.3", - "nette/tester": "~2.0", - "tracy/tracy": "^2.4.1" + "latte/latte": "^2.2", + "nette/application": "^3.0", + "nette/caching": "^3.0", + "nette/database": "^3.0", + "nette/forms": "^3.0", + "nette/http": "^3.0", + "nette/mail": "^3.0", + "nette/robot-loader": "^3.0", + "nette/safe-stream": "^2.2", + "nette/security": "^3.0", + "nette/tester": "^2.0", + "tracy/tracy": "^2.6" }, "suggest": { "nette/robot-loader": "to use Configurator::createRobotLoader()", @@ -529,7 +593,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -560,46 +624,50 @@ "configurator", "nette" ], - "time": "2018-05-17T12:52:20+00:00" + "time": "2019-03-26T12:59:07+00:00" }, { "name": "nette/di", - "version": "v2.4.14", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a" + "reference": "19d83539245aaacb59470828919182411061841f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a", - "reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a", + "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", + "reference": "19d83539245aaacb59470828919182411061841f", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/neon": "^2.3.3 || ~3.0.0", - "nette/php-generator": "^2.6.1 || ~3.0.0", - "nette/utils": "^2.4.3 || ~3.0.0", - "php": ">=5.6.0" + "nette/neon": "^3.0", + "nette/php-generator": "^3.2.2", + "nette/robot-loader": "^3.2", + "nette/schema": "^1.0", + "nette/utils": "^3.0", + "php": ">=7.1" }, "conflict": { - "nette/bootstrap": "<2.4", - "nette/nette": "<2.2" + "nette/bootstrap": "<3.0" }, "require-dev": { - "nette/tester": "^2.0", + "nette/tester": "^2.2", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/compatibility.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -629,37 +697,37 @@ "nette", "static" ], - "time": "2018-09-17T15:47:40+00:00" + "time": "2019-04-03T19:35:46+00:00" }, { "name": "nette/finder", - "version": "v2.4.2", + "version": "v2.5.0", "source": { "type": "git", "url": "https://github.com/nette/finder.git", - "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", - "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", + "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", + "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", "shasum": "" }, "require": { - "nette/utils": "~2.4", - "php": ">=5.6.0" + "nette/utils": "^2.4 || ~3.0.0", + "php": ">=7.1" }, "conflict": { "nette/nette": "<2.2" }, "require-dev": { - "nette/tester": "~2.0", + "nette/tester": "^2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "2.5-dev" } }, "autoload": { @@ -683,7 +751,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🔍 Nette Finder: find files and directories with an intuitive API.", + "description": "? Nette Finder: find files and directories with an intuitive API.", "homepage": "https://nette.org", "keywords": [ "filesystem", @@ -691,35 +759,35 @@ "iterator", "nette" ], - "time": "2018-06-28T11:49:23+00:00" + "time": "2019-02-28T18:13:25+00:00" }, { "name": "nette/neon", - "version": "v2.4.3", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/nette/neon.git", - "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398" + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398", - "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb", "shasum": "" }, "require": { "ext-iconv": "*", "ext-json": "*", - "php": ">=5.6.0" + "php": ">=7.0" }, "require-dev": { - "nette/tester": "~2.0", + "nette/tester": "^2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -743,7 +811,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🍸 Nette NEON: encodes and decodes NEON file format.", + "description": "? Nette NEON: encodes and decodes NEON file format.", "homepage": "http://ne-on.org", "keywords": [ "export", @@ -752,28 +820,25 @@ "nette", "yaml" ], - "time": "2018-03-21T12:12:21+00:00" + "time": "2019-02-05T21:30:40+00:00" }, { "name": "nette/php-generator", - "version": "v3.0.5", + "version": "v3.2.3", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" + "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", - "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "url": "https://api.github.com/repos/nette/php-generator/zipball/aea6e81437bb238e5f0e5b5ce06337433908e63b", + "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b", "shasum": "" }, "require": { "nette/utils": "^2.4.2 || ~3.0.0", - "php": ">=7.0" - }, - "conflict": { - "nette/nette": "<2.2" + "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", @@ -782,7 +847,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -806,7 +871,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", + "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.", "homepage": "https://nette.org", "keywords": [ "code", @@ -814,30 +879,27 @@ "php", "scaffolding" ], - "time": "2018-08-09T14:32:27+00:00" + "time": "2019-07-05T13:01:56+00:00" }, { "name": "nette/robot-loader", - "version": "v3.1.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/nette/robot-loader.git", - "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4" + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/fc76c70e740b10f091e502b2e393d0be912f38d4", - "reference": "fc76c70e740b10f091e502b2e393d0be912f38d4", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/finder": "^2.3 || ^3.0", - "nette/utils": "^2.4 || ^3.0", - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "nette/finder": "^2.5", + "nette/utils": "^3.0", + "php": ">=7.1" }, "require-dev": { "nette/tester": "^2.0", @@ -846,7 +908,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -870,7 +932,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", + "description": "? Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.", "homepage": "https://nette.org", "keywords": [ "autoload", @@ -879,27 +941,81 @@ "nette", "trait" ], - "time": "2018-08-13T14:19:06+00:00" + "time": "2019-03-08T21:57:24+00:00" + }, + { + "name": "nette/schema", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/nette/schema.git", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "shasum": "" + }, + "require": { + "nette/utils": "^3.0.1", + "php": ">=7.1" + }, + "require-dev": { + "nette/tester": "^2.2", + "tracy/tracy": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "📐 Nette Schema: validating data structures against a given Schema.", + "homepage": "https://nette.org", + "keywords": [ + "config", + "nette" + ], + "time": "2019-04-03T15:53:25+00:00" }, { "name": "nette/utils", - "version": "v2.5.3", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce" + "reference": "bd961f49b211997202bda1d0fbc410905be370d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce", - "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce", + "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", + "reference": "bd961f49b211997202bda1d0fbc410905be370d4", "shasum": "" }, "require": { - "php": ">=5.6.0" - }, - "conflict": { - "nette/nette": "<2.2" + "php": ">=7.1" }, "require-dev": { "nette/tester": "~2.0", @@ -908,7 +1024,7 @@ "suggest": { "ext-gd": "to use Image", "ext-iconv": "to use Strings::webalize() and toAscii()", - "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", + "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", "ext-xml": "to use Strings::length() etc. when mbstring is not available" @@ -916,15 +1032,12 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "3.0-dev" } }, "autoload": { "classmap": [ "src/" - ], - "files": [ - "src/loader.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -961,20 +1074,20 @@ "utility", "validation" ], - "time": "2018-09-18T10:22:16+00:00" + "time": "2019-03-22T01:00:30+00:00" }, { "name": "nikic/php-parser", - "version": "v4.1.0", + "version": "v4.2.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "d0230c5c77a7e3cfa69446febf340978540958c0" + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/d0230c5c77a7e3cfa69446febf340978540958c0", - "reference": "d0230c5c77a7e3cfa69446febf340978540958c0", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", "shasum": "" }, "require": { @@ -990,7 +1103,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1012,20 +1125,20 @@ "parser", "php" ], - "time": "2018-10-10T09:24:14+00:00" + "time": "2019-05-25T20:07:01+00:00" }, { "name": "ocramius/package-versions", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f" + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/4489d5002c49d55576fa0ba786f42dbb009be46f", - "reference": "4489d5002c49d55576fa0ba786f42dbb009be46f", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", "shasum": "" }, "require": { @@ -1034,6 +1147,7 @@ }, "require-dev": { "composer/composer": "^1.6.3", + "doctrine/coding-standard": "^5.0.1", "ext-zip": "*", "infection/infection": "^0.7.1", "phpunit/phpunit": "^7.0.0" @@ -1061,7 +1175,7 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2018-02-05T13:05:30+00:00" + "time": "2019-02-21T12:16:21+00:00" }, { "name": "phar-io/manifest", @@ -1221,16 +1335,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", "shasum": "" }, "require": { @@ -1268,7 +1382,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "time": "2019-04-30T17:48:53+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1319,16 +1433,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", "shasum": "" }, "require": { @@ -1349,8 +1463,8 @@ } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -1378,32 +1492,33 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "time": "2019-06-13T12:50:23+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "0.3", + "version": "0.3.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "ed3223362174b8067729930439e139794e9e514a" + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/ed3223362174b8067729930439e139794e9e514a", - "reference": "ed3223362174b8067729930439e139794e9e514a", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8c4ef2aefd9788238897b678a985e1d5c8df6db4", + "reference": "8c4ef2aefd9788238897b678a985e1d5c8df6db4", "shasum": "" }, "require": { "php": "~7.1" }, "require-dev": { - "consistence/coding-standard": "^2.0.0", + "consistence/coding-standard": "^3.5", "jakub-onderka/php-parallel-lint": "^0.9.2", "phing/phing": "^2.16.0", - "phpstan/phpstan": "^0.10@dev", + "phpstan/phpstan": "^0.10", "phpunit/phpunit": "^6.3", - "slevomat/coding-standard": "^3.3.0", + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2", "symfony/process": "^3.4 || ^4.0" }, "type": "library", @@ -1424,20 +1539,20 @@ "MIT" ], "description": "PHPDoc parser with support for nullable, intersection and generic types", - "time": "2018-06-20T17:48:01+00:00" + "time": "2019-06-07T19:13:52+00:00" }, { "name": "phpstan/phpstan", - "version": "0.10.5", + "version": "0.10.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d" + "reference": "4f828460a0276180da76c670a0a6e592e7c38b71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", - "reference": "c6a8cd1fe08a23b9d101a55ffa9ff6b91d71ef5d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/4f828460a0276180da76c670a0a6e592e7c38b71", + "reference": "4f828460a0276180da76c670a0a6e592e7c38b71", "shasum": "" }, "require": { @@ -1453,6 +1568,9 @@ "symfony/console": "~3.2 || ~4.0", "symfony/finder": "~3.2 || ~4.0" }, + "conflict": { + "symfony/console": "3.4.16 || 4.1.5" + }, "require-dev": { "brianium/paratest": "^2.0", "consistence/coding-standard": "^3.5", @@ -1469,7 +1587,8 @@ "phpstan/phpstan-phpunit": "^0.10", "phpstan/phpstan-strict-rules": "^0.10", "phpunit/phpunit": "^7.0", - "slevomat/coding-standard": "^4.7.2" + "slevomat/coding-standard": "^4.7.2", + "squizlabs/php_codesniffer": "^3.3.2" }, "bin": [ "bin/phpstan" @@ -1493,7 +1612,7 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2018-10-20T17:24:55+00:00" + "time": "2019-01-08T09:51:19+00:00" }, { "name": "phpstan/phpstan-beberlei-assert", @@ -1545,16 +1664,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "6.1.3", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f" + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4d3ae9b21a7d7e440bd0cf65565533117976859f", - "reference": "4d3ae9b21a7d7e440bd0cf65565533117976859f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", "shasum": "" }, "require": { @@ -1593,8 +1712,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", @@ -1604,7 +1723,7 @@ "testing", "xunit" ], - "time": "2018-10-23T05:59:32+00:00" + "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1699,16 +1818,16 @@ }, { "name": "phpunit/php-timer", - "version": "2.0.0", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", - "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { @@ -1720,7 +1839,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -1735,8 +1854,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Utility class for timing", @@ -1744,20 +1863,20 @@ "keywords": [ "timer" ], - "time": "2018-02-01T13:07:23+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" + "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", - "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e899757bb3df5ff6e95089132f32cd59aac2220a", + "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a", "shasum": "" }, "require": { @@ -1770,7 +1889,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1793,20 +1912,20 @@ "keywords": [ "tokenizer" ], - "time": "2018-10-30T05:52:18+00:00" + "time": "2019-07-25T05:29:42+00:00" }, { "name": "phpunit/phpunit", - "version": "7.4.3", + "version": "7.5.14", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c151651fb6ed264038d486ea262e243af72e5e64" + "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c151651fb6ed264038d486ea262e243af72e5e64", - "reference": "c151651fb6ed264038d486ea262e243af72e5e64", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2834789aeb9ac182ad69bfdf9ae91856a59945ff", + "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff", "shasum": "" }, "require": { @@ -1824,10 +1943,10 @@ "phpunit/php-code-coverage": "^6.0.7", "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.0", + "phpunit/php-timer": "^2.1", "sebastian/comparator": "^3.0", "sebastian/diff": "^3.0", - "sebastian/environment": "^3.1 || ^4.0", + "sebastian/environment": "^4.0", "sebastian/exporter": "^3.1", "sebastian/global-state": "^2.0", "sebastian/object-enumerator": "^3.0.3", @@ -1851,7 +1970,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.4-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -1866,8 +1985,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "The PHP Unit Testing framework.", @@ -1877,20 +1996,69 @@ "testing", "xunit" ], - "time": "2018-10-23T05:57:41+00:00" + "time": "2019-07-15T06:24:08+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "shasum": "" }, "require": { @@ -1924,7 +2092,7 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2018-11-20T15:27:04+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2037,23 +2205,23 @@ }, { "name": "sebastian/diff", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "366541b989927187c4ca70490a35615d3fef2dce" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", - "reference": "366541b989927187c4ca70490a35615d3fef2dce", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^7.0", + "phpunit/phpunit": "^7.5 || ^8.0", "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", @@ -2089,32 +2257,35 @@ "unidiff", "unified diff" ], - "time": "2018-06-10T07:54:39+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.2.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -2139,7 +2310,7 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "time": "2019-05-05T09:05:15+00:00" }, { "name": "sebastian/exporter", @@ -2491,36 +2662,43 @@ }, { "name": "symfony/console", - "version": "v4.1.6", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b" + "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/dc7122fe5f6113cfaba3b3de575d31112c9aa60b", - "reference": "dc7122fe5f6113cfaba3b3de575d31112c9aa60b", + "url": "https://api.github.com/repos/symfony/console/zipball/8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", + "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", "shasum": "" }, "require": { "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/service-contracts": "^1.1" }, "conflict": { "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3", "symfony/process": "<3.3" }, + "provide": { + "psr/log-implementation": "1.0" + }, "require-dev": { "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/event-dispatcher": "^4.3", "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0" + "symfony/process": "~3.4|~4.0", + "symfony/var-dumper": "^4.3" }, "suggest": { - "psr/log-implementation": "For using the console logger", + "psr/log": "For using the console logger", "symfony/event-dispatcher": "", "symfony/lock": "", "symfony/process": "" @@ -2528,7 +2706,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -2555,20 +2733,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-10-03T08:15:46+00:00" + "time": "2019-07-24T17:13:59+00:00" }, { "name": "symfony/finder", - "version": "v4.1.6", + "version": "v4.3.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "1f17195b44543017a9c9b2d437c670627e96ad06" + "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/1f17195b44543017a9c9b2d437c670627e96ad06", - "reference": "1f17195b44543017a9c9b2d437c670627e96ad06", + "url": "https://api.github.com/repos/symfony/finder/zipball/9638d41e3729459860bb96f6247ccb61faaa45f2", + "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2", "shasum": "" }, "require": { @@ -2577,7 +2755,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -2604,20 +2782,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-10-03T08:47:56+00:00" + "time": "2019-06-28T13:16:30+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.9.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", "shasum": "" }, "require": { @@ -2629,7 +2807,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2663,25 +2841,141 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", + "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-06-13T11:15:36+00:00" }, { "name": "thecodingmachine/phpstan-strict-rules", - "version": "v0.10.7", + "version": "v0.10.8", "source": { "type": "git", "url": "https://github.com/thecodingmachine/phpstan-strict-rules.git", - "reference": "bf15df9169b3909ad5eb3b7825b70e793c8b4520" + "reference": "663fad8801b24c666f3c695ca6cbbc1cb28776a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thecodingmachine/phpstan-strict-rules/zipball/bf15df9169b3909ad5eb3b7825b70e793c8b4520", - "reference": "bf15df9169b3909ad5eb3b7825b70e793c8b4520", + "url": "https://api.github.com/repos/thecodingmachine/phpstan-strict-rules/zipball/663fad8801b24c666f3c695ca6cbbc1cb28776a9", + "reference": "663fad8801b24c666f3c695ca6cbbc1cb28776a9", "shasum": "" }, "require": { "php": "^7.1", - "phpstan/phpstan": "^0.10" + "phpstan/phpstan": "^0.10|^0.11" }, "require-dev": { "php-coveralls/php-coveralls": "^2.1", @@ -2709,20 +3003,20 @@ } ], "description": "A set of additional rules for PHPStan based on best practices followed at TheCodingMachine", - "time": "2018-10-30T10:43:52+00:00" + "time": "2019-01-18T08:10:20+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.0", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", - "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", "shasum": "" }, "require": { @@ -2749,24 +3043,25 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2017-04-07T12:08:54+00:00" + "time": "2019-06-13T22:48:21+00:00" }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -2799,7 +3094,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2018-12-25T11:19:39+00:00" } ], "aliases": [], diff --git a/phpstan.neon b/phpstan.neon index f4ab09b3c..42547bba3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,6 +15,8 @@ parameters: - '#Parameter .* \\$str of function substr expects string, string\\|false given.#' # It turns out that curl_init DOES accept null as first parameter, even if it is not documented. - '#Parameter .* $url of function curl_init expects string, string\\|null given.#' + # The EventDispatcherInterface::dispatch method does actually expect 2 parameters (see PHPDoc) + - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index eeebaab92..68ed16e05 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -99,9 +99,10 @@ public function getEventDispatcher(): EventDispatcherInterface * @param Event $event The event to pass to the event handlers/listeners. * @return Event */ - private function dispatch(string $eventName, Event $event = null): Event + private function dispatch(string $eventName, Event $event): Event { - return $this->getEventDispatcher()->dispatch($eventName, $event); + $this->getEventDispatcher()->dispatch($event, $eventName); + return $event; } /** From 71372309fc35d22223085fe65d95516cc2e6b19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 6 Aug 2019 10:12:46 +0200 Subject: [PATCH 041/204] Fixing event listener breaking change in Symfony 4.3 --- composer.lock | 60 +++++++++++++++++++-------------------- phpstan.neon | 3 ++ src/VCR/Videorecorder.php | 11 ++++++- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/composer.lock b/composer.lock index cd484247a..192ad7ec1 100644 --- a/composer.lock +++ b/composer.lock @@ -191,16 +191,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", "shasum": "" }, "require": { @@ -212,7 +212,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -228,13 +228,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -245,7 +245,7 @@ "polyfill", "portable" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/yaml", @@ -1262,18 +1262,18 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" }, { "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" + "role": "Developer", + "email": "sebastian@phpeople.de" }, { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" + "role": "Developer", + "email": "sebastian@phpunit.de" } ], "description": "Library for handling version information and constraints", @@ -1763,8 +1763,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", @@ -2786,16 +2786,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", "shasum": "" }, "require": { @@ -2807,7 +2807,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -2841,20 +2841,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", - "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188", + "reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188", "shasum": "" }, "require": { @@ -2863,7 +2863,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -2899,7 +2899,7 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/service-contracts", diff --git a/phpstan.neon b/phpstan.neon index 42547bba3..2ab012390 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,6 +17,9 @@ parameters: - '#Parameter .* $url of function curl_init expects string, string\\|null given.#' # The EventDispatcherInterface::dispatch method does actually expect 2 parameters (see PHPDoc) - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#' + # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 + - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given./' + - '/Cannot call method isBuiltin\(\) on ReflectionType|null./' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 68ed16e05..236ef12a9 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -101,7 +101,16 @@ public function getEventDispatcher(): EventDispatcherInterface */ private function dispatch(string $eventName, Event $event): Event { - $this->getEventDispatcher()->dispatch($event, $eventName); + // Symfony 4.3 introduces a breaking change (in a minor release!) in the parameter order of the dispatch method. + // We need to check which version of the dispatcher we are using! + $r = new \ReflectionMethod($this->getEventDispatcher(), 'dispatch'); + $param2 = $r->getParameters()[1] ?? null; + + if (!$param2 || !$param2->hasType() || $param2->getType()->isBuiltin()) { + $this->getEventDispatcher()->dispatch($event, $eventName); + } else { + $this->getEventDispatcher()->dispatch($eventName, $event); + } return $event; } From ee01b30964a24e1c8b76e1ee6847ceb64c8b89d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:14:42 +0200 Subject: [PATCH 042/204] Storage: Yaml: prevent PHP 7.4 deprecation notice --- src/VCR/Storage/Yaml.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index bd698dc67..d1eb416bb 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -4,7 +4,6 @@ use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Dumper; -use VCR\Util\Assertion; /** * Yaml based storage for records. @@ -58,7 +57,7 @@ public function storeRecording(array $recording): void public function next() { $recording = $this->yamlParser->parse($this->readNextRecord()); - $this->current = $recording[0]; + $this->current = $recording[0] ?? null; ++$this->position; } From 0199448c9a40f6bff1de60acd722fe23876cd98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:15:10 +0200 Subject: [PATCH 043/204] Cassette: drop unused use statement --- src/VCR/Cassette.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 2e43117ac..eab3219c4 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -3,7 +3,6 @@ namespace VCR; use VCR\Storage\Storage; -use VCR\Util\Assertion; /** * A Cassette records and plays back pairs of Requests and Responses in a Storage. From f3686b1c0ad283cdb487043f7686c01e17230d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:15:32 +0200 Subject: [PATCH 044/204] Request: drop unused use statement --- src/VCR/Request.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/VCR/Request.php b/src/VCR/Request.php index a6104c446..e24d0514f 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -3,7 +3,6 @@ namespace VCR; use Assert\Assertion; -use function sprintf; use VCR\Exceptions\InvalidHostException; /** From 6963db5c33e239dfe32fda772c1689f913d15bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:15:48 +0200 Subject: [PATCH 045/204] Response: drop unused use statement --- src/VCR/Response.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/VCR/Response.php b/src/VCR/Response.php index fa3d32142..c06d956cd 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -2,7 +2,6 @@ namespace VCR; -use function var_dump; use VCR\Util\Assertion; /** From 09ef936bfb522ec6124a6d372a842575a6d44978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:16:05 +0200 Subject: [PATCH 046/204] Storage: AbstractStorage: drop unused use statement --- src/VCR/Storage/AbstractStorage.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index 3611ce2a3..0a4840823 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -3,7 +3,6 @@ namespace VCR\Storage; use VCR\Util\Assertion; -use VCR\VCRException; /** * Abstract base for reading and storing records. From 9e88cf99c301d5d32ccf1ab12cc470f273692b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:16:23 +0200 Subject: [PATCH 047/204] Storage: Json: drop unused use statement --- src/VCR/Storage/Json.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/VCR/Storage/Json.php b/src/VCR/Storage/Json.php index 7c9002546..47a538bf2 100644 --- a/src/VCR/Storage/Json.php +++ b/src/VCR/Storage/Json.php @@ -2,8 +2,6 @@ namespace VCR\Storage; -use VCR\Util\Assertion; - /** * Json based storage for records. * From 5360a98916a9207d0e91b0d28907f45a2f4dfdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 17:16:51 +0200 Subject: [PATCH 048/204] LibraryHooks: StreamWrapperHook: drop unused use statements --- src/VCR/LibraryHooks/StreamWrapperHook.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index e5ea7eb2d..441630cdb 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -2,11 +2,9 @@ namespace VCR\LibraryHooks; -use VCR\Request; use VCR\Response; use VCR\Util\Assertion; use VCR\Util\CurlException; -use VCR\Util\HttpUtil; use VCR\Util\StreamHelper; /** From e73c98803912fd4b0e956b189dcb278dbbc73c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 18:21:53 +0200 Subject: [PATCH 049/204] U-Tests: LibraryHooks: CurlHookTest: pass second param to curl_multi_exec --- tests/VCR/LibraryHooks/CurlHookTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 65beea8c4..61afff152 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -294,7 +294,8 @@ function (Request $request) use ($testClass, &$callCount) { curl_multi_add_handle($curlMultiHandle, $curlHandle1); curl_multi_add_handle($curlMultiHandle, $curlHandle2); - $mh = curl_multi_exec($curlMultiHandle); + $stillRunning = null; + $mh = curl_multi_exec($curlMultiHandle, $stillRunning); $lastInfo = curl_multi_info_read($mh); $secondLastInfo = curl_multi_info_read($mh); @@ -337,9 +338,10 @@ function () use ($testClass) { $curlHandle = curl_init('http://example.com'); + $stillRunning = null; $curlMultiHandle = curl_multi_init(); curl_multi_add_handle($curlMultiHandle, $curlHandle); - curl_multi_exec($curlMultiHandle); + curl_multi_exec($curlMultiHandle, $stillRunning); curl_multi_remove_handle($curlMultiHandle, $curlHandle); curl_multi_close($curlMultiHandle); } From 22f5a5c0a37ff5b5602bf1cf57bc17b1c6983deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 18:22:39 +0200 Subject: [PATCH 050/204] U-Tests: LibraryHooks: CurlHookTest: make sure we pass Closure --- tests/VCR/LibraryHooks/CurlHookTest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 61afff152..c6c696218 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -2,12 +2,13 @@ namespace VCR\LibraryHooks; -use PHPUnit\Framework\TestCase; +use Closure; use VCR\Request; use VCR\Response; use VCR\Configuration; -use VCR\CodeTransform\CurlCodeTransform; use VCR\Util\StreamProcessor; +use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\CurlCodeTransform; /** * Test if intercepting http/https using curl works. @@ -372,13 +373,13 @@ function (Request $request) use ($testClass) { } /** - * @return \callable + * @return Closure */ - protected function getTestCallback($statusCode = 200) + protected function getTestCallback($statusCode = 200): Closure { $testClass = $this; - return function () use ($statusCode, $testClass) { + return Closure::fromCallable(function () use ($statusCode, $testClass) { return new Response($statusCode, array(), $testClass->expected); - }; + }); } } From 5bc3584dbf4461b79ffcecbb8557f05550c9740f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Mom=C4=8Dilovi=C4=87?= Date: Tue, 6 Aug 2019 18:29:29 +0200 Subject: [PATCH 051/204] U-Tests: LibraryHooks: SoapHookTest: make sure we pass Closure --- tests/VCR/LibraryHooks/SoapHookTest.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index 33738be47..f2fdc2b40 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -2,12 +2,13 @@ namespace VCR\LibraryHooks; -use PHPUnit\Framework\TestCase; +use Closure; use VCR\Request; use VCR\Response; use VCR\Configuration; -use VCR\CodeTransform\SoapCodeTransform; use VCR\Util\StreamProcessor; +use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\SoapCodeTransform; /** * Test if intercepting http/https using soap works. @@ -91,28 +92,28 @@ public function testShouldReturnLastRequestWithTraceOn() } /** - * @return \callable + * @return Closure */ - protected function getContentCheckCallback() + protected function getContentCheckCallback(): Closure { $testClass = $this; - return function () use ($testClass) { + return Closure::fromCallable(function () use ($testClass) { return new Response(200, array(), $testClass->expected); - }; + }); } /** * @param array $expectedHeaders - * @return \callable + * @return Closure */ - protected function getHeadersCheckCallback(array $expectedHeaders) + protected function getHeadersCheckCallback(array $expectedHeaders): Closure { $test = $this; - return function (Request $request) use ($test, $expectedHeaders) { + return Closure::fromCallable(function (Request $request) use ($test, $expectedHeaders) { foreach ($expectedHeaders as $expectedHeaderName => $expectedHeader) { $test->assertEquals($expectedHeader, $request->getHeader($expectedHeaderName)); } return new Response(200, array(), ''); - }; + }); } } From bb4b0390235827d7a64eb386f21de0f6e2a1b2d5 Mon Sep 17 00:00:00 2001 From: AYB Date: Fri, 22 Nov 2019 15:04:12 +0100 Subject: [PATCH 052/204] Fixing Beberlei/assert signature change beberlei/assert changed the signature of Assertion::isCallable (in a patch release!) and we extend this method. This commit updates "assert" to the latest version and updates our signature accordingly. --- composer.json | 2 +- src/VCR/Util/Assertion.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6616722d8..f6f1d4299 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=7.2", "ext-curl": "*", - "beberlei/assert": "^2.7.11 | ^3.0", + "beberlei/assert": "^3.2.5", "symfony/yaml": "~2.1|^3.0|^4.0", "symfony/event-dispatcher": "^2.4|^3.0|^4.0" }, diff --git a/src/VCR/Util/Assertion.php b/src/VCR/Util/Assertion.php index f5d1c80ec..059f1b33a 100644 --- a/src/VCR/Util/Assertion.php +++ b/src/VCR/Util/Assertion.php @@ -21,10 +21,12 @@ class Assertion extends BaseAssertion * * @return void */ - public static function isCallable($value, $message = null, $propertyPath = null) + public static function isCallable($value, $message = null, string $propertyPath = null): bool { if (! is_callable($value)) { throw new VCRException($message, self::INVALID_CALLABLE, $propertyPath); } + + return true; } } From afc470001d4ece174c1c088fd44c0456c1d5b6a7 Mon Sep 17 00:00:00 2001 From: AYB Date: Fri, 22 Nov 2019 15:15:48 +0100 Subject: [PATCH 053/204] Updating composer.lock --- composer.lock | 467 ++++++++++++++++++++++++++------------------------ 1 file changed, 239 insertions(+), 228 deletions(-) diff --git a/composer.lock b/composer.lock index 192ad7ec1..e5f178e5f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,23 +4,27 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "63c3bc1d8732d38581a36c56b227b2d7", + "content-hash": "0b6b633eef450b9ca1b1f3aa91ee52e0", "packages": [ { "name": "beberlei/assert", - "version": "v3.2.1", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7" + "reference": "99508be011753690fe108ded450f5caaae180cfa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7", - "reference": "ce139b6bf8f07fb8389d2c8e15b98dc24fdd93c7", + "url": "https://api.github.com/repos/beberlei/assert/zipball/99508be011753690fe108ded450f5caaae180cfa", + "reference": "99508be011753690fe108ded450f5caaae180cfa", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", "php": "^7" }, "require-dev": { @@ -28,6 +32,9 @@ "phpstan/phpstan-shim": "*", "phpunit/phpunit": ">=6.0.0 <8" }, + "suggest": { + "ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles" + }, "type": "library", "autoload": { "psr-4": { @@ -44,13 +51,13 @@ "authors": [ { "name": "Benjamin Eberlei", - "role": "Lead Developer", - "email": "kontakt@beberlei.de" + "email": "kontakt@beberlei.de", + "role": "Lead Developer" }, { "name": "Richard Quadling", - "role": "Collaborator", - "email": "rquadling@gmail.com" + "email": "rquadling@gmail.com", + "role": "Collaborator" } ], "description": "Thin assertion library for input validation in business models.", @@ -59,20 +66,20 @@ "assertion", "validation" ], - "time": "2019-05-28T15:18:28+00:00" + "time": "2019-10-10T10:33:57+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.3.3", + "version": "v4.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "212b020949331b6531250584531363844b34a94e" + "reference": "ab1c43e17fff802bef0a898f3bc088ac33b8e0e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/212b020949331b6531250584531363844b34a94e", - "reference": "212b020949331b6531250584531363844b34a94e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ab1c43e17fff802bef0a898f3bc088ac33b8e0e1", + "reference": "ab1c43e17fff802bef0a898f3bc088ac33b8e0e1", "shasum": "" }, "require": { @@ -88,12 +95,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "^3.4|^4.0", - "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/dependency-injection": "", @@ -102,7 +109,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -129,20 +136,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-06-27T06:42:14+00:00" + "time": "2019-11-08T22:40:51+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.5", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c" + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c61766f4440ca687de1084a5c00b08e167a2575c", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", "shasum": "" }, "require": { @@ -187,7 +194,7 @@ "interoperability", "standards" ], - "time": "2019-06-20T06:46:26+00:00" + "time": "2019-09-17T09:54:03+00:00" }, { "name": "symfony/polyfill-ctype", @@ -249,16 +256,16 @@ }, { "name": "symfony/yaml", - "version": "v4.3.3", + "version": "v4.4.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "34d29c2acd1ad65688f58452fd48a46bd996d5a6" + "reference": "76de473358fe802578a415d5bb43c296cf09d211" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/34d29c2acd1ad65688f58452fd48a46bd996d5a6", - "reference": "34d29c2acd1ad65688f58452fd48a46bd996d5a6", + "url": "https://api.github.com/repos/symfony/yaml/zipball/76de473358fe802578a415d5bb43c296cf09d211", + "reference": "76de473358fe802578a415d5bb43c296cf09d211", "shasum": "" }, "require": { @@ -269,7 +276,7 @@ "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -277,7 +284,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -304,30 +311,30 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-07-24T14:47:54+00:00" + "time": "2019-11-12T14:51:11+00:00" } ], "packages-dev": [ { "name": "composer/xdebug-handler", - "version": "1.3.3", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" + "reference": "cbe23383749496fe0f373345208b79568e4bc248" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", - "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/cbe23383749496fe0f373345208b79568e4bc248", + "reference": "cbe23383749496fe0f373345208b79568e4bc248", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0", + "php": "^5.3.2 || ^7.0 || ^8.0", "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" }, "type": "library", "autoload": { @@ -345,25 +352,25 @@ "email": "john-stevenson@blueyonder.co.uk" } ], - "description": "Restarts a process without xdebug.", + "description": "Restarts a process without Xdebug.", "keywords": [ "Xdebug", "performance" ], - "time": "2019-05-27T17:52:04+00:00" + "time": "2019-11-06T16:40:04+00:00" }, { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { @@ -406,7 +413,7 @@ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "time": "2019-10-21T16:45:58+00:00" }, { "name": "jean85/pretty-package-versions", @@ -461,16 +468,16 @@ }, { "name": "mikey179/vfsstream", - "version": "v1.6.7", + "version": "v1.6.8", "source": { "type": "git", "url": "https://github.com/bovigo/vfsStream.git", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb" + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", - "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe", + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe", "shasum": "" }, "require": { @@ -497,26 +504,26 @@ "authors": [ { "name": "Frank Kleine", - "role": "Developer", - "homepage": "http://frankkleine.de/" + "homepage": "http://frankkleine.de/", + "role": "Developer" } ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2019-08-01T01:38:37+00:00" + "time": "2019-10-30T15:31:00+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.1", + "version": "1.9.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", "shasum": "" }, "require": { @@ -551,20 +558,20 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2019-08-09T12:45:53+00:00" }, { "name": "nette/bootstrap", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/nette/bootstrap.git", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" + "reference": "b45a1e33b6a44beb307756522396551e5a9ff249" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/b45a1e33b6a44beb307756522396551e5a9ff249", + "reference": "b45a1e33b6a44beb307756522396551e5a9ff249", "shasum": "" }, "require": { @@ -572,6 +579,9 @@ "nette/utils": "^3.0", "php": ">=7.1" }, + "conflict": { + "tracy/tracy": "<2.6" + }, "require-dev": { "latte/latte": "^2.2", "nette/application": "^3.0", @@ -624,20 +634,20 @@ "configurator", "nette" ], - "time": "2019-03-26T12:59:07+00:00" + "time": "2019-09-30T08:19:38+00:00" }, { "name": "nette/di", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "19d83539245aaacb59470828919182411061841f" + "reference": "4aff517a1c6bb5c36fa09733d4cea089f529de6d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", - "reference": "19d83539245aaacb59470828919182411061841f", + "url": "https://api.github.com/repos/nette/di/zipball/4aff517a1c6bb5c36fa09733d4cea089f529de6d", + "reference": "4aff517a1c6bb5c36fa09733d4cea089f529de6d", "shasum": "" }, "require": { @@ -697,20 +707,20 @@ "nette", "static" ], - "time": "2019-04-03T19:35:46+00:00" + "time": "2019-08-07T12:11:33+00:00" }, { "name": "nette/finder", - "version": "v2.5.0", + "version": "v2.5.1", "source": { "type": "git", "url": "https://github.com/nette/finder.git", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" + "reference": "14164e1ddd69e9c5f627ff82a10874b3f5bba5fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", + "url": "https://api.github.com/repos/nette/finder/zipball/14164e1ddd69e9c5f627ff82a10874b3f5bba5fe", + "reference": "14164e1ddd69e9c5f627ff82a10874b3f5bba5fe", "shasum": "" }, "require": { @@ -751,7 +761,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "? Nette Finder: find files and directories with an intuitive API.", + "description": "🔍 Nette Finder: find files and directories with an intuitive API.", "homepage": "https://nette.org", "keywords": [ "filesystem", @@ -759,7 +769,7 @@ "iterator", "nette" ], - "time": "2019-02-28T18:13:25+00:00" + "time": "2019-07-11T18:02:17+00:00" }, { "name": "nette/neon", @@ -824,16 +834,16 @@ }, { "name": "nette/php-generator", - "version": "v3.2.3", + "version": "v3.3.1", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b" + "reference": "4240fd7adf499138c07b814ef9b9a6df9f6d7187" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/aea6e81437bb238e5f0e5b5ce06337433908e63b", - "reference": "aea6e81437bb238e5f0e5b5ce06337433908e63b", + "url": "https://api.github.com/repos/nette/php-generator/zipball/4240fd7adf499138c07b814ef9b9a6df9f6d7187", + "reference": "4240fd7adf499138c07b814ef9b9a6df9f6d7187", "shasum": "" }, "require": { @@ -847,7 +857,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.3-dev" } }, "autoload": { @@ -879,7 +889,7 @@ "php", "scaffolding" ], - "time": "2019-07-05T13:01:56+00:00" + "time": "2019-11-22T11:12:11+00:00" }, { "name": "nette/robot-loader", @@ -945,16 +955,16 @@ }, { "name": "nette/schema", - "version": "v1.0.0", + "version": "v1.0.1", "source": { "type": "git", "url": "https://github.com/nette/schema.git", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" + "reference": "337117df1dade22e2ba1fdc4a4b832c1e9b06b76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", + "url": "https://api.github.com/repos/nette/schema/zipball/337117df1dade22e2ba1fdc4a4b832c1e9b06b76", + "reference": "337117df1dade22e2ba1fdc4a4b832c1e9b06b76", "shasum": "" }, "require": { @@ -998,20 +1008,20 @@ "config", "nette" ], - "time": "2019-04-03T15:53:25+00:00" + "time": "2019-10-31T20:52:19+00:00" }, { "name": "nette/utils", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4" + "reference": "c133e18c922dcf3ad07673077d92d92cef25a148" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4", + "url": "https://api.github.com/repos/nette/utils/zipball/c133e18c922dcf3ad07673077d92d92cef25a148", + "reference": "c133e18c922dcf3ad07673077d92d92cef25a148", "shasum": "" }, "require": { @@ -1027,6 +1037,7 @@ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", "ext-xml": "to use Strings::length() etc. when mbstring is not available" }, "type": "library", @@ -1074,20 +1085,20 @@ "utility", "validation" ], - "time": "2019-03-22T01:00:30+00:00" + "time": "2019-10-21T20:40:16+00:00" }, { "name": "nikic/php-parser", - "version": "v4.2.2", + "version": "v4.3.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420" + "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bd73cc04c3843ad8d6b0bfc0956026a151fc420", - "reference": "1bd73cc04c3843ad8d6b0bfc0956026a151fc420", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/9a9981c347c5c49d6dfe5cf826bb882b824080dc", + "reference": "9a9981c347c5c49d6dfe5cf826bb882b824080dc", "shasum": "" }, "require": { @@ -1095,7 +1106,8 @@ "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^6.5 || ^7.0" + "ircmaxell/php-yacc": "0.0.5", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0" }, "bin": [ "bin/php-parse" @@ -1103,7 +1115,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1125,38 +1137,39 @@ "parser", "php" ], - "time": "2019-05-25T20:07:01+00:00" + "time": "2019-11-08T13:50:10+00:00" }, { "name": "ocramius/package-versions", - "version": "1.4.0", + "version": "1.5.1", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" + "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/1d32342b8c1eb27353c8887c366147b4c2da673c", + "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c", "shasum": "" }, "require": { "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" + "php": "^7.3.0" }, "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", + "composer/composer": "^1.8.6", + "doctrine/coding-standard": "^6.0.0", "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.0.0" + "infection/infection": "^0.13.4", + "phpunit/phpunit": "^8.2.5", + "vimeo/psalm": "^3.4.9" }, "type": "composer-plugin", "extra": { "class": "PackageVersions\\Installer", "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -1175,7 +1188,7 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-02-21T12:16:21+00:00" + "time": "2019-07-17T15:49:50+00:00" }, { "name": "phar-io/manifest", @@ -1262,18 +1275,18 @@ "authors": [ { "name": "Arne Blankerts", - "role": "Developer", - "email": "arne@blankerts.de" + "email": "arne@blankerts.de", + "role": "Developer" }, { "name": "Sebastian Heuer", - "role": "Developer", - "email": "sebastian@phpeople.de" + "email": "sebastian@phpeople.de", + "role": "Developer" }, { "name": "Sebastian Bergmann", - "role": "Developer", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "Developer" } ], "description": "Library for handling version information and constraints", @@ -1281,35 +1294,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1331,30 +1342,30 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "4.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", "phpunit/phpunit": "^6.4" }, @@ -1382,41 +1393,40 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2019-09-12T14:27:41+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1429,26 +1439,27 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, @@ -1492,7 +1503,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -1712,8 +1723,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "role": "lead", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", @@ -1763,8 +1774,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "role": "lead", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", @@ -1854,8 +1865,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "role": "lead", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], "description": "Utility class for timing", @@ -1867,16 +1878,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e899757bb3df5ff6e95089132f32cd59aac2220a", - "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { @@ -1912,20 +1923,20 @@ "keywords": [ "tokenizer" ], - "time": "2019-07-25T05:29:42+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "7.5.14", + "version": "7.5.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff" + "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2834789aeb9ac182ad69bfdf9ae91856a59945ff", - "reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4c92a15296e58191a4cd74cff3b34fc8e374174a", + "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a", "shasum": "" }, "require": { @@ -1985,8 +1996,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "role": "lead", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], "description": "The PHP Unit Testing framework.", @@ -1996,7 +2007,7 @@ "testing", "xunit" ], - "time": "2019-07-15T06:24:08+00:00" + "time": "2019-10-28T10:37:36+00:00" }, { "name": "psr/container", @@ -2049,16 +2060,16 @@ }, { "name": "psr/log", - "version": "1.1.0", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", - "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", + "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", "shasum": "" }, "require": { @@ -2067,7 +2078,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1.x-dev" } }, "autoload": { @@ -2092,7 +2103,7 @@ "psr", "psr-3" ], - "time": "2018-11-20T15:27:04+00:00" + "time": "2019-11-01T11:05:21+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2261,16 +2272,16 @@ }, { "name": "sebastian/environment", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404", - "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { @@ -2310,20 +2321,20 @@ "environment", "hhvm" ], - "time": "2019-05-05T09:05:15+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -2350,6 +2361,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -2358,17 +2373,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -2377,7 +2388,7 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", @@ -2662,27 +2673,28 @@ }, { "name": "symfony/console", - "version": "v4.3.3", + "version": "v4.4.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9" + "reference": "35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", - "reference": "8b0ae5742ce9aaa8b0075665862c1ca397d1c1d9", + "url": "https://api.github.com/repos/symfony/console/zipball/35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8", + "reference": "35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8", "shasum": "" }, "require": { "php": "^7.1.3", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/service-contracts": "^1.1" + "symfony/service-contracts": "^1.1|^2" }, "conflict": { "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", "symfony/process": "<3.3" }, "provide": { @@ -2690,12 +2702,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", "symfony/event-dispatcher": "^4.3", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/var-dumper": "^4.3" + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -2706,7 +2718,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -2733,20 +2745,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-07-24T17:13:59+00:00" + "time": "2019-11-13T07:39:40+00:00" }, { "name": "symfony/finder", - "version": "v4.3.3", + "version": "v4.4.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2" + "reference": "ce8743441da64c41e2a667b8eb66070444ed911e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9638d41e3729459860bb96f6247ccb61faaa45f2", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2", + "url": "https://api.github.com/repos/symfony/finder/zipball/ce8743441da64c41e2a667b8eb66070444ed911e", + "reference": "ce8743441da64c41e2a667b8eb66070444ed911e", "shasum": "" }, "require": { @@ -2755,7 +2767,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -2782,7 +2794,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-06-28T13:16:30+00:00" + "time": "2019-11-17T21:56:56+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2903,20 +2915,20 @@ }, { "name": "symfony/service-contracts", - "version": "v1.1.5", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d" + "reference": "9d99e1556417bf227a62e14856d630672bf10eaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/9d99e1556417bf227a62e14856d630672bf10eaf", + "reference": "9d99e1556417bf227a62e14856d630672bf10eaf", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/container": "^1.0" }, "suggest": { @@ -2925,7 +2937,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2957,7 +2969,7 @@ "interoperability", "standards" ], - "time": "2019-06-13T11:15:36+00:00" + "time": "2019-11-09T09:18:34+00:00" }, { "name": "thecodingmachine/phpstan-strict-rules", @@ -3047,16 +3059,16 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", "shasum": "" }, "require": { @@ -3064,8 +3076,7 @@ "symfony/polyfill-ctype": "^1.8" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", "extra": { @@ -3094,7 +3105,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2019-08-24T08:43:50+00:00" } ], "aliases": [], From 8becc4e42b9491ec5789a0a90f346bbbd90428da Mon Sep 17 00:00:00 2001 From: AymanBenmada <45004727+AymanBenmada@users.noreply.github.com> Date: Wed, 27 Nov 2019 09:30:50 +0100 Subject: [PATCH 054/204] Update src/VCR/Util/Assertion.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: David Négrier --- src/VCR/Util/Assertion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Util/Assertion.php b/src/VCR/Util/Assertion.php index 059f1b33a..7a85631cd 100644 --- a/src/VCR/Util/Assertion.php +++ b/src/VCR/Util/Assertion.php @@ -19,7 +19,7 @@ class Assertion extends BaseAssertion * @param null $propertyPath * @throws \VCR\VCRException If specified value is not a callable. * - * @return void + * @return bool */ public static function isCallable($value, $message = null, string $propertyPath = null): bool { From cf74dbae1a893696051d1ad660adf14bd780791c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 27 Nov 2019 09:38:21 +0100 Subject: [PATCH 055/204] Fixing issue with Guzzle 3 and symfony event dispatcher --- composer.lock | 65 +++++++++++------------- tests/integration/guzzle/3/composer.json | 3 +- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/composer.lock b/composer.lock index e5f178e5f..18e0ab280 100644 --- a/composer.lock +++ b/composer.lock @@ -1141,35 +1141,34 @@ }, { "name": "ocramius/package-versions", - "version": "1.5.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c" + "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/1d32342b8c1eb27353c8887c366147b4c2da673c", - "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", + "reference": "44af6f3a2e2e04f2af46bcb302ad9600cba41c7d", "shasum": "" }, "require": { "composer-plugin-api": "^1.0.0", - "php": "^7.3.0" + "php": "^7.1.0" }, "require-dev": { - "composer/composer": "^1.8.6", - "doctrine/coding-standard": "^6.0.0", + "composer/composer": "^1.6.3", + "doctrine/coding-standard": "^5.0.1", "ext-zip": "*", - "infection/infection": "^0.13.4", - "phpunit/phpunit": "^8.2.5", - "vimeo/psalm": "^3.4.9" + "infection/infection": "^0.7.1", + "phpunit/phpunit": "^7.5.17" }, "type": "composer-plugin", "extra": { "class": "PackageVersions\\Installer", "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1188,7 +1187,7 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-07-17T15:49:50+00:00" + "time": "2019-11-15T16:17:10+00:00" }, { "name": "phar-io/manifest", @@ -1275,18 +1274,18 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" }, { "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" + "role": "Developer", + "email": "sebastian@phpeople.de" }, { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" + "role": "Developer", + "email": "sebastian@phpunit.de" } ], "description": "Library for handling version information and constraints", @@ -1723,8 +1722,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", @@ -1774,8 +1773,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "FilterIterator implementation that filters files based on a list of suffixes.", @@ -1865,8 +1864,8 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "role": "lead", + "email": "sebastian@phpunit.de" } ], "description": "Utility class for timing", @@ -3059,31 +3058,29 @@ }, { "name": "webmozart/assert", - "version": "1.5.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", - "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { "php": "^5.3.3 || ^7.0", "symfony/polyfill-ctype": "^1.8" }, + "conflict": { + "vimeo/psalm": "<3.6.0" + }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -3105,7 +3102,7 @@ "check", "validate" ], - "time": "2019-08-24T08:43:50+00:00" + "time": "2019-11-24T13:36:37+00:00" } ], "aliases": [], diff --git a/tests/integration/guzzle/3/composer.json b/tests/integration/guzzle/3/composer.json index cdd97e7f7..d871811ea 100644 --- a/tests/integration/guzzle/3/composer.json +++ b/tests/integration/guzzle/3/composer.json @@ -1,5 +1,6 @@ { "require": { - "guzzlehttp/guzzle": "~3.0" + "guzzlehttp/guzzle": "~3.0", + "symfony/event-dispatcher": "<4.3" } } From b224adb655a70a9a1c95ef6c442d6c1d2d221e24 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Thu, 21 May 2020 20:48:31 +0200 Subject: [PATCH 056/204] Fixed php-cs in CI --- tests/VCR/RequestTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 3a8379ef6..38c299e8c 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -219,9 +219,9 @@ public function testGetHostReturnsBothHostAndPort() public function testDoNotOverwriteHostHeader() { $this->request = new Request( - 'GET', - 'http://example.com', - array('User-Agent' => 'Unit-Test', 'Host' => 'www.example.com') + 'GET', + 'http://example.com', + array('User-Agent' => 'Unit-Test', 'Host' => 'www.example.com') ); $this->assertEquals( From 5f46a6e6652207162bcd3e08003d6ced7d54bee9 Mon Sep 17 00:00:00 2001 From: James Hall Date: Thu, 21 May 2020 20:15:27 +0100 Subject: [PATCH 057/204] Fix typo in README and remove warning Rationale: It's pretty battle-tested now, as we tidy this up we want to encourage new users. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 75b060ce2..f86722d37 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ This is a port of the [VCR](http://github.com/vcr/vcr) Ruby library to PHP. Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. A bit of documentation can be found on the [php-vcr website](http://php-vcr.github.io). -Disclaimer: Doing this in PHP is not as easy as in programming languages which support monkey patching (I'm looking at you, Ruby) – this project is not yet fully tested, so please use at your own risk! +Disclaimer: Doing this in PHP is not as easy as in programming languages which support monkey patching (I'm looking at you, Ruby) ## Features * Automatically records and replays your HTTP(s) interactions with minimal setup/configuration code. * Supports common http functions and extensions - * everyting using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see #96) + * everything using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see #96) * [SoapClient](http://www.php.net/manual/en/soapclient.soapclient.php) by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * curl(), by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * The same request can receive different responses in different tests -- just use different cassettes. From c7a65d9e6afb282064794dfdf45bbf7c17638f76 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Thu, 21 May 2020 21:27:51 +0200 Subject: [PATCH 058/204] Fixed vfsstream reference --- composer.json | 2 +- composer.lock | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 52544d2ca..70271e266 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require-dev": { "phpunit/phpunit": "^4.8|^5.0", "sebastian/version": "^1.0.3|^2.0", - "mikey179/vfsStream": "^1.2", + "mikey179/vfsstream": "^1.2", "lapistano/proxy-object": "dev-master#d7184a479f502d5a0f96d0bae73566dbb498da8f" }, diff --git a/composer.lock b/composer.lock index 0941b4bfe..420d8e560 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e7620447991c15ab183fd84a2b8dfde2", + "content-hash": "cf8a9feafbf279d837e83e3523cd0870", "packages": [ { "name": "beberlei/assert", @@ -289,12 +289,12 @@ "version": "v1.6.5", "source": { "type": "git", - "url": "https://github.com/mikey179/vfsStream.git", + "url": "https://github.com/bovigo/vfsStream.git", "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", "shasum": "" }, @@ -972,6 +972,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, { From cff09adabcb228de4099dc2865fa39a05b496f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 22 Oct 2018 18:01:38 +0200 Subject: [PATCH 059/204] Adding PHPStan to CI build --- .travis.yml | 3 ++- composer.json | 3 ++- phpstan.neon | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index 06f543c1e..c6498b768 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: php: 7.1 - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" php: 7.1 - - env: TEST_DIR=. PHP_CS_FIXER=true + - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true php: 7.2 - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 @@ -49,6 +49,7 @@ install: script: - $PHPUNIT_BIN --coverage-clover=coverage.clover - if [ "${PHP_CS_FIXER}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php ./php-cs-fixer-v2.phar fix --dry-run --diff $TRAVIS_BUILD_DIR; fi + - if [ "${PHPSTAN}" = "true" ]; then composer require --dev phpstan/phpstan ^0.10 && composer phpstan; fi after_success: - wget https://scrutinizer-ci.com/ocular.phar diff --git a/composer.json b/composer.json index 70271e266..c5670ab3e 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "scripts": { "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", - "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs" + "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", + "phpstan": "phpstan analyse src -c phpstan.neon --level=0 --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..716959083 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +#parameters: +# ignoreErrors: +#includes: +# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon From 15d6b8948507db046090e45e4364e6a302bf6d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 23 Oct 2018 16:36:57 +0200 Subject: [PATCH 060/204] Fixing PHPStan level 0 issues --- phpstan.neon | 5 +++-- src/VCR/CodeTransform/AbstractCodeTransform.php | 2 +- src/VCR/Request.php | 2 +- src/VCR/Util/CurlHelper.php | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 716959083..e0ae64682 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,4 +1,5 @@ -#parameters: -# ignoreErrors: +parameters: + ignoreErrors: + - "#Call to an undefined static method SoapClient::__construct\\(\\)#" #includes: # - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 934367c42..b841d3737 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -7,7 +7,7 @@ * * @package VCR\CodeTransform */ -abstract class AbstractCodeTransform extends \PHP_User_Filter +abstract class AbstractCodeTransform extends \php_user_filter { const NAME = 'vcr_abstract_filter'; diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 5aa02655a..6e85064ba 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -53,7 +53,7 @@ public function __construct($method, $url, array $headers = array()) * with specified request matcher callbacks. * * @param Request $request Request to check if it matches the current one. - * @param \callable[] $requestMatchers Request matcher callbacks. + * @param callable[] $requestMatchers Request matcher callbacks. * * @throws \BadFunctionCallException If one of the specified request matchers is not callable. * @return boolean True if specified request matches the current one. diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 118893a87..799985fd1 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -17,7 +17,6 @@ class CurlHelper //"certinfo"? CURLINFO_HTTP_CODE => 'http_code', CURLINFO_EFFECTIVE_URL => 'url', - CURLINFO_FILETIME => 'filetime', CURLINFO_TOTAL_TIME => 'total_time', CURLINFO_NAMELOOKUP_TIME => 'namelookup_time', CURLINFO_CONNECT_TIME => 'connect_time', From 008e61973ce406f26eaf586cf0247696539aefd6 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 22 May 2020 08:56:36 +0200 Subject: [PATCH 061/204] Updated phpstan to ^0.12 --- .travis.yml | 2 +- composer.json | 2 +- phpstan.neon | 7 +++---- src/VCR/Response.php | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c6498b768..887488532 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ install: script: - $PHPUNIT_BIN --coverage-clover=coverage.clover - if [ "${PHP_CS_FIXER}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php ./php-cs-fixer-v2.phar fix --dry-run --diff $TRAVIS_BUILD_DIR; fi - - if [ "${PHPSTAN}" = "true" ]; then composer require --dev phpstan/phpstan ^0.10 && composer phpstan; fi + - if [ "${PHPSTAN}" = "true" ]; then composer require --dev phpstan/phpstan ^0.12 && composer phpstan; fi after_success: - wget https://scrutinizer-ci.com/ocular.phar diff --git a/composer.json b/composer.json index c5670ab3e..5a0451827 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", - "phpstan": "phpstan analyse src -c phpstan.neon --level=0 --no-progress -vvv" + "phpstan": "phpstan analyse -c phpstan.neon --no-progress -vvv" }, "authors": [ diff --git a/phpstan.neon b/phpstan.neon index e0ae64682..35123d6cc 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,4 @@ parameters: - ignoreErrors: - - "#Call to an undefined static method SoapClient::__construct\\(\\)#" -#includes: -# - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon + level: 0 + paths: + - src diff --git a/src/VCR/Response.php b/src/VCR/Response.php index cd110fe9b..4de60ec12 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -38,7 +38,7 @@ class Response * @param string $body * @param array $curlInfo */ - public function __construct($status, array $headers = array(), $body = null, array $curlInfo = array()) + final public function __construct($status, array $headers = array(), $body = null, array $curlInfo = array()) { $this->setStatus($status); $this->headers = $headers; From a473e77bd96d1427b6fbe61c1519d81399d23263 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 6 Jan 2020 13:28:46 -0800 Subject: [PATCH 062/204] Fix the parse error on PHP 7.4 Do not return the stat since we don't know the resulting the size that the file will have after having all transformations applied. When including files, PHP 7.4 and newer are sensitive to file size reported by stat. --- src/VCR/Util/StreamProcessor.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 89756cf13..1676e526e 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -262,13 +262,17 @@ public function stream_seek($offset, $whence = SEEK_SET) /** * Retrieve information about a file resource. * + * Do not return the stat since we don't know the resulting size that the file will have + * after having all transformations applied. When including files, PHP 7.4 and newer are sensitive + * to file size reported by stat. + * * @link http://www.php.net/manual/en/streamwrapper.stream-stat.php * - * @return array See stat(). + * @return array|false See stat(). */ public function stream_stat() { - return fstat($this->resource); + return false; } /** From 944334e03881e963bb6058d63a49d8839536be09 Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Mon, 2 Dec 2019 11:27:53 +0100 Subject: [PATCH 063/204] Test php 7.3 and 7.4 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 887488532..0f6fd3e77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,10 @@ matrix: php: 7.1 - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true php: 7.2 + - env: TEST_DIR=. + php: 7.3 + - env: TEST_DIR=. + php: 7.4 - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 - env: TEST_DIR=tests/integration/guzzle/4 From 775ccffa2cce8c1abaf9bea0fa854f2a217f3abd Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Mon, 2 Dec 2019 12:10:08 +0100 Subject: [PATCH 064/204] Use 7.4 snapshot for now --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f6fd3e77..1d4b0d0d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ matrix: - env: TEST_DIR=. php: 7.3 - env: TEST_DIR=. - php: 7.4 + php: 7.4snapshot - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 - env: TEST_DIR=tests/integration/guzzle/4 From c91957231db591a542498d5b90ee43171fda7568 Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Mon, 2 Dec 2019 12:28:26 +0100 Subject: [PATCH 065/204] Don't force precise --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1d4b0d0d8..4b58b201e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: php -dist: precise matrix: fast_finish: true From b2611edb6bb3b94446cb7eaa0331a0d417cf4c09 Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Mon, 2 Dec 2019 12:28:26 +0100 Subject: [PATCH 066/204] Don't force precise --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4b58b201e..4c5f3b59c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,20 @@ matrix: include: - env: TEST_DIR=. php: 5.3 + os: linux + dist: precise - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" php: 5.3 + os: linux + dist: precise - env: TEST_DIR=. php: 5.4 + os: linux + dist: precise - env: TEST_DIR=. php: 5.5 + os: linux + dist: precise - env: TEST_DIR=. php: 5.6 - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" From 2d3b3f05cd5405a85999fb93d745e89c096e07a0 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 22 May 2020 19:32:42 +0200 Subject: [PATCH 067/204] Use 7.4, not 7.4snapshot --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c5f3b59c..692bb95c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ matrix: - env: TEST_DIR=. php: 7.3 - env: TEST_DIR=. - php: 7.4snapshot + php: 7.4 - env: TEST_DIR=tests/integration/guzzle/3 php: 5.6 - env: TEST_DIR=tests/integration/guzzle/4 From 198dfb29cc0dd17f70adf86c1470722b3b8ea5c6 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Fri, 22 May 2020 19:58:28 +0200 Subject: [PATCH 068/204] Fixed array offset error --- src/VCR/Storage/Yaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index 2fc798834..c4a59591c 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -58,7 +58,7 @@ public function storeRecording(array $recording) public function next() { $recording = $this->yamlParser->parse($this->readNextRecord()); - $this->current = $recording[0]; + $this->current = isset($recording[0]) ? $recording[0] : null; ++$this->position; } From 274227ec52ceaae00387576f4822e499a0967e53 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Wed, 3 Jun 2020 19:27:11 +0200 Subject: [PATCH 069/204] Temporarily ignore deprecation messages for PHP 7.4 --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c2600cb62..eb4c8d403 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@ Date: Thu, 11 Jun 2020 19:52:39 +0200 Subject: [PATCH 070/204] Fixed PHPStan errors --- composer.lock | 10 ++-- phpstan.neon | 18 ++----- src/VCR/Cassette.php | 4 +- src/VCR/CodeTransform/CurlCodeTransform.php | 3 ++ src/VCR/CodeTransform/SoapCodeTransform.php | 6 +++ src/VCR/Configuration.php | 12 ++--- src/VCR/LibraryHooks/CurlHook.php | 15 ++++-- src/VCR/Request.php | 12 +++-- src/VCR/Response.php | 9 ++-- src/VCR/Storage/AbstractStorage.php | 4 +- src/VCR/Storage/Blackhole.php | 11 ++-- src/VCR/Storage/Storage.php | 1 + src/VCR/Util/CurlException.php | 3 ++ src/VCR/Util/CurlHelper.php | 8 +-- src/VCR/Util/HttpClient.php | 1 + src/VCR/Util/SoapClient.php | 4 +- src/VCR/Util/StreamProcessor.php | 57 ++++++++++++++++++++- src/VCR/VCR.php | 8 ++- src/VCR/VCRException.php | 5 -- src/VCR/VCRFactory.php | 15 ++++-- 20 files changed, 143 insertions(+), 63 deletions(-) diff --git a/composer.lock b/composer.lock index b8939ffe8..7c63ef6ac 100644 --- a/composer.lock +++ b/composer.lock @@ -780,16 +780,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.25", + "version": "0.12.28", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64" + "reference": "76c0c4ec90b1eed66fa4855b8b4b53fa9054353f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9619551d68b2d4c0d681a8df73f3c847c798ee64", - "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/76c0c4ec90b1eed66fa4855b8b4b53fa9054353f", + "reference": "76c0c4ec90b1eed66fa4855b8b4b53fa9054353f", "shasum": "" }, "require": { @@ -818,7 +818,7 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-05-10T20:36:16+00:00" + "time": "2020-06-10T06:20:14+00:00" }, { "name": "phpstan/phpstan-beberlei-assert", diff --git a/phpstan.neon b/phpstan.neon index 7c3f2a321..da5bfee1d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,26 +3,18 @@ parameters: paths: - src ignoreErrors: - - "#Call to an undefined static method SoapClient::__construct\\(\\)#" + # This part of PHP is not very well documented, resulting PHPStan's definitions not being accurate - "#Access to an undefined property object::\\$data\\.#" - "#Access to an undefined property object::\\$datalen\\.#" - # Cast to string is necessary to work around a PHP bug. See SoapClient::__doRequest - - "#Casting to string something that's already string\\.#" - - "#Parameter \\#1 \\$function of function call_user_func_array expects callable, array.* given#" - # Working around a PHPStan bug that does not detect a non falsy value in Yaml::readNextRecord - - "#Parameter \\#1 \\$haystack of function strpos expects string, string\\|false given#" - - "#Parameter \\#1 \\$string of function strlen expects string, string\\|false given#" - # PHPStan cannot detect that curl_exec will return a string and not true (because of the CURLOPT_RETURNTRANSFER option. In HttpClient::send - - '#Parameter .* \\$response of static method VCR\\\\Util\\\\HttpUtil::parseResponse\\(\\) expects string, string\\|true given.#' + - + message: '#Unreachable statement - code above always terminates.#' + path: src/VCR/CodeTransform/AbstractCodeTransform.php # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - - '#Parameter .* \\$str of function substr expects string, string\\|false given.#' - # It turns out that curl_init DOES accept null as first parameter, even if it is not documented. - - '#Parameter .* $url of function curl_init expects string, string\\|null given.#' + - '#Parameter .* \$str of function substr expects string, string\|false given.#' # The EventDispatcherInterface::dispatch method does actually expect 2 parameters (see PHPDoc) - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#' # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given./' - - '/Cannot call method isBuiltin\(\) on ReflectionType|null./' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index eab3219c4..600a52170 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -25,7 +25,7 @@ class Cassette /** * Storage used to store records and request pairs. * - * @var Storage + * @var Storage */ protected $storage; @@ -34,7 +34,7 @@ class Cassette * * @param string $name Name of the cassette. * @param Configuration $config Configuration to use for this cassette. - * @param Storage $storage Storage to use for requests and responses. + * @param Storage $storage Storage to use for requests and responses. * @throws \VCR\VCRException If cassette name is in an invalid format. */ public function __construct(string $name, Configuration $config, Storage $storage) diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index 87a7a208e..7e746db6f 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -8,6 +8,9 @@ class CurlCodeTransform extends AbstractCodeTransform { const NAME = 'vcr_curl'; + /** + * @var array + */ private static $patterns = array( '/(?|\w_)\\\?curl_init\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_init(', '/(?|\w_)\\\?curl_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_exec(', diff --git a/src/VCR/CodeTransform/SoapCodeTransform.php b/src/VCR/CodeTransform/SoapCodeTransform.php index a89d96a24..aac68e0d6 100644 --- a/src/VCR/CodeTransform/SoapCodeTransform.php +++ b/src/VCR/CodeTransform/SoapCodeTransform.php @@ -8,11 +8,17 @@ class SoapCodeTransform extends AbstractCodeTransform { const NAME = 'vcr_soap'; + /** + * @var string[] + */ private static $replacements = array( 'new \VCR\Util\SoapClient(', 'extends \VCR\Util\SoapClient', ); + /** + * @var string[] + */ private static $patterns = array( '@new\s+\\\?SoapClient\W*\(@i', '@extends\s+\\\?SoapClient@i', diff --git a/src/VCR/Configuration.php b/src/VCR/Configuration.php index cdea5fffd..0ea5004a0 100644 --- a/src/VCR/Configuration.php +++ b/src/VCR/Configuration.php @@ -25,7 +25,7 @@ class Configuration * A value of null means all hooks are enabled. * * @see \VCR\LibraryHooks\LibraryHook - * @var array|null List of enabled LibraryHook names. + * @var string[]|null List of enabled LibraryHook names. */ private $enabledLibraryHooks; @@ -36,7 +36,7 @@ class Configuration * array( * 'name' => 'class name' * ) - * @var array List of library hooks. + * @var array List of library hooks. */ private $availableLibraryHooks = array( 'stream_wrapper' => 'VCR\LibraryHooks\StreamWrapperHook', @@ -62,7 +62,7 @@ class Configuration * 'name' => 'class name' * ) * - * @var array List of available storages. + * @var array List of available storages. */ private $availableStorages = array( 'blackhole' => 'VCR\Storage\Blackhole', @@ -73,7 +73,7 @@ class Configuration /** * A value of null means all RequestMatchers are enabled. * - * @var array Names of the RequestMatchers which are enabled. + * @var string[] Names of the RequestMatchers which are enabled. */ private $enabledRequestMatchers; @@ -136,7 +136,7 @@ class Configuration * 'name' * ) * - * @var array List of available modes. + * @var string[] List of available modes. */ private $availableModes = array( VCR::MODE_NEW_EPISODES, @@ -332,7 +332,7 @@ public function getWhiteList(): array /** * Sets a list of paths to whitelist when processing in the StreamProcessor. * - * @param string|array $paths Single path or list of path which are whitelisted. + * @param string|string[] $paths Single path or list of path which are whitelisted. * * @return Configuration */ diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 5d63c1175..cf5635cde 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -37,17 +37,17 @@ class CurlHook implements LibraryHook protected static $responses = array(); /** - * @var array Additinal curl options, which are not stored within a request. + * @var array Additinal curl options, which are not stored within a request. */ protected static $curlOptions = array(); /** - * @var array All curl handles which belong to curl_multi handles. + * @var array All curl handles which belong to curl_multi handles. */ protected static $multiHandles = array(); /** - * @var array Last active curl_multi_exec() handles. + * @var array Last active curl_multi_exec() handles. */ protected static $multiExecLastChs = array(); @@ -157,7 +157,12 @@ public static function __callStatic($method, array $args) } $localMethod = TextUtil::underscoreToLowerCamelcase($method); - return \call_user_func_array(array(__CLASS__, $localMethod), $args); + + $callable = array(__CLASS__, $localMethod); + + Assertion::isCallable($callable); + + return \call_user_func_array($callable, $args); } /** @@ -282,7 +287,7 @@ public static function curlMultiExec($multiHandle, ?int &$stillRunning): int * * @link http://www.php.net/manual/en/function.curl-multi-info-read.php * - * @return array|bool On success, returns an associative array for the message, FALSE on failure. + * @return array|bool On success, returns an associative array for the message, FALSE on failure. */ public static function curlMultiInfoRead() { diff --git a/src/VCR/Request.php b/src/VCR/Request.php index e24d0514f..e0c79d5c6 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -31,7 +31,7 @@ class Request */ protected $postFiles = array(); /** - * @var array $post_fields + * @var array */ protected $postFields = array(); /** @@ -221,7 +221,7 @@ public function getHost(): string $host = parse_url($url, PHP_URL_HOST); - if ($host === null) { + if ($host === null || $host === false) { throw InvalidHostException::create($this->getUrl()); } @@ -239,7 +239,9 @@ public function getPath(): ?string { $url = $this->getUrl(); Assertion::string($url); - return parse_url($url, PHP_URL_PATH); + $path = parse_url($url, PHP_URL_PATH); + Assertion::notSame($path, false); + return $path; } /** @@ -249,7 +251,9 @@ public function getQuery(): ?string { $url = $this->getUrl(); Assertion::string($url); - return parse_url($url, PHP_URL_QUERY); + $query = parse_url($url, PHP_URL_QUERY); + Assertion::notSame($query, false); + return $query; } /** diff --git a/src/VCR/Response.php b/src/VCR/Response.php index 84dfc9213..ca58e934a 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -10,7 +10,7 @@ class Response { /** - * @var array + * @var array */ protected $status = array( 'code' => null, @@ -30,10 +30,13 @@ class Response */ protected $curlInfo = array(); + /** + * @var mixed + */ protected $httpVersion; /** - * @param string|array $status + * @param string|array $status * @param array $headers * @param string|null $body * @param array $curlInfo @@ -170,7 +173,7 @@ public function getStatusMessage(): string } /** - * @param string|array $status + * @param string|array $status */ protected function setStatus($status): void { diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index 0a4840823..ca8c688e4 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -23,7 +23,7 @@ abstract class AbstractStorage implements Storage protected $filePath; /** - * @var array|null Current parsed record. + * @var array|null Current parsed record. */ protected $current; @@ -85,7 +85,7 @@ public function __construct(string $cassettePath, string $cassetteName, string $ /** * Returns the current record. * - * @return array|null Parsed current record. + * @return array|null Parsed current record. */ public function current() { diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index b7daf2520..71939a94a 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -22,25 +22,26 @@ public function isNew(): bool return true; } - public function current() + /** @return array */ + public function current(): ?array { throw new \BadMethodCallException('Not implemented'); } - public function key() + public function key(): int { throw new \BadMethodCallException('Not implemented'); } - public function next() + public function next(): void { } - public function rewind() + public function rewind(): void { } - public function valid() + public function valid(): bool { return false; } diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index e9469fef7..ef012f3ff 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -7,6 +7,7 @@ * * A Storage can be iterated using standard loops. * New recordings can be stored. + * @phpstan-extends \Iterator */ interface Storage extends \Iterator { diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php index aab7ca1fc..c8c80127d 100644 --- a/src/VCR/Util/CurlException.php +++ b/src/VCR/Util/CurlException.php @@ -4,6 +4,9 @@ class CurlException extends \Exception { + /** + * @var array + */ private $info; /** diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 09346bd1e..6c39f63bf 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -11,7 +11,7 @@ class CurlHelper { /** - * @var array List of cURL info constants. + * @var array List of cURL info constants. */ private static $curlInfoList = array( //"certinfo"? @@ -187,7 +187,7 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va break; } } - + /** * Makes sure we've properly handled the POST body, such as ensuring that * CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set. @@ -201,13 +201,13 @@ public static function validateCurlPOSTBody(Request $request, $curlHandle = null if (is_null($readFunction)) { return; } - + // Guzzle 4 sometimes sets the post body in CURLOPT_POSTFIELDS even if // they have already set CURLOPT_READFUNCTION. if ($request->getBody()) { return; } - + $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE); Assertion::notEmpty($bodySize, 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $body = call_user_func_array($readFunction, array($curlHandle, fopen('php://memory', 'r'), $bodySize)); diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index f88e11933..449ba3557 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -37,6 +37,7 @@ public function send(Request $request): Response curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_HEADER, true); + /** @var string|false $result */ $result = curl_exec($ch); if ($result === false) { throw CurlException::create($ch); diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index 44c6e644d..d3c4abf53 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -74,7 +74,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 /** * @inheritdoc */ - public function __getLastRequest() + public function __getLastRequest(): ?string { return $this->request; } @@ -82,7 +82,7 @@ public function __getLastRequest() /** * @inheritdoc */ - public function __getLastResponse() + public function __getLastResponse(): ?string { return $this->response; } diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 16bf6ed93..ac8e53a9b 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -2,6 +2,7 @@ namespace VCR\Util; +use Assert\Assertion; use VCR\Configuration; use VCR\CodeTransform\AbstractCodeTransform; @@ -72,7 +73,7 @@ public function __construct(Configuration $configuration = null) public function intercept(): void { if (!$this->isIntercepting) { - ini_set('opcache.enable', 0); + ini_set('opcache.enable', '0'); stream_wrapper_unregister(self::PROTOCOL); $this->isIntercepting = stream_wrapper_register(self::PROTOCOL, __CLASS__); } @@ -185,7 +186,7 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH)); } - if ($options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { + if ($this->resource !== false && $options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { $this->appendFiltersToStream($this->resource); } @@ -203,6 +204,10 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ */ public function stream_close(): bool { + if ($this->resource === false) { + return true; + } + return fclose($this->resource); } @@ -216,6 +221,10 @@ public function stream_close(): bool */ public function stream_eof(): bool { + if ($this->resource === false) { + return false; + } + return feof($this->resource); } @@ -228,6 +237,10 @@ public function stream_eof(): bool */ public function stream_flush(): bool { + if ($this->resource === false) { + return false; + } + return fflush($this->resource); } @@ -242,6 +255,10 @@ public function stream_flush(): bool */ public function stream_read(int $count) { + if ($this->resource === false) { + return false; + } + return fread($this->resource, $count); } @@ -257,6 +274,10 @@ public function stream_read(int $count) */ public function stream_seek(int $offset, int $whence = SEEK_SET): bool { + if ($this->resource === false) { + return false; + } + return fseek($this->resource, $offset, $whence) === 0; } @@ -287,6 +308,10 @@ public function stream_stat() */ public function stream_tell() { + if ($this->resource === false) { + return false; + } + return ftell($this->resource); } @@ -327,6 +352,10 @@ public function url_stat(string $path, int $flags) */ public function dir_closedir(): bool { + if ($this->resource === false) { + return false; + } + closedir($this->resource); return true; @@ -363,6 +392,10 @@ public function dir_opendir(string $path): bool */ public function dir_readdir() { + if ($this->resource === false) { + return false; + } + return readdir($this->resource); } @@ -375,6 +408,10 @@ public function dir_readdir() */ public function dir_rewinddir(): bool { + if ($this->resource === false) { + return false; + } + rewinddir($this->resource); return true; @@ -474,6 +511,10 @@ public function stream_cast(int $cast_as) */ public function stream_lock(int $operation): bool { + if ($this->resource === false) { + return false; + } + $operation = ($operation === 0 ? LOCK_EX : $operation); return flock($this->resource, $operation); } @@ -492,6 +533,10 @@ public function stream_lock(int $operation): bool */ public function stream_set_option(int $option, int $arg1, int $arg2): bool { + if ($this->resource === false) { + return false; + } + switch ($option) { case STREAM_OPTION_BLOCKING: return stream_set_blocking($this->resource, (bool) $arg1); @@ -522,6 +567,10 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool */ public function stream_write(string $data) { + if ($this->resource === false) { + return false; + } + return fwrite($this->resource, $data); } @@ -598,6 +647,10 @@ public function stream_metadata(string $path, int $option, $value): bool */ public function stream_truncate(int $new_size): bool { + if ($this->resource === false) { + return false; + } + return ftruncate($this->resource, $new_size); } diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index 17be2072d..86784390d 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -2,6 +2,8 @@ namespace VCR; +use Assert\Assertion; + /** * Singleton interface to a Videorecorder. * @@ -35,8 +37,10 @@ class VCR */ public static function __callStatic(string $method, array $parameters) { - $instance = VCRFactory::get('VCR\Videorecorder'); + $callable = [VCRFactory::get('VCR\Videorecorder'), $method]; + + Assertion::isCallable($callable); - return call_user_func_array(array($instance, $method), $parameters); + return call_user_func_array($callable, $parameters); } } diff --git a/src/VCR/VCRException.php b/src/VCR/VCRException.php index b9e39e801..98815d741 100644 --- a/src/VCR/VCRException.php +++ b/src/VCR/VCRException.php @@ -8,9 +8,4 @@ class VCRException extends InvalidArgumentException { const LIBRARY_HOOK_DISABLED = 500; const REQUEST_ERROR = 600; - - public function __construct($message, $code, $propertyPath = null, $value = null, array $constraints = array()) - { - parent::__construct($message, $code, $propertyPath, $value, $constraints); - } } diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index 3f1077659..c4d2bcc84 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -6,6 +6,7 @@ use VCR\LibraryHooks\SoapHook; use VCR\Storage\Storage; use VCR\Util\StreamProcessor; +use VCR\Util\Assertion; class VCRFactory { @@ -14,8 +15,14 @@ class VCRFactory **/ protected $config; + /** + * @var array + */ protected $mapping = array(); + /** + * @var self|null + */ protected static $instance; /** @@ -50,6 +57,7 @@ protected function createVCRUtilStreamProcessor(): StreamProcessor return new StreamProcessor($this->config); } + /** @return Storage */ protected function createStorage(string $cassetteName): Storage { $dsn = $this->config->getCassettePath(); @@ -119,9 +127,10 @@ public function getOrCreate(string $className, array $params = array()) return $this->mapping[$key]; } - if (method_exists($this, $this->getMethodName($className))) { - $callback = array($this, $this->getMethodName($className)); - $instance = call_user_func_array($callback, $params); + $callable = [$this, $this->getMethodName($className)]; + + if (is_callable($callable)) { + $instance = call_user_func_array($callable, $params); } else { $instance = new $className; } From f2efbb80d73ade24e7fbb9678ecb46cee9b8d37c Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Sat, 13 Jun 2020 12:21:26 +0100 Subject: [PATCH 071/204] Updated symfony/event-dispatcher to Symfony 5 --- composer.json | 2 +- composer.lock | 555 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 421 insertions(+), 136 deletions(-) diff --git a/composer.json b/composer.json index 5a0451827..78c617d05 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-curl": "*", "beberlei/assert": "^2.0", "symfony/yaml": "~2.1|^3.0|^4.0", - "symfony/event-dispatcher": "^2.4|^3.0|^4.0" + "symfony/event-dispatcher": "^5.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 420d8e560..e5be4697b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cf8a9feafbf279d837e83e3523cd0870", + "content-hash": "32b59fff52fb92cdbda14c1e4efe036d", "packages": [ { "name": "beberlei/assert", - "version": "v2.7.8", + "version": "v2.9.9", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "be6aa40e3f2d2f0766f159409ab9a80c8db6ca23" + "reference": "124317de301b7c91d5fce34c98bba2c6925bec95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/be6aa40e3f2d2f0766f159409ab9a80c8db6ca23", - "reference": "be6aa40e3f2d2f0766f159409ab9a80c8db6ca23", + "url": "https://api.github.com/repos/beberlei/assert/zipball/124317de301b7c91d5fce34c98bba2c6925bec95", + "reference": "124317de301b7c91d5fce34c98bba2c6925bec95", "shasum": "" }, "require": { @@ -26,7 +26,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.1.1", - "phpunit/phpunit": "^4|^5" + "phpunit/phpunit": "^4.8.35|^5.7" }, "type": "library", "autoload": { @@ -59,34 +59,135 @@ "assertion", "validation" ], - "time": "2017-10-20T15:59:40+00:00" + "time": "2019-05-28T15:27:37+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", + "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "time": "2020-05-27T08:34:37+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.0.0", + "version": "v5.1.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "6223fb2b68e7059e8d5843c0103999a84e7275cf" + "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/6223fb2b68e7059e8d5843c0103999a84e7275cf", - "reference": "6223fb2b68e7059e8d5843c0103999a84e7275cf", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/cc0d059e2e997e79ca34125a52f3e33de4424ac7", + "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/event-dispatcher-contracts": "^2", + "symfony/polyfill-php80": "^1.15" }, "conflict": { - "symfony/dependency-injection": "<3.4" + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^4.4|^5.0" }, "suggest": { "symfony/dependency-injection": "", @@ -95,7 +196,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -122,30 +223,209 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-11-09T17:30:28+00:00" + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "405952c4e90941a17e52ef7489a2bd94870bb290" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/405952c4e90941a17e52ef7489a2bd94870bb290", + "reference": "405952c4e90941a17e52ef7489a2bd94870bb290", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2020-05-12T16:14:59+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/5e30b2799bc1ad68f7feb62b60a73743589438dd", + "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-05-12T16:47:27+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.0", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04" + "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/b3d0c9c11be3831b84825967dc6b52b5a7b84e04", - "reference": "b3d0c9c11be3831b84825967dc6b52b5a7b84e04", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", + "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": ">=7.1.3", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -153,7 +433,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -180,38 +460,40 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-11-29T13:28:14+00:00" + "time": "2020-05-20T08:37:50+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1 || ^8.0" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -231,12 +513,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2020-05-29T17:27:14+00:00" }, { "name": "lapistano/proxy-object", @@ -285,24 +567,24 @@ "time": "2015-06-24T09:27:33+00:00" }, { - "name": "mikey179/vfsStream", - "version": "v1.6.5", + "name": "mikey179/vfsstream", + "version": "v1.6.8", "source": { "type": "git", "url": "https://github.com/bovigo/vfsStream.git", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145" + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", - "reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe", + "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "~4.5" + "phpunit/phpunit": "^4.5|^5.0" }, "type": "library", "extra": { @@ -328,29 +610,32 @@ ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2017-08-01T08:02:14+00:00" + "time": "2019-10-30T15:31:00+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.7.0", + "version": "1.9.5", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", + "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { @@ -373,39 +658,34 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2020-01-17T21:11:47+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", "shasum": "" }, "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -427,38 +707,42 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2020-04-27T09:25:28+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.1.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2" + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2", - "reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.4.0", - "webmozart/assert": "^1.0" + "ext-filter": "^7.1", + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0", + "phpdocumentor/type-resolver": "^1.0", + "webmozart/assert": "^1" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "^1", + "mockery/mockery": "^1" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -469,44 +753,46 @@ { "name": "Mike van Riel", "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-30T18:51:59+00:00" + "time": "2020-02-22T12:28:44+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", + "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.2", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.2", + "mockery/mockery": "~1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -519,42 +805,43 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2020-02-18T18:59:58+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.2", + "version": "v1.10.3", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6" + "reference": "451c3cd1418cf640de218914901e51b064abb093" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", - "reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", + "reference": "451c3cd1418cf640de218914901e51b064abb093", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpspec/phpspec": "^2.5 || ^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.10.x-dev" } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -582,7 +869,7 @@ "spy", "stub" ], - "time": "2017-09-04T11:05:03+00:00" + "time": "2020-03-05T15:02:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -649,16 +936,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -692,7 +979,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -786,16 +1073,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0", - "reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { @@ -831,20 +1118,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-08-20T05:47:52+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.23", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/78532d5269d984660080d8e0f4c99c5c2ea65ffe", - "reference": "78532d5269d984660080d8e0f4c99c5c2ea65ffe", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -868,8 +1155,8 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" @@ -913,7 +1200,7 @@ "testing", "xunit" ], - "time": "2017-10-15T06:13:55+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1490,31 +1777,29 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "vimeo/psalm": "<3.9.1" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -1536,7 +1821,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2020-04-18T12:12:48+00:00" } ], "aliases": [], From 3f1b652df4d2f7009a6563d95ad0bcbde097601a Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Sat, 13 Jun 2020 12:21:37 +0100 Subject: [PATCH 072/204] Fixed broken references --- src/VCR/Event/AfterHttpRequestEvent.php | 2 +- src/VCR/Event/AfterPlaybackEvent.php | 2 +- src/VCR/Event/BeforeHttpRequestEvent.php | 2 +- src/VCR/Event/BeforePlaybackEvent.php | 2 +- src/VCR/Event/BeforeRecordEvent.php | 2 +- src/VCR/Videorecorder.php | 18 +++++++++--------- tests/VCR/VCRTest.php | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/VCR/Event/AfterHttpRequestEvent.php b/src/VCR/Event/AfterHttpRequestEvent.php index de810594b..f4e60bf40 100644 --- a/src/VCR/Event/AfterHttpRequestEvent.php +++ b/src/VCR/Event/AfterHttpRequestEvent.php @@ -4,7 +4,7 @@ use VCR\Request; use VCR\Response; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; class AfterHttpRequestEvent extends Event { diff --git a/src/VCR/Event/AfterPlaybackEvent.php b/src/VCR/Event/AfterPlaybackEvent.php index c15b456c8..acd0afae2 100644 --- a/src/VCR/Event/AfterPlaybackEvent.php +++ b/src/VCR/Event/AfterPlaybackEvent.php @@ -5,7 +5,7 @@ use VCR\Cassette; use VCR\Request; use VCR\Response; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; class AfterPlaybackEvent extends Event { diff --git a/src/VCR/Event/BeforeHttpRequestEvent.php b/src/VCR/Event/BeforeHttpRequestEvent.php index 0bf1211d6..40fed0491 100644 --- a/src/VCR/Event/BeforeHttpRequestEvent.php +++ b/src/VCR/Event/BeforeHttpRequestEvent.php @@ -3,7 +3,7 @@ namespace VCR\Event; use VCR\Request; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; class BeforeHttpRequestEvent extends Event { diff --git a/src/VCR/Event/BeforePlaybackEvent.php b/src/VCR/Event/BeforePlaybackEvent.php index 2c9dd5512..5668977dc 100644 --- a/src/VCR/Event/BeforePlaybackEvent.php +++ b/src/VCR/Event/BeforePlaybackEvent.php @@ -4,7 +4,7 @@ use VCR\Cassette; use VCR\Request; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; class BeforePlaybackEvent extends Event { diff --git a/src/VCR/Event/BeforeRecordEvent.php b/src/VCR/Event/BeforeRecordEvent.php index 5751c0454..71c4244e1 100644 --- a/src/VCR/Event/BeforeRecordEvent.php +++ b/src/VCR/Event/BeforeRecordEvent.php @@ -5,7 +5,7 @@ use VCR\Cassette; use VCR\Request; use VCR\Response; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; class BeforeRecordEvent extends Event { diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 7e0b3f2d7..99a62d63c 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -11,7 +11,7 @@ use VCR\Event\BeforeRecordEvent; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * A videorecorder records requests on a cassette. @@ -95,13 +95,13 @@ public function getEventDispatcher() /** * Dispatches an event to all registered listeners. * - * @param string $eventName The name of the event to dispatch. * @param Event $event The event to pass to the event handlers/listeners. + * @param string $eventName The name of the event to dispatch. * @return Event */ - private function dispatch($eventName, Event $event = null) + private function dispatch(Event $event, $eventName = null) { - return $this->getEventDispatcher()->dispatch($eventName, $event); + return $this->getEventDispatcher()->dispatch($event, $eventName); } /** @@ -218,14 +218,14 @@ public function handleRequest(Request $request) } $event = new BeforePlaybackEvent($request, $this->cassette); - $this->dispatch(VCREvents::VCR_BEFORE_PLAYBACK, $event); + $this->dispatch($event, VCREvents::VCR_BEFORE_PLAYBACK); $response = $this->cassette->playback($request); // Playback succeeded and the recorded response can be returned. if (!empty($response)) { $event = new AfterPlaybackEvent($request, $response, $this->cassette); - $this->dispatch(VCREvents::VCR_AFTER_PLAYBACK, $event); + $this->dispatch($event, VCREvents::VCR_AFTER_PLAYBACK); return $response; } @@ -248,11 +248,11 @@ public function handleRequest(Request $request) $this->disableLibraryHooks(); - $this->dispatch(VCREvents::VCR_BEFORE_HTTP_REQUEST, new BeforeHttpRequestEvent($request)); + $this->dispatch(new BeforeHttpRequestEvent($request), VCREvents::VCR_BEFORE_HTTP_REQUEST); $response = $this->client->send($request); - $this->dispatch(VCREvents::VCR_AFTER_HTTP_REQUEST, new AfterHttpRequestEvent($request, $response)); + $this->dispatch(new AfterHttpRequestEvent($request, $response), VCREvents::VCR_AFTER_HTTP_REQUEST); - $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); + $this->dispatch(new BeforeRecordEvent($request, $response, $this->cassette), VCREvents::VCR_BEFORE_RECORD); $this->cassette->record($request, $response); $this->enableLibraryHooks(); diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 9d63c35a7..848f536fe 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -2,7 +2,7 @@ namespace VCR; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; use org\bovigo\vfs\vfsStream; /** From ec342190a0bb77d66762ddb9fcfef22a63e8a745 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 15 Jun 2020 19:12:18 +0100 Subject: [PATCH 073/204] Removed header folding --- src/VCR/Util/HttpUtil.php | 21 +++++++-------------- tests/VCR/Util/HttpUtilTest.php | 18 +++++++++--------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index c1e8d613d..6ac0f1ce4 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -14,24 +14,17 @@ class HttpUtil */ public static function parseHeaders(array $headers) { - $headerGroups = array(); - $headerList = array(); - // Collect matching headers into groups - foreach ($headers as $line) { + foreach ($headers as $i => $line) { list($key, $value) = explode(': ', $line, 2); - if (!isset($headerGroups[$key])) { - $headerGroups[$key] = array(); + if (!isset($headers[$key])) { + $headers[$key] = array(); } - $headerGroups[$key][] = $value; + $headers[$key][] = $value; + unset($headers[$i]); } - // Collapse groups - foreach ($headerGroups as $key => $values) { - $headerList[$key] = implode(', ', $values); - } - - return $headerList; + return $headers; } /** @@ -66,7 +59,7 @@ public static function parseStatus($status) public static function parseResponse($response) { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); - + list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2); // Parse headers and status. diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index debb2c70e..b29c64aa3 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -101,10 +101,10 @@ public function testParseHeadersBasic() 'Content-Length: 0' ); $excpetedHeaders = array( - 'Content-Type' => 'text/html', - 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', - 'Vary' => 'Accept-Encoding', - 'Content-Length' => '0' + 'Content-Type' => array('text/html'), + 'Date' => array('Fri, 19 Jun 2015 16:05:18 GMT'), + 'Vary' => array('Accept-Encoding'), + 'Content-Length' => array('0') ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); @@ -120,10 +120,10 @@ public function testParseHeadersMultiple() 'Content-Length: 0' ); $excpetedHeaders = array( - 'Content-Type' => 'text/html', - 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', - 'Vary' => 'Accept, Accept-Language, Expect, Accept-Encoding', - 'Content-Length' => '0' + 'Content-Type' => array('text/html'), + 'Date' => array('Fri, 19 Jun 2015 16:05:18 GMT'), + 'Vary' => array('Accept, Accept-Language, Expect', 'Accept-Encoding'), + 'Content-Length' => array('0') ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); @@ -135,7 +135,7 @@ public function testParseHeadersIncludingColons() 'dropbox-api-result: {"name": "a_file.txt"}' ); $excpetedHeaders = array( - 'dropbox-api-result' => '{"name": "a_file.txt"}' + 'dropbox-api-result' => array('{"name": "a_file.txt"}') ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); From fc077aca974f9d42d9ddf0ef824885f56358a78a Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 15 Jun 2020 19:51:17 +0100 Subject: [PATCH 074/204] Refactor header parsing logic --- src/VCR/Util/HttpUtil.php | 11 ++++++++--- tests/VCR/Util/HttpUtilTest.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 6ac0f1ce4..2fe8cd276 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -17,10 +17,15 @@ public static function parseHeaders(array $headers) // Collect matching headers into groups foreach ($headers as $i => $line) { list($key, $value) = explode(': ', $line, 2); - if (!isset($headers[$key])) { - $headers[$key] = array(); + if (isset($headers[$key])) { + if (!is_array($headers[$key])) { + $headers[$key] = array($headers[$key], $value); + } else { + $headers[$key][] = $value; + } + } else { + $headers[$key] = $value; } - $headers[$key][] = $value; unset($headers[$i]); } diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index b29c64aa3..973873c68 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -101,10 +101,10 @@ public function testParseHeadersBasic() 'Content-Length: 0' ); $excpetedHeaders = array( - 'Content-Type' => array('text/html'), - 'Date' => array('Fri, 19 Jun 2015 16:05:18 GMT'), - 'Vary' => array('Accept-Encoding'), - 'Content-Length' => array('0') + 'Content-Type' => 'text/html', + 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', + 'Vary' => 'Accept-Encoding', + 'Content-Length' => '0' ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); @@ -120,10 +120,10 @@ public function testParseHeadersMultiple() 'Content-Length: 0' ); $excpetedHeaders = array( - 'Content-Type' => array('text/html'), - 'Date' => array('Fri, 19 Jun 2015 16:05:18 GMT'), + 'Content-Type' => 'text/html', + 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', 'Vary' => array('Accept, Accept-Language, Expect', 'Accept-Encoding'), - 'Content-Length' => array('0') + 'Content-Length' => '0' ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); @@ -135,7 +135,7 @@ public function testParseHeadersIncludingColons() 'dropbox-api-result: {"name": "a_file.txt"}' ); $excpetedHeaders = array( - 'dropbox-api-result' => array('{"name": "a_file.txt"}') + 'dropbox-api-result' => '{"name": "a_file.txt"}' ); $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); From 35b72934685cdad90c05b2258d4e5ba226cffca8 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 15 Jun 2020 19:51:34 +0100 Subject: [PATCH 075/204] Added null check to request header accessor --- src/VCR/Request.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 6e85064ba..d54e0f957 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -171,6 +171,10 @@ public function getHeaders() */ public function getHeader($key) { + if (!isset($this->headers[$key])) { + return null; + } + return $this->headers[$key]; } From 4fa43b8057c5dd6ba2e713b013f2998e4f59dc2f Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 15 Jun 2020 20:17:49 +0100 Subject: [PATCH 076/204] Header formatting --- src/VCR/Util/HttpUtil.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 2fe8cd276..54c1eb4ef 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -95,8 +95,13 @@ public static function formatHeadersForCurl(array $headers) { $curlHeaders = array(); - foreach ($headers as $key => $value) { - $curlHeaders[] = $key . ': ' . $value; + foreach ($headers as $key => $values) { + if (is_array($values)) { + foreach ($values as $value) { + $curlHeaders[] = $key . ': ' . $value; + } + } + $curlHeaders[] = $key . ': ' . $values; } return $curlHeaders; From 437ec4a81859bc6d7d6de0c681702b0858bb435e Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Tue, 16 Jun 2020 13:07:42 +0100 Subject: [PATCH 077/204] Header formatting --- src/VCR/Util/HttpUtil.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 54c1eb4ef..a2385fb35 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -100,8 +100,9 @@ public static function formatHeadersForCurl(array $headers) foreach ($values as $value) { $curlHeaders[] = $key . ': ' . $value; } + } else { + $curlHeaders[] = $key.': '.$values; } - $curlHeaders[] = $key . ': ' . $values; } return $curlHeaders; From 6572f29bb185dccd34cbc735e75db3d69e0070f4 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Tue, 16 Jun 2020 13:11:42 +0100 Subject: [PATCH 078/204] Refactor header parsing logic --- src/VCR/Util/HttpUtil.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index a2385fb35..2a8bbb387 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -18,10 +18,10 @@ public static function parseHeaders(array $headers) foreach ($headers as $i => $line) { list($key, $value) = explode(': ', $line, 2); if (isset($headers[$key])) { - if (!is_array($headers[$key])) { - $headers[$key] = array($headers[$key], $value); - } else { + if (is_array($headers[$key])) { $headers[$key][] = $value; + } else { + $headers[$key] = array($headers[$key], $value); } } else { $headers[$key] = $value; From 3d88f89ae2f915471043ebe61ff964937bc246d6 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 22 Jun 2020 16:10:57 +0100 Subject: [PATCH 079/204] Symfony LTS backwards compatibility --- composer.json | 2 +- src/VCR/Event/AfterHttpRequestEvent.php | 1 - src/VCR/Event/AfterPlaybackEvent.php | 1 - src/VCR/Event/BeforeHttpRequestEvent.php | 1 - src/VCR/Event/BeforePlaybackEvent.php | 1 - src/VCR/Event/BeforeRecordEvent.php | 1 - src/VCR/Event/Event.php | 15 +++++++++++++++ src/VCR/Videorecorder.php | 6 +++++- 8 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/VCR/Event/Event.php diff --git a/composer.json b/composer.json index 78c617d05..3daf4b1be 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "ext-curl": "*", "beberlei/assert": "^2.0", "symfony/yaml": "~2.1|^3.0|^4.0", - "symfony/event-dispatcher": "^5.0" + "symfony/event-dispatcher": "^2.4|^3.0|^4.0|^5.0" }, "require-dev": { diff --git a/src/VCR/Event/AfterHttpRequestEvent.php b/src/VCR/Event/AfterHttpRequestEvent.php index f4e60bf40..0440d3e61 100644 --- a/src/VCR/Event/AfterHttpRequestEvent.php +++ b/src/VCR/Event/AfterHttpRequestEvent.php @@ -4,7 +4,6 @@ use VCR\Request; use VCR\Response; -use Symfony\Contracts\EventDispatcher\Event; class AfterHttpRequestEvent extends Event { diff --git a/src/VCR/Event/AfterPlaybackEvent.php b/src/VCR/Event/AfterPlaybackEvent.php index acd0afae2..283d2b6fd 100644 --- a/src/VCR/Event/AfterPlaybackEvent.php +++ b/src/VCR/Event/AfterPlaybackEvent.php @@ -5,7 +5,6 @@ use VCR\Cassette; use VCR\Request; use VCR\Response; -use Symfony\Contracts\EventDispatcher\Event; class AfterPlaybackEvent extends Event { diff --git a/src/VCR/Event/BeforeHttpRequestEvent.php b/src/VCR/Event/BeforeHttpRequestEvent.php index 40fed0491..423fbd085 100644 --- a/src/VCR/Event/BeforeHttpRequestEvent.php +++ b/src/VCR/Event/BeforeHttpRequestEvent.php @@ -3,7 +3,6 @@ namespace VCR\Event; use VCR\Request; -use Symfony\Contracts\EventDispatcher\Event; class BeforeHttpRequestEvent extends Event { diff --git a/src/VCR/Event/BeforePlaybackEvent.php b/src/VCR/Event/BeforePlaybackEvent.php index 5668977dc..e9523fd47 100644 --- a/src/VCR/Event/BeforePlaybackEvent.php +++ b/src/VCR/Event/BeforePlaybackEvent.php @@ -4,7 +4,6 @@ use VCR\Cassette; use VCR\Request; -use Symfony\Contracts\EventDispatcher\Event; class BeforePlaybackEvent extends Event { diff --git a/src/VCR/Event/BeforeRecordEvent.php b/src/VCR/Event/BeforeRecordEvent.php index 71c4244e1..e916f8f11 100644 --- a/src/VCR/Event/BeforeRecordEvent.php +++ b/src/VCR/Event/BeforeRecordEvent.php @@ -5,7 +5,6 @@ use VCR\Cassette; use VCR\Request; use VCR\Response; -use Symfony\Contracts\EventDispatcher\Event; class BeforeRecordEvent extends Event { diff --git a/src/VCR/Event/Event.php b/src/VCR/Event/Event.php new file mode 100644 index 000000000..05a9f19d5 --- /dev/null +++ b/src/VCR/Event/Event.php @@ -0,0 +1,15 @@ +getEventDispatcher()->dispatch($eventName, $event); + } + return $this->getEventDispatcher()->dispatch($event, $eventName); } From 414badc77340fe2642a541f25377b2189ef06b52 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 22 Jun 2020 16:14:11 +0100 Subject: [PATCH 080/204] Dispatcher style fix --- src/VCR/Videorecorder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 544da9a20..4931bcaa3 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -99,7 +99,7 @@ public function getEventDispatcher() * @param string $eventName The name of the event to dispatch. * @return Event */ - private function dispatch(Event $event, $eventName = null) + private function dispatch(Event $event, $eventName = null): Event { if (class_exists(\Symfony\Component\EventDispatcher\Event::class)) { return $this->getEventDispatcher()->dispatch($eventName, $event); From 31de7baecc75bfe89d09c3e9aef0fdbd77b11ec7 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 22 Jun 2020 16:18:07 +0100 Subject: [PATCH 081/204] Fixed broken references --- tests/VCR/VCRTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 848f536fe..a6317f591 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -2,7 +2,7 @@ namespace VCR; -use Symfony\Contracts\EventDispatcher\Event; +use VCR\Event\Event; use org\bovigo\vfs\vfsStream; /** From 25f3b19d69078f45b81580d361228263c4f34479 Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Mon, 22 Jun 2020 16:20:25 +0100 Subject: [PATCH 082/204] Style fix --- src/VCR/Util/HttpUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 2a8bbb387..e823690cd 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -101,7 +101,7 @@ public static function formatHeadersForCurl(array $headers) $curlHeaders[] = $key . ': ' . $value; } } else { - $curlHeaders[] = $key.': '.$values; + $curlHeaders[] = $key . ': ' . $values; } } From 50850605268358e451daf9be613789dbad1f4928 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Wed, 24 Jun 2020 18:52:21 +0200 Subject: [PATCH 083/204] Merge branch 'master' of github.com:php-vcr/php-vcr into 1.5 --- src/VCR/Request.php | 8 +++++-- src/VCR/Util/HttpUtil.php | 38 ++++++++++++++++++--------------- tests/VCR/Util/HttpUtilTest.php | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/VCR/Request.php b/src/VCR/Request.php index e0c79d5c6..850ca96a3 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -171,10 +171,14 @@ public function getHeaders(): array /** * @param string $key - * @return string + * @return string|null */ - public function getHeader(string $key): string + public function getHeader(string $key): ?string { + if (!isset($this->headers[$key])) { + return null; + } + return $this->headers[$key]; } diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 5296fea4a..ff8cbce3a 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -14,24 +14,22 @@ class HttpUtil */ public static function parseHeaders(array $headers): array { - $headerGroups = array(); - $headerList = array(); - // Collect matching headers into groups - foreach ($headers as $line) { + foreach ($headers as $i => $line) { list($key, $value) = explode(': ', $line, 2); - if (!isset($headerGroups[$key])) { - $headerGroups[$key] = array(); + if (isset($headers[$key])) { + if (is_array($headers[$key])) { + $headers[$key][] = $value; + } else { + $headers[$key] = array($headers[$key], $value); + } + } else { + $headers[$key] = $value; } - $headerGroups[$key][] = $value; - } - - // Collapse groups - foreach ($headerGroups as $key => $values) { - $headerList[$key] = implode(', ', $values); + unset($headers[$i]); } - return $headerList; + return $headers; } /** @@ -66,7 +64,7 @@ public static function parseStatus(string $status): array public static function parseResponse(string $response): array { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); - + list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2); // Parse headers and status. @@ -90,15 +88,21 @@ public static function parseRawHeader(string $rawHeader): array /** * Returns a list of headers from a key/value paired array. * - * @param array $headers Headers as key/value pairs. + * @param array> $headers Headers as key/value pairs. * @return string[] List of headers ['Content-Type: text/html', '...']. */ public static function formatHeadersForCurl(array $headers): array { $curlHeaders = array(); - foreach ($headers as $key => $value) { - $curlHeaders[] = $key . ': ' . $value; + foreach ($headers as $key => $values) { + if (is_array($values)) { + foreach ($values as $value) { + $curlHeaders[] = $key . ': ' . $value; + } + } else { + $curlHeaders[] = $key . ': ' . $values; + } } return $curlHeaders; diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index 52efc1b9c..d83b7cafb 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -124,7 +124,7 @@ public function testParseHeadersMultiple() $excpetedHeaders = array( 'Content-Type' => 'text/html', 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', - 'Vary' => 'Accept, Accept-Language, Expect, Accept-Encoding', + 'Vary' => array('Accept, Accept-Language, Expect', 'Accept-Encoding'), 'Content-Length' => '0' ); $outputArray = HttpUtil::parseHeaders($inputArray); From 5e7cea813007d7e5ca440710a8dd06cbf59455ff Mon Sep 17 00:00:00 2001 From: Paul Adams Date: Wed, 24 Jun 2020 23:56:00 +0100 Subject: [PATCH 084/204] Bump package versions --- composer.lock | 71 +++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/composer.lock b/composer.lock index 71ad3f290..46d8888e2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fa16e89688f7c2612246ffca0e24d653", + "content-hash": "9cd7f2f701cd0632c2fcb86b368b9211", "packages": [ { "name": "beberlei/assert", @@ -66,7 +66,7 @@ "assertion", "validation" ], - "time": "2019-05-28T15:27:37+00:00" + "time": "2019-12-19T17:51:41+00:00" }, { "name": "psr/event-dispatcher", @@ -162,7 +162,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.1.1", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -187,10 +187,6 @@ "psr/event-dispatcher-implementation": "1.0", "symfony/event-dispatcher-implementation": "2.0" }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "1.1" - }, "require-dev": { "psr/log": "~1.0", "symfony/config": "^4.4|^5.0", @@ -296,16 +292,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", "shasum": "" }, "require": { @@ -318,6 +314,10 @@ "extra": { "branch-alias": { "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -350,20 +350,20 @@ "polyfill", "portable" ], - "time": "2020-05-12T16:14:59+00:00" + "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.17.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd" + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/5e30b2799bc1ad68f7feb62b60a73743589438dd", - "reference": "5e30b2799bc1ad68f7feb62b60a73743589438dd", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", "shasum": "" }, "require": { @@ -373,6 +373,10 @@ "extra": { "branch-alias": { "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -412,7 +416,7 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/yaml", @@ -831,16 +835,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" + "reference": "30441f2752e493c639526b215ed81d54f369d693" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30441f2752e493c639526b215ed81d54f369d693", + "reference": "30441f2752e493c639526b215ed81d54f369d693", "shasum": "" }, "require": { @@ -854,7 +858,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -873,7 +877,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-02-18T18:59:58+00:00" + "time": "2020-06-19T20:22:09+00:00" }, { "name": "phpspec/prophecy", @@ -940,16 +944,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.28", + "version": "0.12.31", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "76c0c4ec90b1eed66fa4855b8b4b53fa9054353f" + "reference": "776c8056b401e1b67f277b9e9fb334d1a274671d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/76c0c4ec90b1eed66fa4855b8b4b53fa9054353f", - "reference": "76c0c4ec90b1eed66fa4855b8b4b53fa9054353f", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/776c8056b401e1b67f277b9e9fb334d1a274671d", + "reference": "776c8056b401e1b67f277b9e9fb334d1a274671d", "shasum": "" }, "require": { @@ -978,7 +982,7 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-06-10T06:20:14+00:00" + "time": "2020-06-24T20:55:29+00:00" }, { "name": "phpstan/phpstan-beberlei-assert", @@ -2028,16 +2032,16 @@ }, { "name": "webmozart/assert", - "version": "1.8.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" + "reference": "9dc4f203e36f2b486149058bade43c851dd97451" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", + "reference": "9dc4f203e36f2b486149058bade43c851dd97451", "shasum": "" }, "require": { @@ -2045,6 +2049,7 @@ "symfony/polyfill-ctype": "^1.8" }, "conflict": { + "phpstan/phpstan": "<0.12.20", "vimeo/psalm": "<3.9.1" }, "require-dev": { @@ -2072,7 +2077,7 @@ "check", "validate" ], - "time": "2020-04-18T12:12:48+00:00" + "time": "2020-06-16T10:16:42+00:00" } ], "aliases": [], From 4a16e1e047bcdf684a7bba58a1531120f533d8a1 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Thu, 25 Jun 2020 10:06:52 +0200 Subject: [PATCH 085/204] Fixed the uncareful merge of PR311 --- phpstan.neon | 5 ++--- src/VCR/Event/Event.php | 17 +++++++++++------ src/VCR/Videorecorder.php | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index da5bfee1d..9c89ab256 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,10 +11,9 @@ parameters: path: src/VCR/CodeTransform/AbstractCodeTransform.php # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - '#Parameter .* \$str of function substr expects string, string\|false given.#' - # The EventDispatcherInterface::dispatch method does actually expect 2 parameters (see PHPDoc) - - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required.#' # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given./' + - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string\|null given./' + - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/src/VCR/Event/Event.php b/src/VCR/Event/Event.php index 05a9f19d5..dda40c61f 100644 --- a/src/VCR/Event/Event.php +++ b/src/VCR/Event/Event.php @@ -2,14 +2,19 @@ namespace VCR\Event; -if (class_exists(\Symfony\Component\EventDispatcher\Event::class)) { - class Event extends \Symfony\Component\EventDispatcher\Event +use Symfony\Component\EventDispatcher\Event as LegacyEvent; +use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; + +if (class_exists(ContractsEvent::class) && !class_exists(LegacyEvent::class)) { + abstract class SymphonyEvent extends ContractsEvent { - // } -} else { - class Event extends \Symfony\Contracts\EventDispatcher\Event +} elseif (class_exists(LegacyEvent::class)) { + abstract class SymphonyEvent extends LegacyEvent { - // } } + +abstract class Event extends SymphonyEvent +{ +} diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 6f4909b90..950178846 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -102,10 +102,18 @@ public function getEventDispatcher(): EventDispatcherInterface private function dispatch(Event $event, $eventName = null): Event { if (class_exists(\Symfony\Component\EventDispatcher\Event::class)) { - return $this->getEventDispatcher()->dispatch($eventName, $event); + $res = $this->getEventDispatcher()->dispatch($eventName, $event); + + Assertion::isInstanceOf($res, Event::class); + + return $res; } - - return $this->getEventDispatcher()->dispatch($event, $eventName); + + $res = $this->getEventDispatcher()->dispatch($event, $eventName); + + Assertion::isInstanceOf($res, Event::class); + + return $res; } /** @@ -251,7 +259,7 @@ public function handleRequest(Request $request): Response } $this->disableLibraryHooks(); - + try { $this->dispatch(new BeforeHttpRequestEvent($request), VCREvents::VCR_BEFORE_HTTP_REQUEST); $response = $this->client->send($request); From 99f88a68d3d5b5e028a628525e8ab8653140ffa8 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Thu, 11 Jun 2020 20:20:50 +0200 Subject: [PATCH 086/204] Configure php-cs-fixer as dev dependency --- .travis.yml | 4 +- composer.json | 7 +- composer.lock | 1686 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 1652 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee96bebca..87ec4fcdf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,8 @@ install: script: - $PHPUNIT_BIN --coverage-clover=coverage.clover - - if [ "${PHP_CS_FIXER}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php ./php-cs-fixer-v2.phar fix --dry-run --diff $TRAVIS_BUILD_DIR; fi - - if [ "${PHPSTAN}" = "true" ]; then composer require --dev phpstan/phpstan ^0.12 && composer phpstan; fi + - if [ "${PHP_CS_FIXER}" = "true" ]; then vendor/bin/php-cs-fixer fix --dry-run --diff $TRAVIS_BUILD_DIR; fi + - if [ "${PHPSTAN}" = "true" ]; then composer phpstan; fi after_success: - wget https://scrutinizer-ci.com/ocular.phar diff --git a/composer.json b/composer.json index e46ddd52b..359e6d7bb 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,8 @@ "scripts": { "test": "./vendor/bin/phpunit", - "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run --config-file=.php_cs", - "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff --config-file=.php_cs", + "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", + "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", "phpstan": "phpstan analyse -c phpstan.neon --no-progress -vvv" }, @@ -31,7 +31,8 @@ "phpstan/phpstan": "^0.12", "phpstan/phpstan-beberlei-assert": "^0.12.0", "thecodingmachine/phpstan-strict-rules": "^0.12", - "sebastian/version": "^1.0.3|^2.0" + "sebastian/version": "^1.0.3|^2.0", + "friendsofphp/php-cs-fixer": "^2.16" }, "autoload": { diff --git a/composer.lock b/composer.lock index 46d8888e2..eb657f550 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9cd7f2f701cd0632c2fcb86b368b9211", + "content-hash": "876c2afaafe6cbcf696cb15681264caf", "packages": [ { "name": "beberlei/assert", @@ -479,6 +479,194 @@ } ], "packages-dev": [ + { + "name": "composer/semver", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2020-01-13T12:06:48+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-06-04T11:16:35+00:00" + }, + { + "name": "doctrine/annotations", + "version": "1.10.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5db60a4969eba0e0c197a19c077780aadbc43c5d", + "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "ext-tokenizer": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2020-05-25T17:24:27+00:00" + }, { "name": "doctrine/instantiator", "version": "1.3.1", @@ -535,6 +723,179 @@ ], "time": "2020-05-29T17:27:14+00:00" }, + { + "name": "doctrine/lexer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042", + "reference": "e864bbf5904cb8f5bb334f99209b48018522f042", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan": "^0.11.8", + "phpunit/phpunit": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", + "keywords": [ + "annotations", + "docblock", + "lexer", + "parser", + "php" + ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], + "time": "2020-05-25T17:44:05+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.16.4", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/1023c3458137ab052f6ff1e09621a721bfdeca13", + "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", + "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", + "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", + "symfony/finder": "^3.0 || ^4.0 || ^5.0", + "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0 || ^5.0", + "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.2", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^5.1", + "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/Test/IsIdenticalConstraint.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2020-06-27T23:57:46+00:00" + }, { "name": "mikey179/vfsstream", "version": "v1.6.8", @@ -583,20 +944,20 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -627,7 +988,58 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-06-29T13:22:24+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" }, { "name": "phar-io/manifest", @@ -732,41 +1144,92 @@ "time": "2018-07-08T19:19:57+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "name": "php-cs-fixer/diff", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^5.6 || ^7.0" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" }, + "type": "library", "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" } ], "description": "Common reflection classes used by phpdocumentor to reflect the code structure", @@ -778,7 +1241,7 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", @@ -835,25 +1298,24 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "30441f2752e493c639526b215ed81d54f369d693" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30441f2752e493c639526b215ed81d54f369d693", - "reference": "30441f2752e493c639526b215ed81d54f369d693", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "ext-tokenizer": "*" }, "type": "library", "extra": { @@ -877,7 +1339,7 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-06-19T20:22:09+00:00" + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", @@ -944,16 +1406,16 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.31", + "version": "0.12.32", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "776c8056b401e1b67f277b9e9fb334d1a274671d" + "reference": "d03863f504c8432b3de4d1881f73f6acb8c0e67c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/776c8056b401e1b67f277b9e9fb334d1a274671d", - "reference": "776c8056b401e1b67f277b9e9fb334d1a274671d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d03863f504c8432b3de4d1881f73f6acb8c0e67c", + "reference": "d03863f504c8432b3de4d1881f73f6acb8c0e67c", "shasum": "" }, "require": { @@ -982,7 +1444,21 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-06-24T20:55:29+00:00" + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2020-07-01T11:57:52+00:00" }, { "name": "phpstan/phpstan-beberlei-assert", @@ -1373,6 +1849,102 @@ ], "time": "2020-01-08T08:45:45+00:00" }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1939,6 +2511,1039 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "symfony/console", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "34ac555a3627e324b660e318daa07572e1140123" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/34ac555a3627e324b660e318daa07572e1140123", + "reference": "34ac555a3627e324b660e318daa07572e1140123", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2", + "symfony/string": "^5.1" + }, + "conflict": { + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-15T12:59:21+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "6e4320f06d5f2cce0d96530162491f4465179157" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/6e4320f06d5f2cce0d96530162491f4465179157", + "reference": "6e4320f06d5f2cce0d96530162491f4465179157", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-30T20:35:19+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/4298870062bfc667cb78d2b379be4bf5dec5f187", + "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187", + "shasum": "" + }, + "require": { + "php": ">=7.2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "663f5dd5e14057d1954fe721f9709d35837f2447" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/663f5dd5e14057d1954fe721f9709d35837f2447", + "reference": "663f5dd5e14057d1954fe721f9709d35837f2447", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-23T13:08:13+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/6e4dbcf5e81eba86e36731f94fe56b1726835846", + "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/40309d1700e8f72447bb9e7b54af756eeea35620", + "reference": "40309d1700e8f72447bb9e7b54af756eeea35620", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-14T14:40:37+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "f048e612a3905f34931127360bdd2def19a5e582" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", + "reference": "f048e612a3905f34931127360bdd2def19a5e582", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-12T16:47:27+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/process", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", + "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-30T20:35:19+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0f7c58cf81dbb5dd67d423a89d577524a2ec0323", + "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/service-contracts": "^1.0|^2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-20T17:43:50+00:00" + }, + { + "name": "symfony/string", + "version": "v5.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/ac70459db781108db7c6d8981dd31ce0e29e3298", + "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "files": [ + "Resources/functions.php" + ], + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony String component", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-11T12:16:36+00:00" + }, { "name": "thecodingmachine/phpstan-strict-rules", "version": "v0.12.0", @@ -2089,5 +3694,6 @@ "php": ">=7.2", "ext-curl": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } From bbf48f3e8bb7bf90b4c8b17ff86c25ebc0d15b1a Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 20 Jun 2020 20:21:45 +0200 Subject: [PATCH 087/204] Updated php-cs-fixer config --- .php_cs.dist | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 871b5ac9a..06819239d 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -3,18 +3,14 @@ return PhpCsFixer\Config::create() ->setRules([ '@PSR2' => true, - 'single_blank_line_before_namespace' => true, - 'concat_space' => ['spacing' => 'one'], - 'single_quote' => true, - 'braces' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + '@PHPUnit60Migration:risky' => true ]) - ->setFinder( PhpCsFixer\Finder::create() ->exclude('vendor') ->exclude('docs') ->in(__DIR__) ) - ->setRiskyAllowed(true); - From a4809a27f028b0539f714143802cf0eb959787ca Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Wed, 1 Jul 2020 16:52:56 +0200 Subject: [PATCH 088/204] Changes by php-cs-fixer --- src/VCR/Cassette.php | 42 ++- .../CodeTransform/AbstractCodeTransform.php | 15 +- src/VCR/CodeTransform/CurlCodeTransform.php | 29 +- src/VCR/CodeTransform/SoapCodeTransform.php | 11 +- src/VCR/Configuration.php | 154 +++++----- src/VCR/Event/AfterHttpRequestEvent.php | 10 - src/VCR/Event/AfterPlaybackEvent.php | 14 - src/VCR/Event/BeforeHttpRequestEvent.php | 6 - src/VCR/Event/BeforePlaybackEvent.php | 10 - src/VCR/Event/BeforeRecordEvent.php | 14 - src/VCR/LibraryHooks/CurlHook.php | 184 ++++++------ src/VCR/LibraryHooks/LibraryHook.php | 14 +- src/VCR/LibraryHooks/SoapHook.php | 36 +-- src/VCR/LibraryHooks/StreamWrapperHook.php | 107 +++---- src/VCR/Request.php | 112 +++---- src/VCR/RequestMatcher.php | 48 +-- src/VCR/Response.php | 59 ++-- src/VCR/Storage/AbstractStorage.php | 34 +-- src/VCR/Storage/Blackhole.php | 4 +- src/VCR/Storage/Json.php | 24 +- src/VCR/Storage/Storage.php | 6 +- src/VCR/Storage/Yaml.php | 32 +- src/VCR/Util/Assertion.php | 11 +- src/VCR/Util/CurlException.php | 4 +- src/VCR/Util/CurlHelper.php | 68 ++--- src/VCR/Util/HttpClient.php | 8 +- src/VCR/Util/HttpUtil.php | 48 +-- src/VCR/Util/SoapClient.php | 47 +-- src/VCR/Util/StreamHelper.php | 22 +- src/VCR/Util/StreamProcessor.php | 275 ++++++++---------- src/VCR/Util/TextUtil.php | 4 +- src/VCR/VCR.php | 4 +- src/VCR/VCRFactory.php | 41 +-- src/VCR/Videorecorder.php | 93 ++---- tests/VCR/CassetteTest.php | 9 +- .../AbstractCodeTransformTest.php | 8 +- .../CodeTransform/CurlCodeTransformTest.php | 81 +++--- .../CodeTransform/SoapCodeTransformTest.php | 19 +- tests/VCR/ConfigurationTest.php | 49 ++-- tests/VCR/Event/AfterPlaybackEventTest.php | 4 +- tests/VCR/Event/BeforePlaybackEventTest.php | 2 +- tests/VCR/Event/BeforeRecordEventTest.php | 4 +- tests/VCR/LibraryHooks/CurlHookTest.php | 36 +-- tests/VCR/LibraryHooks/SoapHookTest.php | 46 ++- .../LibraryHooks/StreamWrapperHookTest.php | 3 +- tests/VCR/RequestMatcherTest.php | 90 +++--- tests/VCR/RequestTest.php | 174 +++++------ tests/VCR/ResponseTest.php | 70 ++--- tests/VCR/Storage/AbstractStorageTest.php | 2 +- tests/VCR/Storage/BlackholeTest.php | 12 +- tests/VCR/Storage/JsonTest.php | 60 ++-- tests/VCR/Storage/YamlTest.php | 86 +++--- tests/VCR/Util/CurlHelperTest.php | 217 +++++++------- tests/VCR/Util/HttpClientTest.php | 1 - tests/VCR/Util/HttpUtilTest.php | 79 +++-- tests/VCR/Util/SoapClientTest.php | 19 +- tests/VCR/Util/StreamHelperTest.php | 75 ++--- tests/VCR/Util/StreamProcessorTest.php | 49 ++-- tests/VCR/Util/TextUtilTest.php | 10 +- tests/VCR/VCRFactoryTest.php | 34 +-- tests/VCR/VCRTest.php | 44 +-- tests/VCR/VideorecorderTest.php | 51 ++-- tests/bootstrap.php | 10 +- tests/integration/apache/test/OpcacheTest.php | 11 +- .../integration/apache/www/performRequest.php | 1 + .../apache/www/performRequestWithPhpVcr.php | 2 +- .../guzzle/3/ExampleHttpClient.php | 8 +- .../guzzle/4/ExampleHttpClient.php | 10 +- .../guzzle/5/ExampleHttpClient.php | 10 +- .../guzzle/6/ExampleHttpClient.php | 10 +- tests/integration/guzzle/6/test/ErrorTest.php | 2 - .../VCR/Example/ExampleHttpClientTest.php | 4 +- tests/integration/guzzle/test/bootstrap.php | 11 +- .../src/VCR/Example/ExampleSoapClient.php | 10 +- .../VCR/Example/ExampleSoapClientTest.php | 5 +- tests/integration/soap/test/bootstrap.php | 3 +- 76 files changed, 1419 insertions(+), 1602 deletions(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 600a52170..8992de89b 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -10,7 +10,8 @@ class Cassette { /** - * Casette name + * Casette name. + * * @var string */ protected $name; @@ -32,10 +33,11 @@ class Cassette /** * Creates a new cassette. * - * @param string $name Name of the cassette. - * @param Configuration $config Configuration to use for this cassette. - * @param Storage $storage Storage to use for requests and responses. - * @throws \VCR\VCRException If cassette name is in an invalid format. + * @param string $name name of the cassette + * @param Configuration $config configuration to use for this cassette + * @param Storage $storage storage to use for requests and responses + * + * @throws \VCR\VCRException if cassette name is in an invalid format */ public function __construct(string $name, Configuration $config, Storage $storage) { @@ -47,21 +49,21 @@ public function __construct(string $name, Configuration $config, Storage $storag /** * Returns true if a response was recorded for specified request. * - * @param Request $request Request to check if it was recorded. + * @param Request $request request to check if it was recorded * - * @return boolean True if a response was recorded for specified request. + * @return bool true if a response was recorded for specified request */ public function hasResponse(Request $request): bool { - return $this->playback($request) !== null; + return null !== $this->playback($request); } /** * Returns a response for given request or null if not found. * - * @param Request $request Request. + * @param Request $request request * - * @return Response|null Response for specified request. + * @return Response|null response for specified request */ public function playback(Request $request): ?Response { @@ -78,10 +80,8 @@ public function playback(Request $request): ?Response /** * Records a request and response pair. * - * @param Request $request Request to record. - * @param Response $response Response to record. - * - * @return void + * @param Request $request request to record + * @param Response $response response to record */ public function record(Request $request, Response $response): void { @@ -89,10 +89,10 @@ public function record(Request $request, Response $response): void return; } - $recording = array( - 'request' => $request->toArray(), - 'response' => $response->toArray() - ); + $recording = [ + 'request' => $request->toArray(), + 'response' => $response->toArray(), + ]; $this->storage->storeRecording($recording); } @@ -100,7 +100,7 @@ public function record(Request $request, Response $response): void /** * Returns the name of the current cassette. * - * @return string Current cassette name. + * @return string current cassette name */ public function getName(): string { @@ -109,8 +109,6 @@ public function getName(): string /** * Returns true if the cassette was created recently. - * - * @return boolean */ public function isNew(): bool { @@ -120,7 +118,7 @@ public function isNew(): bool /** * Returns a list of callbacks to configured request matchers. * - * @return callable[] List of callbacks to configured request matchers. + * @return callable[] list of callbacks to configured request matchers */ protected function getRequestMatchers(): array { diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index e430271c8..5f7532421 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -2,14 +2,11 @@ namespace VCR\CodeTransform; -use function in_array; use function stream_get_filters; use VCR\Util\Assertion; /** * A stream wrapper filter to transform code. - * - * @package VCR\CodeTransform */ abstract class AbstractCodeTransform extends \php_user_filter { @@ -20,9 +17,9 @@ abstract class AbstractCodeTransform extends \php_user_filter */ public function register(): void { - if (!in_array(static::NAME, stream_get_filters(), true)) { - $isRegistered = stream_filter_register(static::NAME, get_called_class()); - Assertion::true($isRegistered, sprintf('Failed registering stream filter "%s" on stream "%s"', get_called_class(), static::NAME)); + if (!\in_array(static::NAME, stream_get_filters(), true)) { + $isRegistered = stream_filter_register(static::NAME, static::class); + Assertion::true($isRegistered, sprintf('Failed registering stream filter "%s" on stream "%s"', static::class, static::NAME)); } } @@ -36,7 +33,7 @@ public function register(): void * * @return int PSFS_PASS_ON * - * @link http://www.php.net/manual/en/php-user-filter.filter.php + * @see http://www.php.net/manual/en/php-user-filter.filter.php */ public function filter($in, $out, &$consumed, $closing) { @@ -51,10 +48,6 @@ public function filter($in, $out, &$consumed, $closing) /** * Transcodes the provided data to whatever. - * - * @param string $code - * - * @return string */ abstract protected function transformCode(string $code): string; } diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index 7e746db6f..6f441b027 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -11,28 +11,29 @@ class CurlCodeTransform extends AbstractCodeTransform /** * @var array */ - private static $patterns = array( - '/(?|\w_)\\\?curl_init\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_init(', - '/(?|\w_)\\\?curl_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_exec(', - '/(?|\w_)\\\?curl_getinfo\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_getinfo(', - '/(?|\w_)\\\?curl_setopt\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_setopt(', - '/(?|\w_)\\\?curl_setopt_array\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_setopt_array(', - '/(?|\w_)\\\?curl_multi_add_handle\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', + private static $patterns = [ + '/(?|\w_)\\\?curl_init\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_init(', + '/(?|\w_)\\\?curl_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_exec(', + '/(?|\w_)\\\?curl_getinfo\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_getinfo(', + '/(?|\w_)\\\?curl_setopt\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_setopt(', + '/(?|\w_)\\\?curl_setopt_array\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_setopt_array(', + '/(?|\w_)\\\?curl_multi_add_handle\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', '/(?|\w_)\\\?curl_multi_remove_handle\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', - '/(?|\w_)\\\?curl_multi_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_exec(', - '/(?|\w_)\\\?curl_multi_info_read\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', - '/(?|\w_)\\\?curl_reset\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_reset(', - '/(?|\w_)\\\?curl_error\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_error(', - '/(?|\w_)\\\?curl_errno\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_errno(' - ); + '/(?|\w_)\\\?curl_multi_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_exec(', + '/(?|\w_)\\\?curl_multi_info_read\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', + '/(?|\w_)\\\?curl_reset\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_reset(', + '/(?|\w_)\\\?curl_error\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_error(', + '/(?|\w_)\\\?curl_errno\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_errno(', + ]; /** - * @inheritdoc + * {@inheritdoc} */ protected function transformCode(string $code): string { $transformedCode = preg_replace(array_keys(self::$patterns), array_values(self::$patterns), $code); Assertion::string($transformedCode); + return $transformedCode; } } diff --git a/src/VCR/CodeTransform/SoapCodeTransform.php b/src/VCR/CodeTransform/SoapCodeTransform.php index aac68e0d6..d196b972b 100644 --- a/src/VCR/CodeTransform/SoapCodeTransform.php +++ b/src/VCR/CodeTransform/SoapCodeTransform.php @@ -11,26 +11,27 @@ class SoapCodeTransform extends AbstractCodeTransform /** * @var string[] */ - private static $replacements = array( + private static $replacements = [ 'new \VCR\Util\SoapClient(', 'extends \VCR\Util\SoapClient', - ); + ]; /** * @var string[] */ - private static $patterns = array( + private static $patterns = [ '@new\s+\\\?SoapClient\W*\(@i', '@extends\s+\\\?SoapClient@i', - ); + ]; /** - * @inheritdoc + * {@inheritdoc} */ protected function transformCode(string $code): string { $transformedCode = preg_replace(self::$patterns, self::$replacements, $code); Assertion::string($transformedCode); + return $transformedCode; } } diff --git a/src/VCR/Configuration.php b/src/VCR/Configuration.php index 0ea5004a0..838c7037e 100644 --- a/src/VCR/Configuration.php +++ b/src/VCR/Configuration.php @@ -15,7 +15,7 @@ class Configuration { /** - * @var string Path where cassette files should be stored. + * @var string path where cassette files should be stored */ private $cassettePath = 'tests/fixtures'; @@ -25,7 +25,8 @@ class Configuration * A value of null means all hooks are enabled. * * @see \VCR\LibraryHooks\LibraryHook - * @var string[]|null List of enabled LibraryHook names. + * + * @var string[]|null list of enabled LibraryHook names */ private $enabledLibraryHooks; @@ -36,13 +37,14 @@ class Configuration * array( * 'name' => 'class name' * ) - * @var array List of library hooks. + * + * @var array List of library hooks */ - private $availableLibraryHooks = array( + private $availableLibraryHooks = [ 'stream_wrapper' => 'VCR\LibraryHooks\StreamWrapperHook', - 'curl' => 'VCR\LibraryHooks\CurlHook', - 'soap' => 'VCR\LibraryHooks\SoapHook', - ); + 'curl' => 'VCR\LibraryHooks\CurlHook', + 'soap' => 'VCR\LibraryHooks\SoapHook', + ]; /** * Name of the enabled storage. @@ -50,7 +52,7 @@ class Configuration * Only one storage can be enabled at a time. * By default YAML is enabled. * - * @var string Enabled storage name. + * @var string enabled storage name */ private $enabledStorage = 'yaml'; @@ -62,18 +64,18 @@ class Configuration * 'name' => 'class name' * ) * - * @var array List of available storages. + * @var array List of available storages */ - private $availableStorages = array( + private $availableStorages = [ 'blackhole' => 'VCR\Storage\Blackhole', - 'json' => 'VCR\Storage\Json', - 'yaml' => 'VCR\Storage\Yaml', - ); + 'json' => 'VCR\Storage\Json', + 'yaml' => 'VCR\Storage\Yaml', + ]; /** * A value of null means all RequestMatchers are enabled. * - * @var string[] Names of the RequestMatchers which are enabled. + * @var string[] names of the RequestMatchers which are enabled */ private $enabledRequestMatchers; @@ -81,23 +83,23 @@ class Configuration * Format: * array( * 'name' => callback - * ) + * ). * * The RequestMatcher callback takes two Request objects and * returns true if they match or false otherwise. * - * @var array List of RequestMatcher names and callbacks. + * @var array List of RequestMatcher names and callbacks */ - private $availableRequestMatchers = array( - 'method' => array(RequestMatcher::class, 'matchMethod'), - 'url' => array(RequestMatcher::class, 'matchUrl'), - 'host' => array(RequestMatcher::class, 'matchHost'), - 'headers' => array(RequestMatcher::class, 'matchHeaders'), - 'body' => array(RequestMatcher::class, 'matchBody'), - 'post_fields' => array(RequestMatcher::class, 'matchPostFields'), - 'query_string' => array(RequestMatcher::class, 'matchQueryString'), - 'soap_operation' => array(RequestMatcher::class, 'matchSoapOperation'), - ); + private $availableRequestMatchers = [ + 'method' => [RequestMatcher::class, 'matchMethod'], + 'url' => [RequestMatcher::class, 'matchUrl'], + 'host' => [RequestMatcher::class, 'matchHost'], + 'headers' => [RequestMatcher::class, 'matchHeaders'], + 'body' => [RequestMatcher::class, 'matchBody'], + 'post_fields' => [RequestMatcher::class, 'matchPostFields'], + 'query_string' => [RequestMatcher::class, 'matchQueryString'], + 'soap_operation' => [RequestMatcher::class, 'matchSoapOperation'], + ]; /** * A whitelist is a list of paths. @@ -107,9 +109,9 @@ class Configuration * all files (which are not blacklisted) are being considered for * code transformation. * - * @var string[] A whitelist is a list of paths. + * @var string[] a whitelist is a list of paths */ - private $whiteList = array(); + private $whiteList = []; /** * A blacklist is a list of paths which may not be processed for code transformation. @@ -117,9 +119,9 @@ class Configuration * Files in this path are left as is. Blacklisting PHP-VCRs own paths is necessary * to avoid infinite loops. * - * @var string[] A blacklist is a list of paths. + * @var string[] a blacklist is a list of paths */ - private $blackList = array('src/VCR/LibraryHooks/', 'src/VCR/Util/SoapClient', 'tests/VCR/Filter'); + private $blackList = ['src/VCR/LibraryHooks/', 'src/VCR/Util/SoapClient', 'tests/VCR/Filter']; /** * The mode which determines how requests are handled. One of the MODE constants. @@ -136,13 +138,13 @@ class Configuration * 'name' * ) * - * @var string[] List of available modes. + * @var string[] list of available modes */ - private $availableModes = array( + private $availableModes = [ VCR::MODE_NEW_EPISODES, VCR::MODE_ONCE, VCR::MODE_NONE, - ); + ]; /** * Returns the current blacklist. @@ -157,13 +159,13 @@ public function getBlackList(): array /** * Sets one or more paths to blacklist. * - * @param string|string[] $paths Path(s) to blacklist. + * @param string|string[] $paths path(s) to blacklist * * @return Configuration */ public function setBlackList($paths): self { - $paths = (is_array($paths)) ? $paths : array($paths); + $paths = (\is_array($paths)) ? $paths : [$paths]; $this->blackList = $paths; @@ -173,7 +175,7 @@ public function setBlackList($paths): self /** * Returns the path to where cassettes are stored. * - * @return string Path to where cassettes are stored. + * @return string path to where cassettes are stored */ public function getCassettePath(): string { @@ -185,10 +187,11 @@ public function getCassettePath(): string /** * Sets the cassette path where a cassettes should be stored in. * - * @param string $cassettePath Path where to store cassettes. + * @param string $cassettePath path where to store cassettes * * @return Configuration - * @throws VCRException If provided cassette path is invalid. + * + * @throws VCRException if provided cassette path is invalid */ public function setCassettePath(string $cassettePath): self { @@ -204,11 +207,11 @@ public function setCassettePath(string $cassettePath): self * Only class names are returned, any object creation happens * in the VCRFactory. * - * @return string[] List of LibraryHook class names. + * @return string[] list of LibraryHook class names */ public function getLibraryHooks(): array { - if ($this->enabledLibraryHooks === null) { + if (null === $this->enabledLibraryHooks) { return array_values($this->availableLibraryHooks); } @@ -221,16 +224,18 @@ public function getLibraryHooks(): array /** * Enables specified LibraryHook(s) by its name. * - * @param string|string[] $hooks Name of the LibraryHook(s) to enable. + * @param string|string[] $hooks name of the LibraryHook(s) to enable + * * @return Configuration - * @throws \InvalidArgumentException If a specified library hook doesn't exist. + * + * @throws \InvalidArgumentException if a specified library hook doesn't exist */ public function enableLibraryHooks($hooks): self { - $hooks = is_array($hooks) ? $hooks : array($hooks); + $hooks = \is_array($hooks) ? $hooks : [$hooks]; $invalidHooks = array_diff($hooks, array_keys($this->availableLibraryHooks)); if ($invalidHooks) { - throw new \InvalidArgumentException("Library hooks don't exist: " . join(', ', $invalidHooks)); + throw new \InvalidArgumentException("Library hooks don't exist: ".implode(', ', $invalidHooks)); } $this->enabledLibraryHooks = $hooks; @@ -242,7 +247,7 @@ public function enableLibraryHooks($hooks): self * * Objects are created in the VCRFactory. * - * @return string Class name of the storage to use. + * @return string class name of the storage to use */ public function getStorage(): string { @@ -252,11 +257,11 @@ public function getStorage(): string /** * Returns a list of enabled RequestMatcher callbacks. * - * @return callable[] List of enabled RequestMatcher callbacks. + * @return callable[] list of enabled RequestMatcher callbacks */ public function getRequestMatchers(): array { - if ($this->enabledRequestMatchers === null) { + if (null === $this->enabledRequestMatchers) { return array_values($this->availableRequestMatchers); } @@ -269,11 +274,12 @@ public function getRequestMatchers(): array /** * Adds a new RequestMatcher callback. * - * @param string $name Name of the RequestMatcher. - * @param callable $callback A callback taking two Request objects as parameters and returns true if those match. + * @param string $name name of the RequestMatcher + * @param callable $callback a callback taking two Request objects as parameters and returns true if those match * * @return Configuration - * @throws VCRException If specified parameters are invalid. + * + * @throws VCRException if specified parameters are invalid */ public function addRequestMatcher(string $name, callable $callback): self { @@ -286,30 +292,29 @@ public function addRequestMatcher(string $name, callable $callback): self /** * Enables specified RequestMatchers by its name. * - * @param string[] $matchers List of RequestMatcher names to enable. + * @param string[] $matchers list of RequestMatcher names to enable * * @return Configuration * - * @throws \InvalidArgumentException If a specified request matcher does not exist. + * @throws \InvalidArgumentException if a specified request matcher does not exist */ public function enableRequestMatchers(array $matchers): self { $invalidMatchers = array_diff($matchers, array_keys($this->availableRequestMatchers)); if ($invalidMatchers) { - throw new \InvalidArgumentException("Request matchers don't exist: " . join(', ', $invalidMatchers)); + throw new \InvalidArgumentException("Request matchers don't exist: ".implode(', ', $invalidMatchers)); } $this->enabledRequestMatchers = $matchers; - + return $this; } /** * Enables a storage by name. * - * @param string $storageName Name of the storage to enable. + * @param string $storageName name of the storage to enable * - * @return self - * @throws VCRException If a invalid storage name is given. + * @throws VCRException if a invalid storage name is given */ public function setStorage(string $storageName): self { @@ -320,10 +325,10 @@ public function setStorage(string $storageName): self } /** - * Returns a list of whitelisted paths. - * - * @return string[] - */ + * Returns a list of whitelisted paths. + * + * @return string[] + */ public function getWhiteList(): array { return $this->whiteList; @@ -332,13 +337,11 @@ public function getWhiteList(): array /** * Sets a list of paths to whitelist when processing in the StreamProcessor. * - * @param string|string[] $paths Single path or list of path which are whitelisted. - * - * @return Configuration + * @param string|string[] $paths single path or list of path which are whitelisted */ - public function setWhiteList($paths): Configuration + public function setWhiteList($paths): self { - $paths = (is_array($paths)) ? $paths : array($paths); + $paths = (\is_array($paths)) ? $paths : [$paths]; $this->whiteList = $paths; @@ -346,10 +349,8 @@ public function setWhiteList($paths): Configuration } /** - * Returns the current mode. - * - * @return string - */ + * Returns the current mode. + */ public function getMode(): string { return $this->mode; @@ -359,10 +360,8 @@ public function getMode(): string * Sets the current mode. * * @param string $mode The mode to set VCR to - * - * @return Configuration */ - public function setMode(string $mode): Configuration + public function setMode(string $mode): self { Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist."); $this->mode = $mode; @@ -373,16 +372,17 @@ public function setMode(string $mode): Configuration /** * Validates a specified cassette path. * - * @param string $cassettePath Path to a cassette. - * @throws VCRException If cassette path is invalid. + * @param string $cassettePath path to a cassette + * + * @throws VCRException if cassette path is invalid */ private function assertValidCassettePath(string $cassettePath): void { Assertion::directory( $cassettePath, "Cassette path '{$cassettePath}' is not a directory. Please either " - . 'create it or set a different cassette path using ' - . "\\VCR\\VCR::configure()->setCassettePath('directory')." + .'create it or set a different cassette path using ' + ."\\VCR\\VCR::configure()->setCassettePath('directory')." ); } } diff --git a/src/VCR/Event/AfterHttpRequestEvent.php b/src/VCR/Event/AfterHttpRequestEvent.php index 37191f037..4f0f39abf 100644 --- a/src/VCR/Event/AfterHttpRequestEvent.php +++ b/src/VCR/Event/AfterHttpRequestEvent.php @@ -17,27 +17,17 @@ class AfterHttpRequestEvent extends Event */ protected $response; - /** - * @param Request $request - * @param Response $response - */ public function __construct(Request $request, Response $response) { $this->request = $request; $this->response = $response; } - /** - * @return Request - */ public function getRequest(): Request { return $this->request; } - /** - * @return Response - */ public function getResponse(): Response { return $this->response; diff --git a/src/VCR/Event/AfterPlaybackEvent.php b/src/VCR/Event/AfterPlaybackEvent.php index 2324ec58c..56a4f4589 100644 --- a/src/VCR/Event/AfterPlaybackEvent.php +++ b/src/VCR/Event/AfterPlaybackEvent.php @@ -23,11 +23,6 @@ class AfterPlaybackEvent extends Event */ protected $cassette; - /** - * @param Request $request - * @param Response $response - * @param Cassette $cassette - */ public function __construct(Request $request, Response $response, Cassette $cassette) { $this->request = $request; @@ -35,25 +30,16 @@ public function __construct(Request $request, Response $response, Cassette $cass $this->cassette = $cassette; } - /** - * @return Request - */ public function getRequest(): Request { return $this->request; } - /** - * @return Response - */ public function getResponse(): Response { return $this->response; } - /** - * @return Cassette - */ public function getCassette(): Cassette { return $this->cassette; diff --git a/src/VCR/Event/BeforeHttpRequestEvent.php b/src/VCR/Event/BeforeHttpRequestEvent.php index 529cc8f56..585f8bb1a 100644 --- a/src/VCR/Event/BeforeHttpRequestEvent.php +++ b/src/VCR/Event/BeforeHttpRequestEvent.php @@ -11,17 +11,11 @@ class BeforeHttpRequestEvent extends Event */ protected $request; - /** - * @param Request $request - */ public function __construct(Request $request) { $this->request = $request; } - /** - * @return Request - */ public function getRequest(): Request { return $this->request; diff --git a/src/VCR/Event/BeforePlaybackEvent.php b/src/VCR/Event/BeforePlaybackEvent.php index 3a51f8f31..2e9e009dc 100644 --- a/src/VCR/Event/BeforePlaybackEvent.php +++ b/src/VCR/Event/BeforePlaybackEvent.php @@ -16,27 +16,17 @@ class BeforePlaybackEvent extends Event */ protected $cassette; - /** - * @param Request $request - * @param Cassette $cassette - */ public function __construct(Request $request, Cassette $cassette) { $this->request = $request; $this->cassette = $cassette; } - /** - * @return Request - */ public function getRequest(): Request { return $this->request; } - /** - * @return Cassette - */ public function getCassette(): Cassette { return $this->cassette; diff --git a/src/VCR/Event/BeforeRecordEvent.php b/src/VCR/Event/BeforeRecordEvent.php index 3d95b616a..447c657d2 100644 --- a/src/VCR/Event/BeforeRecordEvent.php +++ b/src/VCR/Event/BeforeRecordEvent.php @@ -23,11 +23,6 @@ class BeforeRecordEvent extends Event */ protected $cassette; - /** - * @param Request $request - * @param Response $response - * @param Cassette $cassette - */ public function __construct(Request $request, Response $response, Cassette $cassette) { $this->request = $request; @@ -35,25 +30,16 @@ public function __construct(Request $request, Response $response, Cassette $cass $this->cassette = $cassette; } - /** - * @return Request - */ public function getRequest(): Request { return $this->request; } - /** - * @return Response - */ public function getResponse(): Response { return $this->response; } - /** - * @return Cassette - */ public function getCassette(): Cassette { return $this->cassette; diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index cf5635cde..dca394aa3 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -2,10 +2,10 @@ namespace VCR\LibraryHooks; -use VCR\Util\Assertion; +use VCR\CodeTransform\AbstractCodeTransform; use VCR\Request; use VCR\Response; -use VCR\CodeTransform\AbstractCodeTransform; +use VCR\Util\Assertion; use VCR\Util\CurlException; use VCR\Util\CurlHelper; use VCR\Util\StreamProcessor; @@ -17,44 +17,44 @@ class CurlHook implements LibraryHook { /** - * @var \Closure|null Callback which will be executed when a request is intercepted. + * @var \Closure|null callback which will be executed when a request is intercepted */ protected static $requestCallback; /** - * @var string Current status of this hook, either enabled or disabled. + * @var string current status of this hook, either enabled or disabled */ protected static $status = self::DISABLED; /** - * @var Request[] All requests which have been intercepted. + * @var Request[] all requests which have been intercepted */ - protected static $requests = array(); + protected static $requests = []; /** - * @var Response[] All responses which have been intercepted. + * @var Response[] all responses which have been intercepted */ - protected static $responses = array(); + protected static $responses = []; /** - * @var array Additinal curl options, which are not stored within a request. + * @var array additinal curl options, which are not stored within a request */ - protected static $curlOptions = array(); + protected static $curlOptions = []; /** - * @var array All curl handles which belong to curl_multi handles. + * @var array all curl handles which belong to curl_multi handles */ - protected static $multiHandles = array(); + protected static $multiHandles = []; /** - * @var array Last active curl_multi_exec() handles. + * @var array last active curl_multi_exec() handles */ - protected static $multiExecLastChs = array(); + protected static $multiExecLastChs = []; /** - * @var CurlException[] Last cURL error, as a CurlException. + * @var CurlException[] last cURL error, as a CurlException */ - protected static $lastErrors = array(); + protected static $lastErrors = []; /** * @var AbstractCodeTransform @@ -69,18 +69,13 @@ class CurlHook implements LibraryHook /** * Creates a new cURL hook instance. * - * @param AbstractCodeTransform $codeTransformer - * @param StreamProcessor $processor - * - * @throws \BadMethodCallException in case the cURL extension is not installed. + * @throws \BadMethodCallException in case the cURL extension is not installed */ public function __construct(AbstractCodeTransform $codeTransformer, StreamProcessor $processor) { - if (!function_exists('curl_version')) { + if (!\function_exists('curl_version')) { // @codeCoverageIgnoreStart - throw new \BadMethodCallException( - 'cURL extension not installed, please disable the cURL library hook' - ); + throw new \BadMethodCallException('cURL extension not installed, please disable the cURL library hook'); // @codeCoverageIgnoreEnd } $this->processor = $processor; @@ -88,13 +83,13 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces } /** - * @inheritDoc + * {@inheritdoc} */ public function enable(\Closure $requestCallback): void { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); - if (static::$status == self::ENABLED) { + if (self::ENABLED == static::$status) { return; } @@ -108,11 +103,11 @@ public function enable(\Closure $requestCallback): void } /** - * @inheritDoc + * {@inheritdoc} */ public function disable(): void { - if (static::$status == self::DISABLED) { + if (self::DISABLED == static::$status) { return; } @@ -122,35 +117,35 @@ public function disable(): void } /** - * @inheritDoc + * {@inheritdoc} */ public function isEnabled(): bool { - return self::$status == self::ENABLED; + return self::ENABLED == self::$status; } /** * Calls the intercepted curl method if library hook is disabled, otherwise the real one. * - * @param callable&string $method cURL method to call, example: curl_info() - * @param array $args cURL arguments for this function. + * @param callable&string $method cURL method to call, example: curl_info() + * @param array $args cURL arguments for this function * - * @return mixed cURL function return type. + * @return mixed cURL function return type */ public static function __callStatic($method, array $args) { // Call original when disabled - if (static::$status == self::DISABLED) { - if ($method === 'curl_multi_exec') { + if (self::DISABLED == static::$status) { + if ('curl_multi_exec' === $method) { // curl_multi_exec expects to be called with args by reference // which call_user_func_array doesn't do. - return \curl_multi_exec($args[0], $args[1]); + return curl_multi_exec($args[0], $args[1]); } return \call_user_func_array($method, $args); } - if ($method === 'curl_multi_exec') { + if ('curl_multi_exec' === $method) { // curl_multi_exec expects to be called with args by reference // which call_user_func_array doesn't do. return self::curlMultiExec($args[0], $args[1]); @@ -158,27 +153,28 @@ public static function __callStatic($method, array $args) $localMethod = TextUtil::underscoreToLowerCamelcase($method); - $callable = array(__CLASS__, $localMethod); + $callable = [__CLASS__, $localMethod]; Assertion::isCallable($callable); - + return \call_user_func_array($callable, $args); } /** * Initialize a cURL session. * - * @link http://www.php.net/manual/en/function.curl-init.php - * @param string|null $url (Optional) url. + * @see http://www.php.net/manual/en/function.curl-init.php + * + * @param string|null $url (Optional) url * - * @return resource|false cURL handle. + * @return resource|false cURL handle */ public static function curlInit(?string $url = null) { - $curlHandle = \curl_init($url); - if ($curlHandle !== false) { + $curlHandle = curl_init($url); + if (false !== $curlHandle) { self::$requests[(int) $curlHandle] = new Request('GET', $url); - self::$curlOptions[(int) $curlHandle] = array(); + self::$curlOptions[(int) $curlHandle] = []; } return $curlHandle; @@ -187,26 +183,28 @@ public static function curlInit(?string $url = null) /** * Reset a cURL session. * - * @link http://www.php.net/manual/en/function.curl-reset.php - * @param resource $curlHandle A cURL handle returned by curl_init(). + * @see http://www.php.net/manual/en/function.curl-reset.php + * + * @param resource $curlHandle a cURL handle returned by curl_init() */ public static function curlReset($curlHandle): void { - \curl_reset($curlHandle); + curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); - self::$curlOptions[(int) $curlHandle] = array(); + self::$curlOptions[(int) $curlHandle] = []; unset(self::$responses[(int) $curlHandle]); } /** * Perform a cURL session. * - * @link http://www.php.net/manual/en/function.curl-exec.php - * @param resource $curlHandle A cURL handle returned by curl_init(). + * @see http://www.php.net/manual/en/function.curl-exec.php + * + * @param resource $curlHandle a cURL handle returned by curl_init() * * @return mixed Returns TRUE on success or FALSE on failure. - * However, if the CURLOPT_RETURNTRANSFER option is set, it will return the - * result on success, FALSE on failure. + * However, if the CURLOPT_RETURNTRANSFER option is set, it will return the + * result on success, FALSE on failure. */ public static function curlExec($curlHandle) { @@ -225,6 +223,7 @@ public static function curlExec($curlHandle) ); } catch (CurlException $e) { self::$lastErrors[(int) $curlHandle] = $e; + return false; } } @@ -232,14 +231,15 @@ public static function curlExec($curlHandle) /** * Add a normal cURL handle to a cURL multi handle. * - * @link http://www.php.net/manual/en/function.curl-multi-add-handle.php - * @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). - * @param resource $curlHandle A cURL handle returned by curl_init(). + * @see http://www.php.net/manual/en/function.curl-multi-add-handle.php + * + * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() + * @param resource $curlHandle a cURL handle returned by curl_init() */ public static function curlMultiAddHandle($multiHandle, $curlHandle): void { if (!isset(self::$multiHandles[(int) $multiHandle])) { - self::$multiHandles[(int) $multiHandle] = array(); + self::$multiHandles[(int) $multiHandle] = []; } self::$multiHandles[(int) $multiHandle][(int) $curlHandle] = $curlHandle; @@ -248,9 +248,10 @@ public static function curlMultiAddHandle($multiHandle, $curlHandle): void /** * Remove a multi handle from a set of cURL handles. * - * @link http://www.php.net/manual/en/function.curl-multi-remove-handle.php - * @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). - * @param resource $curlHandle A cURL handle returned by curl_init(). + * @see http://www.php.net/manual/en/function.curl-multi-remove-handle.php + * + * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() + * @param resource $curlHandle a cURL handle returned by curl_init() */ public static function curlMultiRemoveHandle($multiHandle, $curlHandle): void { @@ -262,11 +263,12 @@ public static function curlMultiRemoveHandle($multiHandle, $curlHandle): void /** * Run the sub-connections of the current cURL handle. * - * @link http://www.php.net/manual/en/function.curl-multi-exec.php - * @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). - * @param integer $stillRunning A reference to a flag to tell whether the operations are still running. + * @see http://www.php.net/manual/en/function.curl-multi-exec.php + * + * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() + * @param int $stillRunning a reference to a flag to tell whether the operations are still running * - * @return integer A cURL code defined in the cURL Predefined Constants. + * @return int a cURL code defined in the cURL Predefined Constants */ public static function curlMultiExec($multiHandle, ?int &$stillRunning): int { @@ -285,18 +287,18 @@ public static function curlMultiExec($multiHandle, ?int &$stillRunning): int /** * Get information about the current transfers. * - * @link http://www.php.net/manual/en/function.curl-multi-info-read.php + * @see http://www.php.net/manual/en/function.curl-multi-info-read.php * - * @return array|bool On success, returns an associative array for the message, FALSE on failure. + * @return array|bool on success, returns an associative array for the message, FALSE on failure */ public static function curlMultiInfoRead() { if (!empty(self::$multiExecLastChs)) { - $info = array( + $info = [ 'msg' => CURLMSG_DONE, 'handle' => array_pop(self::$multiExecLastChs), - 'result' => CURLE_OK - ); + 'result' => CURLE_OK, + ]; return $info; } @@ -307,9 +309,10 @@ public static function curlMultiInfoRead() /** * Get information regarding a specific transfer. * - * @link http://www.php.net/manual/en/function.curl-getinfo.php - * @param resource $curlHandle A cURL handle returned by curl_init(). - * @param integer $option A cURL option defined in the cURL Predefined Constants. + * @see http://www.php.net/manual/en/function.curl-getinfo.php + * + * @param resource $curlHandle a cURL handle returned by curl_init() + * @param int $option a cURL option defined in the cURL Predefined Constants * * @return mixed */ @@ -330,12 +333,13 @@ public static function curlGetinfo($curlHandle, int $option = 0) /** * Set an option for a cURL transfer. * - * @link http://www.php.net/manual/en/function.curl-setopt.php - * @param resource $curlHandle A cURL handle returned by curl_init(). - * @param integer $option The CURLOPT_XXX option to set. - * @param mixed $value The value to be set on option. + * @see http://www.php.net/manual/en/function.curl-setopt.php * - * @return boolean Returns TRUE on success or FALSE on failure. + * @param resource $curlHandle a cURL handle returned by curl_init() + * @param int $option the CURLOPT_XXX option to set + * @param mixed $value the value to be set on option + * + * @return bool returns TRUE on success or FALSE on failure */ public static function curlSetopt($curlHandle, int $option, $value): bool { @@ -343,19 +347,20 @@ public static function curlSetopt($curlHandle, int $option, $value): bool static::$curlOptions[(int) $curlHandle][$option] = $value; - return \curl_setopt($curlHandle, $option, $value); + return curl_setopt($curlHandle, $option, $value); } /** * Set multiple options for a cURL transfer. * - * @link http://www.php.net/manual/en/function.curl-setopt-array.php - * @param resource $curlHandle A cURL handle returned by curl_init(). - * @param array $options An array specifying which options to set and their values. + * @see http://www.php.net/manual/en/function.curl-setopt-array.php + * + * @param resource $curlHandle a cURL handle returned by curl_init() + * @param array $options an array specifying which options to set and their values */ public static function curlSetoptArray($curlHandle, array $options): void { - if (is_array($options)) { + if (\is_array($options)) { foreach ($options as $option => $value) { static::curlSetopt($curlHandle, $option, $value); } @@ -363,37 +368,40 @@ public static function curlSetoptArray($curlHandle, array $options): void } /** - * Return a string containing the last error for the current session + * Return a string containing the last error for the current session. + * + * @see https://php.net/manual/en/function.curl-error.php * - * @link https://php.net/manual/en/function.curl-error.php * @param resource $curlHandle * * @return string the error message or '' (the empty string) if no - * error occurred. + * error occurred */ public static function curlError($curlHandle): string { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getMessage(); } + return ''; } /** - * Return the last error number + * Return the last error number. * - * @link https://php.net/manual/en/function.curl-errno.php + * @see https://php.net/manual/en/function.curl-errno.php * * @param resource $curlHandle * * @return int the error number or 0 (zero) if no error - * occurred. + * occurred */ public static function curlErrno($curlHandle): int { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getCode(); } + return 0; } } diff --git a/src/VCR/LibraryHooks/LibraryHook.php b/src/VCR/LibraryHooks/LibraryHook.php index 9282602ad..69df7c21c 100644 --- a/src/VCR/LibraryHooks/LibraryHook.php +++ b/src/VCR/LibraryHooks/LibraryHook.php @@ -8,12 +8,12 @@ interface LibraryHook { /** - * @var string Enabled status for a hook. + * @var string enabled status for a hook */ const ENABLED = 'ENABLED'; /** - * @var string Disabled status for a hook. + * @var string disabled status for a hook */ const DISABLED = 'DISABLED'; @@ -21,24 +21,22 @@ interface LibraryHook * Enables library hook which means that all of this library * http interactions are intercepted. * - * @param \Closure $requestCallback Callback which will be called when a request is intercepted. - * @throws \VCR\VCRException When specified callback is not callable. - * @return void + * @param \Closure $requestCallback callback which will be called when a request is intercepted + * + * @throws \VCR\VCRException when specified callback is not callable */ public function enable(\Closure $requestCallback): void; /** * Disables library hook, so no http interactions of * this library are intercepted anymore. - * - * @return void */ public function disable(): void; /** * Returns true if library hook is enabled, false otherwise. * - * @return boolean True if library hook is enabled, false otherwise. + * @return bool true if library hook is enabled, false otherwise */ public function isEnabled(): bool; } diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 9a3470f2b..9e0041c84 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -2,11 +2,11 @@ namespace VCR\LibraryHooks; -use VCR\Util\Assertion; -use VCR\VCRException; -use VCR\Request; use VCR\CodeTransform\AbstractCodeTransform; +use VCR\Request; +use VCR\Util\Assertion; use VCR\Util\StreamProcessor; +use VCR\VCRException; /** * Library hook for curl functions. @@ -36,10 +36,7 @@ class SoapHook implements LibraryHook /** * Creates a SOAP hook instance. * - * @param AbstractCodeTransform $codeTransformer - * @param StreamProcessor $processor - * - * @throws \BadMethodCallException in case the Soap extension is not installed. + * @throws \BadMethodCallException in case the Soap extension is not installed */ public function __construct(AbstractCodeTransform $codeTransformer, StreamProcessor $processor) { @@ -56,24 +53,19 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces } /** - * @param string $request - * @param string $location - * @param string $action - * @param integer $version - * @param int $one_way * @param array $options * - * @return string SOAP response. + * @return string SOAP response */ - public function doRequest(string $request, string $location, string $action, int $version, int $one_way = 0, array $options = array()): string + public function doRequest(string $request, string $location, string $action, int $version, int $one_way = 0, array $options = []): string { - if ($this->status === self::DISABLED) { + if (self::DISABLED === $this->status) { throw new VCRException('Hook must be enabled.', VCRException::LIBRARY_HOOK_DISABLED); } $vcrRequest = new Request('POST', $location); - if ($version === SOAP_1_1) { + if (SOAP_1_1 === $version) { $vcrRequest->setHeader('Content-Type', 'text/xml; charset=utf-8;'); $vcrRequest->setHeader('SOAPAction', $action); } else { // >= SOAP_1_2 @@ -98,14 +90,14 @@ public function doRequest(string $request, string $location, string $action, int } /** - * @inheritDoc + * {@inheritdoc} */ public function enable(\Closure $requestCallback): void { Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; - if ($this->status == self::ENABLED) { + if (self::ENABLED == $this->status) { return; } @@ -117,7 +109,7 @@ public function enable(\Closure $requestCallback): void } /** - * @inheritDoc + * {@inheritdoc} */ public function disable(): void { @@ -131,17 +123,17 @@ public function disable(): void } /** - * @inheritDoc + * {@inheritdoc} */ public function isEnabled(): bool { - return $this->status == self::ENABLED; + return self::ENABLED == $this->status; } /** * Cleanup. * - * @return void + * @return void */ public function __destruct() { diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index 441630cdb..5f469a0bf 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -13,17 +13,17 @@ class StreamWrapperHook implements LibraryHook { /** - * @var \Closure|null Callback which will be executed when a request is intercepted. + * @var \Closure|null callback which will be executed when a request is intercepted */ protected static $requestCallback; /** - * @var integer Position in the current response body. + * @var int position in the current response body */ protected $position; /** - * @var string Current status of this hook, either enabled or disabled. + * @var string current status of this hook, either enabled or disabled */ protected $status = self::DISABLED; @@ -33,12 +33,12 @@ class StreamWrapperHook implements LibraryHook protected $response; /** - * @var resource Current stream context. + * @var resource current stream context */ public $context; /** - * @inheritDoc + * {@inheritdoc} */ public function enable(\Closure $requestCallback): void { @@ -54,7 +54,7 @@ public function enable(\Closure $requestCallback): void } /** - * @inheritDoc + * {@inheritdoc} */ public function disable(): void { @@ -66,23 +66,24 @@ public function disable(): void } /** - * @inheritDoc + * {@inheritdoc} */ public function isEnabled(): bool { - return $this->status == self::ENABLED; + return self::ENABLED == $this->status; } /** * This method is called immediately after the wrapper is initialized (f.e. by fopen() and file_get_contents()). * - * @link http://www.php.net/manual/en/streamwrapper.stream-open.php - * @param string $path Specifies the URL that was passed to the original function. - * @param string $mode The mode used to open the file, as detailed for fopen(). - * @param int $options Holds additional flags set by the streams API. - * @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set. + * @see http://www.php.net/manual/en/streamwrapper.stream-open.php * - * @return boolean Returns TRUE on success or FALSE on failure. + * @param string $path specifies the URL that was passed to the original function + * @param string $mode the mode used to open the file, as detailed for fopen() + * @param int $options holds additional flags set by the streams API + * @param string $opened_path if the path is opened successfully, and STREAM_USE_PATH is set + * + * @return bool returns TRUE on success or FALSE on failure */ public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { @@ -92,6 +93,7 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ Assertion::isCallable($requestCallback); try { $this->response = $requestCallback($request); + return true; } catch (CurlException $e) { return false; @@ -101,8 +103,9 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ /** * Read from stream. * - * @link http://www.php.net/manual/en/streamwrapper.stream-read.php - * @param int $count How many bytes of data from the current position should be returned. + * @see http://www.php.net/manual/en/streamwrapper.stream-read.php + * + * @param int $count how many bytes of data from the current position should be returned * * @return string If there are less than count bytes available, return as many as are available. * If no more data is available, return either FALSE or an empty string. @@ -110,7 +113,7 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ public function stream_read(int $count): string { $ret = substr($this->response->getBody(), $this->position, $count); - $this->position += strlen($ret); + $this->position += \strlen($ret); return $ret; } @@ -118,12 +121,11 @@ public function stream_read(int $count): string /** * Write to stream. * - * @throws \BadMethodCallException If called, because this method is not applicable for this stream. - * @link http://www.php.net/manual/en/streamwrapper.stream-write.php + * @throws \BadMethodCallException if called, because this method is not applicable for this stream * - * @param string $data Should be stored into the underlying stream. + * @see http://www.php.net/manual/en/streamwrapper.stream-write.php * - * @return int + * @param string $data should be stored into the underlying stream */ public function stream_write(string $data): int { @@ -135,9 +137,9 @@ public function stream_write(string $data): int * * This method is called in response to fseek() to determine the current position. * - * @link http://www.php.net/manual/en/streamwrapper.stream-tell.php + * @see http://www.php.net/manual/en/streamwrapper.stream-tell.php * - * @return integer Should return the current position of the stream. + * @return int should return the current position of the stream */ public function stream_tell(): int { @@ -147,56 +149,56 @@ public function stream_tell(): int /** * Tests for end-of-file on a file pointer. * - * @link http://www.php.net/manual/en/streamwrapper.stream-eof.php + * @see http://www.php.net/manual/en/streamwrapper.stream-eof.php * - * @return boolean Should return TRUE if the read/write position is at the end of the stream - * and if no more data is available to be read, or FALSE otherwise. + * @return bool should return TRUE if the read/write position is at the end of the stream + * and if no more data is available to be read, or FALSE otherwise */ public function stream_eof(): bool { - return $this->position >= strlen($this->response->getBody()); + return $this->position >= \strlen($this->response->getBody()); } /** * Retrieve information about a file resource. * - * @link http://www.php.net/manual/en/streamwrapper.stream-stat.php + * @see http://www.php.net/manual/en/streamwrapper.stream-stat.php * - * @return array See stat(). + * @return array see stat() */ public function stream_stat(): array { - return array(); + return []; } /** - * Retrieve information about a file resource. - * - * @link http://www.php.net/manual/en/streamwrapper.url-stat.php - * - * @return array See stat(). - */ - + * Retrieve information about a file resource. + * + * @see http://www.php.net/manual/en/streamwrapper.url-stat.php + * + * @return array see stat() + */ public function url_stat(string $path, int $flags): array { - return array(); + return []; } /** * Seeks to specific location in a stream. * - * @param integer $offset The stream offset to seek to. - * @param integer $whence Possible values: - * SEEK_SET - Set position equal to offset bytes. - * SEEK_CUR - Set position to current location plus offset. - * SEEK_END - Set position to end-of-file plus offset. - * @return boolean Return TRUE if the position was updated, FALSE otherwise. + * @param int $offset the stream offset to seek to + * @param int $whence Possible values: + * SEEK_SET - Set position equal to offset bytes. + * SEEK_CUR - Set position to current location plus offset. + * SEEK_END - Set position to end-of-file plus offset. + * + * @return bool return TRUE if the position was updated, FALSE otherwise */ public function stream_seek(int $offset, int $whence): bool { switch ($whence) { case SEEK_SET: - if ($offset < strlen($this->response->getBody()) && $offset >= 0) { + if ($offset < \strlen($this->response->getBody()) && $offset >= 0) { $this->position = $offset; return true; @@ -210,8 +212,8 @@ public function stream_seek(int $offset, int $whence): bool } break; case SEEK_END: - if (strlen($this->response->getBody()) + $offset >= 0) { - $this->position = strlen($this->response->getBody()) + $offset; + if (\strlen($this->response->getBody()) + $offset >= 0) { + $this->position = \strlen($this->response->getBody()) + $offset; return true; } @@ -223,12 +225,13 @@ public function stream_seek(int $offset, int $whence): bool /** * Change stream options. * - * @link http://www.php.net/manual/en/streamwrapper.stream-metadata.php - * @param string $path The file path or URL to set metadata. - * @param integer $option One of the stream options. - * @param mixed $var Value depending on the option. + * @see http://www.php.net/manual/en/streamwrapper.stream-metadata.php + * + * @param string $path the file path or URL to set metadata + * @param int $option one of the stream options + * @param mixed $var value depending on the option * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function stream_metadata(string $path, int $option, $var): bool { diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 850ca96a3..bab19254d 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -21,7 +21,7 @@ class Request /** * @var array */ - protected $headers = array(); + protected $headers = []; /** * @var string|null */ @@ -29,22 +29,20 @@ class Request /** * @var array> */ - protected $postFiles = array(); + protected $postFiles = []; /** * @var array */ - protected $postFields = array(); + protected $postFields = []; /** * @var array */ - protected $curlOptions = array(); + protected $curlOptions = []; /** - * @param string $method - * @param string|null $url * @param array $headers */ - public function __construct(string $method, ?string $url, array $headers = array()) + public function __construct(string $method, ?string $url, array $headers = []) { $this->method = $method; $this->headers = $headers; @@ -55,22 +53,21 @@ public function __construct(string $method, ?string $url, array $headers = array * Returns true if specified request matches the current one * with specified request matcher callbacks. * - * @param Request $request Request to check if it matches the current one. - * @param callable[] $requestMatchers Request matcher callbacks. + * @param Request $request request to check if it matches the current one + * @param callable[] $requestMatchers request matcher callbacks * - * @throws \BadFunctionCallException If one of the specified request matchers is not callable. - * @return boolean True if specified request matches the current one. + * @throws \BadFunctionCallException if one of the specified request matchers is not callable + * + * @return bool true if specified request matches the current one */ - public function matches(Request $request, array $requestMatchers): bool + public function matches(self $request, array $requestMatchers): bool { foreach ($requestMatchers as $matcher) { - if (!is_callable($matcher)) { - throw new \BadFunctionCallException( - 'Matcher could not be executed. ' . print_r($matcher, true) - ); + if (!\is_callable($matcher)) { + throw new \BadFunctionCallException('Matcher could not be executed. '.print_r($matcher, true)); } - if (call_user_func_array($matcher, array($this, $request)) === false) { + if (false === \call_user_func_array($matcher, [$this, $request])) { return false; } } @@ -81,80 +78,71 @@ public function matches(Request $request, array $requestMatchers): bool /** * Returns an array representation of this request. * - * @return array Array representation of this request. + * @return array array representation of this request */ public function toArray(): array { return array_filter( - array( + [ 'method' => $this->getMethod(), 'url' => $this->getUrl(), 'headers' => $this->getHeaders(), 'body' => $this->getBody(), 'post_files' => $this->getPostFiles(), 'post_fields' => $this->getPostFields(), - ) + ] ); } /** * Creates a new Request from a specified array. * - * @param array $request Request represented as an array. Allowed keys: "method", "url", "headers", - * "post_fields", "post_files", "body" + * @param array $request Request represented as an array. Allowed keys: "method", "url", "headers", + * "post_fields", "post_files", "body" * - * @return Request A new Request from specified array. + * @return Request a new Request from specified array */ - public static function fromArray(array $request): Request + public static function fromArray(array $request): self { - $requestObject = new Request( + $requestObject = new self( $request['method'], $request['url'], - isset($request['headers']) ? $request['headers'] : array() + isset($request['headers']) ? $request['headers'] : [] ); - if (!empty($request['post_fields']) && is_array($request['post_fields'])) { + if (!empty($request['post_fields']) && \is_array($request['post_fields'])) { $requestObject->setPostFields($request['post_fields']); } - if (!empty($request['post_files']) && is_array($request['post_files'])) { + if (!empty($request['post_files']) && \is_array($request['post_files'])) { foreach ($request['post_files'] as $file) { $requestObject->addPostFile($file); } } if (!empty($request['body'])) { - $requestObject->setBody((string)$request['body']); + $requestObject->setBody((string) $request['body']); } return $requestObject; } - /** - * @param string|null $url - */ public function setUrl(?string $url): void { $this->url = $url; - if ($url !== null && $this->hasHeader('Host') === false) { + if (null !== $url && false === $this->hasHeader('Host')) { $this->setHeader('Host', $this->getHost()); } } - /** - * @return string|null - */ public function getBody(): ?string { return $this->body; } - /** - * @return string - */ public function getMethod(): string { - if ($this->getCurlOption(CURLOPT_CUSTOMREQUEST) !== null) { + if (null !== $this->getCurlOption(CURLOPT_CUSTOMREQUEST)) { return $this->getCurlOption(CURLOPT_CUSTOMREQUEST); } @@ -169,10 +157,6 @@ public function getHeaders(): array return $this->headers; } - /** - * @param string $key - * @return string|null - */ public function getHeader(string $key): ?string { if (!isset($this->headers[$key])) { @@ -182,13 +166,9 @@ public function getHeader(string $key): ?string return $this->headers[$key]; } - /** - * @param string $key - * @return boolean - */ public function hasHeader(string $key): bool { - return array_key_exists($key, $this->headers); + return \array_key_exists($key, $this->headers); } /** @@ -207,17 +187,11 @@ public function getPostFiles(): array return $this->postFiles; } - /** - * @return string|null - */ public function getUrl(): ?string { return $this->url; } - /** - * @return string - */ public function getHost(): string { $url = $this->getUrl(); @@ -225,12 +199,12 @@ public function getHost(): string $host = parse_url($url, PHP_URL_HOST); - if ($host === null || $host === false) { + if (null === $host || false === $host) { throw InvalidHostException::create($this->getUrl()); } if ($port = parse_url($url, PHP_URL_PORT)) { - $host .= ':' . $port; + $host .= ':'.$port; } return $host; @@ -245,18 +219,17 @@ public function getPath(): ?string Assertion::string($url); $path = parse_url($url, PHP_URL_PATH); Assertion::notSame($path, false); + return $path; } - /** - * @return string|null - */ public function getQuery(): ?string { $url = $this->getUrl(); Assertion::string($url); $query = parse_url($url, PHP_URL_QUERY); Assertion::notSame($query, false); + return $query; } @@ -269,7 +242,6 @@ public function getCurlOptions(): array } /** - * @param int $key * @return mixed */ public function getCurlOption(int $key) @@ -307,9 +279,6 @@ public function setPostFiles(array $post_files): void $this->postFiles = $post_files; } - /** - * @param string|null $body - */ public function setBody(?string $body): void { $this->body = $body; @@ -318,12 +287,12 @@ public function setBody(?string $body): void /** * Sets the authorization credentials as header. * - * @param string $username Username. - * @param string $password Password. + * @param string $username username + * @param string $password password */ public function setAuthorization(string $username, string $password): void { - $this->setHeader('Authorization', 'Basic ' . base64_encode($username . ':' . $password)); + $this->setHeader('Authorization', 'Basic '.base64_encode($username.':'.$password)); } /** @@ -334,25 +303,17 @@ public function setCurlOptions(array $curlOptions): void $this->curlOptions = $curlOptions; } - /** - * @param string $key - * @param string $value - */ public function setHeader(string $key, string $value): void { $this->headers[$key] = $value; } - /** - * @param string $key - */ public function removeHeader(string $key): void { unset($this->headers[$key]); } /** - * @param string $key * @param mixed $value */ public function setPostField(string $key, $value): void @@ -361,7 +322,6 @@ public function setPostField(string $key, $value): void } /** - * @param int $key * @param mixed $value */ public function setCurlOption(int $key, $value): void diff --git a/src/VCR/RequestMatcher.php b/src/VCR/RequestMatcher.php index 9ecbcb9a2..fff0a0b0c 100644 --- a/src/VCR/RequestMatcher.php +++ b/src/VCR/RequestMatcher.php @@ -10,10 +10,10 @@ class RequestMatcher /** * Returns true if the method of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the method of both specified requests match. + * @return bool true if the method of both specified requests match */ public static function matchMethod(Request $storedRequest, Request $request): bool { @@ -23,10 +23,10 @@ public static function matchMethod(Request $storedRequest, Request $request): bo /** * Returns true if the url of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the url of both specified requests match. + * @return bool true if the url of both specified requests match */ public static function matchUrl(Request $storedRequest, Request $request): bool { @@ -36,10 +36,10 @@ public static function matchUrl(Request $storedRequest, Request $request): bool /** * Returns true if the host of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the host of both specified requests match. + * @return bool true if the host of both specified requests match */ public static function matchHost(Request $storedRequest, Request $request): bool { @@ -49,10 +49,10 @@ public static function matchHost(Request $storedRequest, Request $request): bool /** * Returns true if the headers of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the headers of both specified requests match. + * @return bool true if the headers of both specified requests match */ public static function matchHeaders(Request $storedRequest, Request $request): bool { @@ -64,10 +64,10 @@ public static function matchHeaders(Request $storedRequest, Request $request): b /** * Returns true if the body of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the body of both specified requests match. + * @return bool true if the body of both specified requests match */ public static function matchBody(Request $storedRequest, Request $request): bool { @@ -77,10 +77,10 @@ public static function matchBody(Request $storedRequest, Request $request): bool /** * Returns true if the post fields of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the post fields of both specified requests match. + * @return bool true if the post fields of both specified requests match */ public static function matchPostFields(Request $storedRequest, Request $request): bool { @@ -90,10 +90,10 @@ public static function matchPostFields(Request $storedRequest, Request $request) /** * Returns true if the query string of both specified requests match. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the query string of both specified requests match. + * @return bool true if the query string of both specified requests match */ public static function matchQueryString(Request $storedRequest, Request $request): bool { @@ -103,10 +103,10 @@ public static function matchQueryString(Request $storedRequest, Request $request /** * Returns true if the SOAP operation of both specified requests match, or if the request is not a SOAP request. * - * @param Request $storedRequest First request to match, coming from the cassette. - * @param Request $request Second request to match, the request performed by the user. + * @param Request $storedRequest first request to match, coming from the cassette + * @param Request $request second request to match, the request performed by the user * - * @return boolean True if the query string of both specified requests match. + * @return bool true if the query string of both specified requests match */ public static function matchSoapOperation(Request $storedRequest, Request $request): bool { diff --git a/src/VCR/Response.php b/src/VCR/Response.php index ca58e934a..791866d89 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -10,17 +10,17 @@ class Response { /** - * @var array + * @var array */ - protected $status = array( + protected $status = [ 'code' => null, - 'message' => '' - ); + 'message' => '', + ]; /** * @var array */ - protected $headers = array(); + protected $headers = []; /** * @var string|null */ @@ -28,7 +28,7 @@ class Response /** * @var array */ - protected $curlInfo = array(); + protected $curlInfo = []; /** * @var mixed @@ -37,11 +37,10 @@ class Response /** * @param string|array $status - * @param array $headers - * @param string|null $body - * @param array $curlInfo + * @param array $headers + * @param array $curlInfo */ - final public function __construct($status, array $headers = array(), ?string $body = null, array $curlInfo = array()) + final public function __construct($status, array $headers = [], ?string $body = null, array $curlInfo = []) { $this->setStatus($status); $this->headers = $headers; @@ -52,43 +51,44 @@ final public function __construct($status, array $headers = array(), ?string $bo /** * Returns an array representation of this Response. * - * @return array Array representation of this Request. + * @return array array representation of this Request */ public function toArray(): array { $body = $this->getBody(); // Base64 encode when binary - if (strpos($this->getContentType(), 'application/x-gzip') !== false - || $this->getHeader('Content-Transfer-Encoding') == 'binary' + if (false !== strpos($this->getContentType(), 'application/x-gzip') + || 'binary' == $this->getHeader('Content-Transfer-Encoding') ) { $body = base64_encode($body); } return array_filter( - array( - 'status' => $this->status, - 'headers' => $this->getHeaders(), - 'body' => $body, + [ + 'status' => $this->status, + 'headers' => $this->getHeaders(), + 'body' => $body, 'curl_info' => $this->curlInfo, - ) + ] ); } /** * Creates a new Response from a specified array. * - * @param array $response Array representation of a Response. + * @param array $response array representation of a Response + * * @return Response A new Response from a specified array */ - public static function fromArray(array $response): Response + public static function fromArray(array $response): self { $body = isset($response['body']) ? $response['body'] : null; $gzip = isset($response['headers']['Content-Type']) - && strpos($response['headers']['Content-Type'], 'application/x-gzip') !== false; + && false !== strpos($response['headers']['Content-Type'], 'application/x-gzip'); $binary = isset($response['headers']['Content-Transfer-Encoding']) - && $response['headers']['Content-Transfer-Encoding'] == 'binary'; + && 'binary' == $response['headers']['Content-Transfer-Encoding']; // Base64 decode when binary if ($gzip || $binary) { @@ -97,15 +97,12 @@ public static function fromArray(array $response): Response return new static( isset($response['status']) ? $response['status'] : 200, - isset($response['headers']) ? $response['headers'] : array(), + isset($response['headers']) ? $response['headers'] : [], $body, - isset($response['curl_info']) ? $response['curl_info'] : array() + isset($response['curl_info']) ? $response['curl_info'] : [] ); } - /** - * @return string - */ public function getBody(): string { return $this->body ?: ''; @@ -134,9 +131,6 @@ public function getHeaders(): array return $this->headers; } - /** - * @return string - */ public function getStatusCode(): string { return $this->status['code']; @@ -164,9 +158,6 @@ public function getHttpVersion() return $this->httpVersion; } - /** - * @return string - */ public function getStatusMessage(): string { return $this->status['message']; @@ -177,7 +168,7 @@ public function getStatusMessage(): string */ protected function setStatus($status): void { - if (is_array($status)) { + if (\is_array($status)) { $this->status = $status; if (!empty($status['http_version'])) { $this->httpVersion = $status['http_version']; diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index ca8c688e4..2df29668e 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -13,37 +13,37 @@ abstract class AbstractStorage implements Storage { /** - * @var resource File handle. + * @var resource file handle */ protected $handle; /** - * @var string Path to storage file. + * @var string path to storage file */ protected $filePath; /** - * @var array|null Current parsed record. + * @var array|null current parsed record */ protected $current; /** - * @var integer Number of the current recording. + * @var int number of the current recording */ protected $position = 0; /** - * @var boolean True when parser is at the end of the file. + * @var bool true when parser is at the end of the file */ protected $isEOF = false; /** - * @var boolean If the cassette file is new. + * @var bool if the cassette file is new */ protected $isNew = false; /** - * @var boolean If the current position is valid. + * @var bool if the current position is valid */ protected $isValidPosition = true; @@ -53,18 +53,18 @@ abstract class AbstractStorage implements Storage * If the cassetteName contains PATH_SEPARATORs, subfolders of the * cassettePath are autocreated when not existing. * - * @param string $cassettePath Path to the cassette directory. - * @param string $cassetteName Path to the cassette file, relative to the path. - * @param string $defaultContent Default data for this cassette if its not existing + * @param string $cassettePath path to the cassette directory + * @param string $cassetteName path to the cassette file, relative to the path + * @param string $defaultContent Default data for this cassette if its not existing */ public function __construct(string $cassettePath, string $cassetteName, string $defaultContent = '[]') { Assertion::directory($cassettePath, "Cassette path '{$cassettePath}' is not existing or not a directory"); - $this->filePath = rtrim($cassettePath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $cassetteName; + $this->filePath = rtrim($cassettePath, \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.$cassetteName; - if (!is_dir(dirname($this->filePath))) { - mkdir(dirname($this->filePath), 0777, true); + if (!is_dir(\dirname($this->filePath))) { + mkdir(\dirname($this->filePath), 0777, true); } if (!file_exists($this->filePath) || 0 === filesize($this->filePath)) { @@ -85,7 +85,7 @@ public function __construct(string $cassettePath, string $cassetteName, string $ /** * Returns the current record. * - * @return array|null Parsed current record. + * @return array|null parsed current record */ public function current() { @@ -95,7 +95,7 @@ public function current() /** * Returns the current key. * - * @return integer + * @return int */ public function key() { @@ -105,7 +105,7 @@ public function key() /** * Returns true if the file did not exist and had to be created. * - * @return boolean TRUE if created, FALSE if not + * @return bool TRUE if created, FALSE if not */ public function isNew(): bool { @@ -117,7 +117,7 @@ public function isNew(): bool */ public function __destruct() { - if (is_resource($this->handle)) { + if (\is_resource($this->handle)) { fclose($this->handle); } } diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index 71939a94a..612502246 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -8,14 +8,14 @@ class Blackhole implements Storage { /** - * {@inheritDoc} + * {@inheritdoc} */ public function storeRecording(array $recording): void { } /** - * {@inheritDoc} + * {@inheritdoc} */ public function isNew(): bool { diff --git a/src/VCR/Storage/Json.php b/src/VCR/Storage/Json.php index 47a538bf2..79827c8ed 100644 --- a/src/VCR/Storage/Json.php +++ b/src/VCR/Storage/Json.php @@ -11,7 +11,7 @@ class Json extends AbstractStorage { /** - * @inheritDoc + * {@inheritdoc} */ public function storeRecording(array $recording): void { @@ -19,19 +19,17 @@ public function storeRecording(array $recording): void if (ftell($this->handle) > 2) { fwrite($this->handle, ','); } - if (defined('JSON_PRETTY_PRINT')) { + if (\defined('JSON_PRETTY_PRINT')) { $json = json_encode($recording, JSON_PRETTY_PRINT); } else { $json = json_encode($recording); } - fwrite($this->handle, $json . ']'); + fwrite($this->handle, $json.']'); fflush($this->handle); } /** * Parses the next record. - * - * @return void */ public function next(): void { @@ -42,7 +40,7 @@ public function next(): void /** * Returns the next record in raw format. * - * @return string Next record in raw format. + * @return string next record in raw format */ protected function readNextRecord(): string { @@ -51,14 +49,14 @@ protected function readNextRecord(): string $record = ''; while (false !== ($char = fgetc($this->handle))) { - if ($char === '{') { + if ('{' === $char) { ++$depth; } - if ($char === '}') { + if ('}' === $char) { --$depth; } - if (!$isInRecord && $char === '{') { + if (!$isInRecord && '{' === $char) { $isInRecord = true; } @@ -66,12 +64,12 @@ protected function readNextRecord(): string $record .= $char; } - if ($isInRecord && $char === '}' && $depth == 0) { + if ($isInRecord && '}' === $char && 0 == $depth) { break; } } - if ($char == false) { + if (false == $char) { $this->isEOF = true; } @@ -93,11 +91,11 @@ public function rewind() /** * Returns true if the current record is valid. * - * @return boolean True if the current record is valid. + * @return bool true if the current record is valid */ public function valid() { - if (is_null($this->current)) { + if (null === $this->current) { $this->next(); } diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index ef012f3ff..08334468c 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -7,6 +7,7 @@ * * A Storage can be iterated using standard loops. * New recordings can be stored. + * * @phpstan-extends \Iterator */ interface Storage extends \Iterator @@ -14,15 +15,14 @@ interface Storage extends \Iterator /** * Stores an array of data. * - * @param array> $recording Array to store in storage. - * @return void + * @param array> $recording array to store in storage */ public function storeRecording(array $recording): void; /** * Returns true if the file did not exist and had to be created. * - * @return boolean TRUE if created, FALSE if not + * @return bool TRUE if created, FALSE if not */ public function isNew(): bool; } diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index d1eb416bb..c626746aa 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -2,8 +2,8 @@ namespace VCR\Storage; -use Symfony\Component\Yaml\Parser; use Symfony\Component\Yaml\Dumper; +use Symfony\Component\Yaml\Parser; /** * Yaml based storage for records. @@ -14,22 +14,22 @@ class Yaml extends AbstractStorage { /** - * @var Parser Yaml parser. + * @var Parser yaml parser */ protected $yamlParser; /** - * @var Dumper Yaml writer. + * @var Dumper yaml writer */ protected $yamlDumper; /** * Creates a new YAML based file store. * - * @param string $cassettePath Path to the cassette directory. - * @param string $cassetteName Path to a file, will be created if not existing. - * @param Parser $parser Parser used to decode yaml. - * @param Dumper $dumper Dumper used to encode yaml. + * @param string $cassettePath path to the cassette directory + * @param string $cassetteName path to a file, will be created if not existing + * @param Parser $parser parser used to decode yaml + * @param Dumper $dumper dumper used to encode yaml */ public function __construct($cassettePath, $cassetteName, Parser $parser = null, Dumper $dumper = null) { @@ -40,12 +40,12 @@ public function __construct($cassettePath, $cassetteName, Parser $parser = null, } /** - * @inheritDoc + * {@inheritdoc} */ public function storeRecording(array $recording): void { fseek($this->handle, -1, SEEK_END); - fwrite($this->handle, "\n" . $this->yamlDumper->dump(array($recording), 4)); + fwrite($this->handle, "\n".$this->yamlDumper->dump([$recording], 4)); fflush($this->handle); } @@ -64,7 +64,7 @@ public function next() /** * Returns the next record in raw format. * - * @return string Next record in raw format. + * @return string next record in raw format */ private function readNextRecord(): string { @@ -76,10 +76,10 @@ private function readNextRecord(): string $recording = ''; while (false !== ($line = fgets($this->handle))) { - $isNewArrayStart = strpos($line, '-') === 0; + $isNewArrayStart = 0 === strpos($line, '-'); if ($isInRecord && $isNewArrayStart) { - fseek($this->handle, -strlen($line), SEEK_CUR); + fseek($this->handle, -\strlen($line), SEEK_CUR); break; } @@ -92,7 +92,7 @@ private function readNextRecord(): string } } - if ($line == false) { + if (false == $line) { $this->isEOF = true; } @@ -115,14 +115,14 @@ public function rewind() /** * Returns true if the current record is valid. * - * @return boolean True if the current record is valid. + * @return bool true if the current record is valid */ public function valid() { - if (is_null($this->current)) { + if (null === $this->current) { $this->next(); } - return ! is_null($this->current) && $this->isValidPosition; + return null !== $this->current && $this->isValidPosition; } } diff --git a/src/VCR/Util/Assertion.php b/src/VCR/Util/Assertion.php index 7a85631cd..adadb75f7 100644 --- a/src/VCR/Util/Assertion.php +++ b/src/VCR/Util/Assertion.php @@ -14,16 +14,15 @@ class Assertion extends BaseAssertion /** * Assert that the value is callable. * - * @param mixed $value Variable to check for a callable. - * @param string $message Exception message to show if value is not a callable. - * @param null $propertyPath - * @throws \VCR\VCRException If specified value is not a callable. + * @param mixed $value variable to check for a callable + * @param string $message exception message to show if value is not a callable + * @param null $propertyPath * - * @return bool + * @throws \VCR\VCRException if specified value is not a callable */ public static function isCallable($value, $message = null, string $propertyPath = null): bool { - if (! is_callable($value)) { + if (!\is_callable($value)) { throw new VCRException($message, self::INVALID_CALLABLE, $propertyPath); } diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php index c8c80127d..42a2c99a8 100644 --- a/src/VCR/Util/CurlException.php +++ b/src/VCR/Util/CurlException.php @@ -11,12 +11,14 @@ class CurlException extends \Exception /** * @param resource $ch The cURL handler + * * @return CurlException */ public static function create($ch): self { - $e = new CurlException(curl_error($ch), curl_errno($ch)); + $e = new self(curl_error($ch), curl_errno($ch)); $e->info = curl_getinfo($ch); + return $e; } diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 6c39f63bf..3e234cd83 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -6,14 +6,14 @@ use VCR\Response; /** -* cURL helper class. -*/ + * cURL helper class. + */ class CurlHelper { /** - * @var array List of cURL info constants. + * @var array list of cURL info constants */ - private static $curlInfoList = array( + private static $curlInfoList = [ //"certinfo"? CURLINFO_HTTP_CODE => 'http_code', CURLINFO_EFFECTIVE_URL => 'url', @@ -35,8 +35,8 @@ class CurlHelper CURLINFO_SSL_VERIFYRESULT => 'ssl_verify_result', CURLINFO_CONTENT_LENGTH_DOWNLOAD => 'download_content_length', CURLINFO_CONTENT_LENGTH_UPLOAD => 'upload_content_length', - CURLINFO_CONTENT_TYPE => 'content_type' - ); + CURLINFO_CONTENT_TYPE => 'content_type', + ]; /** * Outputs a response depending on the set cURL option. @@ -46,33 +46,31 @@ class CurlHelper * * The response header might be passed to a custom function. * - * @param Response $response Response which contains the response body. - * @param array $curlOptions cURL options which are not stored within the Response. - * @param resource $ch cURL handle to add headers if needed. - * - * @return null|string + * @param Response $response response which contains the response body + * @param array $curlOptions cURL options which are not stored within the Response + * @param resource $ch cURL handle to add headers if needed */ public static function handleOutput(Response $response, array $curlOptions, $ch): ?string { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) { - $headerList = array(HttpUtil::formatAsStatusString($response)); + $headerList = [HttpUtil::formatAsStatusString($response)]; $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders())); $headerList[] = ''; foreach ($headerList as $header) { - call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); + \call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); } } $body = $response->getBody(); if (!empty($curlOptions[CURLOPT_HEADER])) { - $body = HttpUtil::formatAsStatusWithHeadersString($response) . $body; + $body = HttpUtil::formatAsStatusWithHeadersString($response).$body; } if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) { - call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); - } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && $curlOptions[CURLOPT_RETURNTRANSFER] == true) { + \call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); + } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && true == $curlOptions[CURLOPT_RETURNTRANSFER]) { return $body; } elseif (isset($curlOptions[CURLOPT_FILE])) { $fp = $curlOptions[CURLOPT_FILE]; @@ -81,42 +79,44 @@ public static function handleOutput(Response $response, array $curlOptions, $ch) } else { echo $body; } + return null; } /** * Returns a cURL option from a Response. * - * @param Response $response Response to get cURL option from. - * @param integer $option cURL option to get. + * @param Response $response response to get cURL option from + * @param int $option cURL option to get * * @throws \BadMethodCallException - * @return mixed Value of the cURL option. + * + * @return mixed value of the cURL option */ public static function getCurlOptionFromResponse(Response $response, int $option = 0) { switch ($option) { case 0: // 0 == array of all curl options - $info = array(); + $info = []; foreach (self::$curlInfoList as $option => $key) { $info[$key] = $response->getCurlInfo($key); } break; case CURLINFO_HTTP_CODE: - $info = (int)$response->getStatusCode(); + $info = (int) $response->getStatusCode(); break; case CURLINFO_SIZE_DOWNLOAD: $info = $response->getHeader('Content-Length'); break; case CURLINFO_HEADER_SIZE: - $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); + $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; default: $info = $response->getCurlInfo(self::$curlInfoList[$option]); break; } - if (!is_null($info)) { + if (null !== $info) { return $info; } @@ -128,10 +128,10 @@ public static function getCurlOptionFromResponse(Response $response, int $option /** * Sets a cURL option on a Request. * - * @param Request $request Request to set cURL option to. - * @param integer $option cURL option to set. - * @param mixed $value Value of the cURL option. - * @param resource $curlHandle cURL handle where this option is set on (optional). + * @param Request $request request to set cURL option to + * @param int $option cURL option to set + * @param mixed $value value of the cURL option + * @param resource $curlHandle cURL handle where this option is set on (optional) */ public static function setCurlOptionOnRequest(Request $request, int $option, $value, $curlHandle = null): void { @@ -143,18 +143,18 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va $request->setCurlOption(CURLOPT_CUSTOMREQUEST, $value); break; case CURLOPT_POST: - if ($value == true) { + if (true == $value) { $request->setMethod('POST'); } break; case CURLOPT_POSTFIELDS: // todo: check for file @ - if (is_array($value)) { + if (\is_array($value)) { foreach ($value as $name => $fieldValue) { $request->setPostField($name, $fieldValue); } - if (count($value) == 0) { + if (0 == \count($value)) { $request->removeHeader('Content-Type'); } } elseif (!empty($value)) { @@ -192,13 +192,13 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va * Makes sure we've properly handled the POST body, such as ensuring that * CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set. * - * @param Request $request Request to set cURL option to. - * @param resource $curlHandle cURL handle associated with the request. + * @param Request $request request to set cURL option to + * @param resource $curlHandle cURL handle associated with the request */ public static function validateCurlPOSTBody(Request $request, $curlHandle = null): void { $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION); - if (is_null($readFunction)) { + if (null === $readFunction) { return; } @@ -210,7 +210,7 @@ public static function validateCurlPOSTBody(Request $request, $curlHandle = null $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE); Assertion::notEmpty($bodySize, 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); - $body = call_user_func_array($readFunction, array($curlHandle, fopen('php://memory', 'r'), $bodySize)); + $body = \call_user_func_array($readFunction, [$curlHandle, fopen('php://memory', 'r'), $bodySize]); $request->setBody($body); } } diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 449ba3557..556352732 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -13,9 +13,9 @@ class HttpClient /** * Returns a response for specified HTTP request. * - * @param Request $request HTTP Request to send. + * @param request $request HTTP Request to send * - * @return Response Response for specified request. + * @return Response response for specified request * * @throws CurlException In case of cURL error */ @@ -27,7 +27,7 @@ public function send(Request $request): Response curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); - if (!is_null($request->getBody())) { + if (null !== $request->getBody()) { curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getBody()); } @@ -39,7 +39,7 @@ public function send(Request $request): Response /** @var string|false $result */ $result = curl_exec($ch); - if ($result === false) { + if (false === $result) { throw CurlException::create($ch); } list($status, $headers, $body) = HttpUtil::parseResponse($result); diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index ff8cbce3a..ec380b1df 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -10,6 +10,7 @@ class HttpUtil * Returns key value pairs of response headers. * * @param string[] $headers List of headers. Example: ['Content-Type: text/html', '...'] + * * @return array Key/value pairs of headers, e.g. ['Content-Type' => 'text/html'] */ public static function parseHeaders(array $headers): array @@ -18,10 +19,10 @@ public static function parseHeaders(array $headers): array foreach ($headers as $i => $line) { list($key, $value) = explode(': ', $line, 2); if (isset($headers[$key])) { - if (is_array($headers[$key])) { + if (\is_array($headers[$key])) { $headers[$key][] = $value; } else { - $headers[$key] = array($headers[$key], $value); + $headers[$key] = [$headers[$key], $value]; } } else { $headers[$key] = $value; @@ -36,7 +37,8 @@ public static function parseHeaders(array $headers): array * Returns http_version, code and message from a HTTP status line. * * @param string $status HTTP status line, e.g. HTTP/1.1 200 OK - * @return array Parsed 'http_version', 'code' and 'message'. + * + * @return array parsed 'http_version', 'code' and 'message' */ public static function parseStatus(string $status): array { @@ -48,18 +50,19 @@ public static function parseStatus(string $status): array $part = explode(' ', $status, 3); - return array( + return [ 'http_version' => substr(strrchr($part[0], '/'), 1), 'code' => $part[1], - 'message' => isset($part[2]) ? $part[2] : '' - ); + 'message' => isset($part[2]) ? $part[2] : '', + ]; } /** * Returns status, headers and body from a HTTP response string. * - * @param string $response Response including header and body. - * @return array Status, headers and body as strings. + * @param string $response response including header and body + * + * @return array status, headers and body as strings */ public static function parseResponse(string $response): array { @@ -71,13 +74,12 @@ public static function parseResponse(string $response): array $headers = self::parseRawHeader($rawHeader); $status = array_shift($headers); - return array($status, $headers, $rawBody); + return [$status, $headers, $rawBody]; } /** * Returns an array of arrays for specified raw header string. * - * @param string $rawHeader * @return array */ public static function parseRawHeader(string $rawHeader): array @@ -88,20 +90,21 @@ public static function parseRawHeader(string $rawHeader): array /** * Returns a list of headers from a key/value paired array. * - * @param array> $headers Headers as key/value pairs. + * @param array> $headers Headers as key/value pairs + * * @return string[] List of headers ['Content-Type: text/html', '...']. */ public static function formatHeadersForCurl(array $headers): array { - $curlHeaders = array(); + $curlHeaders = []; foreach ($headers as $key => $values) { - if (is_array($values)) { + if (\is_array($values)) { foreach ($values as $value) { - $curlHeaders[] = $key . ': ' . $value; + $curlHeaders[] = $key.': '.$value; } } else { - $curlHeaders[] = $key . ': ' . $values; + $curlHeaders[] = $key.': '.$values; } } @@ -111,26 +114,25 @@ public static function formatHeadersForCurl(array $headers): array /** * Returns a HTTP status line from specified response. * - * @param Response $response - * @return string HTTP status line. + * @return string HTTP status line */ public static function formatAsStatusString(Response $response): string { - return 'HTTP/' . $response->getHttpVersion() - . ' ' . $response->getStatusCode() - . ' ' . $response->getStatusMessage(); + return 'HTTP/'.$response->getHttpVersion() + .' '.$response->getStatusCode() + .' '.$response->getStatusMessage(); } /** * Returns a HTTP status line with headers from specified response. * - * @param Response $response - * @return string HTTP status line. + * @return string HTTP status line */ public static function formatAsStatusWithHeadersString(Response $response): string { $headers = self::formatHeadersForCurl($response->getHeaders()); array_unshift($headers, self::formatAsStatusString($response)); - return join("\r\n", $headers) . "\r\n\r\n"; + + return implode("\r\n", $headers)."\r\n\r\n"; } } diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index d3c4abf53..78a6279b1 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -11,14 +11,14 @@ class SoapClient extends \SoapClient { /** - * @var \VCR\LibraryHooks\SoapHook SOAP library hook used to intercept SOAP requests. + * @var \VCR\LibraryHooks\SoapHook SOAP library hook used to intercept SOAP requests */ protected $soapHook; /** * @var array */ - protected $options = array(); + protected $options = []; /** * @var string @@ -31,10 +31,10 @@ class SoapClient extends \SoapClient protected $request; /** - * @param mixed $wsdl + * @param mixed $wsdl * @param array $options */ - public function __construct($wsdl, array $options = array()) + public function __construct($wsdl, array $options = []) { $this->options = $options; parent::__construct($wsdl, $options); @@ -45,13 +45,14 @@ public function __construct($wsdl, array $options = array()) * * Requests will be intercepted if the library hook is enabled. * - * @param string $request The XML SOAP request. - * @param string $location The URL to request. - * @param string $action The SOAP action. - * @param integer $version The SOAP version. - * @param integer $one_way If one_way is set to 1, this method returns nothing. - * Use this where a response is not expected. - * @return string|null The XML SOAP response (or null if $one_way is set). + * @param string $request the XML SOAP request + * @param string $location the URL to request + * @param string $action the SOAP action + * @param int $version the SOAP version + * @param int $one_way If one_way is set to 1, this method returns nothing. + * Use this where a response is not expected. + * + * @return string|null the XML SOAP response (or null if $one_way is set) */ public function __doRequest($request, $location, $action, $version, $one_way = 0) { @@ -72,7 +73,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 } /** - * @inheritdoc + * {@inheritdoc} */ public function __getLastRequest(): ?string { @@ -80,7 +81,7 @@ public function __getLastRequest(): ?string } /** - * @inheritdoc + * {@inheritdoc} */ public function __getLastResponse(): ?string { @@ -90,7 +91,7 @@ public function __getLastResponse(): ?string /** * Sets the SOAP library hook which is used to intercept SOAP requests. * - * @param SoapHook $hook SOAP library hook to use when intercepting SOAP requests. + * @param soapHook $hook SOAP library hook to use when intercepting SOAP requests */ public function setLibraryHook(SoapHook $hook): void { @@ -101,13 +102,15 @@ public function setLibraryHook(SoapHook $hook): void * Performs a real SOAP request over HTTP. * * @codeCoverageIgnore - * @param string $request The XML SOAP request. - * @param string $location The URL to request. - * @param string $action The SOAP action. - * @param integer $version The SOAP version. - * @param integer $one_way If one_way is set to 1, this method returns nothing. - * Use this where a response is not expected. - * @return string The XML SOAP response. + * + * @param string $request the XML SOAP request + * @param string $location the URL to request + * @param string $action the SOAP action + * @param int $version the SOAP version + * @param int $one_way If one_way is set to 1, this method returns nothing. + * Use this where a response is not expected. + * + * @return string the XML SOAP response */ protected function realDoRequest(string $request, string $location, string $action, int $version, int $one_way = 0): string { @@ -119,7 +122,7 @@ protected function realDoRequest(string $request, string $location, string $acti * * If no library hook is set, a new one is created. * - * @return SoapHook SOAP library hook. + * @return soapHook SOAP library hook */ protected function getLibraryHook(): SoapHook { diff --git a/src/VCR/Util/StreamHelper.php b/src/VCR/Util/StreamHelper.php index b3bc26d57..c113bd94c 100644 --- a/src/VCR/Util/StreamHelper.php +++ b/src/VCR/Util/StreamHelper.php @@ -5,8 +5,8 @@ use VCR\Request; /** -* Stream helper class. -*/ + * Stream helper class. + */ class StreamHelper { /** @@ -15,11 +15,9 @@ class StreamHelper * If an existing Request is given, the stream context options * are set on the specified Request object. * - * @param resource $context Stream context resource. - * @param string $path Path to use as url. - * @param Request $existing Optional, existing request. - * - * @return Request + * @param resource $context stream context resource + * @param string $path path to use as url + * @param Request $existing optional, existing request */ public static function createRequestFromStreamContext($context, string $path, Request $existing = null): Request { @@ -28,7 +26,7 @@ public static function createRequestFromStreamContext($context, string $path, Re if (empty($request)) { $method = !empty($http['method']) ? $http['method'] : 'GET'; - $request = new Request($method, $path, array()); + $request = new Request($method, $path, []); } if (!empty($http['header'])) { @@ -67,17 +65,19 @@ public static function createRequestFromStreamContext($context, string $path, Re * Returns HTTP options from current stream context. * * @see http://php.net/manual/en/context.http.php + * * @param resource|null $context - * @return array HTTP options. + * + * @return array HTTP options */ protected static function getHttpOptionsFromContext($context): array { if (!$context) { - return array(); + return []; } $options = stream_context_get_options($context); - return !empty($options['http']) ? $options['http'] : array(); + return !empty($options['http']) ? $options['http'] : []; } } diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index ac8e53a9b..b59a835b9 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -2,19 +2,19 @@ namespace VCR\Util; -use Assert\Assertion; -use VCR\Configuration; use VCR\CodeTransform\AbstractCodeTransform; +use VCR\Configuration; /** * Implementation adapted from: - * https://github.com/antecedent/patchwork/blob/418a9aae80ca3228d6763a2dc6d9a30ade7a4e7e/lib/Preprocessor/Stream.php + * https://github.com/antecedent/patchwork/blob/418a9aae80ca3228d6763a2dc6d9a30ade7a4e7e/lib/Preprocessor/Stream.php. * * @author Ignas Rudaitis * @author Adrian Philipp * @copyright 2010-2013 Ignas Rudaitis * @license http://www.opensource.org/licenses/mit-license.html - * @link http://antecedent.github.com/patchwork + * + * @see http://antecedent.github.com/patchwork */ class StreamProcessor { @@ -34,18 +34,19 @@ class StreamProcessor protected static $configuration; /** - * @var AbstractCodeTransform[] $codeTransformers Transformers which have been appended to this stream processor. + * @var AbstractCodeTransform[] transformers which have been appended to this stream processor */ - protected static $codeTransformers = array(); + protected static $codeTransformers = []; /** - * @var resource|false Resource for the currently opened file. + * @var resource|false resource for the currently opened file */ protected $resource; /** - * @link http://www.php.net/manual/en/class.streamwrapper.php#streamwrapper.props.context - * @var resource The current context, or NULL if no context was passed to the caller function. + * @see http://www.php.net/manual/en/class.streamwrapper.php#streamwrapper.props.context + * + * @var resource the current context, or NULL if no context was passed to the caller function */ public $context; @@ -55,7 +56,6 @@ class StreamProcessor protected $isIntercepting = false; /** - * * @param Configuration $configuration */ public function __construct(Configuration $configuration = null) @@ -67,8 +67,6 @@ public function __construct(Configuration $configuration = null) /** * Registers current class as the PHP file stream wrapper. - * - * @return void */ public function intercept(): void { @@ -81,8 +79,6 @@ public function intercept(): void /** * Restores the original file stream wrapper status. - * - * @return void */ public function restore(): void { @@ -92,9 +88,7 @@ public function restore(): void /** * Determines that the provided url is member of a url whitelist. * - * @param string $uri - * - * @return bool True if the specified url is whitelisted, false otherwise. + * @return bool true if the specified url is whitelisted, false otherwise */ protected function isWhitelisted(string $uri): bool { @@ -107,7 +101,7 @@ protected function isWhitelisted(string $uri): bool $uri = $this->normalizePath($uri); foreach ($whiteList as $path) { - if (strpos($uri, $path) !== false) { + if (false !== strpos($uri, $path)) { return true; } } @@ -118,16 +112,14 @@ protected function isWhitelisted(string $uri): bool /** * Determines that the provided url is member of a url blacklist. * - * @param string $uri - * - * @return bool True if the provided url is blacklisted, false otherwise. + * @return bool true if the provided url is blacklisted, false otherwise */ protected function isBlacklisted(string $uri): bool { $uri = $this->normalizePath($uri); foreach (static::$configuration->getBlackList() as $path) { - if (strpos($uri, $path) !== false) { + if (false !== strpos($uri, $path)) { return true; } } @@ -137,22 +129,12 @@ protected function isBlacklisted(string $uri): bool /** * Determines that the provided uri leads to a PHP file. - * - * @param string $uri - * - * @return bool */ protected function isPhpFile(string $uri): bool { - return pathinfo($uri, PATHINFO_EXTENSION) === 'php'; + return 'php' === pathinfo($uri, PATHINFO_EXTENSION); } - /** - * - * @param string $uri - * - * @return bool - */ protected function shouldProcess(string $uri): bool { return $this->isWhitelisted($uri) && !$this->isBlacklisted($uri) && $this->isPhpFile($uri); @@ -161,15 +143,15 @@ protected function shouldProcess(string $uri): bool /** * Opens a stream and attaches registered filters. * - * @param string $path Specifies the URL that was passed to the original function. - * @param string $mode The mode used to open the file, as detailed for fopen(). - * @param integer $options Holds additional flags set by the streams API. - * It can hold one or more of the following values OR'd together. - * @param string $openedPath If the path is opened successfully, and STREAM_USE_PATH is set in options, - * opened_path should be set to the full path of the file/resource that was - * actually opened. + * @param string $path specifies the URL that was passed to the original function + * @param string $mode the mode used to open the file, as detailed for fopen() + * @param int $options Holds additional flags set by the streams API. + * It can hold one or more of the following values OR'd together. + * @param string $openedPath if the path is opened successfully, and STREAM_USE_PATH is set in options, + * opened_path should be set to the full path of the file/resource that was + * actually opened * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool { @@ -186,25 +168,23 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH)); } - if ($this->resource !== false && $options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { + if (false !== $this->resource && $options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { $this->appendFiltersToStream($this->resource); } $this->intercept(); - return $this->resource !== false; + return false !== $this->resource; } /** * Close an resource. * - * @link http://www.php.net/manual/en/streamwrapper.stream-close.php - * - * @return boolean + * @see http://www.php.net/manual/en/streamwrapper.stream-close.php */ public function stream_close(): bool { - if ($this->resource === false) { + if (false === $this->resource) { return true; } @@ -214,14 +194,14 @@ public function stream_close(): bool /** * Tests for end-of-file on a file pointer. * - * @link http://www.php.net/manual/en/streamwrapper.stream-eof.php + * @see http://www.php.net/manual/en/streamwrapper.stream-eof.php * - * @return boolean Should return TRUE if the read/write position is at the end of the stream - * and if no more data is available to be read, or FALSE otherwise. + * @return bool should return TRUE if the read/write position is at the end of the stream + * and if no more data is available to be read, or FALSE otherwise */ public function stream_eof(): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -231,13 +211,11 @@ public function stream_eof(): bool /** * Flushes the output. * - * @link http://www.php.net/manual/en/streamwrapper.stream-flush.php - * - * @return boolean + * @see http://www.php.net/manual/en/streamwrapper.stream-flush.php */ public function stream_flush(): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -247,15 +225,16 @@ public function stream_flush(): bool /** * Read from stream. * - * @link http://www.php.net/manual/en/streamwrapper.stream-read.php - * @param int $count How many bytes of data from the current position should be returned. + * @see http://www.php.net/manual/en/streamwrapper.stream-read.php + * + * @param int $count how many bytes of data from the current position should be returned * * @return string|false If there are less than count bytes available, return as many as are available. * If no more data is available, return either FALSE or an empty string. */ public function stream_read(int $count) { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -265,20 +244,21 @@ public function stream_read(int $count) /** * Seeks to specific location in a stream. * - * @param integer $offset The stream offset to seek to. - * @param integer $whence Possible values: - * SEEK_SET - Set position equal to offset bytes. - * SEEK_CUR - Set position to current location plus offset. - * SEEK_END - Set position to end-of-file plus offset. - * @return boolean Return TRUE if the position was updated, FALSE otherwise. + * @param int $offset the stream offset to seek to + * @param int $whence Possible values: + * SEEK_SET - Set position equal to offset bytes. + * SEEK_CUR - Set position to current location plus offset. + * SEEK_END - Set position to end-of-file plus offset. + * + * @return bool return TRUE if the position was updated, FALSE otherwise */ public function stream_seek(int $offset, int $whence = SEEK_SET): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } - return fseek($this->resource, $offset, $whence) === 0; + return 0 === fseek($this->resource, $offset, $whence); } /** @@ -288,9 +268,9 @@ public function stream_seek(int $offset, int $whence = SEEK_SET): bool * after having all transformations applied. When including files, PHP 7.4 and newer are sensitive * to file size reported by stat. * - * @link http://www.php.net/manual/en/streamwrapper.stream-stat.php + * @see http://www.php.net/manual/en/streamwrapper.stream-stat.php * - * @return array|false See stat(). + * @return array|false see stat() */ public function stream_stat() { @@ -302,13 +282,13 @@ public function stream_stat() * * This method is called in response to fseek() to determine the current position. * - * @link http://www.php.net/manual/en/streamwrapper.stream-tell.php + * @see http://www.php.net/manual/en/streamwrapper.stream-tell.php * - * @return integer|false Should return the current position of the stream. + * @return int|false should return the current position of the stream */ public function stream_tell() { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -318,12 +298,12 @@ public function stream_tell() /** * Retrieve information about a file. * - * @link http://www.php.net/manual/en/streamwrapper.url-stat.php + * @see http://www.php.net/manual/en/streamwrapper.url-stat.php * - * @param string $path The file path or URL to stat. - * @param integer $flags Holds additional flags set by the streams API. + * @param string $path the file path or URL to stat + * @param int $flags holds additional flags set by the streams API * - * @return array|false Should return as many elements as stat() does. + * @return array|false should return as many elements as stat() does */ public function url_stat(string $path, int $flags) { @@ -346,13 +326,13 @@ public function url_stat(string $path, int $flags) /** * Close directory handle. * - * @link http://www.php.net/manual/en/streamwrapper.dir-closedir.php + * @see http://www.php.net/manual/en/streamwrapper.dir-closedir.php * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function dir_closedir(): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -364,11 +344,11 @@ public function dir_closedir(): bool /** * Open directory handle. * - * @link http://www.php.net/manual/en/streamwrapper.dir-opendir.php + * @see http://www.php.net/manual/en/streamwrapper.dir-opendir.php * - * @param string $path The file path or URL to stat. + * @param string $path the file path or URL to stat * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function dir_opendir(string $path): bool { @@ -380,19 +360,19 @@ public function dir_opendir(string $path): bool } $this->intercept(); - return $this->resource !== false; + return false !== $this->resource; } /** * Read entry from directory handle. * - * @link http://www.php.net/manual/en/streamwrapper.dir-readdir.php + * @see http://www.php.net/manual/en/streamwrapper.dir-readdir.php * - * @return mixed Should return string representing the next filename, or FALSE if there is no next file. + * @return mixed should return string representing the next filename, or FALSE if there is no next file */ public function dir_readdir() { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -402,13 +382,13 @@ public function dir_readdir() /** * Rewind directory handle. * - * @link http://www.php.net/manual/en/streamwrapper.dir-rewinddir.php + * @see http://www.php.net/manual/en/streamwrapper.dir-rewinddir.php * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function dir_rewinddir(): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -420,21 +400,21 @@ public function dir_rewinddir(): bool /** * Create a directory. * - * @link http://www.php.net/manual/en/streamwrapper.mkdir.php + * @see http://www.php.net/manual/en/streamwrapper.mkdir.php * - * @param string $path Directory which should be created. - * @param int $mode The value passed to mkdir(). - * @param integer $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE. + * @param string $path directory which should be created + * @param int $mode the value passed to mkdir() + * @param int $options a bitwise mask of values, such as STREAM_MKDIR_RECURSIVE * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function mkdir(string $path, int $mode, int $options): bool { $this->restore(); if (isset($this->context)) { - $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE), $this->context); + $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE), $this->context); } else { - $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE)); + $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE)); } $this->intercept(); @@ -444,12 +424,12 @@ public function mkdir(string $path, int $mode, int $options): bool /** * Renames a file or directory. * - * @link http://www.php.net/manual/en/streamwrapper.rename.php + * @see http://www.php.net/manual/en/streamwrapper.rename.php * - * @param string $path_from The URL to the current file. - * @param string $path_to The URL which the path_from should be renamed to. + * @param string $path_from the URL to the current file + * @param string $path_to the URL which the path_from should be renamed to * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function rename(string $path_from, string $path_to): bool { @@ -465,13 +445,13 @@ public function rename(string $path_from, string $path_to): bool } /** - * Removes a directory + * Removes a directory. * - * @link http://www.php.net/manual/en/streamwrapper.rmdir.php + * @see http://www.php.net/manual/en/streamwrapper.rmdir.php * - * @param string $path The directory URL which should be removed. + * @param string $path the directory URL which should be removed * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function rmdir(string $path): bool { @@ -489,11 +469,12 @@ public function rmdir(string $path): bool /** * Retrieve the underlaying resource. * - * @link http://www.php.net/manual/en/streamwrapper.stream-cast.php + * @see http://www.php.net/manual/en/streamwrapper.stream-cast.php + * + * @param int $cast_as can be STREAM_CAST_FOR_SELECT when stream_select() is calling stream_cast() or + * STREAM_CAST_AS_STREAM when stream_cast() is called for other uses * - * @param integer $cast_as Can be STREAM_CAST_FOR_SELECT when stream_select() is calling stream_cast() or - * STREAM_CAST_AS_STREAM when stream_cast() is called for other uses. - * @return resource|false Should return the underlying stream resource used by the wrapper, or FALSE. + * @return resource|false should return the underlying stream resource used by the wrapper, or FALSE */ public function stream_cast(int $cast_as) { @@ -503,19 +484,20 @@ public function stream_cast(int $cast_as) /** * Advisory file locking. * - * @link http://www.php.net/manual/en/streamwrapper.stream-lock.php + * @see http://www.php.net/manual/en/streamwrapper.stream-lock.php * - * @param integer $operation One of the operation constantes. + * @param int $operation one of the operation constantes * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function stream_lock(int $operation): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } - $operation = ($operation === 0 ? LOCK_EX : $operation); + $operation = (0 === $operation ? LOCK_EX : $operation); + return flock($this->resource, $operation); } @@ -524,16 +506,16 @@ public function stream_lock(int $operation): bool * * @codeCoverageIgnore * - * @param int $option One of STREAM_OPTION_BLOCKING, STREAM_OPTION_READ_TIMEOUT, STREAM_OPTION_WRITE_BUFFER. - * @param int $arg1 Depending on option. - * @param int $arg2 Depending on option. + * @param int $option one of STREAM_OPTION_BLOCKING, STREAM_OPTION_READ_TIMEOUT, STREAM_OPTION_WRITE_BUFFER + * @param int $arg1 depending on option + * @param int $arg2 depending on option * - * @return boolean Returns TRUE on success or FALSE on failure. If option is not implemented, - * FALSE should be returned. + * @return bool Returns TRUE on success or FALSE on failure. If option is not implemented, + * FALSE should be returned. */ public function stream_set_option(int $option, int $arg1, int $arg2): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -544,30 +526,32 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool return stream_set_timeout($this->resource, $arg1, $arg2); case STREAM_OPTION_WRITE_BUFFER: // stream_set_write_buffer returns 0 in case of success - return stream_set_write_buffer($this->resource, $arg1) === 0; + return 0 === stream_set_write_buffer($this->resource, $arg1); case STREAM_OPTION_READ_BUFFER: // stream_set_read_buffer returns 0 in case of success - return stream_set_read_buffer($this->resource, $arg1) === 0; + return 0 === stream_set_read_buffer($this->resource, $arg1); // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 /*case STREAM_OPTION_CHUNK_SIZE: return stream_set_chunk_size($this->resource, $arg1);*/ } + return false; } /** * Write to stream. * - * @throws \BadMethodCallException If called, because this method is not applicable for this stream. - * @link http://www.php.net/manual/en/streamwrapper.stream-write.php + * @throws \BadMethodCallException if called, because this method is not applicable for this stream * - * @param string $data Should be stored into the underlying stream. + * @see http://www.php.net/manual/en/streamwrapper.stream-write.php + * + * @param string $data should be stored into the underlying stream * * @return int|false */ public function stream_write(string $data) { - if ($this->resource === false) { + if (false === $this->resource) { return false; } @@ -577,11 +561,11 @@ public function stream_write(string $data) /** * Delete a file. * - * @link http://www.php.net/manual/en/streamwrapper.unlink.php + * @see http://www.php.net/manual/en/streamwrapper.unlink.php * - * @param string $path The file URL which should be deleted. + * @param string $path the file URL which should be deleted * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function unlink(string $path): bool { @@ -599,12 +583,13 @@ public function unlink(string $path): bool /** * Change stream options. * - * @link http://www.php.net/manual/en/streamwrapper.stream-metadata.php - * @param string $path The file path or URL to set metadata. - * @param integer $option One of the stream options. - * @param mixed $value Value depending on the option. + * @see http://www.php.net/manual/en/streamwrapper.stream-metadata.php + * + * @param string $path the file path or URL to set metadata + * @param int $option one of the stream options + * @param mixed $value value depending on the option * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function stream_metadata(string $path, int $option, $value): bool { @@ -639,27 +624,23 @@ public function stream_metadata(string $path, int $option, $value): bool /** * Truncate stream. * - * @link http://www.php.net/manual/en/streamwrapper.stream-truncate.php + * @see http://www.php.net/manual/en/streamwrapper.stream-truncate.php * - * @param integer $new_size The new size. + * @param int $new_size the new size * - * @return boolean Returns TRUE on success or FALSE on failure. + * @return bool returns TRUE on success or FALSE on failure */ public function stream_truncate(int $new_size): bool { - if ($this->resource === false) { + if (false === $this->resource) { return false; } - + return ftruncate($this->resource, $new_size); } /** * Adds code transformer to the stream processor. - * - * @param AbstractCodeTransform $codeTransformer - * - * @return void */ public function appendCodeTransformer(AbstractCodeTransform $codeTransformer): void { @@ -668,10 +649,6 @@ public function appendCodeTransformer(AbstractCodeTransform $codeTransformer): v /** * Removes a code transformer from the stream processor. - * - * @param AbstractCodeTransform $codeTransformer - * - * @return void */ public function detachCodeTransformer(AbstractCodeTransform $codeTransformer): void { @@ -694,15 +671,11 @@ protected function appendFiltersToStream($stream): void /** * Normalizes the path, to always use the slash as directory separator. - * - * @param string $path - * - * @return string */ private function normalizePath(string $path): string { - if (DIRECTORY_SEPARATOR !== '/') { - return str_replace(DIRECTORY_SEPARATOR, '/', $path); + if (\DIRECTORY_SEPARATOR !== '/') { + return str_replace(\DIRECTORY_SEPARATOR, '/', $path); } return $path; diff --git a/src/VCR/Util/TextUtil.php b/src/VCR/Util/TextUtil.php index 12a3fa7e3..ee7b6e995 100644 --- a/src/VCR/Util/TextUtil.php +++ b/src/VCR/Util/TextUtil.php @@ -12,9 +12,9 @@ class TextUtil * * Example: curl_multi_exec -> curlMultiExec * - * @param string $underscore Lowercased text. + * @param string $underscore lowercased text * - * @return string Lowercase camelcased version of specified text. + * @return string lowercase camelcased version of specified text */ public static function underscoreToLowerCamelcase(string $underscore): string { diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index 86784390d..b684c6e5f 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -31,8 +31,8 @@ class VCR const MODE_NONE = 'none'; /** - * @param string $method * @param mixed[] $parameters + * * @return mixed */ public static function __callStatic(string $method, array $parameters) @@ -41,6 +41,6 @@ public static function __callStatic(string $method, array $parameters) Assertion::isCallable($callable); - return call_user_func_array($callable, $parameters); + return \call_user_func_array($callable, $parameters); } } diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index c4d2bcc84..a629eb5b3 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -6,7 +6,6 @@ use VCR\LibraryHooks\SoapHook; use VCR\Storage\Storage; use VCR\Util\StreamProcessor; -use VCR\Util\Assertion; class VCRFactory { @@ -18,7 +17,7 @@ class VCRFactory /** * @var array */ - protected $mapping = array(); + protected $mapping = []; /** * @var self|null @@ -35,9 +34,6 @@ protected function __construct(Configuration $config = null) $this->config = $config ?: $this->getOrCreate('VCR\Configuration'); } - /** - * @return Videorecorder - */ protected function createVCRVideorecorder(): Videorecorder { return new Videorecorder( @@ -49,8 +45,6 @@ protected function createVCRVideorecorder(): Videorecorder /** * Provides an instance of the StreamProcessor. - * - * @return StreamProcessor */ protected function createVCRUtilStreamProcessor(): StreamProcessor { @@ -85,7 +79,7 @@ protected function createVCRLibraryHooksCurlHook(): CurlHook /** * Returns the same VCRFactory instance on ever call (singleton). * - * @param Configuration $config (Optional) configuration. + * @param Configuration $config (Optional) configuration * * @return VCRFactory */ @@ -101,12 +95,12 @@ public static function getInstance(Configuration $config = null): self /** * Returns an instance for specified class name and parameters. * - * @param string $className Class name to get a instance for. - * @param mixed[] $params Constructor arguments for this class. + * @param string $className class name to get a instance for + * @param mixed[] $params constructor arguments for this class * - * @return mixed An instance for specified class name and parameters. + * @return mixed an instance for specified class name and parameters */ - public static function get(string $className, array $params = array()) + public static function get(string $className, array $params = []) { return self::getInstance()->getOrCreate($className, $params); } @@ -114,14 +108,14 @@ public static function get(string $className, array $params = array()) /** * Returns an instance for specified classname and parameters. * - * @param string $className Class name to get a instance for. - * @param mixed[] $params Constructor arguments for this class. + * @param string $className class name to get a instance for + * @param mixed[] $params constructor arguments for this class * * @return mixed */ - public function getOrCreate(string $className, array $params = array()) + public function getOrCreate(string $className, array $params = []) { - $key = $className . join('-', $params); + $key = $className.implode('-', $params); if (isset($this->mapping[$key])) { return $this->mapping[$key]; @@ -129,28 +123,23 @@ public function getOrCreate(string $className, array $params = array()) $callable = [$this, $this->getMethodName($className)]; - if (is_callable($callable)) { - $instance = call_user_func_array($callable, $params); + if (\is_callable($callable)) { + $instance = \call_user_func_array($callable, $params); } else { - $instance = new $className; + $instance = new $className(); } return $this->mapping[$key] = $instance; } /** - * - * Example: + * Example:. * * ClassName: \Tux\Foo\Linus * Returns: createTuxFooLinus - * - * @param string $className - * - * @return string */ protected function getMethodName(string $className): string { - return 'create' . str_replace('\\', '', $className); + return 'create'.str_replace('\\', '', $className); } } diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 950178846..9d5bd1b17 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -2,16 +2,16 @@ namespace VCR; -use VCR\Event\Event; -use VCR\Util\Assertion; -use VCR\Util\HttpClient; +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use VCR\Event\AfterHttpRequestEvent; use VCR\Event\AfterPlaybackEvent; use VCR\Event\BeforeHttpRequestEvent; use VCR\Event\BeforePlaybackEvent; use VCR\Event\BeforeRecordEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; +use VCR\Event\Event; +use VCR\Util\Assertion; +use VCR\Util\HttpClient; /** * A videorecorder records requests on a cassette. @@ -30,27 +30,27 @@ class Videorecorder { /** - * @var Configuration Config options like which library hooks to use. + * @var Configuration config options like which library hooks to use */ protected $config; /** - * @var HttpClient Client to use to issue HTTP requests. + * @var HttpClient client to use to issue HTTP requests */ protected $client; /** - * @var VCRFactory Factory which can create instances and resolve dependencies. + * @var VCRFactory factory which can create instances and resolve dependencies */ protected $factory; /** - * @var Cassette|null Cassette on which to store requests and responses. + * @var Cassette|null cassette on which to store requests and responses */ protected $cassette; /** - * @var boolean Flag if this videorecorder is turned on or not. + * @var bool flag if this videorecorder is turned on or not */ protected $isOn = false; @@ -62,9 +62,9 @@ class Videorecorder /** * Creates a videorecorder instance. * - * @param Configuration $config Config options like which library hooks to use. - * @param HttpClient $client Client which is used to issue HTTP requests. - * @param VCRFactory $factory Factory which can create instances and resolve dependencies. + * @param Configuration $config config options like which library hooks to use + * @param HttpClient $client client which is used to issue HTTP requests + * @param VCRFactory $factory factory which can create instances and resolve dependencies */ public function __construct(Configuration $config, HttpClient $client, VCRFactory $factory) { @@ -73,31 +73,25 @@ public function __construct(Configuration $config, HttpClient $client, VCRFactor $this->factory = $factory; } - /** - * @param EventDispatcherInterface $dispatcher - */ public function setEventDispatcher(EventDispatcherInterface $dispatcher): void { $this->eventDispatcher = $dispatcher; } - /** - * @return EventDispatcherInterface - */ public function getEventDispatcher(): EventDispatcherInterface { if (!$this->eventDispatcher) { $this->eventDispatcher = new EventDispatcher(); } + return $this->eventDispatcher; } /** * Dispatches an event to all registered listeners. * - * @param Event $event The event to pass to the event handlers/listeners. - * @param string $eventName The name of the event to dispatch. - * @return Event + * @param Event $event the event to pass to the event handlers/listeners + * @param string $eventName the name of the event to dispatch */ private function dispatch(Event $event, $eventName = null): Event { @@ -122,8 +116,6 @@ private function dispatch(Event $event, $eventName = null): Event * This enables configured library hooks. * * @api - * - * @return void */ public function turnOn(): void { @@ -141,8 +133,6 @@ public function turnOn(): void * Library hooks will be disabled and cassettes ejected. * * @api - * - * @return void */ public function turnOff(): void { @@ -159,8 +149,6 @@ public function turnOff(): void * Recording and playing back requests won't be possible after ejecting. * * @api - * - * @return void */ public function eject(): void { @@ -173,20 +161,19 @@ public function eject(): void * * @api * - * @param string $cassetteName Name of the cassette (used for the cassette filename). + * @param string $cassetteName name of the cassette (used for the cassette filename) * - * @return void - * @throws VCRException If videorecorder is turned off when inserting a cassette. + * @throws VCRException if videorecorder is turned off when inserting a cassette */ public function insertCassette(string $cassetteName): void { Assertion::true($this->isOn, 'Please turn on VCR before inserting a cassette, use: VCR::turnOn().'); - if (!is_null($this->cassette)) { + if (null !== $this->cassette) { $this->eject(); } - $storage = $this->factory->get('Storage', array($cassetteName)); + $storage = $this->factory->get('Storage', [$cassetteName]); $this->cassette = new Cassette($cassetteName, $this->config, $storage); $this->enableLibraryHooks(); @@ -197,7 +184,7 @@ public function insertCassette(string $cassetteName): void * * @api * - * @return Configuration Configuration for this videorecorder. + * @return Configuration configuration for this videorecorder */ public function configure(): Configuration { @@ -212,21 +199,18 @@ public function configure(): Configuration * * @api * - * @param Request $request Intercepted request. + * @param Request $request intercepted request * - * @return Response Response for the intercepted request. - * @throws \BadMethodCallException If there was no cassette inserted. - * @throws \LogicException If the mode is set to none or once and - * the cassette did not have a matching response. + * @return Response response for the intercepted request + * + * @throws \BadMethodCallException if there was no cassette inserted + * @throws \LogicException if the mode is set to none or once and + * the cassette did not have a matching response */ public function handleRequest(Request $request): Response { - if ($this->cassette === null) { - throw new \BadMethodCallException( - 'Invalid http request. No cassette inserted. ' - . 'Please make sure to insert a cassette in your unit test using ' - . "VCR::insertCassette('name');" - ); + if (null === $this->cassette) { + throw new \BadMethodCallException('Invalid http request. No cassette inserted. '.'Please make sure to insert a cassette in your unit test using '."VCR::insertCassette('name');"); } $event = new BeforePlaybackEvent($request, $this->cassette); @@ -238,24 +222,15 @@ public function handleRequest(Request $request): Response if (!empty($response)) { $event = new AfterPlaybackEvent($request, $response, $this->cassette); $this->dispatch($event, VCREvents::VCR_AFTER_PLAYBACK); + return $response; } if (VCR::MODE_NONE === $this->config->getMode() || VCR::MODE_ONCE === $this->config->getMode() - && $this->cassette->isNew() === false + && false === $this->cassette->isNew() ) { - throw new \LogicException( - sprintf( - "The request does not match a previously recorded request and the 'mode' is set to '%s'. " - . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. " - . 'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.' - . "\nCassette: %s \n Request: %s", - $this->config->getMode(), - $this->cassette->getName(), - print_r($request->toArray(), true) - ) - ); + throw new \LogicException(sprintf("The request does not match a previously recorded request and the 'mode' is set to '%s'. "."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. ".'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.'."\nCassette: %s \n Request: %s", $this->config->getMode(), $this->cassette->getName(), print_r($request->toArray(), true))); } $this->disableLibraryHooks(); @@ -278,8 +253,6 @@ public function handleRequest(Request $request): Response * Disables all library hooks. * * @api - * - * @return void */ protected function disableLibraryHooks(): void { @@ -293,8 +266,6 @@ protected function disableLibraryHooks(): void * Enables configured library hooks. * * @api - * - * @return void */ protected function enableLibraryHooks(): void { diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index 5372ddb96..e9b14d16d 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -10,7 +10,6 @@ */ class CassetteTest extends TestCase { - /** * @var Cassette */ @@ -30,8 +29,8 @@ public function testGetName() public function testDontOverwriteRecord() { $request = new Request('GET', 'https://example.com'); - $response1 = new Response(200, array(), 'sometest'); - $response2 = new Response(200, array(), 'sometest'); + $response1 = new Response(200, [], 'sometest'); + $response2 = new Response(200, [], 'sometest'); $this->cassette->record($request, $response1); $this->cassette->record($request, $response2); @@ -41,7 +40,7 @@ public function testDontOverwriteRecord() public function testPlaybackAlreadyRecordedRequest() { $request = new Request('GET', 'https://example.com'); - $response = new Response(200, array(), 'sometest'); + $response = new Response(200, [], 'sometest'); $this->cassette->record($request, $response); $this->assertEquals($response->toArray(), $this->cassette->playback($request)->toArray()); @@ -57,7 +56,7 @@ public function testHasResponseNotFound() public function testHasResponseFound() { $request = new Request('GET', 'https://example.com'); - $response = new Response(200, array(), 'sometest'); + $response = new Response(200, [], 'sometest'); $this->cassette->record($request, $response); $this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.'); diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 3cfe0b23a..8ec6f6c8d 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -6,10 +6,10 @@ class AbstractCodeTransformTest extends TestCase { - protected function getFilter(array $methods = array()) + protected function getFilter(array $methods = []) { $defaults = array_merge( - array('transformCode'), + ['transformCode'], $methods ); @@ -17,12 +17,12 @@ protected function getFilter(array $methods = array()) ->setMethods($defaults) ->getMockForAbstractClass(); - if (in_array('transformCode', $methods)) { + if (\in_array('transformCode', $methods)) { $filter ->expects($this->once()) ->method('transformCode') ->with($this->isType('string')) - ->will($this->returnArgument(0)); + ->willReturnArgument(0); } return $filter; diff --git a/tests/VCR/CodeTransform/CurlCodeTransformTest.php b/tests/VCR/CodeTransform/CurlCodeTransformTest.php index 426ccd457..1f5e700db 100644 --- a/tests/VCR/CodeTransform/CurlCodeTransformTest.php +++ b/tests/VCR/CodeTransform/CurlCodeTransformTest.php @@ -2,7 +2,6 @@ namespace VCR\CodeTransform; -use lapistano\ProxyObject\ProxyBuilder; use PHPUnit\Framework\TestCase; class CurlCodeTransformTest extends TestCase @@ -12,7 +11,7 @@ class CurlCodeTransformTest extends TestCase */ public function testTransformCode($expected, $code) { - $codeTransform = new class extends CurlCodeTransform { + $codeTransform = new class() extends CurlCodeTransform { // A proxy to access the protected transformCode method. public function publicTransformCode(string $code): string { @@ -25,48 +24,48 @@ public function publicTransformCode(string $code): string public function codeSnippetProvider() { - return array( - array('\VCR\LibraryHooks\CurlHook::curl_init(', 'CURL_INIT ('), - array('\VCR\LibraryHooks\CurlHook::curl_exec(', 'curl_exec('), - array('\VCR\LibraryHooks\CurlHook::curl_getinfo(', 'curl_getinfo('), - array('\VCR\LibraryHooks\CurlHook::curl_setopt(', 'curl_setopt('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', 'curl_multi_add_handle('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', 'curl_multi_remove_handle('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_exec(', 'curl_multi_exec('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', 'curl_multi_info_read('), - array('\VCR\LibraryHooks\CurlHook::curl_reset(', 'curl_reset('), + return [ + ['\VCR\LibraryHooks\CurlHook::curl_init(', 'CURL_INIT ('], + ['\VCR\LibraryHooks\CurlHook::curl_exec(', 'curl_exec('], + ['\VCR\LibraryHooks\CurlHook::curl_getinfo(', 'curl_getinfo('], + ['\VCR\LibraryHooks\CurlHook::curl_setopt(', 'curl_setopt('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', 'curl_multi_add_handle('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', 'curl_multi_remove_handle('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_exec(', 'curl_multi_exec('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', 'curl_multi_info_read('], + ['\VCR\LibraryHooks\CurlHook::curl_reset(', 'curl_reset('], - array('\VCR\LibraryHooks\CurlHook::curl_init(', '\\CURL_INIT ('), - array('\VCR\LibraryHooks\CurlHook::curl_exec(', '\\curl_exec('), - array('\VCR\LibraryHooks\CurlHook::curl_getinfo(', '\\curl_getinfo('), - array('\VCR\LibraryHooks\CurlHook::curl_setopt(', '\\curl_setopt('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', '\\curl_multi_add_handle('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', '\\curl_multi_remove_handle('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_exec(', '\\curl_multi_exec('), - array('\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', '\\curl_multi_info_read('), - array('\VCR\LibraryHooks\CurlHook::curl_reset(', '\\curl_reset('), + ['\VCR\LibraryHooks\CurlHook::curl_init(', '\\CURL_INIT ('], + ['\VCR\LibraryHooks\CurlHook::curl_exec(', '\\curl_exec('], + ['\VCR\LibraryHooks\CurlHook::curl_getinfo(', '\\curl_getinfo('], + ['\VCR\LibraryHooks\CurlHook::curl_setopt(', '\\curl_setopt('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_add_handle(', '\\curl_multi_add_handle('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', '\\curl_multi_remove_handle('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_exec(', '\\curl_multi_exec('], + ['\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', '\\curl_multi_info_read('], + ['\VCR\LibraryHooks\CurlHook::curl_reset(', '\\curl_reset('], - array('SomeClass::CURL_INIT (', 'SomeClass::CURL_INIT ('), - array('SomeClass::curl_exec(', 'SomeClass::curl_exec('), - array('SomeClass::curl_getinfo(', 'SomeClass::curl_getinfo('), - array('SomeClass::curl_setopt(', 'SomeClass::curl_setopt('), - array('SomeClass::curl_multi_add_handle(', 'SomeClass::curl_multi_add_handle('), - array('SomeClass::curl_multi_remove_handle(', 'SomeClass::curl_multi_remove_handle('), - array('SomeClass::curl_multi_exec(', 'SomeClass::curl_multi_exec('), - array('SomeClass::curl_multi_info_read(', 'SomeClass::curl_multi_info_read('), - array('SomeClass::curl_reset(', 'SomeClass::curl_reset('), + ['SomeClass::CURL_INIT (', 'SomeClass::CURL_INIT ('], + ['SomeClass::curl_exec(', 'SomeClass::curl_exec('], + ['SomeClass::curl_getinfo(', 'SomeClass::curl_getinfo('], + ['SomeClass::curl_setopt(', 'SomeClass::curl_setopt('], + ['SomeClass::curl_multi_add_handle(', 'SomeClass::curl_multi_add_handle('], + ['SomeClass::curl_multi_remove_handle(', 'SomeClass::curl_multi_remove_handle('], + ['SomeClass::curl_multi_exec(', 'SomeClass::curl_multi_exec('], + ['SomeClass::curl_multi_info_read(', 'SomeClass::curl_multi_info_read('], + ['SomeClass::curl_reset(', 'SomeClass::curl_reset('], - array('$object->CURL_INIT (', '$object->CURL_INIT ('), - array('$object->curl_exec(', '$object->curl_exec('), - array('$object->curl_getinfo(', '$object->curl_getinfo('), - array('$object->curl_setopt(', '$object->curl_setopt('), - array('$object->curl_multi_add_handle(', '$object->curl_multi_add_handle('), - array('$object->curl_multi_remove_handle(', '$object->curl_multi_remove_handle('), - array('$object->curl_multi_exec(', '$object->curl_multi_exec('), - array('$object->curl_multi_info_read(', '$object->curl_multi_info_read('), - array('$object->curl_reset(', '$object->curl_reset('), + ['$object->CURL_INIT (', '$object->CURL_INIT ('], + ['$object->curl_exec(', '$object->curl_exec('], + ['$object->curl_getinfo(', '$object->curl_getinfo('], + ['$object->curl_setopt(', '$object->curl_setopt('], + ['$object->curl_multi_add_handle(', '$object->curl_multi_add_handle('], + ['$object->curl_multi_remove_handle(', '$object->curl_multi_remove_handle('], + ['$object->curl_multi_exec(', '$object->curl_multi_exec('], + ['$object->curl_multi_info_read(', '$object->curl_multi_info_read('], + ['$object->curl_reset(', '$object->curl_reset('], - array('function send_http_asynchronous_curl_exec(', 'function send_http_asynchronous_curl_exec(') - ); + ['function send_http_asynchronous_curl_exec(', 'function send_http_asynchronous_curl_exec('], + ]; } } diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/VCR/CodeTransform/SoapCodeTransformTest.php index f0ac0f0d9..54db015a2 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/VCR/CodeTransform/SoapCodeTransformTest.php @@ -2,7 +2,6 @@ namespace VCR\CodeTransform; -use lapistano\ProxyObject\ProxyBuilder; use PHPUnit\Framework\TestCase; class SoapCodeTransformTest extends TestCase @@ -12,7 +11,7 @@ class SoapCodeTransformTest extends TestCase */ public function testTransformCode($expected, $code) { - $codeTransform = new class extends SoapCodeTransform { + $codeTransform = new class() extends SoapCodeTransform { // A proxy to access the protected transformCode method. public function publicTransformCode(string $code): string { @@ -25,13 +24,13 @@ public function publicTransformCode(string $code): string public function codeSnippetProvider() { - return array( - array('new \VCR\Util\SoapClient(', 'new \SoapClient('), - array('new \VCR\Util\SoapClient(', 'new SoapClient('), - array('extends \VCR\Util\SoapClient', 'extends \SoapClient'), - array("extends \\VCR\\Util\\SoapClient\n", "extends \\SoapClient\n"), - array('new SoapClientExtended(', 'new SoapClientExtended('), - array('new \SoapClientExtended(', 'new \SoapClientExtended('), - ); + return [ + ['new \VCR\Util\SoapClient(', 'new \SoapClient('], + ['new \VCR\Util\SoapClient(', 'new SoapClient('], + ['extends \VCR\Util\SoapClient', 'extends \SoapClient'], + ["extends \\VCR\\Util\\SoapClient\n", "extends \\SoapClient\n"], + ['new SoapClientExtended(', 'new SoapClientExtended('], + ['new \SoapClientExtended(', 'new \SoapClientExtended('], + ]; } } diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index fb052a654..006f261a1 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -4,9 +4,6 @@ use PHPUnit\Framework\TestCase; -/** - * - */ class ConfigurationTest extends TestCase { /** @@ -16,7 +13,7 @@ class ConfigurationTest extends TestCase public function setUp() { - $this->config = new Configuration; + $this->config = new Configuration(); } public function testSetCassettePathThrowsErrorOnInvalidPath() @@ -24,8 +21,8 @@ public function testSetCassettePathThrowsErrorOnInvalidPath() $this->expectException( VCRException::class, "Cassette path 'invalid_path' is not a directory. Please either " - . 'create it or set a different cassette path using ' - . "\\VCR\\VCR::configure()->setCassettePath('directory')." + .'create it or set a different cassette path using ' + ."\\VCR\\VCR::configure()->setCassettePath('directory')." ); $this->config->setCassettePath('invalid_path'); } @@ -33,22 +30,22 @@ public function testSetCassettePathThrowsErrorOnInvalidPath() public function testGetLibraryHooks() { $this->assertEquals( - array( + [ 'VCR\LibraryHooks\StreamWrapperHook', 'VCR\LibraryHooks\CurlHook', 'VCR\LibraryHooks\SoapHook', - ), + ], $this->config->getLibraryHooks() ); } public function testEnableLibraryHooks() { - $this->config->enableLibraryHooks(array('stream_wrapper')); + $this->config->enableLibraryHooks(['stream_wrapper']); $this->assertEquals( - array( + [ 'VCR\LibraryHooks\StreamWrapperHook', - ), + ], $this->config->getLibraryHooks() ); } @@ -57,9 +54,9 @@ public function testEnableSingleLibraryHook() { $this->config->enableLibraryHooks('stream_wrapper'); $this->assertEquals( - array( + [ 'VCR\LibraryHooks\StreamWrapperHook', - ), + ], $this->config->getLibraryHooks() ); } @@ -67,17 +64,17 @@ public function testEnableSingleLibraryHook() public function testEnableLibraryHooksFailsWithWrongHookName() { $this->expectException('InvalidArgumentException', "Library hooks don't exist: non_existing"); - $this->config->enableLibraryHooks(array('non_existing')); + $this->config->enableLibraryHooks(['non_existing']); } public function testEnableRequestMatchers() { - $this->config->enableRequestMatchers(array('body', 'headers')); + $this->config->enableRequestMatchers(['body', 'headers']); $this->assertEquals( - array( - array('VCR\RequestMatcher', 'matchHeaders'), - array('VCR\RequestMatcher', 'matchBody'), - ), + [ + ['VCR\RequestMatcher', 'matchHeaders'], + ['VCR\RequestMatcher', 'matchBody'], + ], $this->config->getRequestMatchers() ); } @@ -85,7 +82,7 @@ public function testEnableRequestMatchers() public function testEnableRequestMatchersFailsWithNoExistingName() { $this->expectException('InvalidArgumentException', "Request matchers don't exist: wrong, name"); - $this->config->enableRequestMatchers(array('wrong', 'name')); + $this->config->enableRequestMatchers(['wrong', 'name']); } public function testAddRequestMatcherFailsWithNoName() @@ -117,10 +114,10 @@ public function testSetStorage($name, $className) public function availableStorageProvider() { - return array( - array('json', 'VCR\Storage\Json'), - array('yaml', 'VCR\Storage\Yaml'), - ); + return [ + ['json', 'VCR\Storage\Json'], + ['yaml', 'VCR\Storage\Yaml'], + ]; } public function testSetStorageInvalidName() @@ -139,7 +136,7 @@ public function testGetStorage() public function testWhitelist() { - $expected = array('Tux', 'Gnu'); + $expected = ['Tux', 'Gnu']; $this->config->setWhiteList($expected); @@ -148,7 +145,7 @@ public function testWhitelist() public function testBlacklist() { - $expected = array('Tux', 'Gnu'); + $expected = ['Tux', 'Gnu']; $this->config->setBlackList($expected); diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index aa8b865e0..2ae55b4cb 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -3,11 +3,11 @@ namespace VCR\Event; use PHPUnit\Framework\TestCase; -use VCR\Request; use VCR\Cassette; use VCR\Configuration; -use VCR\Storage; +use VCR\Request; use VCR\Response; +use VCR\Storage; class AfterPlaybackEventTest extends TestCase { diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/VCR/Event/BeforePlaybackEventTest.php index fddbea780..34a359dc2 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/VCR/Event/BeforePlaybackEventTest.php @@ -3,9 +3,9 @@ namespace VCR\Event; use PHPUnit\Framework\TestCase; -use VCR\Request; use VCR\Cassette; use VCR\Configuration; +use VCR\Request; use VCR\Storage; class BeforePlaybackEventTest extends TestCase diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index f3d9e1800..8b8abcee2 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -3,11 +3,11 @@ namespace VCR\Event; use PHPUnit\Framework\TestCase; -use VCR\Request; use VCR\Cassette; use VCR\Configuration; -use VCR\Storage; +use VCR\Request; use VCR\Response; +use VCR\Storage; class BeforeRecordEventTest extends TestCase { diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index c6c696218..6c6d506cb 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -3,12 +3,12 @@ namespace VCR\LibraryHooks; use Closure; +use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\CurlCodeTransform; +use VCR\Configuration; use VCR\Request; use VCR\Response; -use VCR\Configuration; use VCR\Util\StreamProcessor; -use PHPUnit\Framework\TestCase; -use VCR\CodeTransform\CurlCodeTransform; /** * Test if intercepting http/https using curl works. @@ -128,16 +128,17 @@ public function testShouldPostFieldsAsArray() $this->curlHook->enable( function (Request $request) use ($testClass) { $testClass->assertEquals( - array('para1' => 'val1', 'para2' => 'val2'), + ['para1' => 'val1', 'para2' => 'val2'], $request->getPostFields(), 'Post query string was not parsed and set correctly.' ); + return new Response(200); } ); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_POSTFIELDS, array('para1' => 'val1', 'para2' => 'val2')); + curl_setopt($curlHandle, CURLOPT_POSTFIELDS, ['para1' => 'val1', 'para2' => 'val2']); curl_exec($curlHandle); curl_close($curlHandle); $this->curlHook->disable(); @@ -149,10 +150,11 @@ public function testShouldPostFieldsAsArrayUsingSetoptarray() $this->curlHook->enable( function (Request $request) use ($testClass) { $testClass->assertEquals( - array('para1' => 'val1', 'para2' => 'val2'), + ['para1' => 'val1', 'para2' => 'val2'], $request->getPostFields(), 'Post query string was not parsed and set correctly.' ); + return new Response(200); } ); @@ -160,9 +162,9 @@ function (Request $request) use ($testClass) { $curlHandle = curl_init('http://example.com'); curl_setopt_array( $curlHandle, - array( - CURLOPT_POSTFIELDS => array('para1' => 'val1', 'para2' => 'val2') - ) + [ + CURLOPT_POSTFIELDS => ['para1' => 'val1', 'para2' => 'val2'], + ] ); curl_exec($curlHandle); curl_close($curlHandle); @@ -284,6 +286,7 @@ function (Request $request) use ($testClass, &$callCount) { '' ); ++$callCount; + return new Response(200); } ); @@ -298,9 +301,9 @@ function (Request $request) use ($testClass, &$callCount) { $stillRunning = null; $mh = curl_multi_exec($curlMultiHandle, $stillRunning); - $lastInfo = curl_multi_info_read($mh); + $lastInfo = curl_multi_info_read($mh); $secondLastInfo = curl_multi_info_read($mh); - $afterLastInfo = curl_multi_info_read($mh); + $afterLastInfo = curl_multi_info_read($mh); curl_multi_remove_handle($curlMultiHandle, $curlHandle1); curl_multi_remove_handle($curlMultiHandle, $curlHandle2); @@ -310,13 +313,13 @@ function (Request $request) use ($testClass, &$callCount) { $this->assertEquals(2, $callCount, 'Hook should have been called twice.'); $this->assertEquals( - array('msg' => 1, 'result' => 0, 'handle' => $curlHandle2), + ['msg' => 1, 'result' => 0, 'handle' => $curlHandle2], $lastInfo, 'When called the first time curl_multi_info_read should return last curl info.' ); $this->assertEquals( - array('msg' => 1, 'result' => 0, 'handle' => $curlHandle1), + ['msg' => 1, 'result' => 0, 'handle' => $curlHandle1], $secondLastInfo, 'When called the second time curl_multi_info_read should return second to last curl info.' ); @@ -360,6 +363,7 @@ function (Request $request) use ($testClass) { $request->getMethod(), '' ); + return new Response(200); } ); @@ -372,14 +376,12 @@ function (Request $request) use ($testClass) { $this->curlHook->disable(); } - /** - * @return Closure - */ protected function getTestCallback($statusCode = 200): Closure { $testClass = $this; + return Closure::fromCallable(function () use ($statusCode, $testClass) { - return new Response($statusCode, array(), $testClass->expected); + return new Response($statusCode, [], $testClass->expected); }); } } diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index f2fdc2b40..d39f9295c 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -3,12 +3,12 @@ namespace VCR\LibraryHooks; use Closure; +use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\SoapCodeTransform; +use VCR\Configuration; use VCR\Request; use VCR\Response; -use VCR\Configuration; use VCR\Util\StreamProcessor; -use PHPUnit\Framework\TestCase; -use VCR\CodeTransform\SoapCodeTransform; /** * Test if intercepting http/https using soap works. @@ -21,7 +21,7 @@ class SoapHookTest extends TestCase protected $config; - /** @var SoapHook $soapHook */ + /** @var SoapHook */ protected $soapHook; public function setup() @@ -34,9 +34,9 @@ public function testShouldInterceptCallWhenEnabled() { $this->soapHook->enable($this->getContentCheckCallback()); - $client = new \SoapClient(self::WSDL, array('soap_version' => SOAP_1_2)); + $client = new \SoapClient(self::WSDL, ['soap_version' => SOAP_1_2]); $client->setLibraryHook($this->soapHook); - $actual = $client->GetCityWeatherByZIP(array('ZIP' => '10013')); + $actual = $client->GetCityWeatherByZIP(['ZIP' => '10013']); $this->soapHook->disable(); $this->assertInstanceOf('\stdClass', $actual, 'Response was not returned.'); @@ -45,34 +45,34 @@ public function testShouldInterceptCallWhenEnabled() public function testShouldHandleSOAPVersion11() { - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type' => 'text/xml; charset=utf-8;', 'SOAPAction' => 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP', - ); + ]; $this->soapHook->enable($this->getHeadersCheckCallback($expectedHeaders)); $client = new \SoapClient( self::WSDL, - array('soap_version' => SOAP_1_1) + ['soap_version' => SOAP_1_1] ); $client->setLibraryHook($this->soapHook); - $client->GetCityWeatherByZIP(array('ZIP' => '10013')); + $client->GetCityWeatherByZIP(['ZIP' => '10013']); } public function testShouldHandleSOAPVersion12() { - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type' => 'application/soap+xml; charset=utf-8; action="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"', - ); + ]; $this->soapHook->enable($this->getHeadersCheckCallback($expectedHeaders)); $client = new \SoapClient( self::WSDL, - array('soap_version' => SOAP_1_2) + ['soap_version' => SOAP_1_2] ); $client->setLibraryHook($this->soapHook); - $client->GetCityWeatherByZIP(array('ZIP' => '10013')); + $client->GetCityWeatherByZIP(['ZIP' => '10013']); } public function testShouldReturnLastRequestWithTraceOn() @@ -81,39 +81,35 @@ public function testShouldReturnLastRequestWithTraceOn() $client = new \SoapClient( self::WSDL, - array('soap_version' => SOAP_1_1, 'trace' => 1) + ['soap_version' => SOAP_1_1, 'trace' => 1] ); $client->setLibraryHook($this->soapHook); - $client->GetCityWeatherByZIP(array('ZIP' => '10013')); + $client->GetCityWeatherByZIP(['ZIP' => '10013']); $actual = $client->__getLastRequest(); $this->soapHook->disable(); $this->assertNotNull($actual, '__getLastRequest() returned NULL.'); } - /** - * @return Closure - */ protected function getContentCheckCallback(): Closure { $testClass = $this; + return Closure::fromCallable(function () use ($testClass) { - return new Response(200, array(), $testClass->expected); + return new Response(200, [], $testClass->expected); }); } - /** - * @param array $expectedHeaders - * @return Closure - */ protected function getHeadersCheckCallback(array $expectedHeaders): Closure { $test = $this; + return Closure::fromCallable(function (Request $request) use ($test, $expectedHeaders) { foreach ($expectedHeaders as $expectedHeaderName => $expectedHeader) { $test->assertEquals($expectedHeader, $request->getHeader($expectedHeaderName)); } - return new Response(200, array(), ''); + + return new Response(200, [], ''); }); } } diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index 650a8a1bb..cf4e3420d 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -3,7 +3,6 @@ namespace VCR\LibraryHooks; use PHPUnit\Framework\TestCase; -use VCR\Request; use VCR\Response; /** @@ -33,7 +32,7 @@ public function testSeek() { $hook = new StreamWrapperHook(); $hook->enable(function ($request) { - return new Response(200, array(), 'A Test'); + return new Response(200, [], 'A Test'); }); $hook->stream_open('http://example.com', 'r', 0, $openedPath); diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index a16649aa1..6624796cd 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -8,93 +8,93 @@ class RequestMatcherTest extends TestCase { public function testMatchingMethod() { - $first = new Request('GET', 'http://example.com', array()); - $second = new Request('GET', 'http://example.com', array()); + $first = new Request('GET', 'http://example.com', []); + $second = new Request('GET', 'http://example.com', []); $this->assertTrue(RequestMatcher::matchMethod($first, $second)); - $first = new Request('GET', 'http://example.com', array()); - $second = new Request('POST', 'http://example.com', array()); + $first = new Request('GET', 'http://example.com', []); + $second = new Request('POST', 'http://example.com', []); $this->assertFalse(RequestMatcher::matchMethod($first, $second)); } public function testMatchingUrl() { - $first = new Request('GET', 'http://example.com/common/path', array()); - $second = new Request('GET', 'http://example.com/common/path', array()); + $first = new Request('GET', 'http://example.com/common/path', []); + $second = new Request('GET', 'http://example.com/common/path', []); $this->assertTrue(RequestMatcher::matchUrl($first, $second)); - $first = new Request('GET', 'http://example.com/first/path', array()); - $second = new Request('GET', 'http://example.com/second/path', array()); + $first = new Request('GET', 'http://example.com/first/path', []); + $second = new Request('GET', 'http://example.com/second/path', []); $this->assertFalse(RequestMatcher::matchUrl($first, $second)); - $first = new Request('GET', 'http://example.com/second', array()); - $second = new Request('GET', 'http://example.com/second/path', array()); + $first = new Request('GET', 'http://example.com/second', []); + $second = new Request('GET', 'http://example.com/second/path', []); $this->assertFalse(RequestMatcher::matchUrl($first, $second)); } public function testMatchingHost() { - $first = new Request('GET', 'http://example.com/common/path', array()); - $second = new Request('GET', 'http://example.com/common/path', array()); + $first = new Request('GET', 'http://example.com/common/path', []); + $second = new Request('GET', 'http://example.com/common/path', []); $this->assertTrue(RequestMatcher::matchHost($first, $second)); - $first = new Request('GET', 'http://example.com/first/path', array()); - $second = new Request('GET', 'http://elpmaxe.com/second/path', array()); + $first = new Request('GET', 'http://example.com/first/path', []); + $second = new Request('GET', 'http://elpmaxe.com/second/path', []); $this->assertFalse(RequestMatcher::matchHost($first, $second)); } public function testMatchingHeaders() { - $first = new Request('GET', 'http://example.com', array('Accept' => 'Everything')); - $second = new Request('GET', 'http://example.com', array('Accept' => 'Everything')); + $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); + $second = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); $this->assertTrue(RequestMatcher::matchHeaders($first, $second)); - $first = new Request('GET', 'http://example.com', array('Accept' => 'Everything')); - $second = new Request('GET', 'http://example.com', array('Accept' => 'Nothing')); + $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); + $second = new Request('GET', 'http://example.com', ['Accept' => 'Nothing']); $this->assertFalse(RequestMatcher::matchHeaders($first, $second)); } public function testHeaderMatchingDisallowsMissingHeaders() { - $first = new Request('GET', 'http://example.com', array('Accept' => 'Everything', 'MyHeader' => 'value')); - $second = new Request('GET', 'http://example.com', array('Accept' => 'Everything')); + $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything', 'MyHeader' => 'value']); + $second = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); $this->assertFalse(RequestMatcher::matchHeaders($first, $second)); - $first = new Request('GET', 'http://example.com', array('Accept' => 'Everything')); - $second = new Request('GET', 'http://example.com', array('Accept' => 'Everything', 'MyHeader' => 'value')); + $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); + $second = new Request('GET', 'http://example.com', ['Accept' => 'Everything', 'MyHeader' => 'value']); $this->assertFalse(RequestMatcher::matchHeaders($first, $second)); } public function testHeaderMatchingAllowsEmptyVals() { - $first = new Request('GET', 'http://example.com', array('Accept' => null, 'Content-Type' => 'application/json')); - $second = new Request('GET', 'http://example.com', array('Accept' => null, 'Content-Type' => 'application/json')); + $first = new Request('GET', 'http://example.com', ['Accept' => null, 'Content-Type' => 'application/json']); + $second = new Request('GET', 'http://example.com', ['Accept' => null, 'Content-Type' => 'application/json']); $this->assertTrue(RequestMatcher::matchHeaders($first, $second)); } public function testMatchingPostFields() { - $mock = array( + $mock = [ 'method' => 'POST', 'url' => 'http://example.com', - 'headers' => array(), - 'post_fields' => array( + 'headers' => [], + 'post_fields' => [ 'field1' => 'value1', 'field2' => 'value2', - ) - ); + ], + ]; $first = Request::fromArray($mock); $second = Request::fromArray($mock); @@ -109,29 +109,29 @@ public function testMatchingPostFields() public function testMatchingQueryString() { - $first = new Request('GET', 'http://example.com/search?query=test', array()); - $second = new Request('GET', 'http://example.com/search?query=test', array()); + $first = new Request('GET', 'http://example.com/search?query=test', []); + $second = new Request('GET', 'http://example.com/search?query=test', []); $this->assertTrue(RequestMatcher::matchQueryString($first, $second)); - $first = new Request('GET', 'http://example.com/search?query=first', array()); - $second = new Request('GET', 'http://example.com/search?query=second', array()); + $first = new Request('GET', 'http://example.com/search?query=first', []); + $second = new Request('GET', 'http://example.com/search?query=second', []); $this->assertFalse(RequestMatcher::matchQueryString($first, $second)); } public function testMatchingBody() { - $first = new Request('GET', 'http://example.com', array()); + $first = new Request('GET', 'http://example.com', []); $first->setBody('test'); - $second = new Request('GET', 'http://example.com', array()); + $second = new Request('GET', 'http://example.com', []); $second->setBody('test'); $this->assertTrue(RequestMatcher::matchBody($first, $second), 'Bodies should be equal'); - $first = new Request('GET', 'http://example.com', array()); + $first = new Request('GET', 'http://example.com', []); $first->setBody('test'); - $second = new Request('POST', 'http://example.com', array()); + $second = new Request('POST', 'http://example.com', []); $second->setBody('different'); $this->assertFalse(RequestMatcher::matchBody($first, $second), 'Bodies are different.'); @@ -142,31 +142,31 @@ public function testMatchingSoapOperation() $storedRequest = Request::fromArray([ 'method' => 'POST', 'url' => 'http://example.com', - 'headers' => array(), - 'body' => "\n45000\n" + 'headers' => [], + 'body' => "\n45000\n", ]); $request = Request::fromArray([ 'method' => 'POST', 'url' => 'http://example.com', - 'headers' => array(), - 'body' => "\n75008\n" + 'headers' => [], + 'body' => "\n75008\n", ]); $this->assertTrue(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operations are the same'); $request = Request::fromArray([ 'method' => 'POST', 'url' => 'http://example.com', - 'headers' => array(), - 'body' => "\n75008\n" + 'headers' => [], + 'body' => "\n75008\n", ]); $this->assertFalse(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operations are different'); $request = Request::fromArray([ 'method' => 'POST', 'url' => 'http://example.com', - 'headers' => array(), - 'body' => '{}' + 'headers' => [], + 'body' => '{}', ]); $this->assertTrue(RequestMatcher::matchSoapOperation($storedRequest, $request), 'Operation is not SOAP message'); } diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 29e020972..53c4289e1 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -17,16 +17,16 @@ class RequestTest extends TestCase public function setUp() { - $this->request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); + $this->request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); } public function testGetHeaders() { $this->assertEquals( - array( + [ 'User-Agent' => 'Unit-Test', - 'Host' => 'example.com' - ), + 'Host' => 'example.com', + ], $this->request->getHeaders() ); } @@ -47,145 +47,145 @@ public function testSetAuthorization() public function testMatches() { - $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); + $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $this->assertTrue($this->request->matches($request, array(array('VCR\RequestMatcher', 'matchMethod')))); + $this->assertTrue($this->request->matches($request, [['VCR\RequestMatcher', 'matchMethod']])); } public function testDoesntMatch() { - $request = new Request('POST', 'http://example.com', array('User-Agent' => 'Unit-Test')); + $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $this->assertFalse($this->request->matches($request, array(array('VCR\RequestMatcher', 'matchMethod')))); + $this->assertFalse($this->request->matches($request, [['VCR\RequestMatcher', 'matchMethod']])); } public function testMatchesThrowsExceptionIfMatcherNotFound() { - $request = new Request('POST', 'http://example.com', array('User-Agent' => 'Unit-Test')); + $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->expectException( '\BadFunctionCallException', "Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n" ); - $this->request->matches($request, array(array('some', 'method'))); + $this->request->matches($request, [['some', 'method']]); } public function testRestoreRequest() { $restoredRequest = Request::fromArray($this->request->toArray()); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ 'User-Agent' => 'Unit-Test', 'Host' => 'example.com', - ) - ), + ], + ], $restoredRequest->toArray() ); } public function testStorePostFields() { - $this->request->setPostFields(array('para1' => 'val1')); + $this->request->setPostFields(['para1' => 'val1']); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ 'User-Agent' => 'Unit-Test', 'Host' => 'example.com', - ), - 'post_fields' => array('para1' => 'val1'), - ), + ], + 'post_fields' => ['para1' => 'val1'], + ], $this->request->toArray() ); } public function testRestorePostFields() { - $this->request->setPostFields(array('para1' => 'val1')); + $this->request->setPostFields(['para1' => 'val1']); $restoredRequest = Request::fromArray($this->request->toArray()); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ 'User-Agent' => 'Unit-Test', 'Host' => 'example.com', - ), - 'post_fields' => array('para1' => 'val1'), - ), + ], + 'post_fields' => ['para1' => 'val1'], + ], $restoredRequest->toArray() ); } public function testStorePostFile() { - $file = array( - 'fieldName' => 'field_name', + $file = [ + 'fieldName' => 'field_name', 'contentType' => 'application/octet-stream', - 'filename' => 'tests/fixtures/unittest_curl_test', - 'postname' => 'unittest_curl_test', - ); + 'filename' => 'tests/fixtures/unittest_curl_test', + 'postname' => 'unittest_curl_test', + ]; $this->request->addPostFile($file); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( - 'User-Agent' => 'Unit-Test', - 'Host' => 'example.com', - ), - 'post_files' => array($file), - ), + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ + 'User-Agent' => 'Unit-Test', + 'Host' => 'example.com', + ], + 'post_files' => [$file], + ], $this->request->toArray() ); } public function testSetPostFiles() { - $file = array( - 'fieldName' => 'field_name', + $file = [ + 'fieldName' => 'field_name', 'contentType' => 'application/octet-stream', - 'filename' => 'tests/fixtures/unittest_curl_test', - 'postname' => 'unittest_curl_test', - ); + 'filename' => 'tests/fixtures/unittest_curl_test', + 'postname' => 'unittest_curl_test', + ]; $this->request->setPostFiles([$file]); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( - 'User-Agent' => 'Unit-Test', - 'Host' => 'example.com', - ), - 'post_files' => array($file), - ), + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ + 'User-Agent' => 'Unit-Test', + 'Host' => 'example.com', + ], + 'post_files' => [$file], + ], $this->request->toArray() ); } public function testRestorePostFiles() { - $file = array( - 'fieldName' => 'field_name', + $file = [ + 'fieldName' => 'field_name', 'contentType' => 'application/octet-stream', - 'filename' => 'tests/fixtures/unittest_curl_test', - 'postname' => 'unittest_curl_test', - ); + 'filename' => 'tests/fixtures/unittest_curl_test', + 'postname' => 'unittest_curl_test', + ]; $this->request->addPostFile($file); $restoredRequest = Request::fromArray($this->request->toArray()); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( - 'User-Agent' => 'Unit-Test', - 'Host' => 'example.com', - ), - 'post_files' => array($file), - ), + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ + 'User-Agent' => 'Unit-Test', + 'Host' => 'example.com', + ], + 'post_files' => [$file], + ], $restoredRequest->toArray() ); } @@ -195,15 +195,15 @@ public function testRestoreBody() $this->request->setBody('sometest'); $restoredRequest = Request::fromArray($this->request->toArray()); $this->assertEquals( - array( - 'method' => 'GET', - 'url' => 'http://example.com', - 'headers' => array( + [ + 'method' => 'GET', + 'url' => 'http://example.com', + 'headers' => [ 'User-Agent' => 'Unit-Test', 'Host' => 'example.com', - ), + ], 'body' => 'sometest', - ), + ], $restoredRequest->toArray() ); } @@ -217,7 +217,7 @@ public function testMatchesBody() $this->assertTrue( $this->request->matches( Request::fromArray($request->toArray()), - array(array('VCR\RequestMatcher', 'matchBody')) + [['VCR\RequestMatcher', 'matchBody']] ) ); } @@ -231,7 +231,7 @@ public function testDoesntMatchBody() $this->assertFalse( $this->request->matches( Request::fromArray($request->toArray()), - array(array('VCR\RequestMatcher', 'matchBody')) + [['VCR\RequestMatcher', 'matchBody']] ) ); } @@ -247,14 +247,14 @@ public function testDoNotOverwriteHostHeader() $this->request = new Request( 'GET', 'http://example.com', - array('User-Agent' => 'Unit-Test', 'Host' => 'www.example.com') + ['User-Agent' => 'Unit-Test', 'Host' => 'www.example.com'] ); $this->assertEquals( - array( + [ 'User-Agent' => 'Unit-Test', - 'Host' => 'www.example.com' - ), + 'Host' => 'www.example.com', + ], $this->request->getHeaders() ); } @@ -278,7 +278,7 @@ public function testSetCurlOptions() { $getRequest = new Request('GET', 'http://example.com'); $getRequest->setCurlOptions([ - CURLOPT_CUSTOMREQUEST => 'PUT' + CURLOPT_CUSTOMREQUEST => 'PUT', ]); $this->assertEquals('PUT', $getRequest->getCurlOption(CURLOPT_CUSTOMREQUEST)); } diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index 0b92ea897..16d1452c6 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -11,30 +11,30 @@ class ResponseTest extends TestCase { public function testGetHeaders() { - $expectedHeaders = array( + $expectedHeaders = [ 'User-Agent' => 'Unit-Test', - 'Host' => 'example.com' - ); + 'Host' => 'example.com', + ]; - $response = Response::fromArray(array('headers' => $expectedHeaders)); + $response = Response::fromArray(['headers' => $expectedHeaders]); $this->assertEquals($expectedHeaders, $response->getHeaders()); } public function testGetHeadersNoneDefined() { - $response = Response::fromArray(array()); - $this->assertEquals(array(), $response->getHeaders()); + $response = Response::fromArray([]); + $this->assertEquals([], $response->getHeaders()); } public function testRestoreHeadersFromArray() { - $headers = array( - 'Content-Type' => 'application/json', + $headers = [ + 'Content-Type' => 'application/json', 'Content-Length' => '349', - 'Connection' => 'close', - 'Date' => 'Fri, 31 Jan 2014 15:37:13 GMT', - ); + 'Connection' => 'close', + 'Date' => 'Fri, 31 Jan 2014 15:37:13 GMT', + ]; $response = new Response(200, $headers); $restoredResponse = Response::fromArray($response->toArray()); @@ -45,21 +45,21 @@ public function testGetBody() { $expectedBody = 'This is test content'; - $response = Response::fromArray(array('body' => $expectedBody)); + $response = Response::fromArray(['body' => $expectedBody]); $this->assertEquals($expectedBody, $response->getBody()); } public function testGetBodyNoneDefined() { - $response = Response::fromArray(array()); + $response = Response::fromArray([]); $this->assertEmpty($response->getBody()); } public function testRestoreBodyFromArray() { $body = 'this is an example body'; - $response = new Response(200, array(), $body); + $response = new Response(200, [], $body); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($body, $restoredResponse->getBody()); @@ -68,7 +68,7 @@ public function testRestoreBodyFromArray() public function testBase64EncodeCompressedBody() { $body = 'this is an example body'; - $response = new Response(200, array('Content-Type' => 'application/x-gzip'), $body); + $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); $responseArray = $response->toArray(); $this->assertEquals(base64_encode($body), $responseArray['body']); @@ -77,10 +77,10 @@ public function testBase64EncodeCompressedBody() public function testBase64DecodeCompressedBody() { $body = 'this is an example body'; - $responseArray = array( - 'headers' => array('Content-Type' => 'application/x-gzip'), - 'body' => base64_encode($body) - ); + $responseArray = [ + 'headers' => ['Content-Type' => 'application/x-gzip'], + 'body' => base64_encode($body), + ]; $response = Response::fromArray($responseArray); $this->assertEquals($body, $response->getBody()); @@ -89,7 +89,7 @@ public function testBase64DecodeCompressedBody() public function testRestoreCompressedBody() { $body = 'this is an example body'; - $response = new Response(200, array('Content-Type' => 'application/x-gzip'), $body); + $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($body, $restoredResponse->getBody()); @@ -116,16 +116,16 @@ public function testRestoreStatusFromArray() public function testGetCurlInfo() { - $curlOptions = array('option' => 'value'); - $response = new Response(200, array(), null, $curlOptions); + $curlOptions = ['option' => 'value']; + $response = new Response(200, [], null, $curlOptions); $this->assertEquals($curlOptions, $response->getCurlInfo()); } public function testRestoreCurlInfoFromArray() { - $expectedCurlOptions = array('option' => 'value'); - $response = new Response(200, array(), null, $expectedCurlOptions); + $expectedCurlOptions = ['option' => 'value']; + $response = new Response(200, [], null, $expectedCurlOptions); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($expectedCurlOptions, $response->getCurlInfo()); @@ -133,20 +133,20 @@ public function testRestoreCurlInfoFromArray() public function testToArray() { - $expectedArray = array( - 'status' => array( + $expectedArray = [ + 'status' => [ 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', - ), - 'headers' => array( - 'host' => 'example.com' - ), - 'body' => 'Test response', - 'curl_info' => array( - 'content_type' => 'text/html' - ) - ); + ], + 'headers' => [ + 'host' => 'example.com', + ], + 'body' => 'Test response', + 'curl_info' => [ + 'content_type' => 'text/html', + ], + ]; $response = Response::fromArray($expectedArray); diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index bae4904ef..07cdf829e 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -53,7 +53,7 @@ public function next() public function valid() { - return (boolean) $this->position; + return (bool) $this->position; } public function rewind() diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index 3aba13119..115c12d36 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -15,7 +15,7 @@ public function setUp() public function testStoreRecordingIsCallable() { - $this->assertNull($this->storage->storeRecording(array('empty or not, we don\'t care'))); + $this->assertNull($this->storage->storeRecording(['empty or not, we don\'t care'])); } public function testNextIsCallable() @@ -28,19 +28,17 @@ public function testRewindIsCallable() $this->assertNull($this->storage->rewind()); } - /** - * @expectedException BadMethodCallException - */ public function testKeyIsNotCallable() { + $this->expectException(\BadMethodCallException::class); + $this->storage->key(); } - /** - * @expectedException BadMethodCallException - */ public function testCurrentIsNotCallable() { + $this->expectException(\BadMethodCallException::class); + $this->storage->current(); } diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 464d10663..30a7f8703 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -17,7 +17,7 @@ class JsonTest extends TestCase public function setUp() { vfsStream::setup('test'); - $this->filePath = vfsStream::url('test/') . 'json_test'; + $this->filePath = vfsStream::url('test/').'json_test'; $this->jsonObject = new Json(vfsStream::url('test/'), 'json_test'); } @@ -25,9 +25,9 @@ public function testIterateOneObject() { $this->iterateAndTest( '[{"para1": "val1"}]', - array( - array('para1' => 'val1'), - ), + [ + ['para1' => 'val1'], + ], 'Single json object was not parsed correctly.' ); } @@ -36,10 +36,10 @@ public function testIterateTwoObjects() { $this->iterateAndTest( '[{"para1": "val1"}, {"para2": "val2"}]', - array( - array('para1' => 'val1'), - array('para2' => 'val2'), - ), + [ + ['para1' => 'val1'], + ['para2' => 'val2'], + ], 'Two json objects were not parsed correctly.' ); } @@ -48,10 +48,10 @@ public function testIterateFirstNestedObject() { $this->iterateAndTest( '[{"para1": {"para2": "val2"}}, {"para3": "val3"}]', - array( - array('para1' => array('para2' => 'val2')), - array('para3' => 'val3'), - ), + [ + ['para1' => ['para2' => 'val2']], + ['para3' => 'val3'], + ], 'Nested json objects were not parsed correctly.' ); } @@ -60,10 +60,10 @@ public function testIterateSecondNestedObject() { $this->iterateAndTest( '[{"para1": "val1"}, {"para2": {"para3": "val3"}}]', - array( - array('para1' => 'val1'), - array('para2' => array('para3' => 'val3')), - ), + [ + ['para1' => 'val1'], + ['para2' => ['para3' => 'val3']], + ], 'Nested json objects were not parsed correctly.' ); } @@ -72,21 +72,21 @@ public function testIterateEmpty() { $this->iterateAndTest( '[]', - array(), + [], 'Empty json was not parsed correctly.' ); } public function testStoreRecording() { - $expected = array( + $expected = [ 'request' => 'some request', - 'response' => 'some response' - ); + 'response' => 'some response', + ]; $this->jsonObject->storeRecording($expected); - $actual = array(); + $actual = []; foreach ($this->jsonObject as $recording) { $actual[] = $recording; } @@ -96,10 +96,10 @@ public function testStoreRecording() public function testValidJson() { - $stored = array( + $stored = [ 'request' => 'some request', - 'response' => 'some response' - ); + 'response' => 'some response', + ]; $this->jsonObject->storeRecording($stored); $this->jsonObject->storeRecording($stored); @@ -108,14 +108,14 @@ public function testValidJson() public function testStoreRecordingWhenBlankFileAlreadyExists() { - vfsStream::create(array('blank_file_test' => '')); - $filePath = vfsStream::url('test/') . 'blank_file_test'; + vfsStream::create(['blank_file_test' => '']); + $filePath = vfsStream::url('test/').'blank_file_test'; $jsonObject = new Json(vfsStream::url('test/'), 'blank_file_test'); - $stored = array( + $stored = [ 'request' => 'some request', - 'response' => 'some response' - ); + 'response' => 'some response', + ]; $jsonObject->storeRecording($stored); $this->assertJson(file_get_contents($filePath)); @@ -125,7 +125,7 @@ private function iterateAndTest($json, $expected, $message) { file_put_contents($this->filePath, $json); - $actual = array(); + $actual = []; foreach ($this->jsonObject as $object) { $actual[] = $object; } diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index 4e8261e67..45dd5c5c8 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -13,18 +13,18 @@ class YamlTest extends TestCase public function setUp() { vfsStream::setup('test'); - $this->filePath = vfsStream::url('test/') . DIRECTORY_SEPARATOR . 'yaml_test'; + $this->filePath = vfsStream::url('test/').\DIRECTORY_SEPARATOR.'yaml_test'; $this->yamlObject = new Yaml(vfsStream::url('test/'), 'yaml_test'); } public function testIterateOneObject() { $this->iterateAndTest( - '-' . "\n" - . ' para1: val1', - array( - array('para1' => 'val1'), - ), + '-'."\n" + .' para1: val1', + [ + ['para1' => 'val1'], + ], 'Single yaml object was not parsed correctly.' ); } @@ -32,14 +32,14 @@ public function testIterateOneObject() public function testIterateTwoObjects() { $this->iterateAndTest( - '-' . "\n" - . ' para1: val1' . "\n" - . '-' . "\n" - . ' para2: val2', - array( - array('para1' => 'val1'), - array('para2' => 'val2'), - ), + '-'."\n" + .' para1: val1'."\n" + .'-'."\n" + .' para2: val2', + [ + ['para1' => 'val1'], + ['para2' => 'val2'], + ], 'Two yaml objects were not parsed correctly.' ); } @@ -47,15 +47,15 @@ public function testIterateTwoObjects() public function testIterateFirstNestedObject() { $this->iterateAndTest( - '-' . "\n" - . ' para1:' . "\n" - . ' para2: val2' . "\n" - . '-' . "\n" - . ' para3: val3', - array( - array('para1' => array('para2' => 'val2')), - array('para3' => 'val3'), - ), + '-'."\n" + .' para1:'."\n" + .' para2: val2'."\n" + .'-'."\n" + .' para3: val3', + [ + ['para1' => ['para2' => 'val2']], + ['para3' => 'val3'], + ], 'Nested yaml objects were not parsed correctly.' ); } @@ -63,15 +63,15 @@ public function testIterateFirstNestedObject() public function testIterateSecondNestedObject() { $this->iterateAndTest( - '-' . "\n" - . ' para1: val1' . "\n" - . '-' . "\n" - . ' para2:' . "\n" - . ' para3: val3' . "\n", - array( - array('para1' => 'val1'), - array('para2' => array('para3' => 'val3')), - ), + '-'."\n" + .' para1: val1'."\n" + .'-'."\n" + .' para2:'."\n" + .' para3: val3'."\n", + [ + ['para1' => 'val1'], + ['para2' => ['para3' => 'val3']], + ], 'Nested yaml objects were not parsed correctly.' ); } @@ -80,21 +80,21 @@ public function testIterateEmpty() { $this->iterateAndTest( '', - array(), + [], 'Empty yaml was not parsed correctly.' ); } public function testStoreRecording() { - $expected = array( + $expected = [ 'request' => 'some request', - 'response' => 'some response' - ); + 'response' => 'some response', + ]; $this->yamlObject->storeRecording($expected); - $actual = array(); + $actual = []; foreach ($this->yamlObject as $recording) { $actual[] = $recording; } @@ -104,15 +104,15 @@ public function testStoreRecording() public function testStoreTwoRecording() { - $expected = array( - 'request' => array('headers' => array('Content-Type' => 'application/json')), - 'response' => array('body' => 'ok', 'status' => 200) - ); + $expected = [ + 'request' => ['headers' => ['Content-Type' => 'application/json']], + 'response' => ['body' => 'ok', 'status' => 200], + ]; $this->yamlObject->storeRecording($expected); $this->yamlObject->storeRecording($expected); - $actual = array(); + $actual = []; foreach ($this->yamlObject as $recording) { $actual[] = $recording; } @@ -125,7 +125,7 @@ private function iterateAndTest($yaml, $expected, $message) { file_put_contents($this->filePath, $yaml); - $actual = array(); + $actual = []; foreach ($this->yamlObject as $object) { $actual[] = $object; } diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 66816a3f7..81f1cca8c 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -16,7 +16,7 @@ class CurlHelperTest extends TestCase public function testSetCurlOptionMethods($method) { $request = new Request($method, 'http://example.com'); - $headers = array('Host: example.com'); + $headers = ['Host: example.com']; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); @@ -26,20 +26,20 @@ public function testSetCurlOptionMethods($method) /** * Returns a list of HTTP methods for testing testSetCurlOptionMethods. * - * @return array HTTP methods. + * @return array HTTP methods */ public function getHttpMethodsProvider() { - return array( - array('CONNECT'), - array('DELETE'), - array('GET'), - array('HEAD'), - array('OPTIONS'), - array('POST'), - array('PUT'), - array('TRACE'), - ); + return [ + ['CONNECT'], + ['DELETE'], + ['GET'], + ['HEAD'], + ['OPTIONS'], + ['POST'], + ['PUT'], + ['TRACE'], + ]; } public function testSetCurlOptionOnRequestPostFieldsQueryString() @@ -55,7 +55,7 @@ public function testSetCurlOptionOnRequestPostFieldsQueryString() public function testSetCurlOptionOnRequestPostFieldsArray() { $request = new Request('POST', 'http://example.com'); - $payload = array('some' => 'test'); + $payload = ['some' => 'test']; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -66,7 +66,7 @@ public function testSetCurlOptionOnRequestPostFieldsArray() public function testSetCurlOptionOnRequestPostFieldsString() { $request = new Request('POST', 'http://example.com'); - $payload = json_encode(array('some' => 'test')); + $payload = json_encode(['some' => 'test']); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -88,63 +88,63 @@ public function testSetCurlOptionOnRequestPostFieldsEmptyString() public function testSetCurlOptionOnRequestSetSingleHeader() { $request = new Request('GET', 'http://example.com'); - $headers = array('Host: example.com'); + $headers = ['Host: example.com']; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - $this->assertEquals(array('Host' => 'example.com'), $request->getHeaders()); + $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } public function testSetCurlOptionOnRequestSetSingleHeaderTwice() { $request = new Request('GET', 'http://example.com'); - $headers = array('Host: example.com'); + $headers = ['Host: example.com']; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - $this->assertEquals(array('Host' => 'example.com'), $request->getHeaders()); + $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() { $request = new Request('GET', 'http://example.com'); - $headers = array( + $headers = [ 'Host: example.com', 'Content-Type: application/json', - ); + ]; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - $expected = array( + $expected = [ 'Host' => 'example.com', - 'Content-Type' => 'application/json' - ); + 'Content-Type' => 'application/json', + ]; $this->assertEquals($expected, $request->getHeaders()); } public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() { $request = new Request('GET', 'http://example.com'); - $headers = array( + $headers = [ 'Host: example.com', 'Content-Type: application/json', - ); + ]; CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, array()); + CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, []); - $expected = array( + $expected = [ 'Host' => 'example.com', - ); + ]; $this->assertEquals($expected, $request->getHeaders()); } public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() { $request = new Request('GET', 'http://example.com'); - $payload = json_encode(array('some' => 'test')); + $payload = json_encode(['some' => 'test']); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); @@ -187,12 +187,12 @@ public function testSetCurlOptionReadFunction() $callback = function ($curlHandle, $fileHandle, $size) use ($test, $expected) { $test->assertInternalType('resource', $curlHandle); $test->assertInternalType('resource', $fileHandle); - $test->assertEquals(strlen($expected), $size); + $test->assertEquals(\strlen($expected), $size); return $expected; }; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_INFILESIZE, strlen($expected)); + CurlHelper::setCurlOptionOnRequest($request, CURLOPT_INFILESIZE, \strlen($expected)); CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, $callback, curl_init()); CurlHelper::validateCurlPOSTBody($request, curl_init()); @@ -201,10 +201,10 @@ public function testSetCurlOptionReadFunction() public function testHandleResponseReturnsBody() { - $curlOptions = array( - CURLOPT_RETURNTRANSFER => true - ); - $response = new Response(200, array(), 'example response'); + $curlOptions = [ + CURLOPT_RETURNTRANSFER => true, + ]; + $response = new Response(200, [], 'example response'); $output = CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -213,10 +213,10 @@ public function testHandleResponseReturnsBody() public function testHandleResponseEchosBody() { - $response = new Response(200, array(), 'example response'); + $response = new Response(200, [], 'example response'); ob_start(); - CurlHelper::handleOutput($response, array(), curl_init()); + CurlHelper::handleOutput($response, [], curl_init()); $output = ob_get_clean(); $this->assertEquals($response->getBody(true), $output); @@ -224,46 +224,46 @@ public function testHandleResponseEchosBody() public function testHandleResponseIncludesHeader() { - $curlOptions = array( + $curlOptions = [ CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, - ); - $status = array( + ]; + $status = [ 'code' => 200, 'message' => 'OK', - 'http_version' => '1.1' - ); - $response = new Response($status, array(), 'example response'); + 'http_version' => '1.1', + ]; + $response = new Response($status, [], 'example response'); $output = CurlHelper::handleOutput($response, $curlOptions, curl_init()); - $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n" . $response->getBody(), $output); + $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n".$response->getBody(), $output); } public function testHandleOutputHeaderFunction() { - $actualHeaders = array(); - $curlOptions = array( + $actualHeaders = []; + $curlOptions = [ CURLOPT_HEADERFUNCTION => function ($ch, $header) use (&$actualHeaders) { $actualHeaders[] = $header; }, - ); - $status = array( + ]; + $status = [ 'code' => 200, 'message' => 'OK', 'http_version' => '1.1', - ); - $headers = array( + ]; + $headers = [ 'Content-Length' => 0, - ); + ]; $response = new Response($status, $headers, 'example response'); CurlHelper::handleOutput($response, $curlOptions, curl_init()); - $expected = array( + $expected = [ 'HTTP/1.1 200 OK', 'Content-Length: 0', - '' - ); + '', + ]; $this->assertEquals($expected, $actualHeaders); } @@ -272,15 +272,15 @@ public function testHandleResponseUsesWriteFunction() $test = $this; $expectedCh = curl_init(); $expectedBody = 'example response'; - $curlOptions = array( + $curlOptions = [ CURLOPT_WRITEFUNCTION => function ($ch, $body) use ($test, $expectedCh, $expectedBody) { $test->assertEquals($expectedCh, $ch); $test->assertEquals($expectedBody, $body); - return strlen($body); - } - ); - $response = new Response(200, array(), $expectedBody); + return \strlen($body); + }, + ]; + $response = new Response(200, [], $expectedBody); CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } @@ -291,11 +291,11 @@ public function testHandleResponseWritesFile() $expectedBody = 'example response'; $testFile = vfsStream::url('test/write_file'); - $curlOptions = array( - CURLOPT_FILE => fopen($testFile, 'w+') - ); + $curlOptions = [ + CURLOPT_FILE => fopen($testFile, 'w+'), + ]; - $response = new Response(200, array(), $expectedBody); + $response = new Response(200, [], $expectedBody); CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -305,8 +305,7 @@ public function testHandleResponseWritesFile() /** * @dataProvider getCurlOptionProvider() * - * @param Response $response - * @param integer $curlOption cURL option to get. + * @param int $curlOption cURL option to get * @param mixed $expectedCurlOptionValue Expected value of cURL option */ public function testGetCurlOptionFromResponse(Response $response, $curlOption, $expectedCurlOptionValue) @@ -319,93 +318,91 @@ public function testGetCurlOptionFromResponse(Response $response, $curlOption, $ public function getCurlOptionProvider() { - return array( - array( + return [ + [ Response::fromArray( - array( - 'status' => array( + [ + 'status' => [ 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', - ), - 'headers' => array( + ], + 'headers' => [ 'Host' => 'localhost:8000', 'Connection' => 'close', 'Content-type' => 'text/html; charset=UTF-8', - - ), - ) + ], + ] ), CURLINFO_HEADER_SIZE, 100, - ), - array( + ], + [ Response::fromArray( - array( - 'status' => array( + [ + 'status' => [ 'http_version' => '1.1', 'code' => 404, 'message' => 'Not Found', - ), - 'headers' => array( + ], + 'headers' => [ 'Host' => 'localhost:8000', 'Connection' => 'close', 'Content-type' => 'text/html; charset=UTF-8', - - ), - ) + ], + ] ), CURLINFO_HEADER_SIZE, 107, - ), - array( + ], + [ Response::fromArray( - array( - 'status' => array( + [ + 'status' => [ 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', - ), - 'headers' => array( + ], + 'headers' => [ 'Host' => 'localhost:8000', 'Connection' => 'close', 'Content-type' => 'text/html; charset=UTF-8', 'X-Powered-By' => 'PHP/5.6.4-4ubuntu6', - ), - ) + ], + ] ), CURLINFO_HEADER_SIZE, 134, - ), - array( + ], + [ Response::fromArray( - array( - 'status' => array( + [ + 'status' => [ 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', - ), - 'headers' => array( + ], + 'headers' => [ 'Host' => 'localhost:8000', 'Connection' => 'close', 'Content-type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'no-cache, must-revalidate', 'Pragma' => 'no-cache', - ), - ) + ], + ] ), CURLINFO_HEADER_SIZE, 160, - ), - array( + ], + [ Response::fromArray( - array( - 'status' => array( + [ + 'status' => [ 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', - ), - 'headers' => array( + ], + 'headers' => [ 'Host' => 'localhost:8000', 'Connection' => 'close', 'X-Powered-By' => 'PHP/5.6.4-4ubuntu6', @@ -414,13 +411,13 @@ public function getCurlOptionProvider() 'Cache-Control' => 'no-store, no-cache, must-revalidate', 'Pragma' => 'no-cache', 'Content-type' => 'text/html; charset=UTF-8', - ), - ) + ], + ] ), CURLINFO_HEADER_SIZE, 290, - ), - ); + ], + ]; } public function testSetCurlOptionCustomRequest() @@ -440,7 +437,7 @@ public function testCurlCustomRequestAlwaysOverridesMethod() $this->assertEquals('DELETE', $request->getMethod()); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, array('some' => 'test')); + CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, ['some' => 'test']); $this->assertEquals('DELETE', $request->getMethod()); } diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index f4570cfd9..1781ef965 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -3,7 +3,6 @@ namespace VCR\Util; use PHPUnit\Framework\TestCase; -use VCR\Response; use VCR\Request; class HttpClientTest extends TestCase diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index d83b7cafb..e6360a4d6 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -11,15 +11,15 @@ public function testParseResponseBasic() $raw = "HTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; list($status, $headers, $body) = HttpUtil::parseResponse($raw); - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); + 'Content-Length: 0', + ]; $this->assertEquals('HTTP/1.1 201 Created', $status); - $this->assertEquals(null, $body); + $this->assertEquals('', $body); $this->assertEquals($expectedHeaders, $headers); } @@ -28,16 +28,16 @@ public function testParseResponseMultipleHeaders() $raw = "HTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept, Accept-Language, Expect\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; list($status, $headers, $body) = HttpUtil::parseResponse($raw); - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept, Accept-Language, Expect', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); + 'Content-Length: 0', + ]; $this->assertEquals('HTTP/1.1 201 Created', $status); - $this->assertEquals(null, $body); + $this->assertEquals('', $body); $this->assertEquals($expectedHeaders, $headers); } @@ -46,15 +46,15 @@ public function testParseContinuePlusResponse() $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; list($status, $headers, $body) = HttpUtil::parseResponse($raw); - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); + 'Content-Length: 0', + ]; $this->assertEquals('HTTP/1.1 201 Created', $status); - $this->assertEquals(null, $body); + $this->assertEquals('', $body); $this->assertEquals($expectedHeaders, $headers); } @@ -63,82 +63,81 @@ public function testParseiMultipleContinuePlusResponse() $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; list($status, $headers, $body) = HttpUtil::parseResponse($raw); - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); + 'Content-Length: 0', + ]; $this->assertEquals('HTTP/1.1 201 Created', $status); - $this->assertEquals(null, $body); + $this->assertEquals('', $body); $this->assertEquals($expectedHeaders, $headers); } - public function testParseContinuePlusResponseMultipleHeaders() { $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept, Accept-Language, Expect\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; list($status, $headers, $body) = HttpUtil::parseResponse($raw); - $expectedHeaders = array( + $expectedHeaders = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept, Accept-Language, Expect', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); + 'Content-Length: 0', + ]; $this->assertEquals('HTTP/1.1 201 Created', $status); - $this->assertEquals(null, $body); + $this->assertEquals('', $body); $this->assertEquals($expectedHeaders, $headers); } public function testParseHeadersBasic() { - $inputArray = array( + $inputArray = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); - $excpetedHeaders = array( + 'Content-Length: 0', + ]; + $excpetedHeaders = [ 'Content-Type' => 'text/html', 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', 'Vary' => 'Accept-Encoding', - 'Content-Length' => '0' - ); + 'Content-Length' => '0', + ]; $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); } public function testParseHeadersMultiple() { - $inputArray = array( + $inputArray = [ 'Content-Type: text/html', 'Date: Fri, 19 Jun 2015 16:05:18 GMT', 'Vary: Accept, Accept-Language, Expect', 'Vary: Accept-Encoding', - 'Content-Length: 0' - ); - $excpetedHeaders = array( + 'Content-Length: 0', + ]; + $excpetedHeaders = [ 'Content-Type' => 'text/html', 'Date' => 'Fri, 19 Jun 2015 16:05:18 GMT', - 'Vary' => array('Accept, Accept-Language, Expect', 'Accept-Encoding'), - 'Content-Length' => '0' - ); + 'Vary' => ['Accept, Accept-Language, Expect', 'Accept-Encoding'], + 'Content-Length' => '0', + ]; $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); } public function testParseHeadersIncludingColons() { - $inputArray = array( - 'dropbox-api-result: {"name": "a_file.txt"}' - ); - $excpetedHeaders = array( - 'dropbox-api-result' => '{"name": "a_file.txt"}' - ); + $inputArray = [ + 'dropbox-api-result: {"name": "a_file.txt"}', + ]; + $excpetedHeaders = [ + 'dropbox-api-result' => '{"name": "a_file.txt"}', + ]; $outputArray = HttpUtil::parseHeaders($inputArray); $this->assertEquals($excpetedHeaders, $outputArray); } diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index 3d5f247d4..88a6315bf 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -2,11 +2,8 @@ namespace VCR\Util; -use lapistano\ProxyObject\ProxyBuilder; use PHPUnit\Framework\TestCase; use VCR\LibraryHooks\SoapHook; -use VCR\VCRException; -use VCR\Util\SoapClient; class SoapClientTest extends TestCase { @@ -17,13 +14,13 @@ protected function getLibraryHookMock($enabled) { $hookMock = $this->getMockBuilder('\VCR\LibraryHooks\SoapHook') ->disableOriginalConstructor() - ->setMethods(array('isEnabled', 'doRequest')) + ->setMethods(['isEnabled', 'doRequest']) ->getMock(); $hookMock ->expects($this->any()) ->method('isEnabled') - ->will($this->returnValue($enabled)); + ->willReturn($enabled); return $hookMock; } @@ -42,7 +39,7 @@ public function testDoRequest() $this->isType('string'), $this->isType('integer') ) - ->will($this->returnValue($expected)); + ->willReturn($expected); $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); @@ -56,7 +53,7 @@ public function testDoRequest() public function testDoRequestOneWayEnabled() { $hook = $this->getLibraryHookMock(true); - $hook->expects($this->once())->method('doRequest')->will($this->returnValue('some value')); + $hook->expects($this->once())->method('doRequest')->willReturn('some value'); $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); @@ -68,7 +65,7 @@ public function testDoRequestOneWayDisabled() { $expected = 'some value'; $hook = $this->getLibraryHookMock(true); - $hook ->expects($this->once()) ->method('doRequest')->will($this->returnValue($expected)); + $hook->expects($this->once())->method('doRequest')->willReturn($expected); $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); @@ -83,7 +80,7 @@ public function testDoRequestHandlesHookDisabled() { $client = $this->getMockBuilder('\VCR\Util\SoapClient') ->disableOriginalConstructor() - ->setMethods(array('realDoRequest')) + ->setMethods(['realDoRequest']) ->getMock(); $client @@ -152,11 +149,11 @@ public function testGetLastWhateverBeforeRequest() public function testGetLastWhateverAfterRequest() { - $request = 'Knorx ist groß'; + $request = 'Knorx ist groß'; $response = 'some value'; $hook = $this->getLibraryHookMock(true); - $hook->expects($this->once())->method('doRequest')->will($this->returnValue($response)); + $hook->expects($this->once())->method('doRequest')->willReturn($response); $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index d236adab1..a792fd86d 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -11,76 +11,77 @@ public function streamContexts() { $test = $this; - return array( - 'header' => array( - array('header' => 'Content-Type: application/json'), + return [ + 'header' => [ + ['header' => 'Content-Type: application/json'], function (Request $request) use ($test) { $test->assertEquals('application/json', $request->getHeader('Content-Type')); - } - ), + }, + ], - 'header with trailing newline' => array( - array('header' => "Content-Type: application/json\r\n"), + 'header with trailing newline' => [ + ['header' => "Content-Type: application/json\r\n"], function (Request $request) use ($test) { $test->assertEquals('application/json', $request->getHeader('Content-Type')); - } - ), + }, + ], - 'multiple headers' => array( - array('header' => "Content-Type: application/json\r\nContent-Length: 123"), + 'multiple headers' => [ + ['header' => "Content-Type: application/json\r\nContent-Length: 123"], function (Request $request) use ($test) { $test->assertEquals('application/json', $request->getHeader('Content-Type')); $test->assertEquals('123', $request->getHeader('Content-Length')); - } - ), + }, + ], - 'user_agent' => array( - array('user_agent' => 'example'), + 'user_agent' => [ + ['user_agent' => 'example'], function (Request $request) use ($test) { $test->assertEquals('example', $request->getHeader('User-Agent')); - } - ), + }, + ], - 'content' => array( - array('content' => 'example'), + 'content' => [ + ['content' => 'example'], function (Request $request) use ($test) { $test->assertEquals('example', $request->getBody()); - } - ), + }, + ], - 'follow_location' => array( - array('follow_location' => '0'), + 'follow_location' => [ + ['follow_location' => '0'], function (Request $request) use ($test) { $test->assertEquals(false, $request->getCurlOption(CURLOPT_FOLLOWLOCATION)); - } - ), + }, + ], - 'max_redirects' => array( - array('max_redirects' => '2'), + 'max_redirects' => [ + ['max_redirects' => '2'], function (Request $request) use ($test) { $test->assertEquals('2', $request->getCurlOption(CURLOPT_MAXREDIRS)); - } - ), + }, + ], - 'timeout' => array( - array('timeout' => '100'), + 'timeout' => [ + ['timeout' => '100'], function (Request $request) use ($test) { $test->assertEquals('100', $request->getCurlOption(CURLOPT_TIMEOUT)); - } - ) - ); + }, + ], + ]; } /** * @dataProvider streamContexts + * * @param $context * @param $testCallback */ public function testStreamHttpContext($context, $testCallback) { - $context = stream_context_create(array( - 'http' => $context - )); + $context = stream_context_create([ + 'http' => $context, + ]); $request = StreamHelper::createRequestFromStreamContext($context, 'http://example.com'); $testCallback($request); diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index fc3f2d5ec..b685bb6a7 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -2,14 +2,13 @@ namespace VCR\Util; -use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Error\Warning; +use PHPUnit\Framework\TestCase; class StreamProcessorTest extends TestCase { - /** - * test flock with file_put_contents + * test flock with file_put_contents. */ public function testFlockWithFilePutContents() { @@ -22,24 +21,25 @@ public function testFlockWithFilePutContents() unlink($testFilePath); $processor->restore(); - $this->assertEquals(strlen($testData), $res); + $this->assertEquals(\strlen($testData), $res); } /** * @dataProvider streamOpenAppendFilterProvider - * @param boolean $expected - * @param boolean $shouldProcess - * @param integer $option + * + * @param bool $expected + * @param bool $shouldProcess + * @param int $option */ public function testStreamOpenShouldAppendFilters($expected, $option, $shouldProcess = null) { $mock = $this->getMockBuilder('VCR\Util\StreamProcessor') ->disableOriginalConstructor() - ->setMethods(array('intercept', 'restore', 'appendFiltersToStream', 'shouldProcess')) + ->setMethods(['intercept', 'restore', 'appendFiltersToStream', 'shouldProcess']) ->getMock(); - if (!is_null($shouldProcess)) { - $mock->expects($this->once())->method('shouldProcess')->will($this->returnValue($shouldProcess)); + if (null !== $shouldProcess) { + $mock->expects($this->once())->method('shouldProcess')->willReturn($shouldProcess); } if ($expected) { @@ -54,22 +54,23 @@ public function testStreamOpenShouldAppendFilters($expected, $option, $shouldPro public function streamOpenAppendFilterProvider() { - return array( - array(true, StreamProcessor::STREAM_OPEN_FOR_INCLUDE, true), - array(false, StreamProcessor::STREAM_OPEN_FOR_INCLUDE, false), - array(false, 0), - ); + return [ + [true, StreamProcessor::STREAM_OPEN_FOR_INCLUDE, true], + [false, StreamProcessor::STREAM_OPEN_FOR_INCLUDE, false], + [false, 0], + ]; } public function streamOpenFileModesWhichDoNotCreateFiles() { - return array( - array('r'), - array('rb'), - array('rt'), - array('r+') - ); + return [ + ['r'], + ['rb'], + ['rt'], + ['r+'], + ]; } + /** * @dataProvider streamOpenFileModesWhichDoNotCreateFiles */ @@ -167,7 +168,7 @@ public function testStreamMetadata() $this->markTestSkipped('Behavior is only applicable and testable for PHP 5.4+'); } - if (!function_exists('posix_getuid')) { + if (!\function_exists('posix_getuid')) { $this->markTestSkipped('Requires "posix_getuid" function.'); } @@ -177,7 +178,7 @@ public function testStreamMetadata() $path = 'tests/fixtures/unnitest_streamprocessor_metadata'; $this->assertTrue($mock->stream_metadata($path, STREAM_META_TOUCH, null)); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_TOUCH, array(time(), time()))); + $this->assertTrue($mock->stream_metadata($path, STREAM_META_TOUCH, [time(), time()])); $this->assertTrue($mock->stream_metadata($path, STREAM_META_OWNER_NAME, posix_getuid())); $this->assertTrue($mock->stream_metadata($path, STREAM_META_OWNER, posix_getuid())); @@ -194,7 +195,7 @@ protected function getStreamProcessorMock() { return $this->getMockBuilder('VCR\Util\StreamProcessor') ->disableOriginalConstructor() - ->setMethods(array('intercept', 'restore')) + ->setMethods(['intercept', 'restore']) ->getMock(); } } diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/VCR/Util/TextUtilTest.php index 428aaa329..daf2036db 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/VCR/Util/TextUtilTest.php @@ -19,10 +19,10 @@ public function testUnderscoreToLowerCamelcase($expected, $method) public function curlMethodsProvider() { - return array( - 'curl_multi_add_handler' => array('curlMultiAddHandler', 'curl_multi_add_handler'), - 'curl_add_handler' => array('curlAddHandler', 'curl_add_handler'), - 'not a curl function' => array('curlExec', 'curl_exec'), - ); + return [ + 'curl_multi_add_handler' => ['curlMultiAddHandler', 'curl_multi_add_handler'], + 'curl_add_handler' => ['curlAddHandler', 'curl_add_handler'], + 'not a curl function' => ['curlExec', 'curl_exec'], + ]; } } diff --git a/tests/VCR/VCRFactoryTest.php b/tests/VCR/VCRFactoryTest.php index fb0125cd8..a36c4bb64 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/VCR/VCRFactoryTest.php @@ -12,7 +12,7 @@ class VCRFactoryTest extends TestCase { /** * @dataProvider instanceProvider - * @covers VCR\VCRFactory::createVCRVideorecorder() + * @covers \VCR\VCRFactory::createVCRVideorecorder() */ public function testCreateInstances($instance) { @@ -21,17 +21,17 @@ public function testCreateInstances($instance) public function instanceProvider() { - return array( - array('VCR\Videorecorder'), - array('VCR\Configuration'), - array('VCR\Util\StreamProcessor'), - array('VCR\Util\HttpClient'), - array('VCR\CodeTransform\CurlCodeTransform'), - array('VCR\CodeTransform\SoapCodeTransform'), - array('VCR\LibraryHooks\CurlHook'), - array('VCR\LibraryHooks\SoapHook'), - array('VCR\LibraryHooks\StreamWrapperHook'), - ); + return [ + ['VCR\Videorecorder'], + ['VCR\Configuration'], + ['VCR\Util\StreamProcessor'], + ['VCR\Util\HttpClient'], + ['VCR\CodeTransform\CurlCodeTransform'], + ['VCR\CodeTransform\SoapCodeTransform'], + ['VCR\LibraryHooks\CurlHook'], + ['VCR\LibraryHooks\SoapHook'], + ['VCR\LibraryHooks\StreamWrapperHook'], + ]; } /** @@ -44,16 +44,16 @@ public function testCreateStorage($storage, $className) VCRFactory::get('VCR\Configuration')->setStorage($storage); VCRFactory::get('VCR\Configuration')->setCassettePath(vfsStream::url('test/')); - $instance = VCRFactory::get('Storage', array(rand())); + $instance = VCRFactory::get('Storage', [rand()]); $this->assertInstanceOf($className, $instance); } public function storageProvider() { - return array( - array('json', 'VCR\Storage\Json'), - array('yaml', 'VCR\Storage\Yaml'), - ); + return [ + ['json', 'VCR\Storage\Json'], + ['yaml', 'VCR\Storage\Yaml'], + ]; } } diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 4e4db166e..8a8111187 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -2,9 +2,9 @@ namespace VCR; -use VCR\Event\Event; -use PHPUnit\Framework\TestCase; use org\bovigo\vfs\vfsStream; +use PHPUnit\Framework\TestCase; +use VCR\Event\Event; /** * Test integration of PHPVCR with PHPUnit. @@ -13,12 +13,12 @@ class VCRTest extends TestCase { public static function setupBeforeClass() { - VCR::configure()->setCassettePath('tests/fixtures') ; + VCR::configure()->setCassettePath('tests/fixtures'); } public function testUseStaticCallsNotInitialized() { - VCR::configure()->enableLibraryHooks(array('stream_wrapper')); + VCR::configure()->enableLibraryHooks(['stream_wrapper']); $this->expectException( 'VCR\VCRException', 'Please turn on VCR before inserting a cassette, use: VCR::turnOn()' @@ -28,7 +28,7 @@ public function testUseStaticCallsNotInitialized() public function testShouldInterceptStreamWrapper() { - VCR::configure()->enableLibraryHooks(array('stream_wrapper')); + VCR::configure()->enableLibraryHooks(['stream_wrapper']); VCR::turnOn(); VCR::insertCassette('unittest_streamwrapper_test'); $result = file_get_contents('http://example.com'); @@ -39,7 +39,7 @@ public function testShouldInterceptStreamWrapper() public function testShouldInterceptCurlLibrary() { - VCR::configure()->enableLibraryHooks(array('curl')); + VCR::configure()->enableLibraryHooks(['curl']); VCR::turnOn(); VCR::insertCassette('unittest_curl_test'); @@ -64,12 +64,12 @@ private function doCurlGetRequest($url) public function testShouldInterceptSoapLibrary() { - VCR::configure()->enableLibraryHooks(array('soap')); + VCR::configure()->enableLibraryHooks(['soap']); VCR::turnOn(); VCR::insertCassette('unittest_soap_test'); - $client = new \SoapClient('https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl', array('soap_version' => SOAP_1_2)); - $actual = $client->GetCityWeatherByZIP(array('ZIP' => '10013')); + $client = new \SoapClient('https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl', ['soap_version' => SOAP_1_2]); + $actual = $client->GetCityWeatherByZIP(['ZIP' => '10013']); $temperature = $actual->GetCityWeatherByZIPResult->Temperature; $this->assertEquals('1337', $temperature, 'Soap call was not intercepted.'); @@ -82,11 +82,11 @@ public function testShouldInterceptSoapLibrary() */ public function testShouldNotInterceptCallsToDevUrandom() { - if ('\\' === DIRECTORY_SEPARATOR) { + if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('/dev/urandom is not supported on Windows'); } - VCR::configure()->enableLibraryHooks(array('stream_wrapper')); + VCR::configure()->enableLibraryHooks(['stream_wrapper']); VCR::turnOn(); VCR::insertCassette('unittest_urandom_test'); @@ -103,10 +103,10 @@ public function testShouldThrowExceptionIfNoCassettePresent() $this->expectException( 'BadMethodCallException', 'Invalid http request. No cassette inserted. Please make sure to insert ' - . "a cassette in your unit test using VCR::insertCassette('name');" + ."a cassette in your unit test using VCR::insertCassette('name');" ); - VCR::configure()->enableLibraryHooks(array('stream_wrapper')); + VCR::configure()->enableLibraryHooks(['stream_wrapper']); VCR::turnOn(); // If there is no cassette inserted, a request should throw an exception file_get_contents('http://example.com'); @@ -151,7 +151,7 @@ public function testShouldSetAConfiguration() public function testShouldDispatchBeforeAndAfterPlaybackWhenCassetteHasResponse() { VCR::configure() - ->enableLibraryHooks(array('curl')); + ->enableLibraryHooks(['curl']); $this->recordAllEvents(); VCR::turnOn(); VCR::insertCassette('unittest_curl_test'); @@ -159,7 +159,7 @@ public function testShouldDispatchBeforeAndAfterPlaybackWhenCassetteHasResponse( $this->doCurlGetRequest('http://google.com/'); $this->assertEquals( - array(VCREvents::VCR_BEFORE_PLAYBACK, VCREvents::VCR_AFTER_PLAYBACK), + [VCREvents::VCR_BEFORE_PLAYBACK, VCREvents::VCR_AFTER_PLAYBACK], $this->getRecordedEventNames() ); VCR::eject(); @@ -171,7 +171,7 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse vfsStream::setup('testDir'); VCR::configure() ->setCassettePath(vfsStream::url('testDir')) - ->enableLibraryHooks(array('curl')); + ->enableLibraryHooks(['curl']); $this->recordAllEvents(); VCR::turnOn(); VCR::insertCassette('virtual_cassette'); @@ -179,12 +179,12 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse $this->doCurlGetRequest('http://google.com/'); $this->assertEquals( - array( + [ VCREvents::VCR_BEFORE_PLAYBACK, VCREvents::VCR_BEFORE_HTTP_REQUEST, VCREvents::VCR_AFTER_HTTP_REQUEST, - VCREvents::VCR_BEFORE_RECORD - ), + VCREvents::VCR_BEFORE_RECORD, + ], $this->getRecordedEventNames() ); VCR::eject(); @@ -193,15 +193,15 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse private function recordAllEvents() { - $allEventsToListen = array( + $allEventsToListen = [ VCREvents::VCR_BEFORE_PLAYBACK, VCREvents::VCR_AFTER_PLAYBACK, VCREvents::VCR_BEFORE_HTTP_REQUEST, VCREvents::VCR_AFTER_HTTP_REQUEST, VCREvents::VCR_BEFORE_RECORD, - ); + ]; foreach ($allEventsToListen as $eventToListen) { - VCR::getEventDispatcher()->addListener($eventToListen, array($this, 'recordEvent')); + VCR::getEventDispatcher()->addListener($eventToListen, [$this, 'recordEvent']); } } diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index bb7b334a6..069ffcfde 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -2,7 +2,6 @@ namespace VCR; -use lapistano\ProxyObject\ProxyBuilder; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; @@ -25,10 +24,10 @@ public function testInsertCassetteEjectExisting() $factory = VCRFactory::getInstance(); $configuration = $factory->get('VCR\Configuration'); $configuration->setCassettePath(vfsStream::url('testDir')); - $configuration->enableLibraryHooks(array()); + $configuration->enableLibraryHooks([]); $videorecorder = $this->getMockBuilder('\VCR\Videorecorder') - ->setConstructorArgs(array($configuration, new Util\HttpClient(), VCRFactory::getInstance())) - ->setMethods(array('eject')) + ->setConstructorArgs([$configuration, new Util\HttpClient(), VCRFactory::getInstance()]) + ->setMethods(['eject']) ->getMock(); $videorecorder->expects($this->exactly(2))->method('eject'); @@ -41,11 +40,11 @@ public function testInsertCassetteEjectExisting() public function testHandleRequestRecordsRequestWhenModeIsNewRecords() { - $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); - $response = new Response(200, array(), 'example response'); + $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); + $response = new Response(200, [], 'example response'); $client = $this->getClientMock($request, $response); $configuration = new Configuration(); - $configuration->enableLibraryHooks(array()); + $configuration->enableLibraryHooks([]); $configuration->setMode('new_episodes'); $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { @@ -65,14 +64,14 @@ public function testHandleRequestThrowsExceptionWhenModeIsNone() $this->expectException( 'LogicException', "The request does not match a previously recorded request and the 'mode' is set to 'none'. " - . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." + ."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." ); - $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); - $response = new Response(200, array(), 'example response'); + $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); + $response = new Response(200, [], 'example response'); $client = $this->getMockBuilder('\VCR\Util\HttpClient')->getMock(); $configuration = new Configuration(); - $configuration->enableLibraryHooks(array()); + $configuration->enableLibraryHooks([]); $configuration->setMode('none'); $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { @@ -89,11 +88,11 @@ public function setCassette(Cassette $cassette): void public function testHandleRequestRecordsRequestWhenModeIsOnceAndCassetteIsNew() { - $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); - $response = new Response(200, array(), 'example response'); + $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); + $response = new Response(200, [], 'example response'); $client = $this->getClientMock($request, $response); $configuration = new Configuration(); - $configuration->enableLibraryHooks(array()); + $configuration->enableLibraryHooks([]); $configuration->setMode('once'); $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { @@ -113,14 +112,14 @@ public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld() $this->expectException( 'LogicException', "The request does not match a previously recorded request and the 'mode' is set to 'once'. " - . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." + ."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." ); - $request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test')); - $response = new Response(200, array(), 'example response'); + $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); + $response = new Response(200, [], 'example response'); $client = $this->getMockBuilder('\VCR\Util\HttpClient')->getMock(); $configuration = new Configuration(); - $configuration->enableLibraryHooks(array()); + $configuration->enableLibraryHooks([]); $configuration->setMode('once'); $videorecorder = new class($configuration, $client, VCRFactory::getInstance()) extends Videorecorder { @@ -137,12 +136,12 @@ public function setCassette(Cassette $cassette): void protected function getClientMock($request, $response) { - $client = $this->getMockBuilder('\VCR\Util\HttpClient')->setMethods(array('send'))->getMock(); + $client = $this->getMockBuilder('\VCR\Util\HttpClient')->setMethods(['send'])->getMock(); $client ->expects($this->once()) ->method('send') ->with($request) - ->will($this->returnValue($response)); + ->willReturn($response); return $client; } @@ -151,29 +150,29 @@ protected function getCassetteMock($request, $response, $mode = VCR::MODE_NEW_EP { $cassette = $this->getMockBuilder('\VCR\Cassette') ->disableOriginalConstructor() - ->setMethods(array('record', 'playback', 'isNew', 'getName')) + ->setMethods(['record', 'playback', 'isNew', 'getName']) ->getMock(); $cassette ->expects($this->once()) ->method('playback') ->with($request) - ->will($this->returnValue(null)); + ->willReturn(null); $cassette ->method('getName') - ->will($this->returnValue('foobar')); + ->willReturn('foobar'); - if (VCR::MODE_NEW_EPISODES === $mode || VCR::MODE_ONCE === $mode && $isNew === true) { + if (VCR::MODE_NEW_EPISODES === $mode || VCR::MODE_ONCE === $mode && true === $isNew) { $cassette ->expects($this->once()) ->method('record') ->with($request, $response); } - if ($mode == 'once') { + if ('once' == $mode) { $cassette ->expects($this->once()) ->method('isNew') - ->will($this->returnValue($isNew)); + ->willReturn($isNew); } return $cassette; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c2600cb62..f79e80de6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,15 +1,15 @@ fail('Failed to start Apache server'); } diff --git a/tests/integration/apache/www/performRequest.php b/tests/integration/apache/www/performRequest.php index a5dcd1f7d..a32517dcc 100644 --- a/tests/integration/apache/www/performRequest.php +++ b/tests/integration/apache/www/performRequest.php @@ -1,4 +1,5 @@ setCassettePath(__DIR__); diff --git a/tests/integration/guzzle/3/ExampleHttpClient.php b/tests/integration/guzzle/3/ExampleHttpClient.php index 6cf864080..d5a0d2f3d 100644 --- a/tests/integration/guzzle/3/ExampleHttpClient.php +++ b/tests/integration/guzzle/3/ExampleHttpClient.php @@ -17,18 +17,18 @@ public function get($url) return json_decode($response->getBody(), true); } catch (ClientErrorResponseException $e) { - if ($e->getResponse()->getStatusCode() !== 404) { + if (404 !== $e->getResponse()->getStatusCode()) { throw $e; } } return null; } - + public function post($url, $body) { $client = new Client(); - + try { $request = $client->post($url); $request->setBody($body, 'application/json'); @@ -36,7 +36,7 @@ public function post($url, $body) return json_decode($response->getBody(), true); } catch (ClientErrorResponseException $e) { - if ($e->getResponse()->getStatusCode() !== 404) { + if (404 !== $e->getResponse()->getStatusCode()) { throw $e; } } diff --git a/tests/integration/guzzle/4/ExampleHttpClient.php b/tests/integration/guzzle/4/ExampleHttpClient.php index 9a0730887..150647d2b 100644 --- a/tests/integration/guzzle/4/ExampleHttpClient.php +++ b/tests/integration/guzzle/4/ExampleHttpClient.php @@ -13,9 +13,10 @@ public function get($url) try { $response = $client->get($url); + return $response->json(); } catch (ClientException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } @@ -26,12 +27,13 @@ public function get($url) public function post($url, $body) { $client = new Client(); - + try { - $response = $client->post($url, array('body' => $body)); + $response = $client->post($url, ['body' => $body]); + return $response->json(); } catch (ClientErrorResponseException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } diff --git a/tests/integration/guzzle/5/ExampleHttpClient.php b/tests/integration/guzzle/5/ExampleHttpClient.php index 9a0730887..150647d2b 100644 --- a/tests/integration/guzzle/5/ExampleHttpClient.php +++ b/tests/integration/guzzle/5/ExampleHttpClient.php @@ -13,9 +13,10 @@ public function get($url) try { $response = $client->get($url); + return $response->json(); } catch (ClientException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } @@ -26,12 +27,13 @@ public function get($url) public function post($url, $body) { $client = new Client(); - + try { - $response = $client->post($url, array('body' => $body)); + $response = $client->post($url, ['body' => $body]); + return $response->json(); } catch (ClientErrorResponseException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } diff --git a/tests/integration/guzzle/6/ExampleHttpClient.php b/tests/integration/guzzle/6/ExampleHttpClient.php index a32298248..c9d3b259c 100644 --- a/tests/integration/guzzle/6/ExampleHttpClient.php +++ b/tests/integration/guzzle/6/ExampleHttpClient.php @@ -13,9 +13,10 @@ public function get($url) try { $response = $client->get($url); + return json_decode($response->getBody(), true); } catch (ClientException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } @@ -26,12 +27,13 @@ public function get($url) public function post($url, $body) { $client = new Client(); - + try { - $response = $client->post($url, array('body' => $body)); + $response = $client->post($url, ['body' => $body]); + return json_decode($response->getBody(), true); } catch (ClientException $e) { - if ($e->getCode() !== 404) { + if (404 !== $e->getCode()) { throw $e; } } diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php index 6e21b61cb..b04e2a4bc 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -3,11 +3,9 @@ namespace VCR\Example; use GuzzleHttp\Client; -use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ConnectException; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; -use VCR\Util\CurlException; /** * Tests behaviour when an error occurs. diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index 14ca5a161..878b9d617 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -14,12 +14,12 @@ class ExampleHttpClientTest extends TestCase const TEST_POST_URL = 'https://httpbin.org/post'; const TEST_POST_BODY = '{"foo":"bar"}'; - protected $ignoreHeaders = array( + protected $ignoreHeaders = [ 'Accept', 'Connect-Time', 'Total-Route-Time', 'X-Request-Id', - ); + ]; public function setUp() { diff --git a/tests/integration/guzzle/test/bootstrap.php b/tests/integration/guzzle/test/bootstrap.php index 9857972ce..7332452e3 100644 --- a/tests/integration/guzzle/test/bootstrap.php +++ b/tests/integration/guzzle/test/bootstrap.php @@ -1,13 +1,14 @@ addClassMap(array( - 'VCR\\Example\\ExampleHttpClient' => 'ExampleHttpClient.php' -)); +$loader->addClassMap([ + 'VCR\\Example\\ExampleHttpClient' => 'ExampleHttpClient.php', +]); \VCR\VCR::turnOn(); \VCR\VCR::turnOff(); diff --git a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php index 204c7d1c7..94f6a101c 100644 --- a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php +++ b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php @@ -3,9 +3,9 @@ namespace VCR\Example; /** - * Converts temperature units from webservicex + * Converts temperature units from webservicex. * - * @link http://www.webservicex.net/New/Home/ServiceDetail/31 + * @see http://www.webservicex.net/New/Home/ServiceDetail/31 */ class ExampleSoapClient { @@ -13,8 +13,8 @@ class ExampleSoapClient public function call($number = 12) { - $client = new \SoapClient(self::EXAMPLE_WSDL, array('soap_version' => SOAP_1_2)); - $response = $client->NumberToWords(array('ubiNum' => $number)); + $client = new \SoapClient(self::EXAMPLE_WSDL, ['soap_version' => SOAP_1_2]); + $response = $client->NumberToWords(['ubiNum' => $number]); return trim((string) $response->NumberToWordsResult); } @@ -22,6 +22,6 @@ public function call($number = 12) public function callBadUrl() { // The port is not open. This leads to an error - $client = new \SoapClient('http://localhost:9945', array('soap_version' => SOAP_1_2)); + $client = new \SoapClient('http://localhost:9945', ['soap_version' => SOAP_1_2]); } } diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index 19518277f..2f656f904 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -7,9 +7,9 @@ use SoapFault; /** - * Converts temperature units from webservicex + * Converts temperature units from webservicex. * - * @link http://www.webservicex.net/New/Home/ServiceDetail/31 + * @see http://www.webservicex.net/New/Home/ServiceDetail/31 */ class ExampleSoapClientTest extends TestCase { @@ -74,6 +74,7 @@ public function testCallSoapWithError() protected function callSoap() { $soapClient = new ExampleSoapClient(); + return $soapClient->call(12); } diff --git a/tests/integration/soap/test/bootstrap.php b/tests/integration/soap/test/bootstrap.php index d73a1d83e..178c76340 100644 --- a/tests/integration/soap/test/bootstrap.php +++ b/tests/integration/soap/test/bootstrap.php @@ -1,5 +1,6 @@ Date: Wed, 1 Jul 2020 17:15:41 +0200 Subject: [PATCH 089/204] Implemented stream_stat --- src/VCR/Util/StreamProcessor.php | 8 ++++++++ tests/VCR/VCRTest.php | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index b59a835b9..0e836653d 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -274,6 +274,14 @@ public function stream_seek(int $offset, int $whence = SEEK_SET): bool */ public function stream_stat() { + if (false === $this->resource) { + return false; + } + + if (!$this->shouldProcess(stream_get_meta_data($this->resource)['uri'])) { + return fstat($this->resource); + } + return false; } diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 8a8111187..9ea50d9ce 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -191,6 +191,16 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse VCR::turnOff(); } + public function testFinfoWorksCorrectly(): void + { + $fileinfo = new \finfo(FILEINFO_MIME_TYPE); + + $this->assertEquals( + 'text/plain', + $fileinfo->file(__DIR__.'/../../.gitignore') + ); + } + private function recordAllEvents() { $allEventsToListen = [ From ca06c3e4947cdab1535053c183bf87fcd35f215d Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 4 Jul 2020 10:46:20 +0200 Subject: [PATCH 090/204] Allow using symfony/yaml ^5.0 --- composer.json | 2 +- composer.lock | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 359e6d7bb..d0f4a0962 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": ">=7.2", "ext-curl": "*", "beberlei/assert": "^3.2.5", - "symfony/yaml": "~2.1|^3.0|^4.0", + "symfony/yaml": "~2.1|^3.0|^4.0|^5.0", "symfony/event-dispatcher": "^2.4|^3.0|^4.0|^5.0" }, diff --git a/composer.lock b/composer.lock index eb657f550..f4157ed62 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "876c2afaafe6cbcf696cb15681264caf", + "content-hash": "f3f824b7a5e39540529bd1c3aa9b00b3", "packages": [ { "name": "beberlei/assert", @@ -420,35 +420,39 @@ }, { "name": "symfony/yaml", - "version": "v4.4.10", + "version": "v5.1.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a" + "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", - "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ea342353a3ef4f453809acc4ebc55382231d4d23", + "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/console": "<3.4" + "symfony/console": "<4.4" }, "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, + "bin": [ + "Resources/bin/yaml-lint" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -475,7 +479,21 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-05-20T08:37:50+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-20T17:43:50+00:00" } ], "packages-dev": [ From 9297ec7128edd60d10dc49333f913f138d83ab74 Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Fri, 25 Oct 2019 13:26:00 +0200 Subject: [PATCH 091/204] Add Failing test --- tests/VCR/CodeTransform/SoapCodeTransformTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/VCR/CodeTransform/SoapCodeTransformTest.php index 259ee851f..e975387c2 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/VCR/CodeTransform/SoapCodeTransformTest.php @@ -26,6 +26,8 @@ public function codeSnippetProvider() array('new \VCR\Util\SoapClient(', 'new SoapClient('), array('extends \VCR\Util\SoapClient', 'extends \SoapClient'), array("extends \\VCR\\Util\\SoapClient\n", "extends \\SoapClient\n"), + array("extends MySoapClientBuilder\n", "extends MySoapClientBuilder\n"), + array("extends SoapClientFactory\n", "extends SoapClientFactory\n"), array('new SoapClientExtended(', 'new SoapClientExtended('), array('new \SoapClientExtended(', 'new \SoapClientExtended('), ); From 9375ef028f0605f7d2c079e087ff4deaeed28e9f Mon Sep 17 00:00:00 2001 From: Jan Vernieuwe Date: Fri, 25 Oct 2019 13:30:13 +0200 Subject: [PATCH 092/204] Add word boundary to regex --- src/VCR/CodeTransform/SoapCodeTransform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/CodeTransform/SoapCodeTransform.php b/src/VCR/CodeTransform/SoapCodeTransform.php index 6c192b041..0233fb3a7 100644 --- a/src/VCR/CodeTransform/SoapCodeTransform.php +++ b/src/VCR/CodeTransform/SoapCodeTransform.php @@ -13,7 +13,7 @@ class SoapCodeTransform extends AbstractCodeTransform private static $patterns = array( '@new\s+\\\?SoapClient\W*\(@i', - '@extends\s+\\\?SoapClient@i', + '@extends\s+\\\?SoapClient\b@i', ); /** From 2c0e9b3f546e6993a39c05ba6e363dca43d86fb6 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 27 Jul 2020 20:23:18 +0200 Subject: [PATCH 093/204] Updated vfsstream --- composer.json | 2 +- composer.lock | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index d0f4a0962..1b6e6200c 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "require-dev": { "phpunit/phpunit": "^7.4.3", - "mikey179/vfsstream": "^1.2", + "mikey179/vfsstream": "^1.6", "phpstan/phpstan": "^0.12", "phpstan/phpstan-beberlei-assert": "^0.12.0", "thecodingmachine/phpstan-strict-rules": "^0.12", diff --git a/composer.lock b/composer.lock index f4157ed62..7fa105cee 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f3f824b7a5e39540529bd1c3aa9b00b3", + "content-hash": "4557ebbf24cb7867737dda83643f0581", "packages": [ { "name": "beberlei/assert", @@ -230,6 +230,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-05-20T17:43:50+00:00" }, { @@ -350,6 +364,20 @@ "polyfill", "portable" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-06T08:46:27+00:00" }, { @@ -416,6 +444,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-06T08:46:27+00:00" }, { @@ -739,6 +781,20 @@ "constructor", "instantiate" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], "time": "2020-05-29T17:27:14+00:00" }, { From 6ffdd9e6c6e9e9110627d4e4902ef7a1196123d1 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Tue, 28 Jul 2020 10:49:16 +0200 Subject: [PATCH 094/204] Updated readme and composer.json --- README.md | 4 ++-- composer.json | 13 ++----------- composer.lock | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a33a439b9..c739accf8 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,9 @@ $ composer require --dev php-vcr/php-vcr PHP-VCR depends on: - * PHP 5.3+ + * PHP 7.2+ * Curl extension - * HTTP library [Guzzle](http://guzzlephp.org) + * [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher) * [symfony/yaml](https://github.com/symfony/yaml) * [beberlei/assert](https://github.com/beberlei/assert) diff --git a/composer.json b/composer.json index 1b6e6200c..f72751eb0 100644 --- a/composer.json +++ b/composer.json @@ -2,21 +2,18 @@ "name": "php-vcr/php-vcr", "description": "Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.", "license": "MIT", - "scripts": { "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", "phpstan": "phpstan analyse -c phpstan.neon --no-progress -vvv" }, - "authors": [ { "name": "Adrian Philipp", "email": "mail@adrian-philipp.com" } ], - "require": { "php": ">=7.2", "ext-curl": "*", @@ -24,7 +21,6 @@ "symfony/yaml": "~2.1|^3.0|^4.0|^5.0", "symfony/event-dispatcher": "^2.4|^3.0|^4.0|^5.0" }, - "require-dev": { "phpunit/phpunit": "^7.4.3", "mikey179/vfsstream": "^1.6", @@ -34,14 +30,9 @@ "sebastian/version": "^1.0.3|^2.0", "friendsofphp/php-cs-fixer": "^2.16" }, - "autoload": { - "classmap": ["src/"] - }, - - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" + "psr-4": { + "VCR\\": "src/VCR/" } } } diff --git a/composer.lock b/composer.lock index 7fa105cee..897a44237 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4557ebbf24cb7867737dda83643f0581", + "content-hash": "44979e7fe95efbdd1b2f368758a85d6f", "packages": [ { "name": "beberlei/assert", From 82eb7d585a0f89c7a9bf0209fc845cfaf8b708b3 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Tue, 28 Jul 2020 11:03:43 +0200 Subject: [PATCH 095/204] Removed Guzzle 4 test as Guzzle 4 is not compatible with PHP >= 7.1 --- .travis.yml | 5 - .../guzzle/4/ExampleHttpClient.php | 43 ------ tests/integration/guzzle/4/composer.json | 5 - tests/integration/guzzle/4/composer.lock | 136 ------------------ tests/integration/guzzle/4/phpunit.xml | 14 -- 5 files changed, 203 deletions(-) delete mode 100644 tests/integration/guzzle/4/ExampleHttpClient.php delete mode 100644 tests/integration/guzzle/4/composer.json delete mode 100644 tests/integration/guzzle/4/composer.lock delete mode 100644 tests/integration/guzzle/4/phpunit.xml diff --git a/.travis.yml b/.travis.yml index 87ec4fcdf..f6c0c12b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,6 @@ matrix: - docker - env: TEST_DIR=tests/integration/guzzle/3 php: 7.2 -# Guzzle 4 is not compatible with PHP >= 7.1 due to an error in the code that was only fixed in Guzzle 5. -# See: https://github.com/guzzle/guzzle/pull/1393 -# - env: TEST_DIR=tests/integration/guzzle/4 -# php: 7.2 - env: TEST_DIR=tests/integration/guzzle/5 php: 7.2 - env: TEST_DIR=tests/integration/guzzle/6 @@ -52,7 +48,6 @@ cache: directories: - vendor - tests/integration/guzzle/3/vendor -# - tests/integration/guzzle/4/vendor - tests/integration/guzzle/5/vendor - tests/integration/guzzle/6/vendor - tests/integration/soap/vendor diff --git a/tests/integration/guzzle/4/ExampleHttpClient.php b/tests/integration/guzzle/4/ExampleHttpClient.php deleted file mode 100644 index 150647d2b..000000000 --- a/tests/integration/guzzle/4/ExampleHttpClient.php +++ /dev/null @@ -1,43 +0,0 @@ -get($url); - - return $response->json(); - } catch (ClientException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } - - public function post($url, $body) - { - $client = new Client(); - - try { - $response = $client->post($url, ['body' => $body]); - - return $response->json(); - } catch (ClientErrorResponseException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } -} diff --git a/tests/integration/guzzle/4/composer.json b/tests/integration/guzzle/4/composer.json deleted file mode 100644 index 1291254e1..000000000 --- a/tests/integration/guzzle/4/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "guzzlehttp/guzzle": "~4.0" - } -} diff --git a/tests/integration/guzzle/4/composer.lock b/tests/integration/guzzle/4/composer.lock deleted file mode 100644 index b4582dc3d..000000000 --- a/tests/integration/guzzle/4/composer.lock +++ /dev/null @@ -1,136 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "dd5aa4e5d110b03429e712f90ca10a0b", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "4.2.4", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "13a8e5acff26b0a87d353042170b48976da004a1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/13a8e5acff26b0a87d353042170b48976da004a1", - "reference": "13a8e5acff26b0a87d353042170b48976da004a1", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/streams": "~2.1", - "php": ">=5.4.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2016-07-15T17:44:18+00:00" - }, - { - "name": "guzzlehttp/streams", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/f91b721d73f0e561410903b3b3c90a5d0e40b534", - "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple abstraction over streams of data (Guzzle 4+)", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "Guzzle", - "stream" - ], - "time": "2014-08-17T21:15:53+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/tests/integration/guzzle/4/phpunit.xml b/tests/integration/guzzle/4/phpunit.xml deleted file mode 100644 index 30e6c463b..000000000 --- a/tests/integration/guzzle/4/phpunit.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ../test - - - - From 6cc06e2a4074025577a1da5451e1d92b44e8950d Mon Sep 17 00:00:00 2001 From: pvgnd Date: Sat, 21 Nov 2020 19:14:17 +0100 Subject: [PATCH 096/204] fix: phpstan ignore error failure on PHP >= 7.2 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 9c89ab256..81d412d16 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,7 +10,7 @@ parameters: message: '#Unreachable statement - code above always terminates.#' path: src/VCR/CodeTransform/AbstractCodeTransform.php # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - - '#Parameter .* \$str of function substr expects string, string\|false given.#' + - '#Parameter .* \$str(ing)? of function substr expects string, string\|false given.#' # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string\|null given./' - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' From 4b8f627eda2add52be870aa42b9acb62b9a77d59 Mon Sep 17 00:00:00 2001 From: pvgnd Date: Sat, 21 Nov 2020 19:29:24 +0100 Subject: [PATCH 097/204] fix: ensure stream_wrapper_restore does not throw --- src/VCR/Util/StreamProcessor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 0e836653d..3b9e6223a 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -82,6 +82,8 @@ public function intercept(): void */ public function restore(): void { + // stream_wrapper_restore can throw when stream_wrapper was never changed, so we unregister first + stream_wrapper_unregister(self::PROTOCOL); stream_wrapper_restore(self::PROTOCOL); } From 923541262e445f811d6f727a799bcd9c6d738bd5 Mon Sep 17 00:00:00 2001 From: pvgnd Date: Sat, 21 Nov 2020 15:43:02 +0100 Subject: [PATCH 098/204] chore: Ignore composer.lock --- .gitignore | 1 + composer.lock | 3773 ------------------------------------------------- 2 files changed, 1 insertion(+), 3773 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 2883d5b45..f11debb47 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ notes.md tests/fixtures/cassette* /.php_cs.cache /.php_cs +composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 897a44237..000000000 --- a/composer.lock +++ /dev/null @@ -1,3773 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "44979e7fe95efbdd1b2f368758a85d6f", - "packages": [ - { - "name": "beberlei/assert", - "version": "v3.2.7", - "source": { - "type": "git", - "url": "https://github.com/beberlei/assert.git", - "reference": "d63a6943fc4fd1a2aedb65994e3548715105abcf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/d63a6943fc4fd1a2aedb65994e3548715105abcf", - "reference": "d63a6943fc4fd1a2aedb65994e3548715105abcf", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-simplexml": "*", - "php": "^7" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "*", - "phpstan/phpstan-shim": "*", - "phpunit/phpunit": ">=6.0.0 <8" - }, - "suggest": { - "ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles" - }, - "type": "library", - "autoload": { - "psr-4": { - "Assert\\": "lib/Assert" - }, - "files": [ - "lib/Assert/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de", - "role": "Lead Developer" - }, - { - "name": "Richard Quadling", - "email": "rquadling@gmail.com", - "role": "Collaborator" - } - ], - "description": "Thin assertion library for input validation in business models.", - "keywords": [ - "assert", - "assertion", - "validation" - ], - "time": "2019-12-19T17:51:41+00:00" - }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "time": "2019-01-08T18:20:26+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", - "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "time": "2020-05-27T08:34:37+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/cc0d059e2e997e79ca34125a52f3e33de4424ac7", - "reference": "cc0d059e2e997e79ca34125a52f3e33de4424ac7", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/event-dispatcher-contracts": "^2", - "symfony/polyfill-php80": "^1.15" - }, - "conflict": { - "symfony/dependency-injection": "<4.4" - }, - "provide": { - "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/service-contracts": "^1.1|^2", - "symfony/stopwatch": "^4.4|^5.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - }, - { - "name": "symfony/event-dispatcher-contracts", - "version": "v2.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "405952c4e90941a17e52ef7489a2bd94870bb290" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/405952c4e90941a17e52ef7489a2bd94870bb290", - "reference": "405952c4e90941a17e52ef7489a2bd94870bb290", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/event-dispatcher": "^1" - }, - "suggest": { - "symfony/event-dispatcher-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to dispatching event", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "time": "2020-05-20T17:43:50+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", - "shasum": "" - }, - "require": { - "php": ">=7.0.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/yaml", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ea342353a3ef4f453809acc4ebc55382231d4d23", - "reference": "ea342353a3ef4f453809acc4ebc55382231d4d23", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<4.4" - }, - "require-dev": { - "symfony/console": "^4.4|^5.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - } - ], - "packages-dev": [ - { - "name": "composer/semver", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de", - "reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "time": "2020-01-13T12:06:48+00:00" - }, - { - "name": "composer/xdebug-handler", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", - "reference": "fa2aaf99e2087f013a14f7432c1cd2dd7d8f1f51", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without Xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2020-06-04T11:16:35+00:00" - }, - { - "name": "doctrine/annotations", - "version": "1.10.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/5db60a4969eba0e0c197a19c077780aadbc43c5d", - "reference": "5db60a4969eba0e0c197a19c077780aadbc43c5d", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "ext-tokenizer": "*", - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "^7.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2020-05-25T17:24:27+00:00" - }, - { - "name": "doctrine/instantiator", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", - "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2020-05-29T17:27:14+00:00" - }, - { - "name": "doctrine/lexer", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "e864bbf5904cb8f5bb334f99209b48018522f042" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042", - "reference": "e864bbf5904cb8f5bb334f99209b48018522f042", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpstan/phpstan": "^0.11.8", - "phpunit/phpunit": "^8.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", - "type": "tidelift" - } - ], - "time": "2020-05-25T17:44:05+00:00" - }, - { - "name": "friendsofphp/php-cs-fixer", - "version": "v2.16.4", - "source": { - "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/1023c3458137ab052f6ff1e09621a721bfdeca13", - "reference": "1023c3458137ab052f6ff1e09621a721bfdeca13", - "shasum": "" - }, - "require": { - "composer/semver": "^1.4", - "composer/xdebug-handler": "^1.2", - "doctrine/annotations": "^1.2", - "ext-json": "*", - "ext-tokenizer": "*", - "php": "^5.6 || ^7.0", - "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.4.17 || ^4.1.6 || ^5.0", - "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", - "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", - "symfony/finder": "^3.0 || ^4.0 || ^5.0", - "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", - "symfony/polyfill-php70": "^1.0", - "symfony/polyfill-php72": "^1.4", - "symfony/process": "^3.0 || ^4.0 || ^5.0", - "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" - }, - "require-dev": { - "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", - "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.2", - "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^2.1", - "php-cs-fixer/accessible-object": "^1.0", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", - "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", - "phpunitgoodpractices/traits": "^1.8", - "symfony/phpunit-bridge": "^5.1", - "symfony/yaml": "^3.0 || ^4.0 || ^5.0" - }, - "suggest": { - "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters.", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", - "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." - }, - "bin": [ - "php-cs-fixer" - ], - "type": "application", - "autoload": { - "psr-4": { - "PhpCsFixer\\": "src/" - }, - "classmap": [ - "tests/Test/AbstractFixerTestCase.php", - "tests/Test/AbstractIntegrationCaseFactory.php", - "tests/Test/AbstractIntegrationTestCase.php", - "tests/Test/Assert/AssertTokensTrait.php", - "tests/Test/IntegrationCase.php", - "tests/Test/IntegrationCaseFactory.php", - "tests/Test/IntegrationCaseFactoryInterface.php", - "tests/Test/InternalIntegrationCaseFactory.php", - "tests/Test/IsIdenticalConstraint.php", - "tests/TestCase.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - } - ], - "description": "A tool to automatically fix PHP code style", - "funding": [ - { - "url": "https://github.com/keradus", - "type": "github" - } - ], - "time": "2020-06-27T23:57:46+00:00" - }, - { - "name": "mikey179/vfsstream", - "version": "v1.6.8", - "source": { - "type": "git", - "url": "https://github.com/bovigo/vfsStream.git", - "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe", - "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.5|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-0": { - "org\\bovigo\\vfs\\": "src/main/php" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Frank Kleine", - "homepage": "http://frankkleine.de/", - "role": "Developer" - } - ], - "description": "Virtual file system to mock the real file system in unit tests.", - "homepage": "http://vfs.bovigo.org/", - "time": "2019-10-30T15:31:00+00:00" - }, - { - "name": "myclabs/deep-copy", - "version": "1.10.1", - "source": { - "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", - "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "replace": { - "myclabs/deep-copy": "self.version" - }, - "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Create deep copies (clones) of your objects", - "keywords": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" - ], - "funding": [ - { - "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", - "type": "tidelift" - } - ], - "time": "2020-06-29T13:22:24+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.99", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", - "shasum": "" - }, - "require": { - "php": "^7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "time": "2018-07-02T15:55:56+00:00" - }, - { - "name": "phar-io/manifest", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" - }, - { - "name": "phar-io/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - }, - { - "name": "Sebastian Heuer", - "email": "sebastian@phpeople.de", - "role": "Developer" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "Developer" - } - ], - "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" - }, - { - "name": "php-cs-fixer/diff", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", - "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3", - "symfony/process": "^3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "SpacePossum" - } - ], - "description": "sebastian/diff v2 backport support for PHP5.6", - "homepage": "https://github.com/PHP-CS-Fixer", - "keywords": [ - "diff" - ], - "time": "2018-02-15T16:58:55+00:00" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.1.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "shasum": "" - }, - "require": { - "ext-filter": "^7.1", - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0", - "phpdocumentor/type-resolver": "^1.0", - "webmozart/assert": "^1" - }, - "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-02-22T12:28:44+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", - "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-06-27T10:12:23+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.10.3", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2020-03-05T15:02:03+00:00" - }, - { - "name": "phpstan/phpstan", - "version": "0.12.32", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "d03863f504c8432b3de4d1881f73f6acb8c0e67c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d03863f504c8432b3de4d1881f73f6acb8c0e67c", - "reference": "d03863f504c8432b3de4d1881f73f6acb8c0e67c", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "conflict": { - "phpstan/phpstan-shim": "*" - }, - "bin": [ - "phpstan", - "phpstan.phar" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan - PHP Static Analysis Tool", - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], - "time": "2020-07-01T11:57:52+00:00" - }, - { - "name": "phpstan/phpstan-beberlei-assert", - "version": "0.12.2", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan-beberlei-assert.git", - "reference": "c13141d2548ded3724a56ff0f7df37384187a149" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-beberlei-assert/zipball/c13141d2548ded3724a56ff0f7df37384187a149", - "reference": "c13141d2548ded3724a56ff0f7df37384187a149", - "shasum": "" - }, - "require": { - "php": "~7.1", - "phpstan/phpstan": "^0.12.3" - }, - "require-dev": { - "beberlei/assert": "^2.9.5", - "consistence/coding-standard": "^3.0.1", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "ergebnis/composer-normalize": "^2.0.2", - "jakub-onderka/php-parallel-lint": "^1.0", - "phing/phing": "^2.16.0", - "phpstan/phpstan-phpunit": "^0.12.3", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^7.5.18", - "slevomat/coding-standard": "^4.5.2" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "extension.neon" - ] - } - }, - "autoload": { - "psr-4": { - "PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPStan beberlei/assert extension", - "time": "2020-01-03T10:02:05+00:00" - }, - { - "name": "phpunit/php-code-coverage", - "version": "6.1.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1 || ^4.0", - "sebastian/version": "^2.0.1", - "theseer/tokenizer": "^1.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "suggest": { - "ext-xdebug": "^2.6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2018-10-31T16:06:48+00:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2018-09-13T20:33:42+00:00" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21T13:50:34+00:00" - }, - { - "name": "phpunit/php-timer", - "version": "2.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2019-06-07T04:22:29+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2019-09-17T06:23:10+00:00" - }, - { - "name": "phpunit/phpunit", - "version": "7.5.20", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9467db479d1b0487c99733bb1e7944d32deded2c", - "reference": "9467db479d1b0487c99733bb1e7944d32deded2c", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.1", - "ext-dom": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-mbstring": "*", - "ext-xml": "*", - "myclabs/deep-copy": "^1.7", - "phar-io/manifest": "^1.0.2", - "phar-io/version": "^2.0", - "php": "^7.1", - "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0.1", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1", - "sebastian/comparator": "^3.0", - "sebastian/diff": "^3.0", - "sebastian/environment": "^4.0", - "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0", - "sebastian/version": "^2.0.1" - }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, - "require-dev": { - "ext-pdo": "*" - }, - "suggest": { - "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.5-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2020-01-08T08:45:45+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/log", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", - "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2020-03-23T09:12:05+00:00" - }, - { - "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Looks up which function or method a line of code belongs to", - "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" - }, - { - "name": "sebastian/comparator", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "shasum": "" - }, - "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "https://github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2018-07-12T15:12:46+00:00" - }, - { - "name": "sebastian/diff", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff", - "udiff", - "unidiff", - "unified diff" - ], - "time": "2019-02-04T06:01:07+00:00" - }, - { - "name": "sebastian/environment", - "version": "4.2.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.5" - }, - "suggest": { - "ext-posix": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2019-11-20T08:46:58+00:00" - }, - { - "name": "sebastian/exporter", - "version": "3.1.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2019-09-14T09:02:43+00:00" - }, - { - "name": "sebastian/global-state", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2017-04-27T15:39:26+00:00" - }, - { - "name": "sebastian/object-enumerator", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "shasum": "" - }, - "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Traverses array structures and object graphs to enumerate all referenced objects", - "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" - }, - { - "name": "sebastian/object-reflector", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Allows reflection of object attributes, including inherited and non-public ones", - "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" - }, - { - "name": "sebastian/recursion-context", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "shasum": "" - }, - "require": { - "php": "^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" - }, - { - "name": "sebastian/version", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "symfony/console", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "34ac555a3627e324b660e318daa07572e1140123" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/34ac555a3627e324b660e318daa07572e1140123", - "reference": "34ac555a3627e324b660e318daa07572e1140123", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.15", - "symfony/service-contracts": "^1.1|^2", - "symfony/string": "^5.1" - }, - "conflict": { - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/event-dispatcher": "^4.4|^5.0", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", - "symfony/var-dumper": "^4.4|^5.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-15T12:59:21+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "6e4320f06d5f2cce0d96530162491f4465179157" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/6e4320f06d5f2cce0d96530162491f4465179157", - "reference": "6e4320f06d5f2cce0d96530162491f4465179157", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-30T20:35:19+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4298870062bfc667cb78d2b379be4bf5dec5f187", - "reference": "4298870062bfc667cb78d2b379be4bf5dec5f187", - "shasum": "" - }, - "require": { - "php": ">=7.2.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - }, - { - "name": "symfony/options-resolver", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "663f5dd5e14057d1954fe721f9709d35837f2447" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/663f5dd5e14057d1954fe721f9709d35837f2447", - "reference": "663f5dd5e14057d1954fe721f9709d35837f2447", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-php80": "^1.15" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony OptionsResolver Component", - "homepage": "https://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-23T13:08:13+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/6e4dbcf5e81eba86e36731f94fe56b1726835846", - "reference": "6e4dbcf5e81eba86e36731f94fe56b1726835846", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "40309d1700e8f72447bb9e7b54af756eeea35620" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/40309d1700e8f72447bb9e7b54af756eeea35620", - "reference": "40309d1700e8f72447bb9e7b54af756eeea35620", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-14T14:40:37+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/polyfill-php70", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/polyfill-php72", - "version": "v1.17.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "f048e612a3905f34931127360bdd2def19a5e582" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", - "reference": "f048e612a3905f34931127360bdd2def19a5e582", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-12T16:47:27+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, - { - "name": "symfony/process", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", - "reference": "7f6378c1fa2147eeb1b4c385856ce9de0d46ebd1", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.15" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-30T20:35:19+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.0" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - }, - { - "name": "symfony/stopwatch", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/stopwatch.git", - "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0f7c58cf81dbb5dd67d423a89d577524a2ec0323", - "reference": "0f7c58cf81dbb5dd67d423a89d577524a2ec0323", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1.0|^2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Stopwatch\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Stopwatch Component", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-05-20T17:43:50+00:00" - }, - { - "name": "symfony/string", - "version": "v5.1.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ac70459db781108db7c6d8981dd31ce0e29e3298", - "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" - }, - "require-dev": { - "symfony/error-handler": "^4.4|^5.0", - "symfony/http-client": "^4.4|^5.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "files": [ - "Resources/functions.php" - ], - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony String component", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-11T12:16:36+00:00" - }, - { - "name": "thecodingmachine/phpstan-strict-rules", - "version": "v0.12.0", - "source": { - "type": "git", - "url": "https://github.com/thecodingmachine/phpstan-strict-rules.git", - "reference": "8c58cc87dc870382b228c95c4f1cc9fc871aaf28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thecodingmachine/phpstan-strict-rules/zipball/8c58cc87dc870382b228c95c4f1cc9fc871aaf28", - "reference": "8c58cc87dc870382b228c95c4f1cc9fc871aaf28", - "shasum": "" - }, - "require": { - "php": "^7.1", - "phpstan/phpstan": "^0.12" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^7.1" - }, - "type": "phpstan-extension", - "extra": { - "branch-alias": { - "dev-master": "0.12-dev" - }, - "phpstan": { - "includes": [ - "phpstan-strict-rules.neon" - ] - } - }, - "autoload": { - "psr-4": { - "TheCodingMachine\\PHPStan\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "David Négrier", - "email": "d.negrier@thecodingmachine.com" - } - ], - "description": "A set of additional rules for PHPStan based on best practices followed at TheCodingMachine", - "time": "2019-12-04T11:25:22+00:00" - }, - { - "name": "theseer/tokenizer", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": "^7.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" - } - ], - "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.9.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<3.9.1" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" - }, - "type": "library", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2020-06-16T10:16:42+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.2", - "ext-curl": "*" - }, - "platform-dev": [], - "plugin-api-version": "1.1.0" -} From 3f13b2bc9c0690155281d6f296d13829382c14cd Mon Sep 17 00:00:00 2001 From: Alasdair North Date: Mon, 19 Nov 2018 12:42:33 +0000 Subject: [PATCH 099/204] call_user_func doesn't work in this context with private or protected functions. This should solve an issue encountered when using php-vcr with the PayPal SDK (https://github.com/paypal/PayPal-PHP-SDK/issues/1057). --- src/VCR/Util/CurlHelper.php | 28 +++++++- tests/VCR/Util/CurlHelperTest.php | 115 ++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 2 deletions(-) diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 3e234cd83..cc31468a5 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -58,7 +58,7 @@ public static function handleOutput(Response $response, array $curlOptions, $ch) $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders())); $headerList[] = ''; foreach ($headerList as $header) { - \call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); + self::callFunction($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); } } @@ -69,7 +69,7 @@ public static function handleOutput(Response $response, array $curlOptions, $ch) } if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) { - \call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); + self::callFunction($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && true == $curlOptions[CURLOPT_RETURNTRANSFER]) { return $body; } elseif (isset($curlOptions[CURLOPT_FILE])) { @@ -213,4 +213,28 @@ public static function validateCurlPOSTBody(Request $request, $curlHandle = null $body = \call_user_func_array($readFunction, [$curlHandle, fopen('php://memory', 'r'), $bodySize]); $request->setBody($body); } + + /** + * A wrapper around call_user_func that attempts to properly handle private + * and protected methods on objects. + * + * @param mixed $callback The callable to pass to call_user_func + * @param resource $curlHandle cURL handle associated with the request + * @param mixed $argument The third argument to pass to call_user_func + * + * @return mixed value returned by the callback function + */ + private static function callFunction($callback, $curlHandle, $argument) + { + if (!\is_callable($callback) && \is_array($callback) && 2 === \count($callback)) { + // This is probably a private or protected method on an object. Try and + // make it accessible. + $method = new \ReflectionMethod($callback[0], $callback[1]); + $method->setAccessible(true); + + return $method->invoke($callback[0], $curlHandle, $argument); + } else { + return \call_user_func($callback, $curlHandle, $argument); + } + } } diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 81f1cca8c..35fdadf50 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -267,6 +267,81 @@ public function testHandleOutputHeaderFunction() $this->assertEquals($expected, $actualHeaders); } + public function testHandleOutputHeaderFunctionWithPublicFunction() + { + $this->headersFound = []; + $curlOptions = [ + CURLOPT_HEADERFUNCTION => [$this, 'publicCurlHeaderFunction'], + ]; + $status = [ + 'code' => 200, + 'message' => 'OK', + 'http_version' => '1.1', + ]; + $headers = [ + 'Content-Length' => 0, + ]; + $response = new Response($status, $headers, 'example response'); + CurlHelper::handleOutput($response, $curlOptions, curl_init()); + + $expected = [ + 'HTTP/1.1 200 OK', + 'Content-Length: 0', + '', + ]; + $this->assertEquals($expected, $this->headersFound); + } + + public function testHandleOutputHeaderFunctionWithProtectedFunction() + { + $this->headersFound = []; + $curlOptions = [ + CURLOPT_HEADERFUNCTION => [$this, 'protectedCurlHeaderFunction'], + ]; + $status = [ + 'code' => 200, + 'message' => 'OK', + 'http_version' => '1.1', + ]; + $headers = [ + 'Content-Length' => 0, + ]; + $response = new Response($status, $headers, 'example response'); + CurlHelper::handleOutput($response, $curlOptions, curl_init()); + + $expected = [ + 'HTTP/1.1 200 OK', + 'Content-Length: 0', + '', + ]; + $this->assertEquals($expected, $this->headersFound); + } + + public function testHandleOutputHeaderFunctionWithPrivateFunction() + { + $this->headersFound = []; + $curlOptions = [ + CURLOPT_HEADERFUNCTION => [$this, 'privateCurlHeaderFunction'], + ]; + $status = [ + 'code' => 200, + 'message' => 'OK', + 'http_version' => '1.1', + ]; + $headers = [ + 'Content-Length' => 0, + ]; + $response = new Response($status, $headers, 'example response'); + CurlHelper::handleOutput($response, $curlOptions, curl_init()); + + $expected = [ + 'HTTP/1.1 200 OK', + 'Content-Length: 0', + '', + ]; + $this->assertEquals($expected, $this->headersFound); + } + public function testHandleResponseUsesWriteFunction() { $test = $this; @@ -285,6 +360,19 @@ public function testHandleResponseUsesWriteFunction() CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } + public function testHandleResponseUsesWriteFunctionWithPrivateFunction() + { + $test = $this; + $expectedCh = curl_init(); + $expectedBody = 'example response'; + $curlOptions = [ + CURLOPT_WRITEFUNCTION => [$this, 'privateCurlWriteFunction'], + ]; + $response = new Response(200, [], $expectedBody); + + CurlHelper::handleOutput($response, $curlOptions, $expectedCh); + } + public function testHandleResponseWritesFile() { vfsStream::setup('test'); @@ -441,4 +529,31 @@ public function testCurlCustomRequestAlwaysOverridesMethod() $this->assertEquals('DELETE', $request->getMethod()); } + + // Function used for testing CURLOPT_HEADERFUNCTION + public function publicCurlHeaderFunction($ch, $header) + { + $this->headersFound[] = $header; + } + + // Function used for testing CURLOPT_HEADERFUNCTION + protected function protectedCurlHeaderFunction($ch, $header) + { + $this->headersFound[] = $header; + } + + // Function used for testing CURLOPT_HEADERFUNCTION + private function privateCurlHeaderFunction($ch, $header) + { + $this->headersFound[] = $header; + } + + // Function used for testing CURLOPT_WRITEFUNCTION + private function privateCurlWriteFunction($ch, $body) + { + $this->assertEquals('resource', \gettype($ch)); + $this->assertEquals('example response', $body); + + return \strlen($body); + } } From 1ad34135f067ea5b871ff1ab0b7c79ff277f55af Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 23 Nov 2020 13:31:09 +1100 Subject: [PATCH 100/204] Support for ssl requests in some edge cases like paypal php sdk --- src/VCR/Util/CurlHelper.php | 3 +++ src/VCR/VCRFactory.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index cc31468a5..adc2488e7 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -111,6 +111,9 @@ public static function getCurlOptionFromResponse(Response $response, int $option case CURLINFO_HEADER_SIZE: $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; + case CURLPROXY_HTTPS: + $info = ''; + break; default: $info = $response->getCurlInfo(self::$curlInfoList[$option]); break; diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index a629eb5b3..83d923c91 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -32,6 +32,10 @@ class VCRFactory protected function __construct(Configuration $config = null) { $this->config = $config ?: $this->getOrCreate('VCR\Configuration'); + + // This constant exists only from PHP 7.3 + // Once we are no longer supporting 7.2, we can remove this + defined('CURLPROXY_HTTPS') or define('CURLPROXY_HTTPS', 2); } protected function createVCRVideorecorder(): Videorecorder From b83096689115440a15d04bb45ab6660313d0557f Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 23 Nov 2020 13:45:19 +1100 Subject: [PATCH 101/204] CS rule --- src/VCR/VCRFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index 83d923c91..36a8dd399 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -35,7 +35,7 @@ protected function __construct(Configuration $config = null) // This constant exists only from PHP 7.3 // Once we are no longer supporting 7.2, we can remove this - defined('CURLPROXY_HTTPS') or define('CURLPROXY_HTTPS', 2); + \defined('CURLPROXY_HTTPS') or \define('CURLPROXY_HTTPS', 2); } protected function createVCRVideorecorder(): Videorecorder From 1f5e709f0dabaa03b0710b2bdce2a44c8d5cc11e Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 23 Nov 2020 14:05:12 +1100 Subject: [PATCH 102/204] Update phpstan config --- phpstan.neon | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index 81d412d16..33282c1c6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,8 @@ parameters: level: 7 paths: - src + # Can remove reportUnmatchedIgnoredErrors option after php 7.2 is no longer supported + reportUnmatchedIgnoredErrors: false ignoreErrors: # This part of PHP is not very well documented, resulting PHPStan's definitions not being accurate - "#Access to an undefined property object::\\$data\\.#" @@ -14,6 +16,8 @@ parameters: # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string\|null given./' - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' + # PHPStan cannot deal with manually defined constants - can be removed once php 7.2 no longer supported + - '#Constant CURLPROXY_HTTPS not found.#' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon From e35b7af8b13c8346c1ed2491bdcc5b8c442fda5d Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 8 Mar 2021 11:48:55 +0100 Subject: [PATCH 103/204] Adding docker-compose environment --- docker-compose.yaml | 12 +++++++++ resources/docker/workspace/Dockerfile | 35 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 docker-compose.yaml create mode 100644 resources/docker/workspace/Dockerfile diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..ca06f8f53 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3.8" +services: + workspace: + tty: true + build: + context: resources/docker/workspace + args: + PUID: "${PUID:-1000}" + PGID: "${PGID:-1000}" + volumes: + - .:/var/www/html + - ~/.composer:/home/user/.composer diff --git a/resources/docker/workspace/Dockerfile b/resources/docker/workspace/Dockerfile new file mode 100644 index 000000000..40d9bcf0a --- /dev/null +++ b/resources/docker/workspace/Dockerfile @@ -0,0 +1,35 @@ +FROM php:7.2-cli-alpine + +ARG PUID=1000 +ARG PGID=1000 + +RUN apk add --no-cache --virtual .build-deps \ + # for extensions + $PHPIZE_DEPS \ + # for soap + libxml2-dev \ + && \ + apk add --no-cache \ + bash \ + # for soap + libxml2 \ + # for composer + unzip \ + && \ + docker-php-ext-install soap \ + && \ + pecl install \ + # pcov for coverage runs + pcov && docker-php-ext-enable pcov \ + && \ + apk del .build-deps + +COPY --from=composer /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +# Add a non-root user to prevent files being created with root permissions on host machine. +RUN addgroup -g ${PGID} user && \ + adduser -u ${PUID} -G user -D user + +USER user From 7d0de08c4cae60929e094919f70f2ddf0744623e Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 8 Mar 2021 11:51:15 +0100 Subject: [PATCH 104/204] Ran composer fix --- .../CodeTransform/AbstractCodeTransform.php | 2 +- src/VCR/LibraryHooks/CurlHook.php | 6 +- src/VCR/LibraryHooks/StreamWrapperHook.php | 10 +-- src/VCR/Request.php | 12 +-- src/VCR/Storage/Json.php | 4 +- src/VCR/Storage/Yaml.php | 4 +- src/VCR/Util/CurlHelper.php | 90 +++++++++---------- src/VCR/Util/HttpClient.php | 12 +-- src/VCR/Util/StreamHelper.php | 6 +- src/VCR/Util/StreamProcessor.php | 38 ++++---- src/VCR/VCRFactory.php | 2 +- tests/VCR/CassetteTest.php | 2 +- tests/VCR/ConfigurationTest.php | 2 +- tests/VCR/LibraryHooks/CurlHookTest.php | 32 +++---- tests/VCR/LibraryHooks/SoapHookTest.php | 10 +-- .../LibraryHooks/StreamWrapperHookTest.php | 12 +-- tests/VCR/RequestTest.php | 2 +- tests/VCR/Storage/BlackholeTest.php | 2 +- tests/VCR/Storage/JsonTest.php | 2 +- tests/VCR/Storage/YamlTest.php | 2 +- tests/VCR/Util/CurlHelperTest.php | 74 +++++++-------- tests/VCR/Util/StreamHelperTest.php | 6 +- tests/VCR/Util/StreamProcessorTest.php | 20 ++--- tests/VCR/VCRTest.php | 10 +-- tests/bootstrap.php | 2 +- .../integration/apache/www/performRequest.php | 4 +- tests/integration/guzzle/6/test/AsyncTest.php | 2 +- tests/integration/guzzle/6/test/ErrorTest.php | 2 +- .../VCR/Example/ExampleHttpClientTest.php | 2 +- .../VCR/Example/ExampleSoapClientTest.php | 2 +- 30 files changed, 188 insertions(+), 188 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 5f7532421..8bd4ae2d3 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -43,7 +43,7 @@ public function filter($in, $out, &$consumed, $closing) stream_bucket_append($out, $bucket); } - return PSFS_PASS_ON; + return \PSFS_PASS_ON; } /** diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index dca394aa3..4f87c7609 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -281,7 +281,7 @@ public static function curlMultiExec($multiHandle, ?int &$stillRunning): int } } - return CURLM_OK; + return \CURLM_OK; } /** @@ -295,9 +295,9 @@ public static function curlMultiInfoRead() { if (!empty(self::$multiExecLastChs)) { $info = [ - 'msg' => CURLMSG_DONE, + 'msg' => \CURLMSG_DONE, 'handle' => array_pop(self::$multiExecLastChs), - 'result' => CURLE_OK, + 'result' => \CURLE_OK, ]; return $info; diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index 5f469a0bf..19f9758a1 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -45,10 +45,10 @@ public function enable(\Closure $requestCallback): void Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; stream_wrapper_unregister('http'); - stream_wrapper_register('http', __CLASS__, STREAM_IS_URL); + stream_wrapper_register('http', __CLASS__, \STREAM_IS_URL); stream_wrapper_unregister('https'); - stream_wrapper_register('https', __CLASS__, STREAM_IS_URL); + stream_wrapper_register('https', __CLASS__, \STREAM_IS_URL); $this->status = self::ENABLED; } @@ -197,21 +197,21 @@ public function url_stat(string $path, int $flags): array public function stream_seek(int $offset, int $whence): bool { switch ($whence) { - case SEEK_SET: + case \SEEK_SET: if ($offset < \strlen($this->response->getBody()) && $offset >= 0) { $this->position = $offset; return true; } break; - case SEEK_CUR: + case \SEEK_CUR: if ($offset >= 0) { $this->position += $offset; return true; } break; - case SEEK_END: + case \SEEK_END: if (\strlen($this->response->getBody()) + $offset >= 0) { $this->position = \strlen($this->response->getBody()) + $offset; diff --git a/src/VCR/Request.php b/src/VCR/Request.php index bab19254d..8e4d295e3 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -142,8 +142,8 @@ public function getBody(): ?string public function getMethod(): string { - if (null !== $this->getCurlOption(CURLOPT_CUSTOMREQUEST)) { - return $this->getCurlOption(CURLOPT_CUSTOMREQUEST); + if (null !== $this->getCurlOption(\CURLOPT_CUSTOMREQUEST)) { + return $this->getCurlOption(\CURLOPT_CUSTOMREQUEST); } return $this->method; @@ -197,13 +197,13 @@ public function getHost(): string $url = $this->getUrl(); Assertion::string($url); - $host = parse_url($url, PHP_URL_HOST); + $host = parse_url($url, \PHP_URL_HOST); if (null === $host || false === $host) { throw InvalidHostException::create($this->getUrl()); } - if ($port = parse_url($url, PHP_URL_PORT)) { + if ($port = parse_url($url, \PHP_URL_PORT)) { $host .= ':'.$port; } @@ -217,7 +217,7 @@ public function getPath(): ?string { $url = $this->getUrl(); Assertion::string($url); - $path = parse_url($url, PHP_URL_PATH); + $path = parse_url($url, \PHP_URL_PATH); Assertion::notSame($path, false); return $path; @@ -227,7 +227,7 @@ public function getQuery(): ?string { $url = $this->getUrl(); Assertion::string($url); - $query = parse_url($url, PHP_URL_QUERY); + $query = parse_url($url, \PHP_URL_QUERY); Assertion::notSame($query, false); return $query; diff --git a/src/VCR/Storage/Json.php b/src/VCR/Storage/Json.php index 79827c8ed..da4be71e9 100644 --- a/src/VCR/Storage/Json.php +++ b/src/VCR/Storage/Json.php @@ -15,12 +15,12 @@ class Json extends AbstractStorage */ public function storeRecording(array $recording): void { - fseek($this->handle, -1, SEEK_END); + fseek($this->handle, -1, \SEEK_END); if (ftell($this->handle) > 2) { fwrite($this->handle, ','); } if (\defined('JSON_PRETTY_PRINT')) { - $json = json_encode($recording, JSON_PRETTY_PRINT); + $json = json_encode($recording, \JSON_PRETTY_PRINT); } else { $json = json_encode($recording); } diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index c626746aa..8c93fe4b1 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -44,7 +44,7 @@ public function __construct($cassettePath, $cassetteName, Parser $parser = null, */ public function storeRecording(array $recording): void { - fseek($this->handle, -1, SEEK_END); + fseek($this->handle, -1, \SEEK_END); fwrite($this->handle, "\n".$this->yamlDumper->dump([$recording], 4)); fflush($this->handle); } @@ -79,7 +79,7 @@ private function readNextRecord(): string $isNewArrayStart = 0 === strpos($line, '-'); if ($isInRecord && $isNewArrayStart) { - fseek($this->handle, -\strlen($line), SEEK_CUR); + fseek($this->handle, -\strlen($line), \SEEK_CUR); break; } diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index adc2488e7..374ee76d5 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -15,27 +15,27 @@ class CurlHelper */ private static $curlInfoList = [ //"certinfo"? - CURLINFO_HTTP_CODE => 'http_code', - CURLINFO_EFFECTIVE_URL => 'url', - CURLINFO_TOTAL_TIME => 'total_time', - CURLINFO_NAMELOOKUP_TIME => 'namelookup_time', - CURLINFO_CONNECT_TIME => 'connect_time', - CURLINFO_PRETRANSFER_TIME => 'pretransfer_time', - CURLINFO_STARTTRANSFER_TIME => 'starttransfer_time', - CURLINFO_REDIRECT_COUNT => 'redirect_count', - CURLINFO_REDIRECT_TIME => 'redirect_time', - CURLINFO_SIZE_UPLOAD => 'size_upload', - CURLINFO_SIZE_DOWNLOAD => 'size_download', - CURLINFO_SPEED_DOWNLOAD => 'speed_download', - CURLINFO_SPEED_UPLOAD => 'speed_upload', - CURLINFO_HEADER_SIZE => 'header_size', - CURLINFO_HEADER_OUT => 'request_header', - CURLINFO_FILETIME => 'filetime', - CURLINFO_REQUEST_SIZE => 'request_size', - CURLINFO_SSL_VERIFYRESULT => 'ssl_verify_result', - CURLINFO_CONTENT_LENGTH_DOWNLOAD => 'download_content_length', - CURLINFO_CONTENT_LENGTH_UPLOAD => 'upload_content_length', - CURLINFO_CONTENT_TYPE => 'content_type', + \CURLINFO_HTTP_CODE => 'http_code', + \CURLINFO_EFFECTIVE_URL => 'url', + \CURLINFO_TOTAL_TIME => 'total_time', + \CURLINFO_NAMELOOKUP_TIME => 'namelookup_time', + \CURLINFO_CONNECT_TIME => 'connect_time', + \CURLINFO_PRETRANSFER_TIME => 'pretransfer_time', + \CURLINFO_STARTTRANSFER_TIME => 'starttransfer_time', + \CURLINFO_REDIRECT_COUNT => 'redirect_count', + \CURLINFO_REDIRECT_TIME => 'redirect_time', + \CURLINFO_SIZE_UPLOAD => 'size_upload', + \CURLINFO_SIZE_DOWNLOAD => 'size_download', + \CURLINFO_SPEED_DOWNLOAD => 'speed_download', + \CURLINFO_SPEED_UPLOAD => 'speed_upload', + \CURLINFO_HEADER_SIZE => 'header_size', + \CURLINFO_HEADER_OUT => 'request_header', + \CURLINFO_FILETIME => 'filetime', + \CURLINFO_REQUEST_SIZE => 'request_size', + \CURLINFO_SSL_VERIFYRESULT => 'ssl_verify_result', + \CURLINFO_CONTENT_LENGTH_DOWNLOAD => 'download_content_length', + \CURLINFO_CONTENT_LENGTH_UPLOAD => 'upload_content_length', + \CURLINFO_CONTENT_TYPE => 'content_type', ]; /** @@ -53,27 +53,27 @@ class CurlHelper public static function handleOutput(Response $response, array $curlOptions, $ch): ?string { // If there is a header function set, feed the http status and headers to it. - if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) { + if (isset($curlOptions[\CURLOPT_HEADERFUNCTION])) { $headerList = [HttpUtil::formatAsStatusString($response)]; $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders())); $headerList[] = ''; foreach ($headerList as $header) { - self::callFunction($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); + self::callFunction($curlOptions[\CURLOPT_HEADERFUNCTION], $ch, $header); } } $body = $response->getBody(); - if (!empty($curlOptions[CURLOPT_HEADER])) { + if (!empty($curlOptions[\CURLOPT_HEADER])) { $body = HttpUtil::formatAsStatusWithHeadersString($response).$body; } - if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) { - self::callFunction($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); - } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && true == $curlOptions[CURLOPT_RETURNTRANSFER]) { + if (isset($curlOptions[\CURLOPT_WRITEFUNCTION])) { + self::callFunction($curlOptions[\CURLOPT_WRITEFUNCTION], $ch, $body); + } elseif (isset($curlOptions[\CURLOPT_RETURNTRANSFER]) && true == $curlOptions[\CURLOPT_RETURNTRANSFER]) { return $body; - } elseif (isset($curlOptions[CURLOPT_FILE])) { - $fp = $curlOptions[CURLOPT_FILE]; + } elseif (isset($curlOptions[\CURLOPT_FILE])) { + $fp = $curlOptions[\CURLOPT_FILE]; fwrite($fp, $body); fflush($fp); } else { @@ -102,13 +102,13 @@ public static function getCurlOptionFromResponse(Response $response, int $option $info[$key] = $response->getCurlInfo($key); } break; - case CURLINFO_HTTP_CODE: + case \CURLINFO_HTTP_CODE: $info = (int) $response->getStatusCode(); break; - case CURLINFO_SIZE_DOWNLOAD: + case \CURLINFO_SIZE_DOWNLOAD: $info = $response->getHeader('Content-Length'); break; - case CURLINFO_HEADER_SIZE: + case \CURLINFO_HEADER_SIZE: $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; case CURLPROXY_HTTPS: @@ -139,18 +139,18 @@ public static function getCurlOptionFromResponse(Response $response, int $option public static function setCurlOptionOnRequest(Request $request, int $option, $value, $curlHandle = null): void { switch ($option) { - case CURLOPT_URL: + case \CURLOPT_URL: $request->setUrl($value); break; - case CURLOPT_CUSTOMREQUEST: - $request->setCurlOption(CURLOPT_CUSTOMREQUEST, $value); + case \CURLOPT_CUSTOMREQUEST: + $request->setCurlOption(\CURLOPT_CUSTOMREQUEST, $value); break; - case CURLOPT_POST: + case \CURLOPT_POST: if (true == $value) { $request->setMethod('POST'); } break; - case CURLOPT_POSTFIELDS: + case \CURLOPT_POSTFIELDS: // todo: check for file @ if (\is_array($value)) { foreach ($value as $name => $fieldValue) { @@ -167,7 +167,7 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va } $request->setMethod('POST'); break; - case CURLOPT_HTTPHEADER: + case \CURLOPT_HTTPHEADER: foreach ($value as $header) { $headerParts = explode(': ', $header, 2); if (!isset($headerParts[1])) { @@ -177,11 +177,11 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va $request->setHeader($headerParts[0], $headerParts[1]); } break; - case CURLOPT_FILE: - case CURLOPT_HEADER: - case CURLOPT_WRITEFUNCTION: - case CURLOPT_HEADERFUNCTION: - case CURLOPT_UPLOAD: + case \CURLOPT_FILE: + case \CURLOPT_HEADER: + case \CURLOPT_WRITEFUNCTION: + case \CURLOPT_HEADERFUNCTION: + case \CURLOPT_UPLOAD: // Ignore header, file and writer functions. // These options are stored and will be handled later in handleOutput(). break; @@ -200,7 +200,7 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va */ public static function validateCurlPOSTBody(Request $request, $curlHandle = null): void { - $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION); + $readFunction = $request->getCurlOption(\CURLOPT_READFUNCTION); if (null === $readFunction) { return; } @@ -211,7 +211,7 @@ public static function validateCurlPOSTBody(Request $request, $curlHandle = null return; } - $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE); + $bodySize = $request->getCurlOption(\CURLOPT_INFILESIZE); Assertion::notEmpty($bodySize, 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $body = \call_user_func_array($readFunction, [$curlHandle, fopen('php://memory', 'r'), $bodySize]); $request->setBody($body); diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 556352732..6d83d8d13 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -25,17 +25,17 @@ public function send(Request $request): Response Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'"); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); - curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); + curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $request->getMethod()); + curl_setopt($ch, \CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); if (null !== $request->getBody()) { - curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getBody()); + curl_setopt($ch, \CURLOPT_POSTFIELDS, $request->getBody()); } curl_setopt_array($ch, $request->getCurlOptions()); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FAILONERROR, false); - curl_setopt($ch, CURLOPT_HEADER, true); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, \CURLOPT_FAILONERROR, false); + curl_setopt($ch, \CURLOPT_HEADER, true); /** @var string|false $result */ $result = curl_exec($ch); diff --git a/src/VCR/Util/StreamHelper.php b/src/VCR/Util/StreamHelper.php index c113bd94c..6468c2103 100644 --- a/src/VCR/Util/StreamHelper.php +++ b/src/VCR/Util/StreamHelper.php @@ -45,15 +45,15 @@ public static function createRequestFromStreamContext($context, string $path, Re } if (isset($http['follow_location'])) { - $request->setCurlOption(CURLOPT_FOLLOWLOCATION, (bool) $http['follow_location']); + $request->setCurlOption(\CURLOPT_FOLLOWLOCATION, (bool) $http['follow_location']); } if (isset($http['max_redirects'])) { - $request->setCurlOption(CURLOPT_MAXREDIRS, $http['max_redirects']); + $request->setCurlOption(\CURLOPT_MAXREDIRS, $http['max_redirects']); } if (isset($http['timeout'])) { - $request->setCurlOption(CURLOPT_TIMEOUT, $http['timeout']); + $request->setCurlOption(\CURLOPT_TIMEOUT, $http['timeout']); } // TODO: protocol_version diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 3b9e6223a..bee11d823 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -134,7 +134,7 @@ protected function isBlacklisted(string $uri): bool */ protected function isPhpFile(string $uri): bool { - return 'php' === pathinfo($uri, PATHINFO_EXTENSION); + return 'php' === pathinfo($uri, \PATHINFO_EXTENSION); } protected function shouldProcess(string $uri): bool @@ -165,9 +165,9 @@ public function stream_open(string $path, string $mode, int $options, ?string &$ $this->restore(); if (isset($this->context)) { - $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH), $this->context); + $this->resource = fopen($path, $mode, (bool) ($options & \STREAM_USE_PATH), $this->context); } else { - $this->resource = fopen($path, $mode, (bool) ($options & STREAM_USE_PATH)); + $this->resource = fopen($path, $mode, (bool) ($options & \STREAM_USE_PATH)); } if (false !== $this->resource && $options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { @@ -254,7 +254,7 @@ public function stream_read(int $count) * * @return bool return TRUE if the position was updated, FALSE otherwise */ - public function stream_seek(int $offset, int $whence = SEEK_SET): bool + public function stream_seek(int $offset, int $whence = \SEEK_SET): bool { if (false === $this->resource) { return false; @@ -318,7 +318,7 @@ public function stream_tell() public function url_stat(string $path, int $flags) { $this->restore(); - if ($flags & STREAM_URL_STAT_QUIET) { + if ($flags & \STREAM_URL_STAT_QUIET) { set_error_handler(function () { // Use native error handler return false; @@ -422,9 +422,9 @@ public function mkdir(string $path, int $mode, int $options): bool { $this->restore(); if (isset($this->context)) { - $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE), $this->context); + $result = mkdir($path, $mode, (bool) ($options & \STREAM_MKDIR_RECURSIVE), $this->context); } else { - $result = mkdir($path, $mode, (bool) ($options & STREAM_MKDIR_RECURSIVE)); + $result = mkdir($path, $mode, (bool) ($options & \STREAM_MKDIR_RECURSIVE)); } $this->intercept(); @@ -506,7 +506,7 @@ public function stream_lock(int $operation): bool return false; } - $operation = (0 === $operation ? LOCK_EX : $operation); + $operation = (0 === $operation ? \LOCK_EX : $operation); return flock($this->resource, $operation); } @@ -530,14 +530,14 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool } switch ($option) { - case STREAM_OPTION_BLOCKING: + case \STREAM_OPTION_BLOCKING: return stream_set_blocking($this->resource, (bool) $arg1); - case STREAM_OPTION_READ_TIMEOUT: + case \STREAM_OPTION_READ_TIMEOUT: return stream_set_timeout($this->resource, $arg1, $arg2); - case STREAM_OPTION_WRITE_BUFFER: + case \STREAM_OPTION_WRITE_BUFFER: // stream_set_write_buffer returns 0 in case of success return 0 === stream_set_write_buffer($this->resource, $arg1); - case STREAM_OPTION_READ_BUFFER: + case \STREAM_OPTION_READ_BUFFER: // stream_set_read_buffer returns 0 in case of success return 0 === stream_set_read_buffer($this->resource, $arg1); // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 @@ -607,22 +607,22 @@ public function stream_metadata(string $path, int $option, $value): bool $result = false; switch ($option) { - case STREAM_META_TOUCH: + case \STREAM_META_TOUCH: if (empty($value)) { $result = touch($path); } else { $result = touch($path, $value[0], $value[1]); } break; - case STREAM_META_OWNER_NAME: - case STREAM_META_OWNER: + case \STREAM_META_OWNER_NAME: + case \STREAM_META_OWNER: $result = chown($path, $value); break; - case STREAM_META_GROUP_NAME: - case STREAM_META_GROUP: + case \STREAM_META_GROUP_NAME: + case \STREAM_META_GROUP: $result = chgrp($path, $value); break; - case STREAM_META_ACCESS: + case \STREAM_META_ACCESS: $result = chmod($path, $value); break; } @@ -675,7 +675,7 @@ public function detachCodeTransformer(AbstractCodeTransform $codeTransformer): v protected function appendFiltersToStream($stream): void { foreach (static::$codeTransformers as $codeTransformer) { - stream_filter_append($stream, $codeTransformer::NAME, STREAM_FILTER_READ); + stream_filter_append($stream, $codeTransformer::NAME, \STREAM_FILTER_READ); } } diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index 36a8dd399..d4f7709ae 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -35,7 +35,7 @@ protected function __construct(Configuration $config = null) // This constant exists only from PHP 7.3 // Once we are no longer supporting 7.2, we can remove this - \defined('CURLPROXY_HTTPS') or \define('CURLPROXY_HTTPS', 2); + \defined('CURLPROXY_HTTPS') || \define('CURLPROXY_HTTPS', 2); } protected function createVCRVideorecorder(): Videorecorder diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index e9b14d16d..5879f0c81 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -15,7 +15,7 @@ class CassetteTest extends TestCase */ private $cassette; - public function setUp() + protected function setUp() { vfsStream::setup('test'); $this->cassette = new Cassette('test', new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index 006f261a1..9c8f8188c 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -11,7 +11,7 @@ class ConfigurationTest extends TestCase */ private $config; - public function setUp() + protected function setUp() { $this->config = new Configuration(); } diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 6c6d506cb..907a66235 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -25,7 +25,7 @@ class CurlHookTest extends TestCase */ protected $curlHook; - public function setup() + protected function setup() { $this->config = new Configuration(); $this->curlHook = new CurlHook(new CurlCodeTransform(), new StreamProcessor($this->config)); @@ -47,7 +47,7 @@ public function testShouldInterceptCallWhenEnabled() $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $actual = curl_exec($curlHandle); curl_close($curlHandle); @@ -61,7 +61,7 @@ public function testShouldInterceptCallWhenEnabled() public function testShouldNotInterceptCallWhenNotEnabled() { $curlHandle = curl_init('http://example.com/'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curlHandle); curl_close($curlHandle); @@ -82,8 +82,8 @@ function () use (&$intercepted) { $this->curlHook->disable(); $curlHandle = curl_init(); - curl_setopt($curlHandle, CURLOPT_URL, 'http://example.com/'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_URL, 'http://example.com/'); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); curl_close($curlHandle); $this->assertFalse($intercepted, 'This request should not have been intercepted.'); @@ -95,7 +95,7 @@ public function testShouldWriteFileOnFileDownload() $curlHandle = curl_init('https://example.com/'); $filePointer = fopen('php://temp/test_file', 'w'); - curl_setopt($curlHandle, CURLOPT_FILE, $filePointer); + curl_setopt($curlHandle, \CURLOPT_FILE, $filePointer); curl_exec($curlHandle); curl_close($curlHandle); rewind($filePointer); @@ -111,7 +111,7 @@ public function testShouldEchoResponseIfReturnTransferFalse() $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, false); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, false); ob_start(); curl_exec($curlHandle); $actual = ob_get_contents(); @@ -138,7 +138,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_POSTFIELDS, ['para1' => 'val1', 'para2' => 'val2']); + curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, ['para1' => 'val1', 'para2' => 'val2']); curl_exec($curlHandle); curl_close($curlHandle); $this->curlHook->disable(); @@ -163,7 +163,7 @@ function (Request $request) use ($testClass) { curl_setopt_array( $curlHandle, [ - CURLOPT_POSTFIELDS => ['para1' => 'val1', 'para2' => 'val2'], + \CURLOPT_POSTFIELDS => ['para1' => 'val1', 'para2' => 'val2'], ] ); curl_exec($curlHandle); @@ -176,9 +176,9 @@ public function testShouldReturnCurlInfoStatusCode() $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); - $infoHttpCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); curl_close($curlHandle); $this->assertSame(200, $infoHttpCode, 'HTTP status not set.'); @@ -196,9 +196,9 @@ public function testShouldReturnCurlInfoStatusCodeAsInteger() $this->curlHook->enable($this->getTestCallback($stringStatusCode)); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); - $infoHttpCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); curl_close($curlHandle); $this->assertSame($integerStatusCode, $infoHttpCode, 'HTTP status not set.'); @@ -211,7 +211,7 @@ public function testShouldReturnCurlInfoAll() $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); curl_close($curlHandle); @@ -226,7 +226,7 @@ public function testShouldReturnCurlInfoAllKeys() $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); curl_close($curlHandle); @@ -369,7 +369,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); - curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($curlHandle, \CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_reset($curlHandle); curl_exec($curlHandle); diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index d39f9295c..0867c0e42 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -24,7 +24,7 @@ class SoapHookTest extends TestCase /** @var SoapHook */ protected $soapHook; - public function setup() + protected function setup() { $this->config = new Configuration(); $this->soapHook = new SoapHook(new SoapCodeTransform(), new StreamProcessor($this->config)); @@ -34,7 +34,7 @@ public function testShouldInterceptCallWhenEnabled() { $this->soapHook->enable($this->getContentCheckCallback()); - $client = new \SoapClient(self::WSDL, ['soap_version' => SOAP_1_2]); + $client = new \SoapClient(self::WSDL, ['soap_version' => \SOAP_1_2]); $client->setLibraryHook($this->soapHook); $actual = $client->GetCityWeatherByZIP(['ZIP' => '10013']); @@ -53,7 +53,7 @@ public function testShouldHandleSOAPVersion11() $client = new \SoapClient( self::WSDL, - ['soap_version' => SOAP_1_1] + ['soap_version' => \SOAP_1_1] ); $client->setLibraryHook($this->soapHook); $client->GetCityWeatherByZIP(['ZIP' => '10013']); @@ -69,7 +69,7 @@ public function testShouldHandleSOAPVersion12() $client = new \SoapClient( self::WSDL, - ['soap_version' => SOAP_1_2] + ['soap_version' => \SOAP_1_2] ); $client->setLibraryHook($this->soapHook); $client->GetCityWeatherByZIP(['ZIP' => '10013']); @@ -81,7 +81,7 @@ public function testShouldReturnLastRequestWithTraceOn() $client = new \SoapClient( self::WSDL, - ['soap_version' => SOAP_1_1, 'trace' => 1] + ['soap_version' => \SOAP_1_1, 'trace' => 1] ); $client->setLibraryHook($this->soapHook); $client->GetCityWeatherByZIP(['ZIP' => '10013']); diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index cf4e3420d..e423c62f1 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -36,16 +36,16 @@ public function testSeek() }); $hook->stream_open('http://example.com', 'r', 0, $openedPath); - $this->assertFalse($hook->stream_seek(-1, SEEK_SET)); - $this->assertTrue($hook->stream_seek(0, SEEK_SET)); + $this->assertFalse($hook->stream_seek(-1, \SEEK_SET)); + $this->assertTrue($hook->stream_seek(0, \SEEK_SET)); $this->assertEquals('A', $hook->stream_read(1)); - $this->assertFalse($hook->stream_seek(-1, SEEK_CUR)); - $this->assertTrue($hook->stream_seek(1, SEEK_CUR)); + $this->assertFalse($hook->stream_seek(-1, \SEEK_CUR)); + $this->assertTrue($hook->stream_seek(1, \SEEK_CUR)); $this->assertEquals('Test', $hook->stream_read(4)); - $this->assertFalse($hook->stream_seek(-1000, SEEK_END)); - $this->assertTrue($hook->stream_seek(-4, SEEK_END)); + $this->assertFalse($hook->stream_seek(-1000, \SEEK_END)); + $this->assertTrue($hook->stream_seek(-4, \SEEK_END)); $this->assertEquals('Test', $hook->stream_read(4)); // invalid whence diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 53c4289e1..79832789d 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -15,7 +15,7 @@ class RequestTest extends TestCase */ protected $request; - public function setUp() + protected function setUp() { $this->request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); } diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index 115c12d36..26febb886 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -8,7 +8,7 @@ class BlackholeTest extends TestCase { protected $storage; - public function setUp() + protected function setUp() { $this->storage = new Blackhole(); } diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 30a7f8703..5b62fe31f 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -14,7 +14,7 @@ class JsonTest extends TestCase protected $filePath; protected $jsonObject; - public function setUp() + protected function setUp() { vfsStream::setup('test'); $this->filePath = vfsStream::url('test/').'json_test'; diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index 45dd5c5c8..4e46e8a55 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -10,7 +10,7 @@ */ class YamlTest extends TestCase { - public function setUp() + protected function setUp() { vfsStream::setup('test'); $this->filePath = vfsStream::url('test/').\DIRECTORY_SEPARATOR.'yaml_test'; diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 35fdadf50..d6d4de0c3 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -18,7 +18,7 @@ public function testSetCurlOptionMethods($method) $request = new Request($method, 'http://example.com'); $headers = ['Host: example.com']; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); $this->assertEquals($method, $request->getMethod()); } @@ -47,7 +47,7 @@ public function testSetCurlOptionOnRequestPostFieldsQueryString() $request = new Request('POST', 'http://example.com'); $payload = 'para1=val1¶2=val2'; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, $payload); $this->assertEquals($payload, (string) $request->getBody()); } @@ -57,7 +57,7 @@ public function testSetCurlOptionOnRequestPostFieldsArray() $request = new Request('POST', 'http://example.com'); $payload = ['some' => 'test']; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, $payload); $this->assertNull($request->getBody()); $this->assertEquals($payload, $request->getPostFields()); @@ -68,7 +68,7 @@ public function testSetCurlOptionOnRequestPostFieldsString() $request = new Request('POST', 'http://example.com'); $payload = json_encode(['some' => 'test']); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, $payload); $this->assertEquals($payload, (string) $request->getBody()); } @@ -78,7 +78,7 @@ public function testSetCurlOptionOnRequestPostFieldsEmptyString() $request = new Request('POST', 'http://example.com'); $payload = ''; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, $payload); // This is consistent with how requests are read out of storage using // \VCR\Request::fromArray(array $request). @@ -90,7 +90,7 @@ public function testSetCurlOptionOnRequestSetSingleHeader() $request = new Request('GET', 'http://example.com'); $headers = ['Host: example.com']; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } @@ -100,8 +100,8 @@ public function testSetCurlOptionOnRequestSetSingleHeaderTwice() $request = new Request('GET', 'http://example.com'); $headers = ['Host: example.com']; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } @@ -114,8 +114,8 @@ public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() 'Content-Type: application/json', ]; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); $expected = [ 'Host' => 'example.com', @@ -132,8 +132,8 @@ public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() 'Content-Type: application/json', ]; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_HTTPHEADER, $headers); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, []); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_HTTPHEADER, $headers); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, []); $expected = [ 'Host' => 'example.com', @@ -146,7 +146,7 @@ public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() $request = new Request('GET', 'http://example.com'); $payload = json_encode(['some' => 'test']); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, $payload); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, $payload); $this->assertEquals('POST', $request->getMethod()); } @@ -155,9 +155,9 @@ public function testSetCurlOptionReadFunctionToNull() { $request = new Request('POST', 'http://example.com'); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, null, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, null, curl_init()); - $this->assertNull($request->getCurlOption(CURLOPT_READFUNCTION)); + $this->assertNull($request->getCurlOption(\CURLOPT_READFUNCTION)); } public function testInvalidHostException() @@ -174,7 +174,7 @@ public function testSetCurlOptionReadFunctionMissingSize() $callback = function ($curlHandle, $fileHandle, $size) { }; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, $callback, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback, curl_init()); CurlHelper::validateCurlPOSTBody($request, curl_init()); } @@ -192,8 +192,8 @@ public function testSetCurlOptionReadFunction() return $expected; }; - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_INFILESIZE, \strlen($expected)); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_READFUNCTION, $callback, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_INFILESIZE, \strlen($expected)); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback, curl_init()); CurlHelper::validateCurlPOSTBody($request, curl_init()); $this->assertEquals($expected, $request->getBody()); @@ -202,7 +202,7 @@ public function testSetCurlOptionReadFunction() public function testHandleResponseReturnsBody() { $curlOptions = [ - CURLOPT_RETURNTRANSFER => true, + \CURLOPT_RETURNTRANSFER => true, ]; $response = new Response(200, [], 'example response'); @@ -225,8 +225,8 @@ public function testHandleResponseEchosBody() public function testHandleResponseIncludesHeader() { $curlOptions = [ - CURLOPT_HEADER => true, - CURLOPT_RETURNTRANSFER => true, + \CURLOPT_HEADER => true, + \CURLOPT_RETURNTRANSFER => true, ]; $status = [ 'code' => 200, @@ -244,7 +244,7 @@ public function testHandleOutputHeaderFunction() { $actualHeaders = []; $curlOptions = [ - CURLOPT_HEADERFUNCTION => function ($ch, $header) use (&$actualHeaders) { + \CURLOPT_HEADERFUNCTION => function ($ch, $header) use (&$actualHeaders) { $actualHeaders[] = $header; }, ]; @@ -271,7 +271,7 @@ public function testHandleOutputHeaderFunctionWithPublicFunction() { $this->headersFound = []; $curlOptions = [ - CURLOPT_HEADERFUNCTION => [$this, 'publicCurlHeaderFunction'], + \CURLOPT_HEADERFUNCTION => [$this, 'publicCurlHeaderFunction'], ]; $status = [ 'code' => 200, @@ -296,7 +296,7 @@ public function testHandleOutputHeaderFunctionWithProtectedFunction() { $this->headersFound = []; $curlOptions = [ - CURLOPT_HEADERFUNCTION => [$this, 'protectedCurlHeaderFunction'], + \CURLOPT_HEADERFUNCTION => [$this, 'protectedCurlHeaderFunction'], ]; $status = [ 'code' => 200, @@ -321,7 +321,7 @@ public function testHandleOutputHeaderFunctionWithPrivateFunction() { $this->headersFound = []; $curlOptions = [ - CURLOPT_HEADERFUNCTION => [$this, 'privateCurlHeaderFunction'], + \CURLOPT_HEADERFUNCTION => [$this, 'privateCurlHeaderFunction'], ]; $status = [ 'code' => 200, @@ -348,7 +348,7 @@ public function testHandleResponseUsesWriteFunction() $expectedCh = curl_init(); $expectedBody = 'example response'; $curlOptions = [ - CURLOPT_WRITEFUNCTION => function ($ch, $body) use ($test, $expectedCh, $expectedBody) { + \CURLOPT_WRITEFUNCTION => function ($ch, $body) use ($test, $expectedCh, $expectedBody) { $test->assertEquals($expectedCh, $ch); $test->assertEquals($expectedBody, $body); @@ -366,7 +366,7 @@ public function testHandleResponseUsesWriteFunctionWithPrivateFunction() $expectedCh = curl_init(); $expectedBody = 'example response'; $curlOptions = [ - CURLOPT_WRITEFUNCTION => [$this, 'privateCurlWriteFunction'], + \CURLOPT_WRITEFUNCTION => [$this, 'privateCurlWriteFunction'], ]; $response = new Response(200, [], $expectedBody); @@ -380,7 +380,7 @@ public function testHandleResponseWritesFile() $testFile = vfsStream::url('test/write_file'); $curlOptions = [ - CURLOPT_FILE => fopen($testFile, 'w+'), + \CURLOPT_FILE => fopen($testFile, 'w+'), ]; $response = new Response(200, [], $expectedBody); @@ -422,7 +422,7 @@ public function getCurlOptionProvider() ], ] ), - CURLINFO_HEADER_SIZE, + \CURLINFO_HEADER_SIZE, 100, ], [ @@ -440,7 +440,7 @@ public function getCurlOptionProvider() ], ] ), - CURLINFO_HEADER_SIZE, + \CURLINFO_HEADER_SIZE, 107, ], [ @@ -459,7 +459,7 @@ public function getCurlOptionProvider() ], ] ), - CURLINFO_HEADER_SIZE, + \CURLINFO_HEADER_SIZE, 134, ], [ @@ -479,7 +479,7 @@ public function getCurlOptionProvider() ], ] ), - CURLINFO_HEADER_SIZE, + \CURLINFO_HEADER_SIZE, 160, ], [ @@ -502,7 +502,7 @@ public function getCurlOptionProvider() ], ] ), - CURLINFO_HEADER_SIZE, + \CURLINFO_HEADER_SIZE, 290, ], ]; @@ -512,20 +512,20 @@ public function testSetCurlOptionCustomRequest() { $request = new Request('POST', 'http://example.com'); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_CUSTOMREQUEST, 'PUT'); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_CUSTOMREQUEST, 'PUT'); - $this->assertEquals('PUT', $request->getCurlOption(CURLOPT_CUSTOMREQUEST)); + $this->assertEquals('PUT', $request->getCurlOption(\CURLOPT_CUSTOMREQUEST)); } public function testCurlCustomRequestAlwaysOverridesMethod() { $request = new Request('POST', 'http://example.com'); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_CUSTOMREQUEST, 'DELETE'); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_CUSTOMREQUEST, 'DELETE'); $this->assertEquals('DELETE', $request->getMethod()); - CurlHelper::setCurlOptionOnRequest($request, CURLOPT_POSTFIELDS, ['some' => 'test']); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_POSTFIELDS, ['some' => 'test']); $this->assertEquals('DELETE', $request->getMethod()); } diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index a792fd86d..25544d8c1 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -51,21 +51,21 @@ function (Request $request) use ($test) { 'follow_location' => [ ['follow_location' => '0'], function (Request $request) use ($test) { - $test->assertEquals(false, $request->getCurlOption(CURLOPT_FOLLOWLOCATION)); + $test->assertEquals(false, $request->getCurlOption(\CURLOPT_FOLLOWLOCATION)); }, ], 'max_redirects' => [ ['max_redirects' => '2'], function (Request $request) use ($test) { - $test->assertEquals('2', $request->getCurlOption(CURLOPT_MAXREDIRS)); + $test->assertEquals('2', $request->getCurlOption(\CURLOPT_MAXREDIRS)); }, ], 'timeout' => [ ['timeout' => '100'], function (Request $request) use ($test) { - $test->assertEquals('100', $request->getCurlOption(CURLOPT_TIMEOUT)); + $test->assertEquals('100', $request->getCurlOption(\CURLOPT_TIMEOUT)); }, ], ]; diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index b685bb6a7..c09dec13a 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -17,7 +17,7 @@ public function testFlockWithFilePutContents() $testData = 'test data'; $testFilePath = 'tests/fixtures/file_put_contents'; - $res = file_put_contents($testFilePath, $testData, LOCK_EX); + $res = file_put_contents($testFilePath, $testData, \LOCK_EX); unlink($testFilePath); $processor->restore(); @@ -118,7 +118,7 @@ public function testUrlStatFileNotFound() public function testQuietUrlStatFileNotFoundToBeQuiet() { $processor = new StreamProcessor(); - $processor->url_stat('file_not_found', STREAM_URL_STAT_QUIET); + $processor->url_stat('file_not_found', \STREAM_URL_STAT_QUIET); } public function testDirOpendir() @@ -164,7 +164,7 @@ public function testRename() public function testStreamMetadata() { - if (version_compare(PHP_VERSION, '5.4.0', '<')) { + if (version_compare(\PHP_VERSION, '5.4.0', '<')) { $this->markTestSkipped('Behavior is only applicable and testable for PHP 5.4+'); } @@ -177,16 +177,16 @@ public function testStreamMetadata() $mock->expects($this->exactly(8))->method('intercept'); $path = 'tests/fixtures/unnitest_streamprocessor_metadata'; - $this->assertTrue($mock->stream_metadata($path, STREAM_META_TOUCH, null)); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_TOUCH, [time(), time()])); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_TOUCH, null)); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_TOUCH, [time(), time()])); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_OWNER_NAME, posix_getuid())); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_OWNER, posix_getuid())); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_OWNER_NAME, posix_getuid())); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_OWNER, posix_getuid())); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_GROUP_NAME, posix_getgid())); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_GROUP, posix_getgid())); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_GROUP_NAME, posix_getgid())); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_GROUP, posix_getgid())); - $this->assertTrue($mock->stream_metadata($path, STREAM_META_ACCESS, 0777)); + $this->assertTrue($mock->stream_metadata($path, \STREAM_META_ACCESS, 0777)); $this->assertTrue($mock->unlink($path)); } diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 9ea50d9ce..4daa38285 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -53,9 +53,9 @@ public function testShouldInterceptCurlLibrary() private function doCurlGetRequest($url) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, false); + curl_setopt($ch, \CURLOPT_URL, $url); + curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, \CURLOPT_POST, false); $output = curl_exec($ch); curl_close($ch); @@ -68,7 +68,7 @@ public function testShouldInterceptSoapLibrary() VCR::turnOn(); VCR::insertCassette('unittest_soap_test'); - $client = new \SoapClient('https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl', ['soap_version' => SOAP_1_2]); + $client = new \SoapClient('https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl', ['soap_version' => \SOAP_1_2]); $actual = $client->GetCityWeatherByZIP(['ZIP' => '10013']); $temperature = $actual->GetCityWeatherByZIPResult->Temperature; @@ -193,7 +193,7 @@ public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCasse public function testFinfoWorksCorrectly(): void { - $fileinfo = new \finfo(FILEINFO_MIME_TYPE); + $fileinfo = new \finfo(\FILEINFO_MIME_TYPE); $this->assertEquals( 'text/plain', diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f79e80de6..db0c3e68b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,7 @@ setCassettePath(vfsStream::url('testDir')); diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php index b04e2a4bc..bd5741c0d 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -14,7 +14,7 @@ class ErrorTest extends TestCase { const TEST_GET_URL = 'http://localhost:9959'; - public function setUp() + protected function setUp() { vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index 878b9d617..e19dc9fc6 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -21,7 +21,7 @@ class ExampleHttpClientTest extends TestCase 'X-Request-Id', ]; - public function setUp() + protected function setUp() { vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index 2f656f904..e076a86ec 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -13,7 +13,7 @@ */ class ExampleSoapClientTest extends TestCase { - public function setUp() + protected function setUp() { // Configure virtual filesystem. vfsStream::setup('testDir'); From 8f2569b7d07fd5c3b61ccf8bb0f3fcf91cb44e79 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 8 Mar 2021 20:03:17 +0100 Subject: [PATCH 105/204] Upgraded PHPUnit from 7 to 8 --- .gitignore | 1 + .php_cs.dist | 2 +- composer.json | 2 +- src/VCR/LibraryHooks/SoapHook.php | 2 +- tests/VCR/CassetteTest.php | 2 +- tests/VCR/ConfigurationTest.php | 2 +- tests/VCR/Event/AfterHttpRequestEventTest.php | 2 +- tests/VCR/Event/AfterPlaybackEventTest.php | 2 +- tests/VCR/Event/BeforeHttpRequestEventTest.php | 2 +- tests/VCR/Event/BeforePlaybackEventTest.php | 2 +- tests/VCR/Event/BeforeRecordEventTest.php | 2 +- tests/VCR/LibraryHooks/CurlHookTest.php | 8 ++++---- tests/VCR/LibraryHooks/SoapHookTest.php | 2 +- tests/VCR/RequestTest.php | 2 +- tests/VCR/Storage/BlackholeTest.php | 2 +- tests/VCR/Storage/JsonTest.php | 2 +- tests/VCR/Storage/YamlTest.php | 2 +- tests/VCR/Util/CurlHelperTest.php | 4 ++-- tests/VCR/Util/SoapClientTest.php | 14 +++++++------- tests/VCR/Util/StreamProcessorTest.php | 2 +- tests/VCR/VCRTest.php | 2 +- tests/integration/guzzle/6/test/AsyncTest.php | 4 ++-- tests/integration/guzzle/6/test/ErrorTest.php | 2 +- .../test/VCR/Example/ExampleHttpClientTest.php | 8 ++++---- tests/integration/soap/phpunit.xml | 5 +++-- .../soap/src/VCR/Example/ExampleSoapClient.php | 4 ++-- .../test/VCR/Example/ExampleSoapClientTest.php | 6 +++--- 27 files changed, 46 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index f11debb47..5e6f0a860 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tests/fixtures/cassette* /.php_cs.cache /.php_cs composer.lock +.phpunit.result.cache diff --git a/.php_cs.dist b/.php_cs.dist index 06819239d..1da24fa0f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -5,7 +5,7 @@ return PhpCsFixer\Config::create() '@PSR2' => true, '@Symfony' => true, '@Symfony:risky' => true, - '@PHPUnit60Migration:risky' => true + '@PHPUnit84Migration:risky' => true ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/composer.json b/composer.json index f72751eb0..326f1f2bd 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "symfony/event-dispatcher": "^2.4|^3.0|^4.0|^5.0" }, "require-dev": { - "phpunit/phpunit": "^7.4.3", + "phpunit/phpunit": "^8.4.0", "mikey179/vfsstream": "^1.6", "phpstan/phpstan": "^0.12", "phpstan/phpstan-beberlei-assert": "^0.12.0", diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 9e0041c84..2c155ac71 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -65,7 +65,7 @@ public function doRequest(string $request, string $location, string $action, int $vcrRequest = new Request('POST', $location); - if (SOAP_1_1 === $version) { + if (\SOAP_1_1 === $version) { $vcrRequest->setHeader('Content-Type', 'text/xml; charset=utf-8;'); $vcrRequest->setHeader('SOAPAction', $action); } else { // >= SOAP_1_2 diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index 5879f0c81..da9192917 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -15,7 +15,7 @@ class CassetteTest extends TestCase */ private $cassette; - protected function setUp() + protected function setUp(): void { vfsStream::setup('test'); $this->cassette = new Cassette('test', new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index 9c8f8188c..f96a88b75 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -11,7 +11,7 @@ class ConfigurationTest extends TestCase */ private $config; - protected function setUp() + protected function setUp(): void { $this->config = new Configuration(); } diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/VCR/Event/AfterHttpRequestEventTest.php index 151164bca..175ca501b 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/VCR/Event/AfterHttpRequestEventTest.php @@ -13,7 +13,7 @@ class AfterHttpRequestEventTest extends TestCase */ private $event; - protected function setUp() + protected function setUp(): void { $this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response(200)); } diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index 2ae55b4cb..ff06fb263 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -16,7 +16,7 @@ class AfterPlaybackEventTest extends TestCase */ private $event; - protected function setUp() + protected function setUp(): void { $this->event = new AfterPlaybackEvent( new Request('GET', 'http://example.com'), diff --git a/tests/VCR/Event/BeforeHttpRequestEventTest.php b/tests/VCR/Event/BeforeHttpRequestEventTest.php index 94363129a..b5630aba4 100644 --- a/tests/VCR/Event/BeforeHttpRequestEventTest.php +++ b/tests/VCR/Event/BeforeHttpRequestEventTest.php @@ -12,7 +12,7 @@ class BeforeHttpRequestEventTest extends TestCase */ private $event; - protected function setUp() + protected function setUp(): void { $this->event = new BeforeHttpRequestEvent(new Request('GET', 'http://example.com')); } diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/VCR/Event/BeforePlaybackEventTest.php index 34a359dc2..f9dd985aa 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/VCR/Event/BeforePlaybackEventTest.php @@ -15,7 +15,7 @@ class BeforePlaybackEventTest extends TestCase */ private $event; - protected function setUp() + protected function setUp(): void { $this->event = new BeforePlaybackEvent( new Request('GET', 'http://example.com'), diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index 8b8abcee2..37d6fb936 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -16,7 +16,7 @@ class BeforeRecordEventTest extends TestCase */ private $event; - protected function setUp() + protected function setUp(): void { $this->event = new BeforeRecordEvent( new Request('GET', 'http://example.com'), diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 907a66235..5bfa9a546 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -25,7 +25,7 @@ class CurlHookTest extends TestCase */ protected $curlHook; - protected function setup() + protected function setup(): void { $this->config = new Configuration(); $this->curlHook = new CurlHook(new CurlCodeTransform(), new StreamProcessor($this->config)); @@ -65,7 +65,7 @@ public function testShouldNotInterceptCallWhenNotEnabled() $response = curl_exec($curlHandle); curl_close($curlHandle); - $this->assertContains('Example Domain', $response, 'Response from http://example.com should contain "Example Domain".'); + $this->assertStringContainsString('Example Domain', $response, 'Response from http://example.com should contain "Example Domain".'); } /** @@ -216,7 +216,7 @@ public function testShouldReturnCurlInfoAll() $info = curl_getinfo($curlHandle); curl_close($curlHandle); - $this->assertInternalType('array', $info, 'curl_getinfo() should return an array.'); + $this->assertIsArray($info, 'curl_getinfo() should return an array.'); $this->assertCount(21, $info, 'curl_getinfo() should return 21 values.'); $this->curlHook->disable(); } @@ -231,7 +231,7 @@ public function testShouldReturnCurlInfoAllKeys() $info = curl_getinfo($curlHandle); curl_close($curlHandle); - $this->assertInternalType('array', $info, 'curl_getinfo() should return an array.'); + $this->assertIsArray($info, 'curl_getinfo() should return an array.'); $this->assertArrayHasKey('url', $info); $this->assertArrayHasKey('content_type', $info); $this->assertArrayHasKey('http_code', $info); diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index 0867c0e42..cd0986d42 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -24,7 +24,7 @@ class SoapHookTest extends TestCase /** @var SoapHook */ protected $soapHook; - protected function setup() + protected function setup(): void { $this->config = new Configuration(); $this->soapHook = new SoapHook(new SoapCodeTransform(), new StreamProcessor($this->config)); diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 79832789d..00721fb81 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -15,7 +15,7 @@ class RequestTest extends TestCase */ protected $request; - protected function setUp() + protected function setUp(): void { $this->request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); } diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index 26febb886..a2ee8ca3c 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -8,7 +8,7 @@ class BlackholeTest extends TestCase { protected $storage; - protected function setUp() + protected function setUp(): void { $this->storage = new Blackhole(); } diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 5b62fe31f..3c7c3e1b3 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -14,7 +14,7 @@ class JsonTest extends TestCase protected $filePath; protected $jsonObject; - protected function setUp() + protected function setUp(): void { vfsStream::setup('test'); $this->filePath = vfsStream::url('test/').'json_test'; diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index 4e46e8a55..ed48def2a 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -10,7 +10,7 @@ */ class YamlTest extends TestCase { - protected function setUp() + protected function setUp(): void { vfsStream::setup('test'); $this->filePath = vfsStream::url('test/').\DIRECTORY_SEPARATOR.'yaml_test'; diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index d6d4de0c3..fb1fe52bc 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -185,8 +185,8 @@ public function testSetCurlOptionReadFunction() $test = $this; $callback = function ($curlHandle, $fileHandle, $size) use ($test, $expected) { - $test->assertInternalType('resource', $curlHandle); - $test->assertInternalType('resource', $fileHandle); + $test->assertIsResource($curlHandle); + $test->assertIsResource($fileHandle); $test->assertEquals(\strlen($expected), $size); return $expected; diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index 88a6315bf..6afec838f 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -46,7 +46,7 @@ public function testDoRequest() $this->assertEquals( $expected, - $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2) + $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2) ); } @@ -58,7 +58,7 @@ public function testDoRequestOneWayEnabled() $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); - $this->assertNull($client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2, 1)); + $this->assertNull($client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, 1)); } public function testDoRequestOneWayDisabled() @@ -72,7 +72,7 @@ public function testDoRequestOneWayDisabled() $this->assertEquals( $expected, - $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2, 0) + $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, 0) ); } @@ -90,14 +90,14 @@ public function testDoRequestHandlesHookDisabled() $this->equalTo('Knorx ist groß'), $this->equalTo(self::WSDL), $this->equalTo(self::ACTION), - $this->equalTo(SOAP_1_2), + $this->equalTo(\SOAP_1_2), $this->equalTo(0) ); $hook = $this->getLibraryHookMock(false); $client->setLibraryHook($hook); - $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2); + $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2); } public function testDoRequestExpectingException() @@ -119,7 +119,7 @@ public function testDoRequestExpectingException() $this->expectException($exception); - $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, SOAP_1_2); + $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2); } public function testLibraryHook() @@ -158,7 +158,7 @@ public function testGetLastWhateverAfterRequest() $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); - $client->__doRequest($request, self::WSDL, self::ACTION, SOAP_1_2, 0); + $client->__doRequest($request, self::WSDL, self::ACTION, \SOAP_1_2, 0); $this->assertEquals($request, $client->__getLastRequest()); $this->assertEquals($response, $client->__getLastResponse()); diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index c09dec13a..00d834375 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -132,7 +132,7 @@ public function testDirOpendirNotFound() { $test = $this; set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test) { - $test->assertContains('opendir(not_found', $errstr); + $test->assertStringContainsString('opendir(not_found', $errstr); }); $processor = new StreamProcessor(); diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 4daa38285..eb590f8e3 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -11,7 +11,7 @@ */ class VCRTest extends TestCase { - public static function setupBeforeClass() + public static function setupBeforeClass(): void { VCR::configure()->setCassettePath('tests/fixtures'); } diff --git a/tests/integration/guzzle/6/test/AsyncTest.php b/tests/integration/guzzle/6/test/AsyncTest.php index e9510658d..9375be945 100644 --- a/tests/integration/guzzle/6/test/AsyncTest.php +++ b/tests/integration/guzzle/6/test/AsyncTest.php @@ -14,7 +14,7 @@ class AsyncTest extends TestCase const TEST_GET_URL = 'https://api.chew.pro/trbmb'; const TEST_GET_URL_2 = 'https://api.chew.pro/trbmb?foo=42'; - protected function setUp() + protected function setUp(): void { vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); @@ -40,7 +40,7 @@ public function testAsyncLock() protected function assertValidGETResponse($info) { - $this->assertInternalType('array', $info, 'Response is not an array.'); + $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('0', $info, 'API did not return any value.'); } } diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php index bd5741c0d..c24268cda 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -14,7 +14,7 @@ class ErrorTest extends TestCase { const TEST_GET_URL = 'http://localhost:9959'; - protected function setUp() + protected function setUp(): void { vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index e19dc9fc6..050262ef4 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -21,7 +21,7 @@ class ExampleHttpClientTest extends TestCase 'X-Request-Id', ]; - protected function setUp() + protected function setUp(): void { vfsStream::setup('testDir'); \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); @@ -89,17 +89,17 @@ protected function requestPOSTIntercepted() protected function assertValidGETResponse($info) { - $this->assertInternalType('array', $info, 'Response is not an array.'); + $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('0', $info, 'API did not return any value.'); } protected function assertValidPOSTResponse($info) { - $this->assertInternalType('array', $info, 'Response is not an array.'); + $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('url', $info, "Key 'url' not found."); $this->assertEquals(self::TEST_POST_URL, $info['url'], "Value for key 'url' wrong."); $this->assertArrayHasKey('headers', $info, "Key 'headers' not found."); - $this->assertInternalType('array', $info['headers'], 'Headers is not an array.'); + $this->assertIsArray($info['headers'], 'Headers is not an array.'); $this->assertEquals(self::TEST_POST_BODY, $info['data'], 'Correct request body was not sent.'); } } diff --git a/tests/integration/soap/phpunit.xml b/tests/integration/soap/phpunit.xml index bfc5d44e7..689dc6888 100644 --- a/tests/integration/soap/phpunit.xml +++ b/tests/integration/soap/phpunit.xml @@ -1,5 +1,6 @@ - SOAP_1_2]); + $client = new \SoapClient(self::EXAMPLE_WSDL, ['soap_version' => \SOAP_1_2]); $response = $client->NumberToWords(['ubiNum' => $number]); return trim((string) $response->NumberToWordsResult); @@ -22,6 +22,6 @@ public function call($number = 12) public function callBadUrl() { // The port is not open. This leads to an error - $client = new \SoapClient('http://localhost:9945', ['soap_version' => SOAP_1_2]); + $client = new \SoapClient('http://localhost:9945', ['soap_version' => \SOAP_1_2]); } } diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index e076a86ec..a13339267 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -13,7 +13,7 @@ */ class ExampleSoapClientTest extends TestCase { - protected function setUp() + protected function setUp(): void { // Configure virtual filesystem. vfsStream::setup('testDir'); @@ -27,14 +27,14 @@ protected function setUp() public function testCallDirectly() { $actual = $this->callSoap(); - $this->assertInternalType('string', $actual); + $this->assertIsString($actual); $this->assertEquals('twelve', $actual); } public function testCallIntercepted() { $actual = $this->callSoapIntercepted(); - $this->assertInternalType('string', $actual); + $this->assertIsString($actual); $this->assertEquals('twelve', $actual); } From 620269f43ad91caac3f95052be94f3ac6b09c5df Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 8 Mar 2021 20:03:31 +0100 Subject: [PATCH 106/204] Updated php-cs-fixer config --- .php_cs.dist | 8 ++- .../CodeTransform/AbstractCodeTransform.php | 2 +- src/VCR/CodeTransform/CurlCodeTransform.php | 2 +- src/VCR/CodeTransform/SoapCodeTransform.php | 2 +- src/VCR/LibraryHooks/LibraryHook.php | 4 +- src/VCR/Request.php | 2 +- src/VCR/Response.php | 8 +-- src/VCR/Storage/Json.php | 4 +- src/VCR/Storage/Yaml.php | 8 +-- src/VCR/Util/Assertion.php | 2 +- src/VCR/Util/HttpClient.php | 2 +- src/VCR/Util/HttpUtil.php | 6 +- src/VCR/Util/StreamProcessor.php | 4 +- src/VCR/VCR.php | 6 +- src/VCR/VCREvents.php | 10 +-- src/VCR/VCRException.php | 4 +- tests/VCR/CassetteTest.php | 10 +-- .../AbstractCodeTransformTest.php | 2 +- .../CodeTransform/CurlCodeTransformTest.php | 2 +- .../CodeTransform/SoapCodeTransformTest.php | 2 +- tests/VCR/ConfigurationTest.php | 30 ++++----- tests/VCR/Event/AfterHttpRequestEventTest.php | 4 +- tests/VCR/Event/AfterPlaybackEventTest.php | 6 +- .../VCR/Event/BeforeHttpRequestEventTest.php | 2 +- tests/VCR/Event/BeforePlaybackEventTest.php | 4 +- tests/VCR/Event/BeforeRecordEventTest.php | 6 +- tests/VCR/LibraryHooks/CurlHookTest.php | 38 +++++------ tests/VCR/LibraryHooks/SoapHookTest.php | 10 +-- .../LibraryHooks/StreamWrapperHookTest.php | 8 +-- tests/VCR/RequestMatcherTest.php | 20 +++--- tests/VCR/RequestTest.php | 38 +++++------ tests/VCR/ResponseTest.php | 28 ++++---- tests/VCR/Storage/AbstractStorageTest.php | 8 +-- tests/VCR/Storage/BlackholeTest.php | 14 ++-- tests/VCR/Storage/JsonTest.php | 18 +++--- tests/VCR/Storage/YamlTest.php | 16 ++--- tests/VCR/Util/CurlHelperTest.php | 64 +++++++++---------- tests/VCR/Util/HttpClientTest.php | 2 +- tests/VCR/Util/HttpUtilTest.php | 26 ++++---- tests/VCR/Util/SoapClientTest.php | 20 +++--- tests/VCR/Util/StreamHelperTest.php | 18 +++--- tests/VCR/Util/StreamProcessorTest.php | 28 ++++---- tests/VCR/Util/TextUtilTest.php | 2 +- tests/VCR/VCRFactoryTest.php | 6 +- tests/VCR/VCRTest.php | 26 ++++---- tests/VCR/VideorecorderTest.php | 12 ++-- tests/integration/apache/test/OpcacheTest.php | 2 +- tests/integration/guzzle/6/test/AsyncTest.php | 8 +-- tests/integration/guzzle/6/test/ErrorTest.php | 6 +- .../VCR/Example/ExampleHttpClientTest.php | 14 ++-- .../src/VCR/Example/ExampleSoapClient.php | 4 +- .../VCR/Example/ExampleSoapClientTest.php | 8 +-- 52 files changed, 292 insertions(+), 294 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 1da24fa0f..4744223bb 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -2,10 +2,14 @@ return PhpCsFixer\Config::create() ->setRules([ - '@PSR2' => true, + '@PSR12' => true, '@Symfony' => true, '@Symfony:risky' => true, - '@PHPUnit84Migration:risky' => true + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + '@PHPUnit84Migration:risky' => true, + // Causes too much problems for now, fix later + 'declare_strict_types' => false, ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 8bd4ae2d3..05b69dbe2 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -10,7 +10,7 @@ */ abstract class AbstractCodeTransform extends \php_user_filter { - const NAME = 'vcr_abstract_filter'; + public const NAME = 'vcr_abstract_filter'; /** * Attaches the current filter to a stream. diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index 6f441b027..baf93f67f 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -6,7 +6,7 @@ class CurlCodeTransform extends AbstractCodeTransform { - const NAME = 'vcr_curl'; + public const NAME = 'vcr_curl'; /** * @var array diff --git a/src/VCR/CodeTransform/SoapCodeTransform.php b/src/VCR/CodeTransform/SoapCodeTransform.php index 4d5603127..9a0b2ee88 100644 --- a/src/VCR/CodeTransform/SoapCodeTransform.php +++ b/src/VCR/CodeTransform/SoapCodeTransform.php @@ -6,7 +6,7 @@ class SoapCodeTransform extends AbstractCodeTransform { - const NAME = 'vcr_soap'; + public const NAME = 'vcr_soap'; /** * @var string[] diff --git a/src/VCR/LibraryHooks/LibraryHook.php b/src/VCR/LibraryHooks/LibraryHook.php index 69df7c21c..0806dfb24 100644 --- a/src/VCR/LibraryHooks/LibraryHook.php +++ b/src/VCR/LibraryHooks/LibraryHook.php @@ -10,12 +10,12 @@ interface LibraryHook /** * @var string enabled status for a hook */ - const ENABLED = 'ENABLED'; + public const ENABLED = 'ENABLED'; /** * @var string disabled status for a hook */ - const DISABLED = 'DISABLED'; + public const DISABLED = 'DISABLED'; /** * Enables library hook which means that all of this library diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 8e4d295e3..3293776f3 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -107,7 +107,7 @@ public static function fromArray(array $request): self $requestObject = new self( $request['method'], $request['url'], - isset($request['headers']) ? $request['headers'] : [] + $request['headers'] ?? [] ); if (!empty($request['post_fields']) && \is_array($request['post_fields'])) { diff --git a/src/VCR/Response.php b/src/VCR/Response.php index 791866d89..0618504b9 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -82,7 +82,7 @@ public function toArray(): array */ public static function fromArray(array $response): self { - $body = isset($response['body']) ? $response['body'] : null; + $body = $response['body'] ?? null; $gzip = isset($response['headers']['Content-Type']) && false !== strpos($response['headers']['Content-Type'], 'application/x-gzip'); @@ -96,10 +96,10 @@ public static function fromArray(array $response): self } return new static( - isset($response['status']) ? $response['status'] : 200, - isset($response['headers']) ? $response['headers'] : [], + $response['status'] ?? 200, + $response['headers'] ?? [], $body, - isset($response['curl_info']) ? $response['curl_info'] : [] + $response['curl_info'] ?? [] ); } diff --git a/src/VCR/Storage/Json.php b/src/VCR/Storage/Json.php index da4be71e9..f306c9053 100644 --- a/src/VCR/Storage/Json.php +++ b/src/VCR/Storage/Json.php @@ -78,10 +78,8 @@ protected function readNextRecord(): string /** * Resets the storage to the beginning. - * - * @return void */ - public function rewind() + public function rewind(): void { rewind($this->handle); $this->isEOF = false; diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index 8c93fe4b1..5af665db1 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -51,10 +51,8 @@ public function storeRecording(array $recording): void /** * Parses the next record. - * - * @return void */ - public function next() + public function next(): void { $recording = $this->yamlParser->parse($this->readNextRecord()); $this->current = $recording[0] ?? null; @@ -101,10 +99,8 @@ private function readNextRecord(): string /** * Resets the storage to the beginning. - * - * @return void */ - public function rewind() + public function rewind(): void { rewind($this->handle); $this->isEOF = false; diff --git a/src/VCR/Util/Assertion.php b/src/VCR/Util/Assertion.php index adadb75f7..3cbac5372 100644 --- a/src/VCR/Util/Assertion.php +++ b/src/VCR/Util/Assertion.php @@ -9,7 +9,7 @@ class Assertion extends BaseAssertion { protected static $exceptionClass = 'VCR\VCRException'; - const INVALID_CALLABLE = 910; + public const INVALID_CALLABLE = 910; /** * Assert that the value is callable. diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 6d83d8d13..5a65f0e15 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -42,7 +42,7 @@ public function send(Request $request): Response if (false === $result) { throw CurlException::create($ch); } - list($status, $headers, $body) = HttpUtil::parseResponse($result); + [$status, $headers, $body] = HttpUtil::parseResponse($result); return new Response( HttpUtil::parseStatus($status), diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index ec380b1df..7e80df7a7 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -17,7 +17,7 @@ public static function parseHeaders(array $headers): array { // Collect matching headers into groups foreach ($headers as $i => $line) { - list($key, $value) = explode(': ', $line, 2); + [$key, $value] = explode(': ', $line, 2); if (isset($headers[$key])) { if (\is_array($headers[$key])) { $headers[$key][] = $value; @@ -53,7 +53,7 @@ public static function parseStatus(string $status): array return [ 'http_version' => substr(strrchr($part[0], '/'), 1), 'code' => $part[1], - 'message' => isset($part[2]) ? $part[2] : '', + 'message' => $part[2] ?? '', ]; } @@ -68,7 +68,7 @@ public static function parseResponse(string $response): array { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); - list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2); + [$rawHeader, $rawBody] = explode("\r\n\r\n", $response, 2); // Parse headers and status. $headers = self::parseRawHeader($rawHeader); diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index bee11d823..1e933a7a8 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -21,12 +21,12 @@ class StreamProcessor /** * Constant for a stream which was opened while including a file. */ - const STREAM_OPEN_FOR_INCLUDE = 128; + public const STREAM_OPEN_FOR_INCLUDE = 128; /** * Stream protocol which is used when registering this wrapper. */ - const PROTOCOL = 'file'; + public const PROTOCOL = 'file'; /** * @var Configuration diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index b684c6e5f..ab313a6bd 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -18,17 +18,17 @@ class VCR /** * Always allow to do HTTP requests and add to the cassette. Default mode. */ - const MODE_NEW_EPISODES = 'new_episodes'; + public const MODE_NEW_EPISODES = 'new_episodes'; /** * Only allow new HTTP requests when the cassette is newly created. */ - const MODE_ONCE = 'once'; + public const MODE_ONCE = 'once'; /** * Treat the fixtures as read only and never allow new HTTP requests. */ - const MODE_NONE = 'none'; + public const MODE_NONE = 'none'; /** * @param mixed[] $parameters diff --git a/src/VCR/VCREvents.php b/src/VCR/VCREvents.php index 1fb3cf9a5..c4c27d8a2 100644 --- a/src/VCR/VCREvents.php +++ b/src/VCR/VCREvents.php @@ -4,9 +4,9 @@ final class VCREvents { - const VCR_BEFORE_RECORD = 'vcr.before_record'; - const VCR_BEFORE_PLAYBACK = 'vcr.before_playback'; - const VCR_AFTER_PLAYBACK = 'vcr.after_playback'; - const VCR_BEFORE_HTTP_REQUEST = 'vcr.before_http_request'; - const VCR_AFTER_HTTP_REQUEST = 'vcr.after_http_request'; + public const VCR_BEFORE_RECORD = 'vcr.before_record'; + public const VCR_BEFORE_PLAYBACK = 'vcr.before_playback'; + public const VCR_AFTER_PLAYBACK = 'vcr.after_playback'; + public const VCR_BEFORE_HTTP_REQUEST = 'vcr.before_http_request'; + public const VCR_AFTER_HTTP_REQUEST = 'vcr.after_http_request'; } diff --git a/src/VCR/VCRException.php b/src/VCR/VCRException.php index 98815d741..39476b30e 100644 --- a/src/VCR/VCRException.php +++ b/src/VCR/VCRException.php @@ -6,6 +6,6 @@ class VCRException extends InvalidArgumentException { - const LIBRARY_HOOK_DISABLED = 500; - const REQUEST_ERROR = 600; + public const LIBRARY_HOOK_DISABLED = 500; + public const REQUEST_ERROR = 600; } diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index da9192917..00b0de0eb 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -21,12 +21,12 @@ protected function setUp(): void $this->cassette = new Cassette('test', new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); } - public function testGetName() + public function testGetName(): void { $this->assertEquals('test', $this->cassette->getName()); } - public function testDontOverwriteRecord() + public function testDontOverwriteRecord(): void { $request = new Request('GET', 'https://example.com'); $response1 = new Response(200, [], 'sometest'); @@ -37,7 +37,7 @@ public function testDontOverwriteRecord() $this->assertEquals($response1->toArray(), $this->cassette->playback($request)->toArray()); } - public function testPlaybackAlreadyRecordedRequest() + public function testPlaybackAlreadyRecordedRequest(): void { $request = new Request('GET', 'https://example.com'); $response = new Response(200, [], 'sometest'); @@ -46,14 +46,14 @@ public function testPlaybackAlreadyRecordedRequest() $this->assertEquals($response->toArray(), $this->cassette->playback($request)->toArray()); } - public function testHasResponseNotFound() + public function testHasResponseNotFound(): void { $request = new Request('GET', 'https://example.com'); $this->assertFalse($this->cassette->hasResponse($request), 'Expected false if request not found.'); } - public function testHasResponseFound() + public function testHasResponseFound(): void { $request = new Request('GET', 'https://example.com'); $response = new Response(200, [], 'sometest'); diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 8ec6f6c8d..0bfafa0b2 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -28,7 +28,7 @@ protected function getFilter(array $methods = []) return $filter; } - public function testRegisterAlreadyRegistered() + public function testRegisterAlreadyRegistered(): void { $filter = $this->getFilter(); $filter->register(); diff --git a/tests/VCR/CodeTransform/CurlCodeTransformTest.php b/tests/VCR/CodeTransform/CurlCodeTransformTest.php index 1f5e700db..aed07095d 100644 --- a/tests/VCR/CodeTransform/CurlCodeTransformTest.php +++ b/tests/VCR/CodeTransform/CurlCodeTransformTest.php @@ -9,7 +9,7 @@ class CurlCodeTransformTest extends TestCase /** * @dataProvider codeSnippetProvider */ - public function testTransformCode($expected, $code) + public function testTransformCode($expected, $code): void { $codeTransform = new class() extends CurlCodeTransform { // A proxy to access the protected transformCode method. diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/VCR/CodeTransform/SoapCodeTransformTest.php index bc0e192e1..240be2641 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/VCR/CodeTransform/SoapCodeTransformTest.php @@ -9,7 +9,7 @@ class SoapCodeTransformTest extends TestCase /** * @dataProvider codeSnippetProvider */ - public function testTransformCode($expected, $code) + public function testTransformCode($expected, $code): void { $codeTransform = new class() extends SoapCodeTransform { // A proxy to access the protected transformCode method. diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index f96a88b75..63051b653 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -16,7 +16,7 @@ protected function setUp(): void $this->config = new Configuration(); } - public function testSetCassettePathThrowsErrorOnInvalidPath() + public function testSetCassettePathThrowsErrorOnInvalidPath(): void { $this->expectException( VCRException::class, @@ -27,7 +27,7 @@ public function testSetCassettePathThrowsErrorOnInvalidPath() $this->config->setCassettePath('invalid_path'); } - public function testGetLibraryHooks() + public function testGetLibraryHooks(): void { $this->assertEquals( [ @@ -39,7 +39,7 @@ public function testGetLibraryHooks() ); } - public function testEnableLibraryHooks() + public function testEnableLibraryHooks(): void { $this->config->enableLibraryHooks(['stream_wrapper']); $this->assertEquals( @@ -50,7 +50,7 @@ public function testEnableLibraryHooks() ); } - public function testEnableSingleLibraryHook() + public function testEnableSingleLibraryHook(): void { $this->config->enableLibraryHooks('stream_wrapper'); $this->assertEquals( @@ -61,13 +61,13 @@ public function testEnableSingleLibraryHook() ); } - public function testEnableLibraryHooksFailsWithWrongHookName() + public function testEnableLibraryHooksFailsWithWrongHookName(): void { $this->expectException('InvalidArgumentException', "Library hooks don't exist: non_existing"); $this->config->enableLibraryHooks(['non_existing']); } - public function testEnableRequestMatchers() + public function testEnableRequestMatchers(): void { $this->config->enableRequestMatchers(['body', 'headers']); $this->assertEquals( @@ -79,13 +79,13 @@ public function testEnableRequestMatchers() ); } - public function testEnableRequestMatchersFailsWithNoExistingName() + public function testEnableRequestMatchersFailsWithNoExistingName(): void { $this->expectException('InvalidArgumentException', "Request matchers don't exist: wrong, name"); $this->config->enableRequestMatchers(['wrong', 'name']); } - public function testAddRequestMatcherFailsWithNoName() + public function testAddRequestMatcherFailsWithNoName(): void { $this->expectException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''"); $expected = function ($first, $second) { @@ -94,7 +94,7 @@ public function testAddRequestMatcherFailsWithNoName() $this->config->addRequestMatcher('', $expected); } - public function testAddRequestMatchers() + public function testAddRequestMatchers(): void { $expected = function () { return true; @@ -106,7 +106,7 @@ public function testAddRequestMatchers() /** * @dataProvider availableStorageProvider */ - public function testSetStorage($name, $className) + public function testSetStorage($name, $className): void { $this->config->setStorage($name); $this->assertEquals($className, $this->config->getStorage(), "$name should be class $className."); @@ -120,13 +120,13 @@ public function availableStorageProvider() ]; } - public function testSetStorageInvalidName() + public function testSetStorageInvalidName(): void { $this->expectException('VCR\VCRException', "Storage 'Does not exist' not available."); $this->config->setStorage('Does not exist'); } - public function testGetStorage() + public function testGetStorage(): void { $class = $this->config->getStorage(); $this->assertContains('Iterator', class_implements($class)); @@ -134,7 +134,7 @@ public function testGetStorage() $this->assertContains('VCR\Storage\AbstractStorage', class_parents($class)); } - public function testWhitelist() + public function testWhitelist(): void { $expected = ['Tux', 'Gnu']; @@ -143,7 +143,7 @@ public function testWhitelist() $this->assertEquals($expected, $this->config->getWhiteList()); } - public function testBlacklist() + public function testBlacklist(): void { $expected = ['Tux', 'Gnu']; @@ -152,7 +152,7 @@ public function testBlacklist() $this->assertEquals($expected, $this->config->getBlackList()); } - public function testSetModeInvalidName() + public function testSetModeInvalidName(): void { $this->expectException('VCR\VCRException', "Mode 'invalid' does not exist."); $this->config->setMode('invalid'); diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/VCR/Event/AfterHttpRequestEventTest.php index 175ca501b..0c9ad0ed0 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/VCR/Event/AfterHttpRequestEventTest.php @@ -18,12 +18,12 @@ protected function setUp(): void $this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response(200)); } - public function testGetRequest() + public function testGetRequest(): void { $this->assertInstanceOf('VCR\Request', $this->event->getRequest()); } - public function testGetResponse() + public function testGetResponse(): void { $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); } diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index ff06fb263..ed72e787b 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -25,17 +25,17 @@ protected function setUp(): void ); } - public function testGetRequest() + public function testGetRequest(): void { $this->assertInstanceOf('VCR\Request', $this->event->getRequest()); } - public function testGetResponse() + public function testGetResponse(): void { $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); } - public function testGetCassette() + public function testGetCassette(): void { $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); } diff --git a/tests/VCR/Event/BeforeHttpRequestEventTest.php b/tests/VCR/Event/BeforeHttpRequestEventTest.php index b5630aba4..09a66c72d 100644 --- a/tests/VCR/Event/BeforeHttpRequestEventTest.php +++ b/tests/VCR/Event/BeforeHttpRequestEventTest.php @@ -17,7 +17,7 @@ protected function setUp(): void $this->event = new BeforeHttpRequestEvent(new Request('GET', 'http://example.com')); } - public function testGetRequest() + public function testGetRequest(): void { $this->assertInstanceOf('VCR\Request', $this->event->getRequest()); } diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/VCR/Event/BeforePlaybackEventTest.php index f9dd985aa..580a7a55a 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/VCR/Event/BeforePlaybackEventTest.php @@ -23,12 +23,12 @@ protected function setUp(): void ); } - public function testGetRequest() + public function testGetRequest(): void { $this->assertInstanceOf('VCR\Request', $this->event->getRequest()); } - public function testGetCassette() + public function testGetCassette(): void { $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); } diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index 37d6fb936..b6c332292 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -25,17 +25,17 @@ protected function setUp(): void ); } - public function testGetRequest() + public function testGetRequest(): void { $this->assertInstanceOf('VCR\Request', $this->event->getRequest()); } - public function testGetResponse() + public function testGetResponse(): void { $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); } - public function testGetCassette() + public function testGetCassette(): void { $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); } diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 5bfa9a546..69b2ac1bc 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -31,7 +31,7 @@ protected function setup(): void $this->curlHook = new CurlHook(new CurlCodeTransform(), new StreamProcessor($this->config)); } - public function testShouldBeEnabledAfterEnabling() + public function testShouldBeEnabledAfterEnabling(): void { $this->assertFalse($this->curlHook->isEnabled(), 'Initially the CurlHook should be disabled.'); @@ -42,7 +42,7 @@ public function testShouldBeEnabledAfterEnabling() $this->assertFalse($this->curlHook->isEnabled(), 'After disabling the CurlHook should be disabled.'); } - public function testShouldInterceptCallWhenEnabled() + public function testShouldInterceptCallWhenEnabled(): void { $this->curlHook->enable($this->getTestCallback()); @@ -58,7 +58,7 @@ public function testShouldInterceptCallWhenEnabled() /** * @group uses_internet */ - public function testShouldNotInterceptCallWhenNotEnabled() + public function testShouldNotInterceptCallWhenNotEnabled(): void { $curlHandle = curl_init('http://example.com/'); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); @@ -71,11 +71,11 @@ public function testShouldNotInterceptCallWhenNotEnabled() /** * @group uses_internet */ - public function testShouldNotInterceptCallWhenDisabled() + public function testShouldNotInterceptCallWhenDisabled(): void { $intercepted = false; $this->curlHook->enable( - function () use (&$intercepted) { + function () use (&$intercepted): void { $intercepted = true; } ); @@ -89,7 +89,7 @@ function () use (&$intercepted) { $this->assertFalse($intercepted, 'This request should not have been intercepted.'); } - public function testShouldWriteFileOnFileDownload() + public function testShouldWriteFileOnFileDownload(): void { $this->curlHook->enable($this->getTestCallback()); @@ -106,7 +106,7 @@ public function testShouldWriteFileOnFileDownload() $this->assertEquals($this->expected, $actual, 'Response was not written in file.'); } - public function testShouldEchoResponseIfReturnTransferFalse() + public function testShouldEchoResponseIfReturnTransferFalse(): void { $this->curlHook->enable($this->getTestCallback()); @@ -122,7 +122,7 @@ public function testShouldEchoResponseIfReturnTransferFalse() $this->assertEquals($this->expected, $actual, 'Response was not written on stdout.'); } - public function testShouldPostFieldsAsArray() + public function testShouldPostFieldsAsArray(): void { $testClass = $this; $this->curlHook->enable( @@ -144,7 +144,7 @@ function (Request $request) use ($testClass) { $this->curlHook->disable(); } - public function testShouldPostFieldsAsArrayUsingSetoptarray() + public function testShouldPostFieldsAsArrayUsingSetoptarray(): void { $testClass = $this; $this->curlHook->enable( @@ -171,7 +171,7 @@ function (Request $request) use ($testClass) { $this->curlHook->disable(); } - public function testShouldReturnCurlInfoStatusCode() + public function testShouldReturnCurlInfoStatusCode(): void { $this->curlHook->enable($this->getTestCallback()); @@ -189,7 +189,7 @@ public function testShouldReturnCurlInfoStatusCode() /** * @see https://github.com/php-vcr/php-vcr/issues/136 */ - public function testShouldReturnCurlInfoStatusCodeAsInteger() + public function testShouldReturnCurlInfoStatusCodeAsInteger(): void { $stringStatusCode = '200'; $integerStatusCode = 200; @@ -206,7 +206,7 @@ public function testShouldReturnCurlInfoStatusCodeAsInteger() $this->curlHook->disable(); } - public function testShouldReturnCurlInfoAll() + public function testShouldReturnCurlInfoAll(): void { $this->curlHook->enable($this->getTestCallback()); @@ -221,7 +221,7 @@ public function testShouldReturnCurlInfoAll() $this->curlHook->disable(); } - public function testShouldReturnCurlInfoAllKeys() + public function testShouldReturnCurlInfoAllKeys(): void { $this->curlHook->enable($this->getTestCallback()); @@ -258,7 +258,7 @@ public function testShouldReturnCurlInfoAllKeys() /** * @doesNotPerformAssertions */ - public function testShouldNotThrowErrorWhenDisabledTwice() + public function testShouldNotThrowErrorWhenDisabledTwice(): void { $this->curlHook->disable(); $this->curlHook->disable(); @@ -267,14 +267,14 @@ public function testShouldNotThrowErrorWhenDisabledTwice() /** * @doesNotPerformAssertions */ - public function testShouldNotThrowErrorWhenEnabledTwice() + public function testShouldNotThrowErrorWhenEnabledTwice(): void { $this->curlHook->enable($this->getTestCallback()); $this->curlHook->enable($this->getTestCallback()); $this->curlHook->disable(); } - public function testShouldInterceptMultiCallWhenEnabled() + public function testShouldInterceptMultiCallWhenEnabled(): void { $testClass = $this; $callCount = 0; @@ -330,11 +330,11 @@ function (Request $request) use ($testClass, &$callCount) { /** * @doesNotPerformAssertions */ - public function testShouldNotInterceptMultiCallWhenDisabled() + public function testShouldNotInterceptMultiCallWhenDisabled(): void { $testClass = $this; $this->curlHook->enable( - function () use ($testClass) { + function () use ($testClass): void { $testClass->fail('This request should not have been intercepted.'); } ); @@ -353,7 +353,7 @@ function () use ($testClass) { /** * @requires PHP 5.5.0 */ - public function testShouldResetRequest() + public function testShouldResetRequest(): void { $testClass = $this; $this->curlHook->enable( diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index cd0986d42..57deb5a78 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -15,7 +15,7 @@ */ class SoapHookTest extends TestCase { - const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; + public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; public $expected = 'true'; @@ -30,7 +30,7 @@ protected function setup(): void $this->soapHook = new SoapHook(new SoapCodeTransform(), new StreamProcessor($this->config)); } - public function testShouldInterceptCallWhenEnabled() + public function testShouldInterceptCallWhenEnabled(): void { $this->soapHook->enable($this->getContentCheckCallback()); @@ -43,7 +43,7 @@ public function testShouldInterceptCallWhenEnabled() $this->assertTrue($actual->GetCityWeatherByZIPResult->Success, 'Response was not returned.'); } - public function testShouldHandleSOAPVersion11() + public function testShouldHandleSOAPVersion11(): void { $expectedHeaders = [ 'Content-Type' => 'text/xml; charset=utf-8;', @@ -59,7 +59,7 @@ public function testShouldHandleSOAPVersion11() $client->GetCityWeatherByZIP(['ZIP' => '10013']); } - public function testShouldHandleSOAPVersion12() + public function testShouldHandleSOAPVersion12(): void { $expectedHeaders = [ 'Content-Type' => 'application/soap+xml; charset=utf-8; action="http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP"', @@ -75,7 +75,7 @@ public function testShouldHandleSOAPVersion12() $client->GetCityWeatherByZIP(['ZIP' => '10013']); } - public function testShouldReturnLastRequestWithTraceOn() + public function testShouldReturnLastRequestWithTraceOn(): void { $this->soapHook->enable($this->getContentCheckCallback()); diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index e423c62f1..1a4fce082 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -10,25 +10,25 @@ */ class StreamWrapperHookTest extends TestCase { - public function testEnable() + public function testEnable(): void { $streamWrapper = new StreamWrapperHook(); $testClass = $this; - $streamWrapper->enable(function ($request) use ($testClass) { + $streamWrapper->enable(function ($request) use ($testClass): void { $testClass->assertInstanceOf('\VCR\Request', $request); }); $this->assertTrue($streamWrapper->isEnabled()); } - public function testDisable() + public function testDisable(): void { $streamWrapper = new StreamWrapperHook(); $streamWrapper->disable(); $this->assertFalse($streamWrapper->isEnabled()); } - public function testSeek() + public function testSeek(): void { $hook = new StreamWrapperHook(); $hook->enable(function ($request) { diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index 6624796cd..a09a123ec 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -6,7 +6,7 @@ class RequestMatcherTest extends TestCase { - public function testMatchingMethod() + public function testMatchingMethod(): void { $first = new Request('GET', 'http://example.com', []); $second = new Request('GET', 'http://example.com', []); @@ -19,7 +19,7 @@ public function testMatchingMethod() $this->assertFalse(RequestMatcher::matchMethod($first, $second)); } - public function testMatchingUrl() + public function testMatchingUrl(): void { $first = new Request('GET', 'http://example.com/common/path', []); $second = new Request('GET', 'http://example.com/common/path', []); @@ -37,7 +37,7 @@ public function testMatchingUrl() $this->assertFalse(RequestMatcher::matchUrl($first, $second)); } - public function testMatchingHost() + public function testMatchingHost(): void { $first = new Request('GET', 'http://example.com/common/path', []); $second = new Request('GET', 'http://example.com/common/path', []); @@ -50,7 +50,7 @@ public function testMatchingHost() $this->assertFalse(RequestMatcher::matchHost($first, $second)); } - public function testMatchingHeaders() + public function testMatchingHeaders(): void { $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); $second = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); @@ -63,7 +63,7 @@ public function testMatchingHeaders() $this->assertFalse(RequestMatcher::matchHeaders($first, $second)); } - public function testHeaderMatchingDisallowsMissingHeaders() + public function testHeaderMatchingDisallowsMissingHeaders(): void { $first = new Request('GET', 'http://example.com', ['Accept' => 'Everything', 'MyHeader' => 'value']); $second = new Request('GET', 'http://example.com', ['Accept' => 'Everything']); @@ -76,7 +76,7 @@ public function testHeaderMatchingDisallowsMissingHeaders() $this->assertFalse(RequestMatcher::matchHeaders($first, $second)); } - public function testHeaderMatchingAllowsEmptyVals() + public function testHeaderMatchingAllowsEmptyVals(): void { $first = new Request('GET', 'http://example.com', ['Accept' => null, 'Content-Type' => 'application/json']); $second = new Request('GET', 'http://example.com', ['Accept' => null, 'Content-Type' => 'application/json']); @@ -84,7 +84,7 @@ public function testHeaderMatchingAllowsEmptyVals() $this->assertTrue(RequestMatcher::matchHeaders($first, $second)); } - public function testMatchingPostFields() + public function testMatchingPostFields(): void { $mock = [ 'method' => 'POST', @@ -107,7 +107,7 @@ public function testMatchingPostFields() $this->assertFalse(RequestMatcher::matchPostFields($first, $third)); } - public function testMatchingQueryString() + public function testMatchingQueryString(): void { $first = new Request('GET', 'http://example.com/search?query=test', []); $second = new Request('GET', 'http://example.com/search?query=test', []); @@ -120,7 +120,7 @@ public function testMatchingQueryString() $this->assertFalse(RequestMatcher::matchQueryString($first, $second)); } - public function testMatchingBody() + public function testMatchingBody(): void { $first = new Request('GET', 'http://example.com', []); $first->setBody('test'); @@ -137,7 +137,7 @@ public function testMatchingBody() $this->assertFalse(RequestMatcher::matchBody($first, $second), 'Bodies are different.'); } - public function testMatchingSoapOperation() + public function testMatchingSoapOperation(): void { $storedRequest = Request::fromArray([ 'method' => 'POST', diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 00721fb81..0895b8625 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -20,7 +20,7 @@ protected function setUp(): void $this->request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); } - public function testGetHeaders() + public function testGetHeaders(): void { $this->assertEquals( [ @@ -31,35 +31,35 @@ public function testGetHeaders() ); } - public function testSetMethod() + public function testSetMethod(): void { $this->request->setMethod('post'); $this->assertEquals('POST', $this->request->getMethod()); } - public function testSetAuthorization() + public function testSetAuthorization(): void { $this->request->setAuthorization('login', 'password'); $this->assertEquals('Basic bG9naW46cGFzc3dvcmQ=', $this->request->getHeader('Authorization')); } - public function testMatches() + public function testMatches(): void { $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->assertTrue($this->request->matches($request, [['VCR\RequestMatcher', 'matchMethod']])); } - public function testDoesntMatch() + public function testDoesntMatch(): void { $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->assertFalse($this->request->matches($request, [['VCR\RequestMatcher', 'matchMethod']])); } - public function testMatchesThrowsExceptionIfMatcherNotFound() + public function testMatchesThrowsExceptionIfMatcherNotFound(): void { $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->expectException( @@ -69,7 +69,7 @@ public function testMatchesThrowsExceptionIfMatcherNotFound() $this->request->matches($request, [['some', 'method']]); } - public function testRestoreRequest() + public function testRestoreRequest(): void { $restoredRequest = Request::fromArray($this->request->toArray()); $this->assertEquals( @@ -85,7 +85,7 @@ public function testRestoreRequest() ); } - public function testStorePostFields() + public function testStorePostFields(): void { $this->request->setPostFields(['para1' => 'val1']); $this->assertEquals( @@ -102,7 +102,7 @@ public function testStorePostFields() ); } - public function testRestorePostFields() + public function testRestorePostFields(): void { $this->request->setPostFields(['para1' => 'val1']); $restoredRequest = Request::fromArray($this->request->toArray()); @@ -120,7 +120,7 @@ public function testRestorePostFields() ); } - public function testStorePostFile() + public function testStorePostFile(): void { $file = [ 'fieldName' => 'field_name', @@ -143,7 +143,7 @@ public function testStorePostFile() ); } - public function testSetPostFiles() + public function testSetPostFiles(): void { $file = [ 'fieldName' => 'field_name', @@ -166,7 +166,7 @@ public function testSetPostFiles() ); } - public function testRestorePostFiles() + public function testRestorePostFiles(): void { $file = [ 'fieldName' => 'field_name', @@ -190,7 +190,7 @@ public function testRestorePostFiles() ); } - public function testRestoreBody() + public function testRestoreBody(): void { $this->request->setBody('sometest'); $restoredRequest = Request::fromArray($this->request->toArray()); @@ -208,7 +208,7 @@ public function testRestoreBody() ); } - public function testMatchesBody() + public function testMatchesBody(): void { $this->request->setBody('sometest'); $request = new Request('POST', 'http://example.com'); @@ -222,7 +222,7 @@ public function testMatchesBody() ); } - public function testDoesntMatchBody() + public function testDoesntMatchBody(): void { $this->request->setBody('sometest'); $request = new Request('POST', 'http://example.com'); @@ -236,13 +236,13 @@ public function testDoesntMatchBody() ); } - public function testGetHostReturnsBothHostAndPort() + public function testGetHostReturnsBothHostAndPort(): void { $request = new Request('GET', 'http://example.com:5000/foo?param=key'); $this->assertEquals('example.com:5000', $request->getHost()); } - public function testDoNotOverwriteHostHeader() + public function testDoNotOverwriteHostHeader(): void { $this->request = new Request( 'GET', @@ -259,7 +259,7 @@ public function testDoNotOverwriteHostHeader() ); } - public function testCurlCustomRequestOverridesMethod() + public function testCurlCustomRequestOverridesMethod(): void { $postRequest = new Request('POST', 'http://example.com'); $getRequest = new Request('GET', 'http://example.com'); @@ -274,7 +274,7 @@ public function testCurlCustomRequestOverridesMethod() $this->assertEquals('POST', $getRequest->getMethod()); } - public function testSetCurlOptions() + public function testSetCurlOptions(): void { $getRequest = new Request('GET', 'http://example.com'); $getRequest->setCurlOptions([ diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index 16d1452c6..8fe3394d1 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -9,7 +9,7 @@ */ class ResponseTest extends TestCase { - public function testGetHeaders() + public function testGetHeaders(): void { $expectedHeaders = [ 'User-Agent' => 'Unit-Test', @@ -21,13 +21,13 @@ public function testGetHeaders() $this->assertEquals($expectedHeaders, $response->getHeaders()); } - public function testGetHeadersNoneDefined() + public function testGetHeadersNoneDefined(): void { $response = Response::fromArray([]); $this->assertEquals([], $response->getHeaders()); } - public function testRestoreHeadersFromArray() + public function testRestoreHeadersFromArray(): void { $headers = [ 'Content-Type' => 'application/json', @@ -41,7 +41,7 @@ public function testRestoreHeadersFromArray() $this->assertEquals($headers, $restoredResponse->getHeaders()); } - public function testGetBody() + public function testGetBody(): void { $expectedBody = 'This is test content'; @@ -50,13 +50,13 @@ public function testGetBody() $this->assertEquals($expectedBody, $response->getBody()); } - public function testGetBodyNoneDefined() + public function testGetBodyNoneDefined(): void { $response = Response::fromArray([]); $this->assertEmpty($response->getBody()); } - public function testRestoreBodyFromArray() + public function testRestoreBodyFromArray(): void { $body = 'this is an example body'; $response = new Response(200, [], $body); @@ -65,7 +65,7 @@ public function testRestoreBodyFromArray() $this->assertEquals($body, $restoredResponse->getBody()); } - public function testBase64EncodeCompressedBody() + public function testBase64EncodeCompressedBody(): void { $body = 'this is an example body'; $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); @@ -74,7 +74,7 @@ public function testBase64EncodeCompressedBody() $this->assertEquals(base64_encode($body), $responseArray['body']); } - public function testBase64DecodeCompressedBody() + public function testBase64DecodeCompressedBody(): void { $body = 'this is an example body'; $responseArray = [ @@ -86,7 +86,7 @@ public function testBase64DecodeCompressedBody() $this->assertEquals($body, $response->getBody()); } - public function testRestoreCompressedBody() + public function testRestoreCompressedBody(): void { $body = 'this is an example body'; $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); @@ -95,7 +95,7 @@ public function testRestoreCompressedBody() $this->assertEquals($body, $restoredResponse->getBody()); } - public function testGetStatus() + public function testGetStatus(): void { $expectedStatus = 200; @@ -104,7 +104,7 @@ public function testGetStatus() $this->assertEquals($expectedStatus, $response->getStatusCode()); } - public function testRestoreStatusFromArray() + public function testRestoreStatusFromArray(): void { $expectedStatus = 200; @@ -114,7 +114,7 @@ public function testRestoreStatusFromArray() $this->assertEquals($expectedStatus, $restoredResponse->getStatusCode()); } - public function testGetCurlInfo() + public function testGetCurlInfo(): void { $curlOptions = ['option' => 'value']; $response = new Response(200, [], null, $curlOptions); @@ -122,7 +122,7 @@ public function testGetCurlInfo() $this->assertEquals($curlOptions, $response->getCurlInfo()); } - public function testRestoreCurlInfoFromArray() + public function testRestoreCurlInfoFromArray(): void { $expectedCurlOptions = ['option' => 'value']; $response = new Response(200, [], null, $expectedCurlOptions); @@ -131,7 +131,7 @@ public function testRestoreCurlInfoFromArray() $this->assertEquals($expectedCurlOptions, $response->getCurlInfo()); } - public function testToArray() + public function testToArray(): void { $expectedArray = [ 'status' => [ diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index 07cdf829e..d1f1f189b 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -14,7 +14,7 @@ class AbstractStorageTest extends TestCase protected $filePath; protected $storage; - public function testFilePathCreated() + public function testFilePathCreated(): void { $fs = vfsStream::setup('test'); @@ -26,7 +26,7 @@ public function testFilePathCreated() $this->assertTrue($fs->getChild('folder')->hasChild('file')); } - public function testRootNotExisting() + public function testRootNotExisting(): void { $this->expectException('\VCR\VCRException', "Cassette path 'vfs://test/foo' is not existing or not a directory"); @@ -46,7 +46,7 @@ public function storeRecording(array $recording): void public function next() { - list($this->position, $this->current) = each($this->recording); + [$this->position, $this->current] = each($this->recording); return $this->current; } @@ -56,7 +56,7 @@ public function valid() return (bool) $this->position; } - public function rewind() + public function rewind(): void { reset($this->recording); } diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index a2ee8ca3c..0fec7ba16 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -13,41 +13,41 @@ protected function setUp(): void $this->storage = new Blackhole(); } - public function testStoreRecordingIsCallable() + public function testStoreRecordingIsCallable(): void { $this->assertNull($this->storage->storeRecording(['empty or not, we don\'t care'])); } - public function testNextIsCallable() + public function testNextIsCallable(): void { $this->assertNull($this->storage->next()); } - public function testRewindIsCallable() + public function testRewindIsCallable(): void { $this->assertNull($this->storage->rewind()); } - public function testKeyIsNotCallable() + public function testKeyIsNotCallable(): void { $this->expectException(\BadMethodCallException::class); $this->storage->key(); } - public function testCurrentIsNotCallable() + public function testCurrentIsNotCallable(): void { $this->expectException(\BadMethodCallException::class); $this->storage->current(); } - public function testValidIsAlwaysFalse() + public function testValidIsAlwaysFalse(): void { $this->assertFalse($this->storage->valid()); } - public function testIsNewIsAlwaysTrue() + public function testIsNewIsAlwaysTrue(): void { $this->assertTrue($this->storage->isNew()); } diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 3c7c3e1b3..d0ab315a5 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -21,7 +21,7 @@ protected function setUp(): void $this->jsonObject = new Json(vfsStream::url('test/'), 'json_test'); } - public function testIterateOneObject() + public function testIterateOneObject(): void { $this->iterateAndTest( '[{"para1": "val1"}]', @@ -32,7 +32,7 @@ public function testIterateOneObject() ); } - public function testIterateTwoObjects() + public function testIterateTwoObjects(): void { $this->iterateAndTest( '[{"para1": "val1"}, {"para2": "val2"}]', @@ -44,7 +44,7 @@ public function testIterateTwoObjects() ); } - public function testIterateFirstNestedObject() + public function testIterateFirstNestedObject(): void { $this->iterateAndTest( '[{"para1": {"para2": "val2"}}, {"para3": "val3"}]', @@ -56,7 +56,7 @@ public function testIterateFirstNestedObject() ); } - public function testIterateSecondNestedObject() + public function testIterateSecondNestedObject(): void { $this->iterateAndTest( '[{"para1": "val1"}, {"para2": {"para3": "val3"}}]', @@ -68,7 +68,7 @@ public function testIterateSecondNestedObject() ); } - public function testIterateEmpty() + public function testIterateEmpty(): void { $this->iterateAndTest( '[]', @@ -77,7 +77,7 @@ public function testIterateEmpty() ); } - public function testStoreRecording() + public function testStoreRecording(): void { $expected = [ 'request' => 'some request', @@ -94,7 +94,7 @@ public function testStoreRecording() $this->assertEquals($expected, $actual[0], 'Storing and reading a recording failed.'); } - public function testValidJson() + public function testValidJson(): void { $stored = [ 'request' => 'some request', @@ -106,7 +106,7 @@ public function testValidJson() $this->assertJson(file_get_contents($this->filePath)); } - public function testStoreRecordingWhenBlankFileAlreadyExists() + public function testStoreRecordingWhenBlankFileAlreadyExists(): void { vfsStream::create(['blank_file_test' => '']); $filePath = vfsStream::url('test/').'blank_file_test'; @@ -121,7 +121,7 @@ public function testStoreRecordingWhenBlankFileAlreadyExists() $this->assertJson(file_get_contents($filePath)); } - private function iterateAndTest($json, $expected, $message) + private function iterateAndTest($json, $expected, $message): void { file_put_contents($this->filePath, $json); diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index ed48def2a..6b51cc154 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -17,7 +17,7 @@ protected function setUp(): void $this->yamlObject = new Yaml(vfsStream::url('test/'), 'yaml_test'); } - public function testIterateOneObject() + public function testIterateOneObject(): void { $this->iterateAndTest( '-'."\n" @@ -29,7 +29,7 @@ public function testIterateOneObject() ); } - public function testIterateTwoObjects() + public function testIterateTwoObjects(): void { $this->iterateAndTest( '-'."\n" @@ -44,7 +44,7 @@ public function testIterateTwoObjects() ); } - public function testIterateFirstNestedObject() + public function testIterateFirstNestedObject(): void { $this->iterateAndTest( '-'."\n" @@ -60,7 +60,7 @@ public function testIterateFirstNestedObject() ); } - public function testIterateSecondNestedObject() + public function testIterateSecondNestedObject(): void { $this->iterateAndTest( '-'."\n" @@ -76,7 +76,7 @@ public function testIterateSecondNestedObject() ); } - public function testIterateEmpty() + public function testIterateEmpty(): void { $this->iterateAndTest( '', @@ -85,7 +85,7 @@ public function testIterateEmpty() ); } - public function testStoreRecording() + public function testStoreRecording(): void { $expected = [ 'request' => 'some request', @@ -102,7 +102,7 @@ public function testStoreRecording() $this->assertEquals($expected, $actual[0], 'Storing and reading a recording failed.'); } - public function testStoreTwoRecording() + public function testStoreTwoRecording(): void { $expected = [ 'request' => ['headers' => ['Content-Type' => 'application/json']], @@ -121,7 +121,7 @@ public function testStoreTwoRecording() $this->assertEquals($expected, $actual[1], 'Storing and reading second recording failed.'); } - private function iterateAndTest($yaml, $expected, $message) + private function iterateAndTest($yaml, $expected, $message): void { file_put_contents($this->filePath, $yaml); diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index fb1fe52bc..4d1ecbd54 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -13,7 +13,7 @@ class CurlHelperTest extends TestCase /** * @dataProvider getHttpMethodsProvider() */ - public function testSetCurlOptionMethods($method) + public function testSetCurlOptionMethods($method): void { $request = new Request($method, 'http://example.com'); $headers = ['Host: example.com']; @@ -42,7 +42,7 @@ public function getHttpMethodsProvider() ]; } - public function testSetCurlOptionOnRequestPostFieldsQueryString() + public function testSetCurlOptionOnRequestPostFieldsQueryString(): void { $request = new Request('POST', 'http://example.com'); $payload = 'para1=val1¶2=val2'; @@ -52,7 +52,7 @@ public function testSetCurlOptionOnRequestPostFieldsQueryString() $this->assertEquals($payload, (string) $request->getBody()); } - public function testSetCurlOptionOnRequestPostFieldsArray() + public function testSetCurlOptionOnRequestPostFieldsArray(): void { $request = new Request('POST', 'http://example.com'); $payload = ['some' => 'test']; @@ -63,7 +63,7 @@ public function testSetCurlOptionOnRequestPostFieldsArray() $this->assertEquals($payload, $request->getPostFields()); } - public function testSetCurlOptionOnRequestPostFieldsString() + public function testSetCurlOptionOnRequestPostFieldsString(): void { $request = new Request('POST', 'http://example.com'); $payload = json_encode(['some' => 'test']); @@ -73,7 +73,7 @@ public function testSetCurlOptionOnRequestPostFieldsString() $this->assertEquals($payload, (string) $request->getBody()); } - public function testSetCurlOptionOnRequestPostFieldsEmptyString() + public function testSetCurlOptionOnRequestPostFieldsEmptyString(): void { $request = new Request('POST', 'http://example.com'); $payload = ''; @@ -85,7 +85,7 @@ public function testSetCurlOptionOnRequestPostFieldsEmptyString() $this->assertNull($request->getBody()); } - public function testSetCurlOptionOnRequestSetSingleHeader() + public function testSetCurlOptionOnRequestSetSingleHeader(): void { $request = new Request('GET', 'http://example.com'); $headers = ['Host: example.com']; @@ -95,7 +95,7 @@ public function testSetCurlOptionOnRequestSetSingleHeader() $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } - public function testSetCurlOptionOnRequestSetSingleHeaderTwice() + public function testSetCurlOptionOnRequestSetSingleHeaderTwice(): void { $request = new Request('GET', 'http://example.com'); $headers = ['Host: example.com']; @@ -106,7 +106,7 @@ public function testSetCurlOptionOnRequestSetSingleHeaderTwice() $this->assertEquals(['Host' => 'example.com'], $request->getHeaders()); } - public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() + public function testSetCurlOptionOnRequestSetMultipleHeadersTwice(): void { $request = new Request('GET', 'http://example.com'); $headers = [ @@ -124,7 +124,7 @@ public function testSetCurlOptionOnRequestSetMultipleHeadersTwice() $this->assertEquals($expected, $request->getHeaders()); } - public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() + public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType(): void { $request = new Request('GET', 'http://example.com'); $headers = [ @@ -141,7 +141,7 @@ public function testSetCurlOptionOnRequestEmptyPostFieldsRemovesContentType() $this->assertEquals($expected, $request->getHeaders()); } - public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() + public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod(): void { $request = new Request('GET', 'http://example.com'); $payload = json_encode(['some' => 'test']); @@ -151,7 +151,7 @@ public function testSetCurlOptionOnRequestPostFieldsSetsPostMethod() $this->assertEquals('POST', $request->getMethod()); } - public function testSetCurlOptionReadFunctionToNull() + public function testSetCurlOptionReadFunctionToNull(): void { $request = new Request('POST', 'http://example.com'); @@ -160,25 +160,25 @@ public function testSetCurlOptionReadFunctionToNull() $this->assertNull($request->getCurlOption(\CURLOPT_READFUNCTION)); } - public function testInvalidHostException() + public function testInvalidHostException(): void { $this->expectException(InvalidHostException::class, 'URL must be valid.'); new Request('POST', 'example.com'); } - public function testSetCurlOptionReadFunctionMissingSize() + public function testSetCurlOptionReadFunctionMissingSize(): void { $this->expectException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $request = new Request('POST', 'http://example.com'); - $callback = function ($curlHandle, $fileHandle, $size) { + $callback = function ($curlHandle, $fileHandle, $size): void { }; CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback, curl_init()); CurlHelper::validateCurlPOSTBody($request, curl_init()); } - public function testSetCurlOptionReadFunction() + public function testSetCurlOptionReadFunction(): void { $expected = 'test body'; $request = new Request('POST', 'http://example.com'); @@ -199,7 +199,7 @@ public function testSetCurlOptionReadFunction() $this->assertEquals($expected, $request->getBody()); } - public function testHandleResponseReturnsBody() + public function testHandleResponseReturnsBody(): void { $curlOptions = [ \CURLOPT_RETURNTRANSFER => true, @@ -211,7 +211,7 @@ public function testHandleResponseReturnsBody() $this->assertEquals($response->getBody(true), $output); } - public function testHandleResponseEchosBody() + public function testHandleResponseEchosBody(): void { $response = new Response(200, [], 'example response'); @@ -222,7 +222,7 @@ public function testHandleResponseEchosBody() $this->assertEquals($response->getBody(true), $output); } - public function testHandleResponseIncludesHeader() + public function testHandleResponseIncludesHeader(): void { $curlOptions = [ \CURLOPT_HEADER => true, @@ -240,11 +240,11 @@ public function testHandleResponseIncludesHeader() $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n".$response->getBody(), $output); } - public function testHandleOutputHeaderFunction() + public function testHandleOutputHeaderFunction(): void { $actualHeaders = []; $curlOptions = [ - \CURLOPT_HEADERFUNCTION => function ($ch, $header) use (&$actualHeaders) { + \CURLOPT_HEADERFUNCTION => function ($ch, $header) use (&$actualHeaders): void { $actualHeaders[] = $header; }, ]; @@ -267,7 +267,7 @@ public function testHandleOutputHeaderFunction() $this->assertEquals($expected, $actualHeaders); } - public function testHandleOutputHeaderFunctionWithPublicFunction() + public function testHandleOutputHeaderFunctionWithPublicFunction(): void { $this->headersFound = []; $curlOptions = [ @@ -292,7 +292,7 @@ public function testHandleOutputHeaderFunctionWithPublicFunction() $this->assertEquals($expected, $this->headersFound); } - public function testHandleOutputHeaderFunctionWithProtectedFunction() + public function testHandleOutputHeaderFunctionWithProtectedFunction(): void { $this->headersFound = []; $curlOptions = [ @@ -317,7 +317,7 @@ public function testHandleOutputHeaderFunctionWithProtectedFunction() $this->assertEquals($expected, $this->headersFound); } - public function testHandleOutputHeaderFunctionWithPrivateFunction() + public function testHandleOutputHeaderFunctionWithPrivateFunction(): void { $this->headersFound = []; $curlOptions = [ @@ -342,7 +342,7 @@ public function testHandleOutputHeaderFunctionWithPrivateFunction() $this->assertEquals($expected, $this->headersFound); } - public function testHandleResponseUsesWriteFunction() + public function testHandleResponseUsesWriteFunction(): void { $test = $this; $expectedCh = curl_init(); @@ -360,7 +360,7 @@ public function testHandleResponseUsesWriteFunction() CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } - public function testHandleResponseUsesWriteFunctionWithPrivateFunction() + public function testHandleResponseUsesWriteFunctionWithPrivateFunction(): void { $test = $this; $expectedCh = curl_init(); @@ -373,7 +373,7 @@ public function testHandleResponseUsesWriteFunctionWithPrivateFunction() CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } - public function testHandleResponseWritesFile() + public function testHandleResponseWritesFile(): void { vfsStream::setup('test'); $expectedBody = 'example response'; @@ -396,7 +396,7 @@ public function testHandleResponseWritesFile() * @param int $curlOption cURL option to get * @param mixed $expectedCurlOptionValue Expected value of cURL option */ - public function testGetCurlOptionFromResponse(Response $response, $curlOption, $expectedCurlOptionValue) + public function testGetCurlOptionFromResponse(Response $response, $curlOption, $expectedCurlOptionValue): void { $this->assertEquals( $expectedCurlOptionValue, @@ -508,7 +508,7 @@ public function getCurlOptionProvider() ]; } - public function testSetCurlOptionCustomRequest() + public function testSetCurlOptionCustomRequest(): void { $request = new Request('POST', 'http://example.com'); @@ -517,7 +517,7 @@ public function testSetCurlOptionCustomRequest() $this->assertEquals('PUT', $request->getCurlOption(\CURLOPT_CUSTOMREQUEST)); } - public function testCurlCustomRequestAlwaysOverridesMethod() + public function testCurlCustomRequestAlwaysOverridesMethod(): void { $request = new Request('POST', 'http://example.com'); @@ -531,19 +531,19 @@ public function testCurlCustomRequestAlwaysOverridesMethod() } // Function used for testing CURLOPT_HEADERFUNCTION - public function publicCurlHeaderFunction($ch, $header) + public function publicCurlHeaderFunction($ch, $header): void { $this->headersFound[] = $header; } // Function used for testing CURLOPT_HEADERFUNCTION - protected function protectedCurlHeaderFunction($ch, $header) + protected function protectedCurlHeaderFunction($ch, $header): void { $this->headersFound[] = $header; } // Function used for testing CURLOPT_HEADERFUNCTION - private function privateCurlHeaderFunction($ch, $header) + private function privateCurlHeaderFunction($ch, $header): void { $this->headersFound[] = $header; } diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/VCR/Util/HttpClientTest.php index 1781ef965..c7c4b2965 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/VCR/Util/HttpClientTest.php @@ -7,7 +7,7 @@ class HttpClientTest extends TestCase { - public function testHttpClientOnError() + public function testHttpClientOnError(): void { $httpClient = new HttpClient(); // Request on a closed port diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/VCR/Util/HttpUtilTest.php index e6360a4d6..afef2b5c9 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/VCR/Util/HttpUtilTest.php @@ -6,10 +6,10 @@ class HttpUtilTest extends TestCase { - public function testParseResponseBasic() + public function testParseResponseBasic(): void { $raw = "HTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; - list($status, $headers, $body) = HttpUtil::parseResponse($raw); + [$status, $headers, $body] = HttpUtil::parseResponse($raw); $expectedHeaders = [ 'Content-Type: text/html', @@ -23,10 +23,10 @@ public function testParseResponseBasic() $this->assertEquals($expectedHeaders, $headers); } - public function testParseResponseMultipleHeaders() + public function testParseResponseMultipleHeaders(): void { $raw = "HTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept, Accept-Language, Expect\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; - list($status, $headers, $body) = HttpUtil::parseResponse($raw); + [$status, $headers, $body] = HttpUtil::parseResponse($raw); $expectedHeaders = [ 'Content-Type: text/html', @@ -41,10 +41,10 @@ public function testParseResponseMultipleHeaders() $this->assertEquals($expectedHeaders, $headers); } - public function testParseContinuePlusResponse() + public function testParseContinuePlusResponse(): void { $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; - list($status, $headers, $body) = HttpUtil::parseResponse($raw); + [$status, $headers, $body] = HttpUtil::parseResponse($raw); $expectedHeaders = [ 'Content-Type: text/html', @@ -58,10 +58,10 @@ public function testParseContinuePlusResponse() $this->assertEquals($expectedHeaders, $headers); } - public function testParseiMultipleContinuePlusResponse() + public function testParseiMultipleContinuePlusResponse(): void { $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; - list($status, $headers, $body) = HttpUtil::parseResponse($raw); + [$status, $headers, $body] = HttpUtil::parseResponse($raw); $expectedHeaders = [ 'Content-Type: text/html', @@ -75,10 +75,10 @@ public function testParseiMultipleContinuePlusResponse() $this->assertEquals($expectedHeaders, $headers); } - public function testParseContinuePlusResponseMultipleHeaders() + public function testParseContinuePlusResponseMultipleHeaders(): void { $raw = "HTTP/1.1 100 Continue\r\n\r\nHTTP/1.1 201 Created\r\nContent-Type: text/html\r\nDate: Fri, 19 Jun 2015 16:05:18 GMT\r\nVary: Accept, Accept-Language, Expect\r\nVary: Accept-Encoding\r\nContent-Length: 0\r\n\r\n"; - list($status, $headers, $body) = HttpUtil::parseResponse($raw); + [$status, $headers, $body] = HttpUtil::parseResponse($raw); $expectedHeaders = [ 'Content-Type: text/html', @@ -93,7 +93,7 @@ public function testParseContinuePlusResponseMultipleHeaders() $this->assertEquals($expectedHeaders, $headers); } - public function testParseHeadersBasic() + public function testParseHeadersBasic(): void { $inputArray = [ 'Content-Type: text/html', @@ -111,7 +111,7 @@ public function testParseHeadersBasic() $this->assertEquals($excpetedHeaders, $outputArray); } - public function testParseHeadersMultiple() + public function testParseHeadersMultiple(): void { $inputArray = [ 'Content-Type: text/html', @@ -130,7 +130,7 @@ public function testParseHeadersMultiple() $this->assertEquals($excpetedHeaders, $outputArray); } - public function testParseHeadersIncludingColons() + public function testParseHeadersIncludingColons(): void { $inputArray = [ 'dropbox-api-result: {"name": "a_file.txt"}', diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index 6afec838f..b442ee0d6 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -7,8 +7,8 @@ class SoapClientTest extends TestCase { - const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; - const ACTION = 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP'; + public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; + public const ACTION = 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP'; protected function getLibraryHookMock($enabled) { @@ -25,7 +25,7 @@ protected function getLibraryHookMock($enabled) return $hookMock; } - public function testDoRequest() + public function testDoRequest(): void { $expected = 'Knorx ist groß'; @@ -50,7 +50,7 @@ public function testDoRequest() ); } - public function testDoRequestOneWayEnabled() + public function testDoRequestOneWayEnabled(): void { $hook = $this->getLibraryHookMock(true); $hook->expects($this->once())->method('doRequest')->willReturn('some value'); @@ -61,7 +61,7 @@ public function testDoRequestOneWayEnabled() $this->assertNull($client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, 1)); } - public function testDoRequestOneWayDisabled() + public function testDoRequestOneWayDisabled(): void { $expected = 'some value'; $hook = $this->getLibraryHookMock(true); @@ -76,7 +76,7 @@ public function testDoRequestOneWayDisabled() ); } - public function testDoRequestHandlesHookDisabled() + public function testDoRequestHandlesHookDisabled(): void { $client = $this->getMockBuilder('\VCR\Util\SoapClient') ->disableOriginalConstructor() @@ -100,7 +100,7 @@ public function testDoRequestHandlesHookDisabled() $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2); } - public function testDoRequestExpectingException() + public function testDoRequestExpectingException(): void { $exception = '\LogicException'; @@ -122,7 +122,7 @@ public function testDoRequestExpectingException() $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2); } - public function testLibraryHook() + public function testLibraryHook(): void { $client = new class(self::WSDL) extends SoapClient { // A proxy to access the protected getLibraryHook method. @@ -139,7 +139,7 @@ public function publicGetLibraryHook(): SoapHook $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->publicGetLibraryHook()); } - public function testGetLastWhateverBeforeRequest() + public function testGetLastWhateverBeforeRequest(): void { $client = new SoapClient(self::WSDL); @@ -147,7 +147,7 @@ public function testGetLastWhateverBeforeRequest() $this->assertNull($client->__getLastResponse()); } - public function testGetLastWhateverAfterRequest() + public function testGetLastWhateverAfterRequest(): void { $request = 'Knorx ist groß'; $response = 'some value'; diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index 25544d8c1..eef1ab0f9 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -14,21 +14,21 @@ public function streamContexts() return [ 'header' => [ ['header' => 'Content-Type: application/json'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('application/json', $request->getHeader('Content-Type')); }, ], 'header with trailing newline' => [ ['header' => "Content-Type: application/json\r\n"], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('application/json', $request->getHeader('Content-Type')); }, ], 'multiple headers' => [ ['header' => "Content-Type: application/json\r\nContent-Length: 123"], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('application/json', $request->getHeader('Content-Type')); $test->assertEquals('123', $request->getHeader('Content-Length')); }, @@ -36,35 +36,35 @@ function (Request $request) use ($test) { 'user_agent' => [ ['user_agent' => 'example'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('example', $request->getHeader('User-Agent')); }, ], 'content' => [ ['content' => 'example'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('example', $request->getBody()); }, ], 'follow_location' => [ ['follow_location' => '0'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals(false, $request->getCurlOption(\CURLOPT_FOLLOWLOCATION)); }, ], 'max_redirects' => [ ['max_redirects' => '2'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('2', $request->getCurlOption(\CURLOPT_MAXREDIRS)); }, ], 'timeout' => [ ['timeout' => '100'], - function (Request $request) use ($test) { + function (Request $request) use ($test): void { $test->assertEquals('100', $request->getCurlOption(\CURLOPT_TIMEOUT)); }, ], @@ -77,7 +77,7 @@ function (Request $request) use ($test) { * @param $context * @param $testCallback */ - public function testStreamHttpContext($context, $testCallback) + public function testStreamHttpContext($context, $testCallback): void { $context = stream_context_create([ 'http' => $context, diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index 00d834375..10157373b 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -10,7 +10,7 @@ class StreamProcessorTest extends TestCase /** * test flock with file_put_contents. */ - public function testFlockWithFilePutContents() + public function testFlockWithFilePutContents(): void { $processor = new StreamProcessor(); $processor->intercept(); @@ -31,7 +31,7 @@ public function testFlockWithFilePutContents() * @param bool $shouldProcess * @param int $option */ - public function testStreamOpenShouldAppendFilters($expected, $option, $shouldProcess = null) + public function testStreamOpenShouldAppendFilters($expected, $option, $shouldProcess = null): void { $mock = $this->getMockBuilder('VCR\Util\StreamProcessor') ->disableOriginalConstructor() @@ -74,10 +74,10 @@ public function streamOpenFileModesWhichDoNotCreateFiles() /** * @dataProvider streamOpenFileModesWhichDoNotCreateFiles */ - public function testStreamOpenShouldNotFailOnNonExistingFile($fileMode) + public function testStreamOpenShouldNotFailOnNonExistingFile($fileMode): void { $test = $this; - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test) { + set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): void { $test->fail('should not throw errors'); }); @@ -92,10 +92,10 @@ public function testStreamOpenShouldNotFailOnNonExistingFile($fileMode) /** * @doesNotPerformAssertions */ - public function testUrlStatSuccessfully() + public function testUrlStatSuccessfully(): void { $test = $this; - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test) { + set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): void { $test->fail('should not throw errors'); }); @@ -105,7 +105,7 @@ public function testUrlStatSuccessfully() restore_error_handler(); } - public function testUrlStatFileNotFound() + public function testUrlStatFileNotFound(): void { $processor = new StreamProcessor(); $this->expectException(Warning::class); @@ -115,23 +115,23 @@ public function testUrlStatFileNotFound() /** * @doesNotPerformAssertions */ - public function testQuietUrlStatFileNotFoundToBeQuiet() + public function testQuietUrlStatFileNotFoundToBeQuiet(): void { $processor = new StreamProcessor(); $processor->url_stat('file_not_found', \STREAM_URL_STAT_QUIET); } - public function testDirOpendir() + public function testDirOpendir(): void { $processor = new StreamProcessor(); $this->assertTrue($processor->dir_opendir('tests/fixtures')); $processor->dir_closedir(); } - public function testDirOpendirNotFound() + public function testDirOpendirNotFound(): void { $test = $this; - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test) { + set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): void { $test->assertStringContainsString('opendir(not_found', $errstr); }); @@ -141,7 +141,7 @@ public function testDirOpendirNotFound() restore_error_handler(); } - public function testMakeDir() + public function testMakeDir(): void { $mock = $this->getStreamProcessorMock(); $mock->expects($this->exactly(2))->method('restore'); @@ -151,7 +151,7 @@ public function testMakeDir() $this->assertTrue($mock->rmdir('tests/fixtures/unittest_streamprocessor')); } - public function testRename() + public function testRename(): void { $mock = $this->getStreamProcessorMock(); $mock->expects($this->exactly(3))->method('restore'); @@ -162,7 +162,7 @@ public function testRename() $this->assertTrue($mock->rmdir('tests/fixtures/sp')); } - public function testStreamMetadata() + public function testStreamMetadata(): void { if (version_compare(\PHP_VERSION, '5.4.0', '<')) { $this->markTestSkipped('Behavior is only applicable and testable for PHP 5.4+'); diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/VCR/Util/TextUtilTest.php index daf2036db..e8f91d1cb 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/VCR/Util/TextUtilTest.php @@ -12,7 +12,7 @@ class TextUtilTest extends TestCase /** * @dataProvider curlMethodsProvider */ - public function testUnderscoreToLowerCamelcase($expected, $method) + public function testUnderscoreToLowerCamelcase($expected, $method): void { $this->assertEquals($expected, TextUtil::underscoreToLowerCamelcase($method)); } diff --git a/tests/VCR/VCRFactoryTest.php b/tests/VCR/VCRFactoryTest.php index a36c4bb64..707526a83 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/VCR/VCRFactoryTest.php @@ -14,7 +14,7 @@ class VCRFactoryTest extends TestCase * @dataProvider instanceProvider * @covers \VCR\VCRFactory::createVCRVideorecorder() */ - public function testCreateInstances($instance) + public function testCreateInstances($instance): void { $this->assertInstanceOf($instance, VCRFactory::get($instance)); } @@ -37,14 +37,14 @@ public function instanceProvider() /** * @dataProvider storageProvider */ - public function testCreateStorage($storage, $className) + public function testCreateStorage($storage, $className): void { vfsStream::setup('test'); VCRFactory::get('VCR\Configuration')->setStorage($storage); VCRFactory::get('VCR\Configuration')->setCassettePath(vfsStream::url('test/')); - $instance = VCRFactory::get('Storage', [rand()]); + $instance = VCRFactory::get('Storage', [random_int(0, getrandmax())]); $this->assertInstanceOf($className, $instance); } diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index eb590f8e3..9bcfd7c29 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -16,7 +16,7 @@ public static function setupBeforeClass(): void VCR::configure()->setCassettePath('tests/fixtures'); } - public function testUseStaticCallsNotInitialized() + public function testUseStaticCallsNotInitialized(): void { VCR::configure()->enableLibraryHooks(['stream_wrapper']); $this->expectException( @@ -26,7 +26,7 @@ public function testUseStaticCallsNotInitialized() VCR::insertCassette('some_name'); } - public function testShouldInterceptStreamWrapper() + public function testShouldInterceptStreamWrapper(): void { VCR::configure()->enableLibraryHooks(['stream_wrapper']); VCR::turnOn(); @@ -37,7 +37,7 @@ public function testShouldInterceptStreamWrapper() VCR::turnOff(); } - public function testShouldInterceptCurlLibrary() + public function testShouldInterceptCurlLibrary(): void { VCR::configure()->enableLibraryHooks(['curl']); VCR::turnOn(); @@ -62,7 +62,7 @@ private function doCurlGetRequest($url) return $output; } - public function testShouldInterceptSoapLibrary() + public function testShouldInterceptSoapLibrary(): void { VCR::configure()->enableLibraryHooks(['soap']); VCR::turnOn(); @@ -80,7 +80,7 @@ public function testShouldInterceptSoapLibrary() /** * @doesNotPerformAssertions */ - public function testShouldNotInterceptCallsToDevUrandom() + public function testShouldNotInterceptCallsToDevUrandom(): void { if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('/dev/urandom is not supported on Windows'); @@ -98,7 +98,7 @@ public function testShouldNotInterceptCallsToDevUrandom() VCR::turnOff(); } - public function testShouldThrowExceptionIfNoCassettePresent() + public function testShouldThrowExceptionIfNoCassettePresent(): void { $this->expectException( 'BadMethodCallException', @@ -124,7 +124,7 @@ public function testShouldThrowExceptionIfNoCassettePresent() // TODO: Check of cassette was changed }*/ - public function testDoesNotBlockThrowingExceptions() + public function testDoesNotBlockThrowingExceptions(): void { $this->configureVirtualCassette(); @@ -134,13 +134,13 @@ public function testDoesNotBlockThrowingExceptions() throw new \InvalidArgumentException('test'); } - private function configureVirtualCassette() + private function configureVirtualCassette(): void { vfsStream::setup('testDir'); VCR::configure()->setCassettePath(vfsStream::url('testDir')); } - public function testShouldSetAConfiguration() + public function testShouldSetAConfiguration(): void { VCR::configure()->setCassettePath('tests'); VCR::turnOn(); @@ -148,7 +148,7 @@ public function testShouldSetAConfiguration() VCR::turnOff(); } - public function testShouldDispatchBeforeAndAfterPlaybackWhenCassetteHasResponse() + public function testShouldDispatchBeforeAndAfterPlaybackWhenCassetteHasResponse(): void { VCR::configure() ->enableLibraryHooks(['curl']); @@ -166,7 +166,7 @@ public function testShouldDispatchBeforeAndAfterPlaybackWhenCassetteHasResponse( VCR::turnOff(); } - public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCassetteHasNoResponse() + public function testShouldDispatchBeforeAfterHttpRequestAndBeforeRecordWhenCassetteHasNoResponse(): void { vfsStream::setup('testDir'); VCR::configure() @@ -201,7 +201,7 @@ public function testFinfoWorksCorrectly(): void ); } - private function recordAllEvents() + private function recordAllEvents(): void { $allEventsToListen = [ VCREvents::VCR_BEFORE_PLAYBACK, @@ -215,7 +215,7 @@ private function recordAllEvents() } } - public function recordEvent(Event $event, $eventName) + public function recordEvent(Event $event, $eventName): void { $this->events[$eventName] = $event; } diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 069ffcfde..020dcf401 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -10,7 +10,7 @@ */ class VideorecorderTest extends TestCase { - public function testCreateVideorecorder() + public function testCreateVideorecorder(): void { $this->assertInstanceOf( '\VCR\Videorecorder', @@ -18,7 +18,7 @@ public function testCreateVideorecorder() ); } - public function testInsertCassetteEjectExisting() + public function testInsertCassetteEjectExisting(): void { vfsStream::setup('testDir'); $factory = VCRFactory::getInstance(); @@ -38,7 +38,7 @@ public function testInsertCassetteEjectExisting() $videorecorder->turnOff(); } - public function testHandleRequestRecordsRequestWhenModeIsNewRecords() + public function testHandleRequestRecordsRequestWhenModeIsNewRecords(): void { $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); $response = new Response(200, [], 'example response'); @@ -59,7 +59,7 @@ public function setCassette(Cassette $cassette): void $this->assertEquals($response, $videorecorder->handleRequest($request)); } - public function testHandleRequestThrowsExceptionWhenModeIsNone() + public function testHandleRequestThrowsExceptionWhenModeIsNone(): void { $this->expectException( 'LogicException', @@ -86,7 +86,7 @@ public function setCassette(Cassette $cassette): void $videorecorder->handleRequest($request); } - public function testHandleRequestRecordsRequestWhenModeIsOnceAndCassetteIsNew() + public function testHandleRequestRecordsRequestWhenModeIsOnceAndCassetteIsNew(): void { $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); $response = new Response(200, [], 'example response'); @@ -107,7 +107,7 @@ public function setCassette(Cassette $cassette): void $this->assertEquals($response, $videorecorder->handleRequest($request)); } - public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld() + public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld(): void { $this->expectException( 'LogicException', diff --git a/tests/integration/apache/test/OpcacheTest.php b/tests/integration/apache/test/OpcacheTest.php index 46ad594a1..58460ed47 100644 --- a/tests/integration/apache/test/OpcacheTest.php +++ b/tests/integration/apache/test/OpcacheTest.php @@ -11,7 +11,7 @@ class OpcacheTest extends TestCase { - public function testOpcache() + public function testOpcache(): void { // Step 0: cleanup if (file_exists(__DIR__.'/../www/vcr.yaml')) { diff --git a/tests/integration/guzzle/6/test/AsyncTest.php b/tests/integration/guzzle/6/test/AsyncTest.php index 9375be945..c27e2207f 100644 --- a/tests/integration/guzzle/6/test/AsyncTest.php +++ b/tests/integration/guzzle/6/test/AsyncTest.php @@ -11,8 +11,8 @@ */ class AsyncTest extends TestCase { - const TEST_GET_URL = 'https://api.chew.pro/trbmb'; - const TEST_GET_URL_2 = 'https://api.chew.pro/trbmb?foo=42'; + public const TEST_GET_URL = 'https://api.chew.pro/trbmb'; + public const TEST_GET_URL_2 = 'https://api.chew.pro/trbmb?foo=42'; protected function setUp(): void { @@ -20,7 +20,7 @@ protected function setUp(): void \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); } - public function testAsyncLock() + public function testAsyncLock(): void { \VCR\VCR::turnOn(); \VCR\VCR::insertCassette('test-cassette.yml'); @@ -38,7 +38,7 @@ public function testAsyncLock() \VCR\VCR::turnOff(); } - protected function assertValidGETResponse($info) + protected function assertValidGETResponse($info): void { $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('0', $info, 'API did not return any value.'); diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/integration/guzzle/6/test/ErrorTest.php index c24268cda..ca9f0bcf4 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/integration/guzzle/6/test/ErrorTest.php @@ -12,7 +12,7 @@ */ class ErrorTest extends TestCase { - const TEST_GET_URL = 'http://localhost:9959'; + public const TEST_GET_URL = 'http://localhost:9959'; protected function setUp(): void { @@ -20,7 +20,7 @@ protected function setUp(): void \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); } - public function testConnectException() + public function testConnectException(): void { $nonInstrumentedException = null; try { @@ -44,7 +44,7 @@ public function testConnectException() \VCR\VCR::turnOff(); } - protected function assertValidGETResponse($info) + protected function assertValidGETResponse($info): void { } } diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index 050262ef4..e97e625fd 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -10,9 +10,9 @@ */ class ExampleHttpClientTest extends TestCase { - const TEST_GET_URL = 'https://api.chew.pro/trbmb'; - const TEST_POST_URL = 'https://httpbin.org/post'; - const TEST_POST_BODY = '{"foo":"bar"}'; + public const TEST_GET_URL = 'https://api.chew.pro/trbmb'; + public const TEST_POST_URL = 'https://httpbin.org/post'; + public const TEST_POST_BODY = '{"foo":"bar"}'; protected $ignoreHeaders = [ 'Accept', @@ -27,7 +27,7 @@ protected function setUp(): void \VCR\VCR::configure()->setCassettePath(vfsStream::url('testDir')); } - public function testRequestGET() + public function testRequestGET(): void { \VCR\VCR::turnOn(); \VCR\VCR::insertCassette('test-cassette.yml'); @@ -41,7 +41,7 @@ public function testRequestGET() \VCR\VCR::turnOff(); } - public function testRequestPOST() + public function testRequestPOST(): void { \VCR\VCR::turnOn(); \VCR\VCR::insertCassette('test-cassette.yml'); @@ -87,13 +87,13 @@ protected function requestPOSTIntercepted() return $info; } - protected function assertValidGETResponse($info) + protected function assertValidGETResponse($info): void { $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('0', $info, 'API did not return any value.'); } - protected function assertValidPOSTResponse($info) + protected function assertValidPOSTResponse($info): void { $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('url', $info, "Key 'url' not found."); diff --git a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php index cd786a4f8..1e9f28801 100644 --- a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php +++ b/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php @@ -9,7 +9,7 @@ */ class ExampleSoapClient { - const EXAMPLE_WSDL = 'http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL'; + public const EXAMPLE_WSDL = 'http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL'; public function call($number = 12) { @@ -19,7 +19,7 @@ public function call($number = 12) return trim((string) $response->NumberToWordsResult); } - public function callBadUrl() + public function callBadUrl(): void { // The port is not open. This leads to an error $client = new \SoapClient('http://localhost:9945', ['soap_version' => \SOAP_1_2]); diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php index a13339267..3668cbb61 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php @@ -24,21 +24,21 @@ protected function setUp(): void $this->assertTrue(true); } - public function testCallDirectly() + public function testCallDirectly(): void { $actual = $this->callSoap(); $this->assertIsString($actual); $this->assertEquals('twelve', $actual); } - public function testCallIntercepted() + public function testCallIntercepted(): void { $actual = $this->callSoapIntercepted(); $this->assertIsString($actual); $this->assertEquals('twelve', $actual); } - public function testCallDirectlyEqualsIntercepted() + public function testCallDirectlyEqualsIntercepted(): void { $this->assertEquals($this->callSoap(), $this->callSoapIntercepted()); } @@ -47,7 +47,7 @@ public function testCallDirectlyEqualsIntercepted() * This test performs a SOAP request on a buggy WSDL. * It checks that the non instrumented code and the instrumented code return the same exception. */ - public function testCallSoapWithError() + public function testCallSoapWithError(): void { $nonInstrumentedException = null; try { From d72761ed80ee7b5218454e0027286ebfc40158c9 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 10:56:17 +0100 Subject: [PATCH 107/204] Added .editorconfig --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..dd7983d3d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml,neon}] +indent_size = 2 From 3eeecb097e21ced7d163e73c9abe3dfcd3dc313a Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 10:56:29 +0100 Subject: [PATCH 108/204] Level 0 --- tests/VCR/Storage/YamlTest.php | 6 ++++++ tests/VCR/Util/CurlHelperTest.php | 3 +++ tests/VCR/VCRTest.php | 3 +++ 3 files changed, 12 insertions(+) diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index 6b51cc154..8a490c79a 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -10,6 +10,12 @@ */ class YamlTest extends TestCase { + /** @var string */ + private $filePath; + + /** @var Yaml */ + private $yamlObject; + protected function setUp(): void { vfsStream::setup('test'); diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 4d1ecbd54..093ef6545 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -10,6 +10,9 @@ class CurlHelperTest extends TestCase { + /** @var string[] */ + private $headersFound; + /** * @dataProvider getHttpMethodsProvider() */ diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 9bcfd7c29..90ed0e111 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -11,6 +11,9 @@ */ class VCRTest extends TestCase { + /** @var array */ + private $events; + public static function setupBeforeClass(): void { VCR::configure()->setCassettePath('tests/fixtures'); From a02bb575a772413feae31a9a7ba3c627ca43eeab Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 11:12:29 +0100 Subject: [PATCH 109/204] Level 1 --- src/VCR/VCR.php | 3 ++- tests/VCR/ConfigurationTest.php | 19 ++++++++++++------- tests/VCR/RequestTest.php | 6 ++---- tests/VCR/Storage/AbstractStorageTest.php | 3 ++- tests/VCR/Util/CurlHelperTest.php | 6 ++++-- tests/VCR/VCRTest.php | 10 ++++------ tests/VCR/VideorecorderTest.php | 8 ++++---- 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index ab313a6bd..70e2db77b 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -12,6 +12,7 @@ * @method static void turnOn() * @method static void turnOff() * @method static void eject() + * @mixin Videorecorder */ class VCR { @@ -37,7 +38,7 @@ class VCR */ public static function __callStatic(string $method, array $parameters) { - $callable = [VCRFactory::get('VCR\Videorecorder'), $method]; + $callable = [VCRFactory::get(Videorecorder::class), $method]; Assertion::isCallable($callable); diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index 63051b653..714b42309 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -18,8 +18,8 @@ protected function setUp(): void public function testSetCassettePathThrowsErrorOnInvalidPath(): void { - $this->expectException( - VCRException::class, + $this->expectException(VCRException::class); + $this->expectExceptionMessage( "Cassette path 'invalid_path' is not a directory. Please either " .'create it or set a different cassette path using ' ."\\VCR\\VCR::configure()->setCassettePath('directory')." @@ -63,7 +63,8 @@ public function testEnableSingleLibraryHook(): void public function testEnableLibraryHooksFailsWithWrongHookName(): void { - $this->expectException('InvalidArgumentException', "Library hooks don't exist: non_existing"); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("Library hooks don't exist: non_existing"); $this->config->enableLibraryHooks(['non_existing']); } @@ -81,13 +82,15 @@ public function testEnableRequestMatchers(): void public function testEnableRequestMatchersFailsWithNoExistingName(): void { - $this->expectException('InvalidArgumentException', "Request matchers don't exist: wrong, name"); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("Request matchers don't exist: wrong, name"); $this->config->enableRequestMatchers(['wrong', 'name']); } public function testAddRequestMatcherFailsWithNoName(): void { - $this->expectException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''"); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage("A request matchers name must be at least one character long. Found ''"); $expected = function ($first, $second) { return true; }; @@ -122,7 +125,8 @@ public function availableStorageProvider() public function testSetStorageInvalidName(): void { - $this->expectException('VCR\VCRException', "Storage 'Does not exist' not available."); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage("Storage 'Does not exist' not available."); $this->config->setStorage('Does not exist'); } @@ -154,7 +158,8 @@ public function testBlacklist(): void public function testSetModeInvalidName(): void { - $this->expectException('VCR\VCRException', "Mode 'invalid' does not exist."); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage("Mode 'invalid' does not exist."); $this->config->setMode('invalid'); } } diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 0895b8625..39c05e29c 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -62,10 +62,8 @@ public function testDoesntMatch(): void public function testMatchesThrowsExceptionIfMatcherNotFound(): void { $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $this->expectException( - '\BadFunctionCallException', - "Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n" - ); + $this->expectException(\BadFunctionCallException::class); + $this->expectExceptionMessage("Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n"); $this->request->matches($request, [['some', 'method']]); } diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index d1f1f189b..93c76e6b9 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -28,7 +28,8 @@ public function testFilePathCreated(): void public function testRootNotExisting(): void { - $this->expectException('\VCR\VCRException', "Cassette path 'vfs://test/foo' is not existing or not a directory"); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage("Cassette path 'vfs://test/foo' is not existing or not a directory"); vfsStream::setup('test'); new TestStorage(vfsStream::url('test/foo'), 'file'); diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index 093ef6545..b9f823762 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -165,13 +165,15 @@ public function testSetCurlOptionReadFunctionToNull(): void public function testInvalidHostException(): void { - $this->expectException(InvalidHostException::class, 'URL must be valid.'); + $this->expectException(InvalidHostException::class); + $this->expectExceptionMessage('Could not read host from URL "example.com". Please check the URL syntax.'); new Request('POST', 'example.com'); } public function testSetCurlOptionReadFunctionMissingSize(): void { - $this->expectException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage('To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $request = new Request('POST', 'http://example.com'); $callback = function ($curlHandle, $fileHandle, $size): void { diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 90ed0e111..92fe23e91 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -22,10 +22,8 @@ public static function setupBeforeClass(): void public function testUseStaticCallsNotInitialized(): void { VCR::configure()->enableLibraryHooks(['stream_wrapper']); - $this->expectException( - 'VCR\VCRException', - 'Please turn on VCR before inserting a cassette, use: VCR::turnOn()' - ); + $this->expectException(\VCR\VCRException::class); + $this->expectExceptionMessage('Please turn on VCR before inserting a cassette, use: VCR::turnOn()'); VCR::insertCassette('some_name'); } @@ -103,8 +101,8 @@ public function testShouldNotInterceptCallsToDevUrandom(): void public function testShouldThrowExceptionIfNoCassettePresent(): void { - $this->expectException( - 'BadMethodCallException', + $this->expectException(\BadMethodCallException::class); + $this->expectExceptionMessage( 'Invalid http request. No cassette inserted. Please make sure to insert ' ."a cassette in your unit test using VCR::insertCassette('name');" ); diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 020dcf401..2478bcdf6 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -61,8 +61,8 @@ public function setCassette(Cassette $cassette): void public function testHandleRequestThrowsExceptionWhenModeIsNone(): void { - $this->expectException( - 'LogicException', + $this->expectException(\LogicException::class); + $this->expectExceptionMessage( "The request does not match a previously recorded request and the 'mode' is set to 'none'. " ."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." ); @@ -109,8 +109,8 @@ public function setCassette(Cassette $cassette): void public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld(): void { - $this->expectException( - 'LogicException', + $this->expectException(\LogicException::class); + $this->expectExceptionMessage( "The request does not match a previously recorded request and the 'mode' is set to 'once'. " ."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'." ); From f26c8f426631a2a3ee6bd7aeab2851fdcb7ed9fd Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 11:22:55 +0100 Subject: [PATCH 110/204] Level 2 --- phpstan.neon | 2 ++ tests/VCR/LibraryHooks/SoapHookTest.php | 4 ++++ tests/VCR/Util/CurlHelperTest.php | 4 ++-- tests/VCR/Util/StreamHelperTest.php | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 33282c1c6..4d2b1b2a9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -18,6 +18,8 @@ parameters: - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' # PHPStan cannot deal with manually defined constants - can be removed once php 7.2 no longer supported - '#Constant CURLPROXY_HTTPS not found.#' + - '#Call to an undefined method (VCR\\Util\\|)SoapClient::GetCityWeatherByZIP\(\)\.#' + - '#Call to an undefined method org\\bovigo\\vfs\\vfsStreamContent::hasChild\(\)\.#' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index 57deb5a78..c86dc27e4 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -34,6 +34,7 @@ public function testShouldInterceptCallWhenEnabled(): void { $this->soapHook->enable($this->getContentCheckCallback()); + /** @var \VCR\Util\SoapClient $client */ $client = new \SoapClient(self::WSDL, ['soap_version' => \SOAP_1_2]); $client->setLibraryHook($this->soapHook); $actual = $client->GetCityWeatherByZIP(['ZIP' => '10013']); @@ -51,6 +52,7 @@ public function testShouldHandleSOAPVersion11(): void ]; $this->soapHook->enable($this->getHeadersCheckCallback($expectedHeaders)); + /** @var \VCR\Util\SoapClient $client */ $client = new \SoapClient( self::WSDL, ['soap_version' => \SOAP_1_1] @@ -67,6 +69,7 @@ public function testShouldHandleSOAPVersion12(): void $this->soapHook->enable($this->getHeadersCheckCallback($expectedHeaders)); + /** @var \VCR\Util\SoapClient $client */ $client = new \SoapClient( self::WSDL, ['soap_version' => \SOAP_1_2] @@ -79,6 +82,7 @@ public function testShouldReturnLastRequestWithTraceOn(): void { $this->soapHook->enable($this->getContentCheckCallback()); + /** @var \VCR\Util\SoapClient $client */ $client = new \SoapClient( self::WSDL, ['soap_version' => \SOAP_1_1, 'trace' => 1] diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index b9f823762..b349b75fc 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -213,7 +213,7 @@ public function testHandleResponseReturnsBody(): void $output = CurlHelper::handleOutput($response, $curlOptions, curl_init()); - $this->assertEquals($response->getBody(true), $output); + $this->assertEquals($response->getBody(), $output); } public function testHandleResponseEchosBody(): void @@ -224,7 +224,7 @@ public function testHandleResponseEchosBody(): void CurlHelper::handleOutput($response, [], curl_init()); $output = ob_get_clean(); - $this->assertEquals($response->getBody(true), $output); + $this->assertEquals($response->getBody(), $output); } public function testHandleResponseIncludesHeader(): void diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index eef1ab0f9..328f7524c 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -74,8 +74,8 @@ function (Request $request) use ($test): void { /** * @dataProvider streamContexts * - * @param $context - * @param $testCallback + * @param array $context + * @param callable $testCallback */ public function testStreamHttpContext($context, $testCallback): void { From b52942f9e8d80f8a71a1c088301248545d4a4825 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 11:25:34 +0100 Subject: [PATCH 111/204] Level 3 --- tests/VCR/Storage/AbstractStorageTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index 93c76e6b9..bce74acb7 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -45,11 +45,9 @@ public function storeRecording(array $recording): void $this->recording = $recording; } - public function next() + public function next(): void { [$this->position, $this->current] = each($this->recording); - - return $this->current; } public function valid() From 1af9cde074d0384e0a5b37b5af8e218024627d22 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 11:54:47 +0100 Subject: [PATCH 112/204] Level 5 --- src/VCR/Request.php | 2 +- src/VCR/Storage/Storage.php | 2 +- tests/VCR/CassetteTest.php | 8 +++--- tests/VCR/Event/AfterHttpRequestEventTest.php | 2 +- tests/VCR/Event/AfterPlaybackEventTest.php | 2 +- tests/VCR/Event/BeforeRecordEventTest.php | 2 +- tests/VCR/LibraryHooks/CurlHookTest.php | 16 +++++------ tests/VCR/LibraryHooks/SoapHookTest.php | 4 +-- .../LibraryHooks/StreamWrapperHookTest.php | 2 +- tests/VCR/ResponseTest.php | 16 +++++------ tests/VCR/Storage/JsonTest.php | 8 ++++-- tests/VCR/Util/CurlHelperTest.php | 28 +++++++++---------- tests/VCR/Util/StreamProcessorTest.php | 4 ++- tests/VCR/VideorecorderTest.php | 8 +++--- 14 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 3293776f3..05cf499cf 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -40,7 +40,7 @@ class Request protected $curlOptions = []; /** - * @param array $headers + * @param array $headers */ public function __construct(string $method, ?string $url, array $headers = []) { diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index 08334468c..596ba54c8 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -15,7 +15,7 @@ interface Storage extends \Iterator /** * Stores an array of data. * - * @param array> $recording array to store in storage + * @param array> $recording array to store in storage */ public function storeRecording(array $recording): void; diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index 00b0de0eb..fa6b47779 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -29,8 +29,8 @@ public function testGetName(): void public function testDontOverwriteRecord(): void { $request = new Request('GET', 'https://example.com'); - $response1 = new Response(200, [], 'sometest'); - $response2 = new Response(200, [], 'sometest'); + $response1 = new Response('200', [], 'sometest'); + $response2 = new Response('200', [], 'sometest'); $this->cassette->record($request, $response1); $this->cassette->record($request, $response2); @@ -40,7 +40,7 @@ public function testDontOverwriteRecord(): void public function testPlaybackAlreadyRecordedRequest(): void { $request = new Request('GET', 'https://example.com'); - $response = new Response(200, [], 'sometest'); + $response = new Response('200', [], 'sometest'); $this->cassette->record($request, $response); $this->assertEquals($response->toArray(), $this->cassette->playback($request)->toArray()); @@ -56,7 +56,7 @@ public function testHasResponseNotFound(): void public function testHasResponseFound(): void { $request = new Request('GET', 'https://example.com'); - $response = new Response(200, [], 'sometest'); + $response = new Response('200', [], 'sometest'); $this->cassette->record($request, $response); $this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.'); diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/VCR/Event/AfterHttpRequestEventTest.php index 0c9ad0ed0..283ffea71 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/VCR/Event/AfterHttpRequestEventTest.php @@ -15,7 +15,7 @@ class AfterHttpRequestEventTest extends TestCase protected function setUp(): void { - $this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response(200)); + $this->event = new AfterHttpRequestEvent(new Request('GET', 'http://example.com'), new Response('200')); } public function testGetRequest(): void diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index ed72e787b..b365991e8 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -20,7 +20,7 @@ protected function setUp(): void { $this->event = new AfterPlaybackEvent( new Request('GET', 'http://example.com'), - new Response(200), + new Response('200'), new Cassette('test', new Configuration(), new Storage\Blackhole()) ); } diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index b6c332292..3259a8a85 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -20,7 +20,7 @@ protected function setUp(): void { $this->event = new BeforeRecordEvent( new Request('GET', 'http://example.com'), - new Response(200), + new Response('200'), new Cassette('test', new Configuration(), new Storage\Blackhole()) ); } diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 69b2ac1bc..12fed73d4 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -133,7 +133,7 @@ function (Request $request) use ($testClass) { 'Post query string was not parsed and set correctly.' ); - return new Response(200); + return new Response('200'); } ); @@ -155,7 +155,7 @@ function (Request $request) use ($testClass) { 'Post query string was not parsed and set correctly.' ); - return new Response(200); + return new Response('200'); } ); @@ -287,7 +287,7 @@ function (Request $request) use ($testClass, &$callCount) { ); ++$callCount; - return new Response(200); + return new Response('200'); } ); @@ -299,11 +299,11 @@ function (Request $request) use ($testClass, &$callCount) { curl_multi_add_handle($curlMultiHandle, $curlHandle2); $stillRunning = null; - $mh = curl_multi_exec($curlMultiHandle, $stillRunning); + curl_multi_exec($curlMultiHandle, $stillRunning); - $lastInfo = curl_multi_info_read($mh); - $secondLastInfo = curl_multi_info_read($mh); - $afterLastInfo = curl_multi_info_read($mh); + $lastInfo = curl_multi_info_read($curlMultiHandle); + $secondLastInfo = curl_multi_info_read($curlMultiHandle); + $afterLastInfo = curl_multi_info_read($curlMultiHandle); curl_multi_remove_handle($curlMultiHandle, $curlHandle1); curl_multi_remove_handle($curlMultiHandle, $curlHandle2); @@ -364,7 +364,7 @@ function (Request $request) use ($testClass) { '' ); - return new Response(200); + return new Response('200'); } ); diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index c86dc27e4..3b0233bb6 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -100,7 +100,7 @@ protected function getContentCheckCallback(): Closure $testClass = $this; return Closure::fromCallable(function () use ($testClass) { - return new Response(200, [], $testClass->expected); + return new Response('200', [], $testClass->expected); }); } @@ -113,7 +113,7 @@ protected function getHeadersCheckCallback(array $expectedHeaders): Closure $test->assertEquals($expectedHeader, $request->getHeader($expectedHeaderName)); } - return new Response(200, [], ''); + return new Response('200', [], ''); }); } } diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index 1a4fce082..737cc8fac 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -32,7 +32,7 @@ public function testSeek(): void { $hook = new StreamWrapperHook(); $hook->enable(function ($request) { - return new Response(200, [], 'A Test'); + return new Response('200', [], 'A Test'); }); $hook->stream_open('http://example.com', 'r', 0, $openedPath); diff --git a/tests/VCR/ResponseTest.php b/tests/VCR/ResponseTest.php index 8fe3394d1..102b6630b 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/VCR/ResponseTest.php @@ -35,7 +35,7 @@ public function testRestoreHeadersFromArray(): void 'Connection' => 'close', 'Date' => 'Fri, 31 Jan 2014 15:37:13 GMT', ]; - $response = new Response(200, $headers); + $response = new Response('200', $headers); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($headers, $restoredResponse->getHeaders()); @@ -59,7 +59,7 @@ public function testGetBodyNoneDefined(): void public function testRestoreBodyFromArray(): void { $body = 'this is an example body'; - $response = new Response(200, [], $body); + $response = new Response('200', [], $body); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($body, $restoredResponse->getBody()); @@ -68,7 +68,7 @@ public function testRestoreBodyFromArray(): void public function testBase64EncodeCompressedBody(): void { $body = 'this is an example body'; - $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); + $response = new Response('200', ['Content-Type' => 'application/x-gzip'], $body); $responseArray = $response->toArray(); $this->assertEquals(base64_encode($body), $responseArray['body']); @@ -89,7 +89,7 @@ public function testBase64DecodeCompressedBody(): void public function testRestoreCompressedBody(): void { $body = 'this is an example body'; - $response = new Response(200, ['Content-Type' => 'application/x-gzip'], $body); + $response = new Response('200', ['Content-Type' => 'application/x-gzip'], $body); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($body, $restoredResponse->getBody()); @@ -97,7 +97,7 @@ public function testRestoreCompressedBody(): void public function testGetStatus(): void { - $expectedStatus = 200; + $expectedStatus = '200'; $response = new Response($expectedStatus); @@ -106,7 +106,7 @@ public function testGetStatus(): void public function testRestoreStatusFromArray(): void { - $expectedStatus = 200; + $expectedStatus = '200'; $response = new Response($expectedStatus); $restoredResponse = Response::fromArray($response->toArray()); @@ -117,7 +117,7 @@ public function testRestoreStatusFromArray(): void public function testGetCurlInfo(): void { $curlOptions = ['option' => 'value']; - $response = new Response(200, [], null, $curlOptions); + $response = new Response('200', [], null, $curlOptions); $this->assertEquals($curlOptions, $response->getCurlInfo()); } @@ -125,7 +125,7 @@ public function testGetCurlInfo(): void public function testRestoreCurlInfoFromArray(): void { $expectedCurlOptions = ['option' => 'value']; - $response = new Response(200, [], null, $expectedCurlOptions); + $response = new Response('200', [], null, $expectedCurlOptions); $restoredResponse = Response::fromArray($response->toArray()); $this->assertEquals($expectedCurlOptions, $response->getCurlInfo()); diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index d0ab315a5..4e50896ec 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -80,8 +80,12 @@ public function testIterateEmpty(): void public function testStoreRecording(): void { $expected = [ - 'request' => 'some request', - 'response' => 'some response', + 'request' => [ + 'some' => 'request', + ], + 'response' => [ + 'some' => 'response', + ], ]; $this->jsonObject->storeRecording($expected); diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index b349b75fc..d50e14816 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -209,7 +209,7 @@ public function testHandleResponseReturnsBody(): void $curlOptions = [ \CURLOPT_RETURNTRANSFER => true, ]; - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); $output = CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -218,7 +218,7 @@ public function testHandleResponseReturnsBody(): void public function testHandleResponseEchosBody(): void { - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); ob_start(); CurlHelper::handleOutput($response, [], curl_init()); @@ -234,7 +234,7 @@ public function testHandleResponseIncludesHeader(): void \CURLOPT_RETURNTRANSFER => true, ]; $status = [ - 'code' => 200, + 'code' => '200', 'message' => 'OK', 'http_version' => '1.1', ]; @@ -254,12 +254,12 @@ public function testHandleOutputHeaderFunction(): void }, ]; $status = [ - 'code' => 200, + 'code' => '200', 'message' => 'OK', 'http_version' => '1.1', ]; $headers = [ - 'Content-Length' => 0, + 'Content-Length' => '0', ]; $response = new Response($status, $headers, 'example response'); CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -279,12 +279,12 @@ public function testHandleOutputHeaderFunctionWithPublicFunction(): void \CURLOPT_HEADERFUNCTION => [$this, 'publicCurlHeaderFunction'], ]; $status = [ - 'code' => 200, + 'code' => '200', 'message' => 'OK', 'http_version' => '1.1', ]; $headers = [ - 'Content-Length' => 0, + 'Content-Length' => '0', ]; $response = new Response($status, $headers, 'example response'); CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -304,12 +304,12 @@ public function testHandleOutputHeaderFunctionWithProtectedFunction(): void \CURLOPT_HEADERFUNCTION => [$this, 'protectedCurlHeaderFunction'], ]; $status = [ - 'code' => 200, + 'code' => '200', 'message' => 'OK', 'http_version' => '1.1', ]; $headers = [ - 'Content-Length' => 0, + 'Content-Length' => '0', ]; $response = new Response($status, $headers, 'example response'); CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -329,12 +329,12 @@ public function testHandleOutputHeaderFunctionWithPrivateFunction(): void \CURLOPT_HEADERFUNCTION => [$this, 'privateCurlHeaderFunction'], ]; $status = [ - 'code' => 200, + 'code' => '200', 'message' => 'OK', 'http_version' => '1.1', ]; $headers = [ - 'Content-Length' => 0, + 'Content-Length' => '0', ]; $response = new Response($status, $headers, 'example response'); CurlHelper::handleOutput($response, $curlOptions, curl_init()); @@ -360,7 +360,7 @@ public function testHandleResponseUsesWriteFunction(): void return \strlen($body); }, ]; - $response = new Response(200, [], $expectedBody); + $response = new Response('200', [], $expectedBody); CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } @@ -373,7 +373,7 @@ public function testHandleResponseUsesWriteFunctionWithPrivateFunction(): void $curlOptions = [ \CURLOPT_WRITEFUNCTION => [$this, 'privateCurlWriteFunction'], ]; - $response = new Response(200, [], $expectedBody); + $response = new Response('200', [], $expectedBody); CurlHelper::handleOutput($response, $curlOptions, $expectedCh); } @@ -388,7 +388,7 @@ public function testHandleResponseWritesFile(): void \CURLOPT_FILE => fopen($testFile, 'w+'), ]; - $response = new Response(200, [], $expectedBody); + $response = new Response('200', [], $expectedBody); CurlHelper::handleOutput($response, $curlOptions, curl_init()); diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index 10157373b..371d947c0 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -131,8 +131,10 @@ public function testDirOpendir(): void public function testDirOpendirNotFound(): void { $test = $this; - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): void { + set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): bool { $test->assertStringContainsString('opendir(not_found', $errstr); + + return true; }); $processor = new StreamProcessor(); diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 2478bcdf6..3173e5a45 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -41,7 +41,7 @@ public function testInsertCassetteEjectExisting(): void public function testHandleRequestRecordsRequestWhenModeIsNewRecords(): void { $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); $client = $this->getClientMock($request, $response); $configuration = new Configuration(); $configuration->enableLibraryHooks([]); @@ -68,7 +68,7 @@ public function testHandleRequestThrowsExceptionWhenModeIsNone(): void ); $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); $client = $this->getMockBuilder('\VCR\Util\HttpClient')->getMock(); $configuration = new Configuration(); $configuration->enableLibraryHooks([]); @@ -89,7 +89,7 @@ public function setCassette(Cassette $cassette): void public function testHandleRequestRecordsRequestWhenModeIsOnceAndCassetteIsNew(): void { $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); $client = $this->getClientMock($request, $response); $configuration = new Configuration(); $configuration->enableLibraryHooks([]); @@ -116,7 +116,7 @@ public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld() ); $request = new Request('GET', 'http://example.com', ['User-Agent' => 'Unit-Test']); - $response = new Response(200, [], 'example response'); + $response = new Response('200', [], 'example response'); $client = $this->getMockBuilder('\VCR\Util\HttpClient')->getMock(); $configuration = new Configuration(); $configuration->enableLibraryHooks([]); From 1108d2d5436dbf309adb12e5cea476abc43dccce Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 13:47:57 +0100 Subject: [PATCH 113/204] Level 6 --- src/VCR/Storage/Blackhole.php | 4 +- .../AbstractCodeTransformTest.php | 8 +++- .../CodeTransform/CurlCodeTransformTest.php | 5 ++- .../CodeTransform/SoapCodeTransformTest.php | 5 ++- tests/VCR/ConfigurationTest.php | 5 ++- tests/VCR/LibraryHooks/CurlHookTest.php | 5 ++- tests/VCR/LibraryHooks/SoapHookTest.php | 3 ++ tests/VCR/Storage/AbstractStorageTest.php | 4 +- tests/VCR/Storage/BlackholeTest.php | 18 +++++++- tests/VCR/Storage/JsonTest.php | 7 ++- tests/VCR/Storage/YamlTest.php | 3 +- tests/VCR/Util/CurlHelperTest.php | 43 +++++++++++++------ tests/VCR/Util/SoapClientTest.php | 6 ++- tests/VCR/Util/StreamHelperTest.php | 9 ++-- tests/VCR/Util/StreamProcessorTest.php | 22 +++++----- tests/VCR/Util/TextUtilTest.php | 5 ++- tests/VCR/VCRFactoryTest.php | 8 ++-- tests/VCR/VCRTest.php | 7 +-- tests/VCR/VideorecorderTest.php | 9 ++-- 19 files changed, 117 insertions(+), 59 deletions(-) diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index 612502246..12503e47d 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -33,8 +33,10 @@ public function key(): int throw new \BadMethodCallException('Not implemented'); } - public function next(): void + /** @return array|null */ + public function next(): ?array { + return null; } public function rewind(): void diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 0bfafa0b2..c3f2e9543 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -2,10 +2,16 @@ namespace VCR\CodeTransform; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class AbstractCodeTransformTest extends TestCase { + /** + * @param string[] $methods + * + * @return AbstractCodeTransform|MockObject + */ protected function getFilter(array $methods = []) { $defaults = array_merge( @@ -13,7 +19,7 @@ protected function getFilter(array $methods = []) $methods ); - $filter = $this->getMockBuilder('\VCR\CodeTransform\AbstractCodeTransform') + $filter = $this->getMockBuilder(AbstractCodeTransform::class) ->setMethods($defaults) ->getMockForAbstractClass(); diff --git a/tests/VCR/CodeTransform/CurlCodeTransformTest.php b/tests/VCR/CodeTransform/CurlCodeTransformTest.php index aed07095d..672d8a85d 100644 --- a/tests/VCR/CodeTransform/CurlCodeTransformTest.php +++ b/tests/VCR/CodeTransform/CurlCodeTransformTest.php @@ -9,7 +9,7 @@ class CurlCodeTransformTest extends TestCase /** * @dataProvider codeSnippetProvider */ - public function testTransformCode($expected, $code): void + public function testTransformCode(string $expected, string $code): void { $codeTransform = new class() extends CurlCodeTransform { // A proxy to access the protected transformCode method. @@ -22,7 +22,8 @@ public function publicTransformCode(string $code): string $this->assertEquals($expected, $codeTransform->publicTransformCode($code)); } - public function codeSnippetProvider() + /** @return array */ + public function codeSnippetProvider(): array { return [ ['\VCR\LibraryHooks\CurlHook::curl_init(', 'CURL_INIT ('], diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/VCR/CodeTransform/SoapCodeTransformTest.php index 240be2641..9b0df08a5 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/VCR/CodeTransform/SoapCodeTransformTest.php @@ -9,7 +9,7 @@ class SoapCodeTransformTest extends TestCase /** * @dataProvider codeSnippetProvider */ - public function testTransformCode($expected, $code): void + public function testTransformCode(string $expected, string $code): void { $codeTransform = new class() extends SoapCodeTransform { // A proxy to access the protected transformCode method. @@ -22,7 +22,8 @@ public function publicTransformCode(string $code): string $this->assertEquals($expected, $codeTransform->publicTransformCode($code)); } - public function codeSnippetProvider() + /** @return array */ + public function codeSnippetProvider(): array { return [ ['new \VCR\Util\SoapClient(', 'new \SoapClient('], diff --git a/tests/VCR/ConfigurationTest.php b/tests/VCR/ConfigurationTest.php index 714b42309..e9a3ff45d 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/VCR/ConfigurationTest.php @@ -109,13 +109,14 @@ public function testAddRequestMatchers(): void /** * @dataProvider availableStorageProvider */ - public function testSetStorage($name, $className): void + public function testSetStorage(string $name, string $className): void { $this->config->setStorage($name); $this->assertEquals($className, $this->config->getStorage(), "$name should be class $className."); } - public function availableStorageProvider() + /** @return array */ + public function availableStorageProvider(): array { return [ ['json', 'VCR\Storage\Json'], diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 12fed73d4..0822e80af 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -15,11 +15,14 @@ */ class CurlHookTest extends TestCase { + /** @var string */ public $expected = 'example response body'; + /** * @var \VCR\Configuration */ protected $config; + /** * @var \VCR\LibraryHooks\CurlHook */ @@ -376,7 +379,7 @@ function (Request $request) use ($testClass) { $this->curlHook->disable(); } - protected function getTestCallback($statusCode = 200): Closure + protected function getTestCallback(string $statusCode = '200'): Closure { $testClass = $this; diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index 3b0233bb6..c2b8036ba 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -17,8 +17,10 @@ class SoapHookTest extends TestCase { public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; + /** @var string */ public $expected = 'true'; + /** @var Configuration */ protected $config; /** @var SoapHook */ @@ -104,6 +106,7 @@ protected function getContentCheckCallback(): Closure }); } + /** @param array $expectedHeaders */ protected function getHeadersCheckCallback(array $expectedHeaders): Closure { $test = $this; diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index bce74acb7..cbf6d5c14 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -10,8 +10,7 @@ */ class AbstractStorageTest extends TestCase { - protected $handle; - protected $filePath; + /** @var TestStorage */ protected $storage; public function testFilePathCreated(): void @@ -38,6 +37,7 @@ public function testRootNotExisting(): void class TestStorage extends AbstractStorage { + /** @var array */ private $recording; public function storeRecording(array $recording): void diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/VCR/Storage/BlackholeTest.php index 0fec7ba16..b9f40a151 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/VCR/Storage/BlackholeTest.php @@ -6,6 +6,7 @@ class BlackholeTest extends TestCase { + /** @var Blackhole */ protected $storage; protected function setUp(): void @@ -13,9 +14,19 @@ protected function setUp(): void $this->storage = new Blackhole(); } + /** + * @doesNotPerformAssertions + */ public function testStoreRecordingIsCallable(): void { - $this->assertNull($this->storage->storeRecording(['empty or not, we don\'t care'])); + $this->storage->storeRecording([ + 'request' => [ + 'some' => 'request', + ], + 'response' => [ + 'some' => 'response', + ], + ]); } public function testNextIsCallable(): void @@ -23,9 +34,12 @@ public function testNextIsCallable(): void $this->assertNull($this->storage->next()); } + /** + * @doesNotPerformAssertions + */ public function testRewindIsCallable(): void { - $this->assertNull($this->storage->rewind()); + $this->storage->rewind(); } public function testKeyIsNotCallable(): void diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index 4e50896ec..d356a9d29 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -10,8 +10,10 @@ */ class JsonTest extends TestCase { - protected $handle; + /** @var string */ protected $filePath; + + /** @var Json */ protected $jsonObject; protected function setUp(): void @@ -125,7 +127,8 @@ public function testStoreRecordingWhenBlankFileAlreadyExists(): void $this->assertJson(file_get_contents($filePath)); } - private function iterateAndTest($json, $expected, $message): void + /** @param array $expected */ + private function iterateAndTest(string $json, $expected, string $message): void { file_put_contents($this->filePath, $json); diff --git a/tests/VCR/Storage/YamlTest.php b/tests/VCR/Storage/YamlTest.php index 8a490c79a..c1b73c0cc 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/VCR/Storage/YamlTest.php @@ -127,7 +127,8 @@ public function testStoreTwoRecording(): void $this->assertEquals($expected, $actual[1], 'Storing and reading second recording failed.'); } - private function iterateAndTest($yaml, $expected, $message): void + /** @param array $expected */ + private function iterateAndTest(string $yaml, array $expected, string $message): void { file_put_contents($this->filePath, $yaml); diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index d50e14816..a8d5a33cf 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -16,7 +16,7 @@ class CurlHelperTest extends TestCase /** * @dataProvider getHttpMethodsProvider() */ - public function testSetCurlOptionMethods($method): void + public function testSetCurlOptionMethods(string $method): void { $request = new Request($method, 'http://example.com'); $headers = ['Host: example.com']; @@ -27,11 +27,9 @@ public function testSetCurlOptionMethods($method): void } /** - * Returns a list of HTTP methods for testing testSetCurlOptionMethods. - * - * @return array HTTP methods + * @return array */ - public function getHttpMethodsProvider() + public function getHttpMethodsProvider(): array { return [ ['CONNECT'], @@ -409,7 +407,8 @@ public function testGetCurlOptionFromResponse(Response $response, $curlOption, $ ); } - public function getCurlOptionProvider() + /** @return array */ + public function getCurlOptionProvider(): array { return [ [ @@ -535,26 +534,42 @@ public function testCurlCustomRequestAlwaysOverridesMethod(): void $this->assertEquals('DELETE', $request->getMethod()); } - // Function used for testing CURLOPT_HEADERFUNCTION - public function publicCurlHeaderFunction($ch, $header): void + /** + * Function used for testing CURLOPT_HEADERFUNCTION. + * + * @param resource $ch + */ + public function publicCurlHeaderFunction($ch, string $header): void { $this->headersFound[] = $header; } - // Function used for testing CURLOPT_HEADERFUNCTION - protected function protectedCurlHeaderFunction($ch, $header): void + /** + * Function used for testing CURLOPT_HEADERFUNCTION. + * + * @param resource $ch + */ + protected function protectedCurlHeaderFunction($ch, string $header): void { $this->headersFound[] = $header; } - // Function used for testing CURLOPT_HEADERFUNCTION - private function privateCurlHeaderFunction($ch, $header): void + /** + * Function used for testing CURLOPT_HEADERFUNCTION. + * + * @param resource $ch + */ + private function privateCurlHeaderFunction($ch, string $header): void { $this->headersFound[] = $header; } - // Function used for testing CURLOPT_WRITEFUNCTION - private function privateCurlWriteFunction($ch, $body) + /** + * Function used for testing CURLOPT_WRITEFUNCTION. + * + * @param resource $ch + */ + private function privateCurlWriteFunction($ch, string $body): int { $this->assertEquals('resource', \gettype($ch)); $this->assertEquals('example response', $body); diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index b442ee0d6..57f35e919 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -2,6 +2,7 @@ namespace VCR\Util; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use VCR\LibraryHooks\SoapHook; @@ -10,9 +11,10 @@ class SoapClientTest extends TestCase public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; public const ACTION = 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP'; - protected function getLibraryHookMock($enabled) + /** @return SoapHook|MockObject */ + protected function getLibraryHookMock(bool $enabled) { - $hookMock = $this->getMockBuilder('\VCR\LibraryHooks\SoapHook') + $hookMock = $this->getMockBuilder(SoapHook::class) ->disableOriginalConstructor() ->setMethods(['isEnabled', 'doRequest']) ->getMock(); diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index 328f7524c..a67d8ac4e 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -7,7 +7,8 @@ class StreamHelperTest extends TestCase { - public function streamContexts() + /** @return array */ + public function streamContexts(): array { $test = $this; @@ -74,10 +75,10 @@ function (Request $request) use ($test): void { /** * @dataProvider streamContexts * - * @param array $context - * @param callable $testCallback + * @param array $context + * @param callable $testCallback */ - public function testStreamHttpContext($context, $testCallback): void + public function testStreamHttpContext(array $context, $testCallback): void { $context = stream_context_create([ 'http' => $context, diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index 371d947c0..7303b0767 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -3,6 +3,7 @@ namespace VCR\Util; use PHPUnit\Framework\Error\Warning; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class StreamProcessorTest extends TestCase @@ -26,12 +27,8 @@ public function testFlockWithFilePutContents(): void /** * @dataProvider streamOpenAppendFilterProvider - * - * @param bool $expected - * @param bool $shouldProcess - * @param int $option */ - public function testStreamOpenShouldAppendFilters($expected, $option, $shouldProcess = null): void + public function testStreamOpenShouldAppendFilters(bool $expected, int $option, ?bool $shouldProcess = null): void { $mock = $this->getMockBuilder('VCR\Util\StreamProcessor') ->disableOriginalConstructor() @@ -52,7 +49,8 @@ public function testStreamOpenShouldAppendFilters($expected, $option, $shouldPro $mock->stream_close(); } - public function streamOpenAppendFilterProvider() + /** @return array> */ + public function streamOpenAppendFilterProvider(): array { return [ [true, StreamProcessor::STREAM_OPEN_FOR_INCLUDE, true], @@ -61,7 +59,8 @@ public function streamOpenAppendFilterProvider() ]; } - public function streamOpenFileModesWhichDoNotCreateFiles() + /** @return array */ + public function streamOpenFileModesWhichDoNotCreateFiles(): array { return [ ['r'], @@ -74,7 +73,7 @@ public function streamOpenFileModesWhichDoNotCreateFiles() /** * @dataProvider streamOpenFileModesWhichDoNotCreateFiles */ - public function testStreamOpenShouldNotFailOnNonExistingFile($fileMode): void + public function testStreamOpenShouldNotFailOnNonExistingFile(string $fileMode): void { $test = $this; set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($test): void { @@ -149,7 +148,7 @@ public function testMakeDir(): void $mock->expects($this->exactly(2))->method('restore'); $mock->expects($this->exactly(2))->method('intercept'); - $this->assertTrue($mock->mkdir('tests/fixtures/unittest_streamprocessor', 0777, false)); + $this->assertTrue($mock->mkdir('tests/fixtures/unittest_streamprocessor', 0777, 0)); $this->assertTrue($mock->rmdir('tests/fixtures/unittest_streamprocessor')); } @@ -159,7 +158,7 @@ public function testRename(): void $mock->expects($this->exactly(3))->method('restore'); $mock->expects($this->exactly(3))->method('intercept'); - $this->assertTrue($mock->mkdir('tests/fixtures/unittest_streamprocessor', 0777, false)); + $this->assertTrue($mock->mkdir('tests/fixtures/unittest_streamprocessor', 0777, 0)); $this->assertTrue($mock->rename('tests/fixtures/unittest_streamprocessor', 'tests/fixtures/sp')); $this->assertTrue($mock->rmdir('tests/fixtures/sp')); } @@ -193,9 +192,10 @@ public function testStreamMetadata(): void $this->assertTrue($mock->unlink($path)); } + /** @return StreamProcessor|MockObject */ protected function getStreamProcessorMock() { - return $this->getMockBuilder('VCR\Util\StreamProcessor') + return $this->getMockBuilder(StreamProcessor::class) ->disableOriginalConstructor() ->setMethods(['intercept', 'restore']) ->getMock(); diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/VCR/Util/TextUtilTest.php index e8f91d1cb..9283d0a71 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/VCR/Util/TextUtilTest.php @@ -12,12 +12,13 @@ class TextUtilTest extends TestCase /** * @dataProvider curlMethodsProvider */ - public function testUnderscoreToLowerCamelcase($expected, $method): void + public function testUnderscoreToLowerCamelcase(string $expected, string $method): void { $this->assertEquals($expected, TextUtil::underscoreToLowerCamelcase($method)); } - public function curlMethodsProvider() + /** @return array */ + public function curlMethodsProvider(): array { return [ 'curl_multi_add_handler' => ['curlMultiAddHandler', 'curl_multi_add_handler'], diff --git a/tests/VCR/VCRFactoryTest.php b/tests/VCR/VCRFactoryTest.php index 707526a83..4b07b9160 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/VCR/VCRFactoryTest.php @@ -14,12 +14,13 @@ class VCRFactoryTest extends TestCase * @dataProvider instanceProvider * @covers \VCR\VCRFactory::createVCRVideorecorder() */ - public function testCreateInstances($instance): void + public function testCreateInstances(string $instance): void { $this->assertInstanceOf($instance, VCRFactory::get($instance)); } - public function instanceProvider() + /** @return array */ + public function instanceProvider(): array { return [ ['VCR\Videorecorder'], @@ -37,7 +38,7 @@ public function instanceProvider() /** * @dataProvider storageProvider */ - public function testCreateStorage($storage, $className): void + public function testCreateStorage(string $storage, string $className): void { vfsStream::setup('test'); @@ -49,6 +50,7 @@ public function testCreateStorage($storage, $className): void $this->assertInstanceOf($className, $instance); } + /** @return array */ public function storageProvider() { return [ diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 92fe23e91..9210f5a21 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -51,7 +51,7 @@ public function testShouldInterceptCurlLibrary(): void VCR::turnOff(); } - private function doCurlGetRequest($url) + private function doCurlGetRequest(string $url): string { $ch = curl_init(); curl_setopt($ch, \CURLOPT_URL, $url); @@ -216,12 +216,13 @@ private function recordAllEvents(): void } } - public function recordEvent(Event $event, $eventName): void + public function recordEvent(Event $event, string $eventName): void { $this->events[$eventName] = $event; } - private function getRecordedEventNames() + /** @return string[] */ + private function getRecordedEventNames(): array { return array_keys($this->events); } diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 3173e5a45..926d4789f 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -4,6 +4,7 @@ use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Util\HttpClient; /** * Test Videorecorder. @@ -134,9 +135,9 @@ public function setCassette(Cassette $cassette): void $videorecorder->handleRequest($request); } - protected function getClientMock($request, $response) + protected function getClientMock(Request $request, Response $response): HttpClient { - $client = $this->getMockBuilder('\VCR\Util\HttpClient')->setMethods(['send'])->getMock(); + $client = $this->getMockBuilder(HttpClient::class)->setMethods(['send'])->getMock(); $client ->expects($this->once()) ->method('send') @@ -146,9 +147,9 @@ protected function getClientMock($request, $response) return $client; } - protected function getCassetteMock($request, $response, $mode = VCR::MODE_NEW_EPISODES, $isNew = false) + protected function getCassetteMock(Request $request, Response $response, string $mode = VCR::MODE_NEW_EPISODES, bool $isNew = false): Cassette { - $cassette = $this->getMockBuilder('\VCR\Cassette') + $cassette = $this->getMockBuilder(Cassette::class) ->disableOriginalConstructor() ->setMethods(['record', 'playback', 'isNew', 'getName']) ->getMock(); From 413efe64c51a6cb2694e12e96b48feea5283ac55 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 14 Mar 2021 14:03:01 +0100 Subject: [PATCH 114/204] Level 7 --- phpstan.neon | 1 + .../AbstractCodeTransformTest.php | 2 +- tests/VCR/LibraryHooks/CurlHookTest.php | 21 +++++++++++++++++++ tests/VCR/RequestTest.php | 1 + tests/VCR/Storage/JsonTest.php | 4 ++-- tests/VCR/Util/SoapClientTest.php | 2 +- tests/VCR/Util/StreamProcessorTest.php | 2 +- tests/VCR/VCRFactoryTest.php | 4 ++++ tests/VCR/VCRTest.php | 3 +++ 9 files changed, 35 insertions(+), 5 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 4d2b1b2a9..47cd4678a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ parameters: level: 7 paths: - src + - tests/VCR # Can remove reportUnmatchedIgnoredErrors option after php 7.2 is no longer supported reportUnmatchedIgnoredErrors: false ignoreErrors: diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index c3f2e9543..379dfa521 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -10,7 +10,7 @@ class AbstractCodeTransformTest extends TestCase /** * @param string[] $methods * - * @return AbstractCodeTransform|MockObject + * @return AbstractCodeTransform&MockObject */ protected function getFilter(array $methods = []) { diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 0822e80af..d6903647a 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -2,6 +2,7 @@ namespace VCR\LibraryHooks; +use Assert\Assertion; use Closure; use PHPUnit\Framework\TestCase; use VCR\CodeTransform\CurlCodeTransform; @@ -50,6 +51,7 @@ public function testShouldInterceptCallWhenEnabled(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $actual = curl_exec($curlHandle); curl_close($curlHandle); @@ -64,8 +66,10 @@ public function testShouldInterceptCallWhenEnabled(): void public function testShouldNotInterceptCallWhenNotEnabled(): void { $curlHandle = curl_init('http://example.com/'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curlHandle); + Assertion::string($response); curl_close($curlHandle); $this->assertStringContainsString('Example Domain', $response, 'Response from http://example.com should contain "Example Domain".'); @@ -85,6 +89,7 @@ function () use (&$intercepted): void { $this->curlHook->disable(); $curlHandle = curl_init(); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_URL, 'http://example.com/'); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); @@ -97,7 +102,9 @@ public function testShouldWriteFileOnFileDownload(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('https://example.com/'); + Assertion::isResource($curlHandle); $filePointer = fopen('php://temp/test_file', 'w'); + Assertion::isResource($filePointer); curl_setopt($curlHandle, \CURLOPT_FILE, $filePointer); curl_exec($curlHandle); curl_close($curlHandle); @@ -114,6 +121,7 @@ public function testShouldEchoResponseIfReturnTransferFalse(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, false); ob_start(); curl_exec($curlHandle); @@ -141,6 +149,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, ['para1' => 'val1', 'para2' => 'val2']); curl_exec($curlHandle); curl_close($curlHandle); @@ -163,6 +172,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt_array( $curlHandle, [ @@ -179,6 +189,7 @@ public function testShouldReturnCurlInfoStatusCode(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); @@ -199,6 +210,7 @@ public function testShouldReturnCurlInfoStatusCodeAsInteger(): void $this->curlHook->enable($this->getTestCallback($stringStatusCode)); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); @@ -214,6 +226,7 @@ public function testShouldReturnCurlInfoAll(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); @@ -229,6 +242,7 @@ public function testShouldReturnCurlInfoAllKeys(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); @@ -297,7 +311,11 @@ function (Request $request) use ($testClass, &$callCount) { $curlHandle1 = curl_init('http://example.com'); $curlHandle2 = curl_init('http://example.com'); + Assertion::isResource($curlHandle1); + Assertion::isResource($curlHandle2); + $curlMultiHandle = curl_multi_init(); + Assertion::isResource($curlMultiHandle); curl_multi_add_handle($curlMultiHandle, $curlHandle1); curl_multi_add_handle($curlMultiHandle, $curlHandle2); @@ -344,9 +362,11 @@ function () use ($testClass): void { $this->curlHook->disable(); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); $stillRunning = null; $curlMultiHandle = curl_multi_init(); + Assertion::isResource($curlMultiHandle); curl_multi_add_handle($curlMultiHandle, $curlHandle); curl_multi_exec($curlMultiHandle, $stillRunning); curl_multi_remove_handle($curlMultiHandle, $curlHandle); @@ -372,6 +392,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); + Assertion::isResource($curlHandle); curl_setopt($curlHandle, \CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_reset($curlHandle); curl_exec($curlHandle); diff --git a/tests/VCR/RequestTest.php b/tests/VCR/RequestTest.php index 39c05e29c..b6a097ba3 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/VCR/RequestTest.php @@ -64,6 +64,7 @@ public function testMatchesThrowsExceptionIfMatcherNotFound(): void $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->expectException(\BadFunctionCallException::class); $this->expectExceptionMessage("Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n"); + /* @phpstan-ignore-next-line */ $this->request->matches($request, [['some', 'method']]); } diff --git a/tests/VCR/Storage/JsonTest.php b/tests/VCR/Storage/JsonTest.php index d356a9d29..a400d8b0c 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/VCR/Storage/JsonTest.php @@ -109,7 +109,7 @@ public function testValidJson(): void $this->jsonObject->storeRecording($stored); $this->jsonObject->storeRecording($stored); - $this->assertJson(file_get_contents($this->filePath)); + $this->assertJson((string) file_get_contents($this->filePath)); } public function testStoreRecordingWhenBlankFileAlreadyExists(): void @@ -124,7 +124,7 @@ public function testStoreRecordingWhenBlankFileAlreadyExists(): void ]; $jsonObject->storeRecording($stored); - $this->assertJson(file_get_contents($filePath)); + $this->assertJson((string) file_get_contents($filePath)); } /** @param array $expected */ diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index 57f35e919..43bc8fcc9 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -11,7 +11,7 @@ class SoapClientTest extends TestCase public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; public const ACTION = 'http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP'; - /** @return SoapHook|MockObject */ + /** @return SoapHook&MockObject */ protected function getLibraryHookMock(bool $enabled) { $hookMock = $this->getMockBuilder(SoapHook::class) diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index 7303b0767..db3f82525 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -192,7 +192,7 @@ public function testStreamMetadata(): void $this->assertTrue($mock->unlink($path)); } - /** @return StreamProcessor|MockObject */ + /** @return StreamProcessor&MockObject */ protected function getStreamProcessorMock() { return $this->getMockBuilder(StreamProcessor::class) diff --git a/tests/VCR/VCRFactoryTest.php b/tests/VCR/VCRFactoryTest.php index 4b07b9160..47b182a2d 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/VCR/VCRFactoryTest.php @@ -13,6 +13,8 @@ class VCRFactoryTest extends TestCase /** * @dataProvider instanceProvider * @covers \VCR\VCRFactory::createVCRVideorecorder() + * + * @param class-string $instance */ public function testCreateInstances(string $instance): void { @@ -37,6 +39,8 @@ public function instanceProvider(): array /** * @dataProvider storageProvider + * + * @param class-string $className */ public function testCreateStorage(string $storage, string $className): void { diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 9210f5a21..1020ef49e 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -2,6 +2,7 @@ namespace VCR; +use Assert\Assertion; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use VCR\Event\Event; @@ -60,6 +61,8 @@ private function doCurlGetRequest(string $url): string $output = curl_exec($ch); curl_close($ch); + Assertion::string($output); + return $output; } From 8adc4f5a4eb9ee6486a9cd587429e727f1e8772f Mon Sep 17 00:00:00 2001 From: Thomas Gnandt Date: Fri, 19 Feb 2021 10:23:19 +0100 Subject: [PATCH 115/204] add support for curl_multi_getcontent s --- src/VCR/CodeTransform/CurlCodeTransform.php | 1 + src/VCR/LibraryHooks/CurlHook.php | 23 ++++++- tests/VCR/LibraryHooks/CurlHookTest.php | 72 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) diff --git a/src/VCR/CodeTransform/CurlCodeTransform.php b/src/VCR/CodeTransform/CurlCodeTransform.php index baf93f67f..75b6bea95 100644 --- a/src/VCR/CodeTransform/CurlCodeTransform.php +++ b/src/VCR/CodeTransform/CurlCodeTransform.php @@ -21,6 +21,7 @@ class CurlCodeTransform extends AbstractCodeTransform '/(?|\w_)\\\?curl_multi_remove_handle\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_remove_handle(', '/(?|\w_)\\\?curl_multi_exec\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_exec(', '/(?|\w_)\\\?curl_multi_info_read\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_info_read(', + '/(?|\w_)\\\?curl_multi_getcontent\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_multi_getcontent(', '/(?|\w_)\\\?curl_reset\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_reset(', '/(?|\w_)\\\?curl_error\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_error(', '/(?|\w_)\\\?curl_errno\s*\(/i' => '\VCR\LibraryHooks\CurlHook::curl_errno(', diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 4f87c7609..31aa52ffe 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -37,7 +37,7 @@ class CurlHook implements LibraryHook protected static $responses = []; /** - * @var array additinal curl options, which are not stored within a request + * @var array additional curl options, which are not stored within a request */ protected static $curlOptions = []; @@ -51,6 +51,11 @@ class CurlHook implements LibraryHook */ protected static $multiExecLastChs = []; + /** + * @var array return values of curl_multi responses + */ + protected static $multiReturnValues = []; + /** * @var CurlException[] last cURL error, as a CurlException */ @@ -276,7 +281,7 @@ public static function curlMultiExec($multiHandle, ?int &$stillRunning): int foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { if (!isset(self::$responses[(int) $curlHandle])) { self::$multiExecLastChs[] = $curlHandle; - self::curlExec($curlHandle); + self::$multiReturnValues[(int) $curlHandle] = self::curlExec($curlHandle); } } } @@ -306,6 +311,20 @@ public static function curlMultiInfoRead() return false; } + /** + * Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set. + * + * @see https://www.php.net/manual/en/function.curl-multi-getcontent.php + * + * @param resource $curlHandle + * + * @return string|null return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set + */ + public static function curlMultiGetcontent($curlHandle): ?string + { + return self::$multiReturnValues[(int) $curlHandle] ?? null; + } + /** * Get information regarding a specific transfer. * diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index d6903647a..6092d8854 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -373,6 +373,78 @@ function () use ($testClass): void { curl_multi_close($curlMultiHandle); } + public function testShouldReturnMultiCallValues(): void + { + $testClass = $this; + $callCount = 0; + $this->curlHook->enable( + function (Request $request) use ($testClass, &$callCount) { + $testClass->assertEquals( + 'example.com', + $request->getHost(), + '' + ); + ++$callCount; + + return new Response('200', [], $testClass->expected.$callCount); + } + ); + + $curlHandle1 = curl_init('http://example.com'); + Assertion::isResource($curlHandle1); + curl_setopt($curlHandle1, \CURLOPT_RETURNTRANSFER, true); + $curlHandle2 = curl_init('http://example.com'); + Assertion::isResource($curlHandle2); + curl_setopt($curlHandle2, \CURLOPT_RETURNTRANSFER, true); + $curlHandle3 = curl_init('http://example.com'); + Assertion::isResource($curlHandle3); + curl_setopt($curlHandle3, \CURLOPT_RETURNTRANSFER, false); + + $curlMultiHandle = curl_multi_init(); + Assertion::isResource($curlMultiHandle); + curl_multi_add_handle($curlMultiHandle, $curlHandle1); + curl_multi_add_handle($curlMultiHandle, $curlHandle2); + curl_multi_add_handle($curlMultiHandle, $curlHandle3); + + $stillRunning = null; + ob_start(); + curl_multi_exec($curlMultiHandle, $stillRunning); + $output = ob_get_contents(); + ob_end_clean(); + + $returnValue1 = curl_multi_getcontent($curlHandle1); + $returnValue2 = curl_multi_getcontent($curlHandle2); + $returnValue3 = curl_multi_getcontent($curlHandle3); + + curl_multi_remove_handle($curlMultiHandle, $curlHandle1); + curl_multi_remove_handle($curlMultiHandle, $curlHandle2); + curl_multi_remove_handle($curlMultiHandle, $curlHandle3); + curl_multi_close($curlMultiHandle); + + $this->curlHook->disable(); + + $this->assertEquals(3, $callCount, 'Hook should have been called thrice.'); + $this->assertSame( + $this->expected.'1', + $returnValue1, + 'When called with the first handle the curl_multi_getcontent should return the body of the first response.' + ); + + $this->assertSame( + $this->expected.'2', + $returnValue2, + 'When called with the second handle the curl_multi_getcontent should return the body of the second response.' + ); + + $this->assertNull($returnValue3, 'When called with the third handle the curl_multi_getcontent should return null.'); + + $this->assertSame( + $this->expected.'3', + $output, + 'The third response was not written on stdout.' + ); + } + /** * @requires PHP 5.5.0 */ From d60490c7392db0ea5f505e9845e51c4078f0fa8c Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 22 Aug 2021 10:53:28 +0200 Subject: [PATCH 116/204] Dropped support for PHP 7.2 --- .php_cs.dist => .php-cs-fixer.dist.php | 4 ++-- .travis.yml | 14 ++++++-------- composer.json | 2 +- phpstan.neon | 8 -------- resources/docker/workspace/Dockerfile | 2 +- src/VCR/Storage/Storage.php | 2 +- src/VCR/Util/CurlHelper.php | 2 +- 7 files changed, 12 insertions(+), 22 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (87%) diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 87% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index 4744223bb..cd9444abe 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,11 +1,11 @@ setRules([ '@PSR12' => true, '@Symfony' => true, '@Symfony:risky' => true, - '@PHP71Migration' => true, + '@PHP73Migration' => true, '@PHP71Migration:risky' => true, '@PHPUnit84Migration:risky' => true, // Causes too much problems for now, fix later diff --git a/.travis.yml b/.travis.yml index f6c0c12b9..6bea7c717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,27 +4,25 @@ matrix: fast_finish: true include: - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true - php: 7.2 + php: 7.3 - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.2 - - env: TEST_DIR=. php: 7.3 - env: TEST_DIR=. php: 7.4 - env: TEST_DIR=tests/integration/apache - php: 7.2 + php: 7.3 dist: trusty sudo: required services: - docker - env: TEST_DIR=tests/integration/guzzle/3 - php: 7.2 + php: 7.3 - env: TEST_DIR=tests/integration/guzzle/5 - php: 7.2 + php: 7.3 - env: TEST_DIR=tests/integration/guzzle/6 - php: 7.2 + php: 7.3 - env: TEST_DIR=tests/integration/soap - php: 7.2 + php: 7.3 before_install: - composer self-update diff --git a/composer.json b/composer.json index 326f1f2bd..ec08947d6 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.3", "ext-curl": "*", "beberlei/assert": "^3.2.5", "symfony/yaml": "~2.1|^3.0|^4.0|^5.0", diff --git a/phpstan.neon b/phpstan.neon index 47cd4678a..fd2e6d454 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,23 +3,15 @@ parameters: paths: - src - tests/VCR - # Can remove reportUnmatchedIgnoredErrors option after php 7.2 is no longer supported - reportUnmatchedIgnoredErrors: false ignoreErrors: # This part of PHP is not very well documented, resulting PHPStan's definitions not being accurate - "#Access to an undefined property object::\\$data\\.#" - "#Access to an undefined property object::\\$datalen\\.#" - - - message: '#Unreachable statement - code above always terminates.#' - path: src/VCR/CodeTransform/AbstractCodeTransform.php # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - '#Parameter .* \$str(ing)? of function substr expects string, string\|false given.#' # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string\|null given./' - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' - # PHPStan cannot deal with manually defined constants - can be removed once php 7.2 no longer supported - - '#Constant CURLPROXY_HTTPS not found.#' - - '#Call to an undefined method (VCR\\Util\\|)SoapClient::GetCityWeatherByZIP\(\)\.#' - '#Call to an undefined method org\\bovigo\\vfs\\vfsStreamContent::hasChild\(\)\.#' includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon diff --git a/resources/docker/workspace/Dockerfile b/resources/docker/workspace/Dockerfile index 40d9bcf0a..d1299b267 100644 --- a/resources/docker/workspace/Dockerfile +++ b/resources/docker/workspace/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.2-cli-alpine +FROM php:7.3-cli-alpine ARG PUID=1000 ARG PGID=1000 diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index 596ba54c8..7357dccc2 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -15,7 +15,7 @@ interface Storage extends \Iterator /** * Stores an array of data. * - * @param array> $recording array to store in storage + * @param array|null> $recording array to store in storage */ public function storeRecording(array $recording): void; diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 374ee76d5..48fb8632c 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -111,7 +111,7 @@ public static function getCurlOptionFromResponse(Response $response, int $option case \CURLINFO_HEADER_SIZE: $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; - case CURLPROXY_HTTPS: + case \CURLPROXY_HTTPS: $info = ''; break; default: From 2267d784a5022cb01f02aa16c127a6e729768336 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sun, 22 Aug 2021 11:33:05 +0200 Subject: [PATCH 117/204] Converted travis to github actions --- .github/workflows/tests.yml | 155 ++++++++++++++++++ .travis.yml | 52 ------ README.md | 2 +- composer.json | 5 + tests/integration/guzzle/6/test/AsyncTest.php | 8 +- .../VCR/Example/ExampleHttpClientTest.php | 4 +- 6 files changed, 167 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..f99b42595 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,155 @@ +name: "tests" + +on: + push: + branches: + - "master" + pull_request: + +jobs: + phpstan: + name: "PHPStan" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.3" + extensions: "curl, soap" + tools: "composer:v2" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + run: "composer update --prefer-dist --no-interaction --no-progress" + + - name: "Execute static analysis" + run: "composer run-script phpstan" + + lint: + name: "PHP-CS-Fixer" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.3" + extensions: "curl, soap" + tools: "composer:v2" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + run: "composer update --prefer-dist --no-interaction --no-progress" + + - name: "Execute linting" + run: "composer run-script lint" + + tests: + strategy: + fail-fast: true + matrix: + php: ["7.3", "7.4"] + composer_flags: ["", "--prefer-lowest"] + + name: "Tests PHP ${{ matrix.php }} ${{ matrix.composer_flags}}" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php }}" + extensions: "curl, soap" + tools: "composer:v2" + coverage: "pcov" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + run: "composer update -o ${{ matrix.composer_flags }} --prefer-dist --no-interaction --no-progress" + + - name: "Execute tests" + run: "vendor/bin/phpunit --coverage-clover=coverage.clover" + + - name: "Upload code coverage" + run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" + + guzzle: + strategy: + fail-fast: true + matrix: + guzzle: ["3", "5", "6"] + + name: "Integration test for Guzzle ${{ matrix.guzzle }}" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.3" + extensions: "curl, soap" + tools: "composer:v2" + coverage: "pcov" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + run: "composer update --prefer-dist --no-interaction --no-progress" + + - name: "Execute tests" + run: "cd tests/integration/guzzle/${{ matrix.guzzle }}/ && composer update --prefer-dist --no-interaction --no-progress && ../../../../vendor/bin/phpunit --coverage-clover=coverage.clover" + + - name: "Upload code coverage" + run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" + + soap: + strategy: + fail-fast: true + + name: "SOAP integration test" + + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Setup PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "7.3" + extensions: "curl, soap" + tools: "composer:v2" + coverage: "pcov" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies" + run: "composer update --prefer-dist --no-interaction --no-progress" + + - name: "Execute tests" + run: "cd tests/integration/soap/ && composer update --prefer-dist --no-interaction --no-progress && ../../../vendor/bin/phpunit --coverage-clover=coverage.clover" + + - name: "Upload code coverage" + run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6bea7c717..000000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: php - -matrix: - fast_finish: true - include: - - env: TEST_DIR=. PHP_CS_FIXER=true PHPSTAN=true - php: 7.3 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.3 - - env: TEST_DIR=. - php: 7.4 - - env: TEST_DIR=tests/integration/apache - php: 7.3 - dist: trusty - sudo: required - services: - - docker - - env: TEST_DIR=tests/integration/guzzle/3 - php: 7.3 - - env: TEST_DIR=tests/integration/guzzle/5 - php: 7.3 - - env: TEST_DIR=tests/integration/guzzle/6 - php: 7.3 - - env: TEST_DIR=tests/integration/soap - php: 7.3 - -before_install: - - composer self-update - -install: - - composer update --prefer-source -o $COMPOSER_FLAGS - - PHPUNIT_BIN=$(pwd)/vendor/bin/phpunit - - cd ${TEST_DIR} - - composer update --prefer-source -o $COMPOSER_FLAGS - -script: - - $PHPUNIT_BIN --coverage-clover=coverage.clover - - if [ "${PHP_CS_FIXER}" = "true" ]; then vendor/bin/php-cs-fixer fix --dry-run --diff $TRAVIS_BUILD_DIR; fi - - if [ "${PHPSTAN}" = "true" ]; then composer phpstan; fi - -after_success: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - -cache: - directories: - - vendor - - tests/integration/guzzle/3/vendor - - tests/integration/guzzle/5/vendor - - tests/integration/guzzle/6/vendor - - tests/integration/soap/vendor - - $HOME/.composer/cache diff --git a/README.md b/README.md index c739accf8..ac93babba 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![PHP-VCR](https://user-images.githubusercontent.com/133832/27151811-0d95c6c4-514c-11e7-834e-eff1eec2ea16.png) -[![Build Status](https://travis-ci.org/php-vcr/php-vcr.svg?branch=master)](https://travis-ci.org/php-vcr/php-vcr) +[![Build Status](https://github.com/php-vcr/php-vcr/actions/workflows/tests.yml/badge.svg)](https://github.com/php-vcr/php-vcr/actions/workflows/tests.yml) [![Code Coverage](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/coverage.png?s=15cf1644c8cf37a868e03cfba809a5e24c78f285)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/quality-score.png?s=4f638dbca5eb51fb9c87a1dd45c5df94687d85bd)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) diff --git a/composer.json b/composer.json index ec08947d6..45a03265e 100644 --- a/composer.json +++ b/composer.json @@ -34,5 +34,10 @@ "psr-4": { "VCR\\": "src/VCR/" } + }, + "autoload-dev": { + "classmap": [ + "tests/" + ] } } diff --git a/tests/integration/guzzle/6/test/AsyncTest.php b/tests/integration/guzzle/6/test/AsyncTest.php index c27e2207f..586f14f0c 100644 --- a/tests/integration/guzzle/6/test/AsyncTest.php +++ b/tests/integration/guzzle/6/test/AsyncTest.php @@ -11,8 +11,8 @@ */ class AsyncTest extends TestCase { - public const TEST_GET_URL = 'https://api.chew.pro/trbmb'; - public const TEST_GET_URL_2 = 'https://api.chew.pro/trbmb?foo=42'; + public const TEST_GET_URL = 'https://httpbin.org/get'; + public const TEST_GET_URL_2 = 'https://httpbin.org/get?foo=42'; protected function setUp(): void { @@ -33,7 +33,7 @@ public function testAsyncLock(): void // Let's check that we can perform 2 async request on different URLs without locking. // Solves https://github.com/php-vcr/php-vcr/issues/211 - $this->assertValidGETResponse(\GuzzleHttp\json_decode($response->getBody())); + $this->assertValidGETResponse(\GuzzleHttp\json_decode($response->getBody(), true)); \VCR\VCR::turnOff(); } @@ -41,6 +41,6 @@ public function testAsyncLock(): void protected function assertValidGETResponse($info): void { $this->assertIsArray($info, 'Response is not an array.'); - $this->assertArrayHasKey('0', $info, 'API did not return any value.'); + $this->assertArrayHasKey('url', $info, 'API did not return any value.'); } } diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php index e97e625fd..60939efb1 100644 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php @@ -10,7 +10,7 @@ */ class ExampleHttpClientTest extends TestCase { - public const TEST_GET_URL = 'https://api.chew.pro/trbmb'; + public const TEST_GET_URL = 'https://httpbin.org/get'; public const TEST_POST_URL = 'https://httpbin.org/post'; public const TEST_POST_BODY = '{"foo":"bar"}'; @@ -90,7 +90,7 @@ protected function requestPOSTIntercepted() protected function assertValidGETResponse($info): void { $this->assertIsArray($info, 'Response is not an array.'); - $this->assertArrayHasKey('0', $info, 'API did not return any value.'); + $this->assertArrayHasKey('url', $info, 'API did not return any value.'); } protected function assertValidPOSTResponse($info): void From f036ea911561f15aae514bcf5872b1d3617c282b Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 4 Oct 2021 14:17:54 +0200 Subject: [PATCH 118/204] Adding support for PHP8, dropping support for PHP7 --- .github/workflows/tests.yml | 12 +- .gitignore | 1 + composer.json | 16 +- phpstan.neon | 7 - resources/docker/workspace/Dockerfile | 2 +- src/VCR/Event/Event.php | 15 +- src/VCR/LibraryHooks/CurlHook.php | 59 ++---- src/VCR/LibraryHooks/SoapHook.php | 4 +- src/VCR/Util/CurlException.php | 9 +- src/VCR/Util/CurlHelper.php | 26 +-- src/VCR/Util/HttpClient.php | 2 +- src/VCR/Util/SoapClient.php | 17 +- src/VCR/Videorecorder.php | 8 - tests/VCR/LibraryHooks/CurlHookTest.php | 42 ++--- tests/VCR/Storage/AbstractStorageTest.php | 5 +- tests/VCR/Util/CurlHelperTest.php | 14 +- tests/VCR/Util/SoapClientTest.php | 6 +- tests/integration/apache/README.md | 3 - tests/integration/apache/composer.json | 6 - .../integration/apache/expected_cassette.yaml | 21 --- tests/integration/apache/phpunit.xml | 13 -- tests/integration/apache/startApache.sh | 3 - tests/integration/apache/test/OpcacheTest.php | 54 ------ tests/integration/apache/www/.gitignore | 1 - .../integration/apache/www/performRequest.php | 8 - .../apache/www/performRequestWithPhpVcr.php | 11 -- tests/integration/apache/www/target.html | 1 - .../guzzle/3/ExampleHttpClient.php | 46 ----- tests/integration/guzzle/3/composer.json | 6 - tests/integration/guzzle/3/composer.lock | 173 ------------------ tests/integration/guzzle/3/phpunit.xml | 14 -- 31 files changed, 80 insertions(+), 525 deletions(-) delete mode 100644 tests/integration/apache/README.md delete mode 100644 tests/integration/apache/composer.json delete mode 100644 tests/integration/apache/expected_cassette.yaml delete mode 100644 tests/integration/apache/phpunit.xml delete mode 100755 tests/integration/apache/startApache.sh delete mode 100644 tests/integration/apache/test/OpcacheTest.php delete mode 100644 tests/integration/apache/www/.gitignore delete mode 100644 tests/integration/apache/www/performRequest.php delete mode 100644 tests/integration/apache/www/performRequestWithPhpVcr.php delete mode 100644 tests/integration/apache/www/target.html delete mode 100644 tests/integration/guzzle/3/ExampleHttpClient.php delete mode 100644 tests/integration/guzzle/3/composer.json delete mode 100644 tests/integration/guzzle/3/composer.lock delete mode 100644 tests/integration/guzzle/3/phpunit.xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f99b42595..14e48a494 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: - name: "Setup PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "7.3" + php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" @@ -40,7 +40,7 @@ jobs: - name: "Setup PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "7.3" + php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" @@ -57,7 +57,7 @@ jobs: strategy: fail-fast: true matrix: - php: ["7.3", "7.4"] + php: ["8.0"] composer_flags: ["", "--prefer-lowest"] name: "Tests PHP ${{ matrix.php }} ${{ matrix.composer_flags}}" @@ -92,7 +92,7 @@ jobs: strategy: fail-fast: true matrix: - guzzle: ["3", "5", "6"] + guzzle: ["5", "6"] name: "Integration test for Guzzle ${{ matrix.guzzle }}" @@ -105,7 +105,7 @@ jobs: - name: "Setup PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "7.3" + php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" coverage: "pcov" @@ -137,7 +137,7 @@ jobs: - name: "Setup PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "7.3" + php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" coverage: "pcov" diff --git a/.gitignore b/.gitignore index 5e6f0a860..4c8dfd449 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tests/fixtures/cassette* /.php_cs composer.lock .phpunit.result.cache +.php-cs-fixer.cache diff --git a/composer.json b/composer.json index 45a03265e..af3e6095c 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "test": "./vendor/bin/phpunit", "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", - "phpstan": "phpstan analyse -c phpstan.neon --no-progress -vvv" + "phpstan": "php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon --no-progress -vvv" }, "authors": [ { @@ -15,20 +15,22 @@ } ], "require": { - "php": ">=7.3", + "php": "^8.0", "ext-curl": "*", "beberlei/assert": "^3.2.5", - "symfony/yaml": "~2.1|^3.0|^4.0|^5.0", - "symfony/event-dispatcher": "^2.4|^3.0|^4.0|^5.0" + "symfony/yaml": "^3.0|^4.0|^5.0", + "symfony/event-dispatcher": "^5.0" }, "require-dev": { "phpunit/phpunit": "^8.4.0", - "mikey179/vfsstream": "^1.6", - "phpstan/phpstan": "^0.12", + "mikey179/vfsstream": "^1.6.10", + "phpstan/phpstan": "^0.12.92", "phpstan/phpstan-beberlei-assert": "^0.12.0", "thecodingmachine/phpstan-strict-rules": "^0.12", "sebastian/version": "^1.0.3|^2.0", - "friendsofphp/php-cs-fixer": "^2.16" + "friendsofphp/php-cs-fixer": "^3.0", + "phpstan/phpstan-phpunit": "^0.12.22", + "phpstan/extension-installer": "^1.1" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index fd2e6d454..10d0d03c8 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,10 +9,3 @@ parameters: - "#Access to an undefined property object::\\$datalen\\.#" # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - '#Parameter .* \$str(ing)? of function substr expects string, string\|false given.#' - # The EventDispatcherInterface::dispatch signature is different (!) between Symfony <4.3 and >=4.3 - - '/Parameter #1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string\|null given./' - - '/Parameter #2 \$eventName of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects string\|null, VCR\\Event\\Event given./' - - '#Call to an undefined method org\\bovigo\\vfs\\vfsStreamContent::hasChild\(\)\.#' -includes: - - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - - vendor/phpstan/phpstan-beberlei-assert/extension.neon diff --git a/resources/docker/workspace/Dockerfile b/resources/docker/workspace/Dockerfile index d1299b267..7e8595696 100644 --- a/resources/docker/workspace/Dockerfile +++ b/resources/docker/workspace/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.3-cli-alpine +FROM php:8.0-cli-alpine ARG PUID=1000 ARG PGID=1000 diff --git a/src/VCR/Event/Event.php b/src/VCR/Event/Event.php index dda40c61f..afb917268 100644 --- a/src/VCR/Event/Event.php +++ b/src/VCR/Event/Event.php @@ -2,19 +2,6 @@ namespace VCR\Event; -use Symfony\Component\EventDispatcher\Event as LegacyEvent; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; - -if (class_exists(ContractsEvent::class) && !class_exists(LegacyEvent::class)) { - abstract class SymphonyEvent extends ContractsEvent - { - } -} elseif (class_exists(LegacyEvent::class)) { - abstract class SymphonyEvent extends LegacyEvent - { - } -} - -abstract class Event extends SymphonyEvent +abstract class Event extends \Symfony\Contracts\EventDispatcher\Event { } diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 31aa52ffe..9e0325852 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -2,6 +2,7 @@ namespace VCR\LibraryHooks; +use CurlHandle; use VCR\CodeTransform\AbstractCodeTransform; use VCR\Request; use VCR\Response; @@ -166,15 +167,9 @@ public static function __callStatic($method, array $args) } /** - * Initialize a cURL session. - * * @see http://www.php.net/manual/en/function.curl-init.php - * - * @param string|null $url (Optional) url - * - * @return resource|false cURL handle */ - public static function curlInit(?string $url = null) + public static function curlInit(?string $url = null): CurlHandle|false { $curlHandle = curl_init($url); if (false !== $curlHandle) { @@ -186,13 +181,9 @@ public static function curlInit(?string $url = null) } /** - * Reset a cURL session. - * * @see http://www.php.net/manual/en/function.curl-reset.php - * - * @param resource $curlHandle a cURL handle returned by curl_init() */ - public static function curlReset($curlHandle): void + public static function curlReset(CurlHandle $curlHandle): void { curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); @@ -205,13 +196,11 @@ public static function curlReset($curlHandle): void * * @see http://www.php.net/manual/en/function.curl-exec.php * - * @param resource $curlHandle a cURL handle returned by curl_init() - * * @return mixed Returns TRUE on success or FALSE on failure. * However, if the CURLOPT_RETURNTRANSFER option is set, it will return the * result on success, FALSE on failure. */ - public static function curlExec($curlHandle) + public static function curlExec(CurlHandle $curlHandle) { try { $request = self::$requests[(int) $curlHandle]; @@ -330,12 +319,9 @@ public static function curlMultiGetcontent($curlHandle): ?string * * @see http://www.php.net/manual/en/function.curl-getinfo.php * - * @param resource $curlHandle a cURL handle returned by curl_init() - * @param int $option a cURL option defined in the cURL Predefined Constants - * * @return mixed */ - public static function curlGetinfo($curlHandle, int $option = 0) + public static function curlGetinfo(CurlHandle $curlHandle, int $option = 0) { if (isset(self::$responses[(int) $curlHandle])) { return CurlHelper::getCurlOptionFromResponse( @@ -354,15 +340,11 @@ public static function curlGetinfo($curlHandle, int $option = 0) * * @see http://www.php.net/manual/en/function.curl-setopt.php * - * @param resource $curlHandle a cURL handle returned by curl_init() - * @param int $option the CURLOPT_XXX option to set - * @param mixed $value the value to be set on option - * - * @return bool returns TRUE on success or FALSE on failure + * @param mixed $value the value to be set on option */ - public static function curlSetopt($curlHandle, int $option, $value): bool + public static function curlSetopt(CurlHandle $curlHandle, int $option, $value): bool { - CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value, $curlHandle); + CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value); static::$curlOptions[(int) $curlHandle][$option] = $value; @@ -374,15 +356,12 @@ public static function curlSetopt($curlHandle, int $option, $value): bool * * @see http://www.php.net/manual/en/function.curl-setopt-array.php * - * @param resource $curlHandle a cURL handle returned by curl_init() - * @param array $options an array specifying which options to set and their values + * @param array $options an array specifying which options to set and their values */ - public static function curlSetoptArray($curlHandle, array $options): void + public static function curlSetoptArray(CurlHandle $curlHandle, array $options): void { - if (\is_array($options)) { - foreach ($options as $option => $value) { - static::curlSetopt($curlHandle, $option, $value); - } + foreach ($options as $option => $value) { + static::curlSetopt($curlHandle, $option, $value); } } @@ -390,13 +369,8 @@ public static function curlSetoptArray($curlHandle, array $options): void * Return a string containing the last error for the current session. * * @see https://php.net/manual/en/function.curl-error.php - * - * @param resource $curlHandle - * - * @return string the error message or '' (the empty string) if no - * error occurred */ - public static function curlError($curlHandle): string + public static function curlError(CurlHandle $curlHandle): string { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getMessage(); @@ -409,13 +383,8 @@ public static function curlError($curlHandle): string * Return the last error number. * * @see https://php.net/manual/en/function.curl-errno.php - * - * @param resource $curlHandle - * - * @return int the error number or 0 (zero) if no error - * occurred */ - public static function curlErrno($curlHandle): int + public static function curlErrno(CurlHandle $curlHandle): int { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getCode(); diff --git a/src/VCR/LibraryHooks/SoapHook.php b/src/VCR/LibraryHooks/SoapHook.php index 2c155ac71..ee7c1e22a 100644 --- a/src/VCR/LibraryHooks/SoapHook.php +++ b/src/VCR/LibraryHooks/SoapHook.php @@ -54,10 +54,8 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces /** * @param array $options - * - * @return string SOAP response */ - public function doRequest(string $request, string $location, string $action, int $version, int $one_way = 0, array $options = []): string + public function doRequest(string $request, string $location, string $action, int $version, bool $one_way = false, array $options = []): string { if (self::DISABLED === $this->status) { throw new VCRException('Hook must be enabled.', VCRException::LIBRARY_HOOK_DISABLED); diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php index 42a2c99a8..cc3e06120 100644 --- a/src/VCR/Util/CurlException.php +++ b/src/VCR/Util/CurlException.php @@ -2,6 +2,8 @@ namespace VCR\Util; +use CurlHandle; + class CurlException extends \Exception { /** @@ -9,12 +11,7 @@ class CurlException extends \Exception */ private $info; - /** - * @param resource $ch The cURL handler - * - * @return CurlException - */ - public static function create($ch): self + public static function create(CurlHandle $ch): self { $e = new self(curl_error($ch), curl_errno($ch)); $e->info = curl_getinfo($ch); diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 48fb8632c..77d03d269 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -2,6 +2,7 @@ namespace VCR\Util; +use CurlHandle; use VCR\Request; use VCR\Response; @@ -46,11 +47,9 @@ class CurlHelper * * The response header might be passed to a custom function. * - * @param Response $response response which contains the response body * @param array $curlOptions cURL options which are not stored within the Response - * @param resource $ch cURL handle to add headers if needed */ - public static function handleOutput(Response $response, array $curlOptions, $ch): ?string + public static function handleOutput(Response $response, array $curlOptions, CurlHandle $ch): ?string { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[\CURLOPT_HEADERFUNCTION])) { @@ -129,14 +128,9 @@ public static function getCurlOptionFromResponse(Response $response, int $option } /** - * Sets a cURL option on a Request. - * - * @param Request $request request to set cURL option to - * @param int $option cURL option to set - * @param mixed $value value of the cURL option - * @param resource $curlHandle cURL handle where this option is set on (optional) + * @param mixed $value value of the cURL option */ - public static function setCurlOptionOnRequest(Request $request, int $option, $value, $curlHandle = null): void + public static function setCurlOptionOnRequest(Request $request, int $option, $value): void { switch ($option) { case \CURLOPT_URL: @@ -194,11 +188,8 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va /** * Makes sure we've properly handled the POST body, such as ensuring that * CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set. - * - * @param Request $request request to set cURL option to - * @param resource $curlHandle cURL handle associated with the request */ - public static function validateCurlPOSTBody(Request $request, $curlHandle = null): void + public static function validateCurlPOSTBody(Request $request, CurlHandle $curlHandle = null): void { $readFunction = $request->getCurlOption(\CURLOPT_READFUNCTION); if (null === $readFunction) { @@ -221,13 +212,12 @@ public static function validateCurlPOSTBody(Request $request, $curlHandle = null * A wrapper around call_user_func that attempts to properly handle private * and protected methods on objects. * - * @param mixed $callback The callable to pass to call_user_func - * @param resource $curlHandle cURL handle associated with the request - * @param mixed $argument The third argument to pass to call_user_func + * @param mixed $callback The callable to pass to call_user_func + * @param mixed $argument The third argument to pass to call_user_func * * @return mixed value returned by the callback function */ - private static function callFunction($callback, $curlHandle, $argument) + private static function callFunction($callback, CurlHandle $curlHandle, $argument) { if (!\is_callable($callback) && \is_array($callback) && 2 === \count($callback)) { // This is probably a private or protected method on an object. Try and diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 5a65f0e15..27e951e76 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -23,7 +23,7 @@ public function send(Request $request): Response { $ch = curl_init($request->getUrl()); - Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'"); + Assertion::notSame($ch, false, "Could not init curl with URL '{$request->getUrl()}'"); curl_setopt($ch, \CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, \CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index 78a6279b1..b257bf134 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -49,12 +49,10 @@ public function __construct($wsdl, array $options = []) * @param string $location the URL to request * @param string $action the SOAP action * @param int $version the SOAP version - * @param int $one_way If one_way is set to 1, this method returns nothing. - * Use this where a response is not expected. * * @return string|null the XML SOAP response (or null if $one_way is set) */ - public function __doRequest($request, $location, $action, $version, $one_way = 0) + public function __doRequest($request, $location, $action, $version, bool $one_way = false) { // Save a copy of the request, not the request itself -- see issue #153 $this->request = (string) $request; @@ -102,17 +100,8 @@ public function setLibraryHook(SoapHook $hook): void * Performs a real SOAP request over HTTP. * * @codeCoverageIgnore - * - * @param string $request the XML SOAP request - * @param string $location the URL to request - * @param string $action the SOAP action - * @param int $version the SOAP version - * @param int $one_way If one_way is set to 1, this method returns nothing. - * Use this where a response is not expected. - * - * @return string the XML SOAP response */ - protected function realDoRequest(string $request, string $location, string $action, int $version, int $one_way = 0): string + protected function realDoRequest(string $request, string $location, string $action, int $version, bool $one_way = false): string { return parent::__doRequest($request, $location, $action, $version, $one_way); } @@ -121,8 +110,6 @@ protected function realDoRequest(string $request, string $location, string $acti * Returns currently used SOAP library hook. * * If no library hook is set, a new one is created. - * - * @return soapHook SOAP library hook */ protected function getLibraryHook(): SoapHook { diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 9d5bd1b17..40b60555d 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -95,14 +95,6 @@ public function getEventDispatcher(): EventDispatcherInterface */ private function dispatch(Event $event, $eventName = null): Event { - if (class_exists(\Symfony\Component\EventDispatcher\Event::class)) { - $res = $this->getEventDispatcher()->dispatch($eventName, $event); - - Assertion::isInstanceOf($res, Event::class); - - return $res; - } - $res = $this->getEventDispatcher()->dispatch($event, $eventName); Assertion::isInstanceOf($res, Event::class); diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 6092d8854..83f136562 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -51,7 +51,7 @@ public function testShouldInterceptCallWhenEnabled(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $actual = curl_exec($curlHandle); curl_close($curlHandle); @@ -66,7 +66,7 @@ public function testShouldInterceptCallWhenEnabled(): void public function testShouldNotInterceptCallWhenNotEnabled(): void { $curlHandle = curl_init('http://example.com/'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curlHandle); Assertion::string($response); @@ -89,7 +89,7 @@ function () use (&$intercepted): void { $this->curlHook->disable(); $curlHandle = curl_init(); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_URL, 'http://example.com/'); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); @@ -102,7 +102,7 @@ public function testShouldWriteFileOnFileDownload(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('https://example.com/'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); $filePointer = fopen('php://temp/test_file', 'w'); Assertion::isResource($filePointer); curl_setopt($curlHandle, \CURLOPT_FILE, $filePointer); @@ -121,7 +121,7 @@ public function testShouldEchoResponseIfReturnTransferFalse(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com/'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, false); ob_start(); curl_exec($curlHandle); @@ -149,7 +149,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_POSTFIELDS, ['para1' => 'val1', 'para2' => 'val2']); curl_exec($curlHandle); curl_close($curlHandle); @@ -172,7 +172,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt_array( $curlHandle, [ @@ -189,7 +189,7 @@ public function testShouldReturnCurlInfoStatusCode(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); @@ -210,7 +210,7 @@ public function testShouldReturnCurlInfoStatusCodeAsInteger(): void $this->curlHook->enable($this->getTestCallback($stringStatusCode)); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $infoHttpCode = curl_getinfo($curlHandle, \CURLINFO_HTTP_CODE); @@ -226,7 +226,7 @@ public function testShouldReturnCurlInfoAll(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); @@ -242,7 +242,7 @@ public function testShouldReturnCurlInfoAllKeys(): void $this->curlHook->enable($this->getTestCallback()); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_RETURNTRANSFER, true); curl_exec($curlHandle); $info = curl_getinfo($curlHandle); @@ -311,11 +311,11 @@ function (Request $request) use ($testClass, &$callCount) { $curlHandle1 = curl_init('http://example.com'); $curlHandle2 = curl_init('http://example.com'); - Assertion::isResource($curlHandle1); - Assertion::isResource($curlHandle2); + Assertion::notSame($curlHandle1, false); + Assertion::notSame($curlHandle2, false); $curlMultiHandle = curl_multi_init(); - Assertion::isResource($curlMultiHandle); + Assertion::notSame($curlMultiHandle, false); curl_multi_add_handle($curlMultiHandle, $curlHandle1); curl_multi_add_handle($curlMultiHandle, $curlHandle2); @@ -362,11 +362,11 @@ function () use ($testClass): void { $this->curlHook->disable(); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); $stillRunning = null; $curlMultiHandle = curl_multi_init(); - Assertion::isResource($curlMultiHandle); + Assertion::notSame($curlMultiHandle, false); curl_multi_add_handle($curlMultiHandle, $curlHandle); curl_multi_exec($curlMultiHandle, $stillRunning); curl_multi_remove_handle($curlMultiHandle, $curlHandle); @@ -391,17 +391,17 @@ function (Request $request) use ($testClass, &$callCount) { ); $curlHandle1 = curl_init('http://example.com'); - Assertion::isResource($curlHandle1); + Assertion::notSame($curlHandle1, false); curl_setopt($curlHandle1, \CURLOPT_RETURNTRANSFER, true); $curlHandle2 = curl_init('http://example.com'); - Assertion::isResource($curlHandle2); + Assertion::notSame($curlHandle2, false); curl_setopt($curlHandle2, \CURLOPT_RETURNTRANSFER, true); $curlHandle3 = curl_init('http://example.com'); - Assertion::isResource($curlHandle3); + Assertion::notSame($curlHandle3, false); curl_setopt($curlHandle3, \CURLOPT_RETURNTRANSFER, false); $curlMultiHandle = curl_multi_init(); - Assertion::isResource($curlMultiHandle); + Assertion::notSame($curlMultiHandle, false); curl_multi_add_handle($curlMultiHandle, $curlHandle1); curl_multi_add_handle($curlMultiHandle, $curlHandle2); curl_multi_add_handle($curlMultiHandle, $curlHandle3); @@ -464,7 +464,7 @@ function (Request $request) use ($testClass) { ); $curlHandle = curl_init('http://example.com'); - Assertion::isResource($curlHandle); + Assertion::notSame($curlHandle, false); curl_setopt($curlHandle, \CURLOPT_CUSTOMREQUEST, 'DELETE'); curl_reset($curlHandle); curl_exec($curlHandle); diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index cbf6d5c14..2e158a8d0 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -3,6 +3,7 @@ namespace VCR\Storage; use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamDirectory; use PHPUnit\Framework\TestCase; /** @@ -22,7 +23,8 @@ public function testFilePathCreated(): void $this->storage = new TestStorage(vfsStream::url('test/'), 'folder/file'); $this->assertTrue($fs->hasChild('folder')); - $this->assertTrue($fs->getChild('folder')->hasChild('file')); + $this->assertInstanceOf(vfsStreamDirectory::class, $child = $fs->getChild('folder')); + $this->assertTrue($child->hasChild('file')); } public function testRootNotExisting(): void @@ -47,7 +49,6 @@ public function storeRecording(array $recording): void public function next(): void { - [$this->position, $this->current] = each($this->recording); } public function valid() diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/VCR/Util/CurlHelperTest.php index a8d5a33cf..3f9b31b72 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/VCR/Util/CurlHelperTest.php @@ -2,6 +2,7 @@ namespace VCR\Util; +use CurlHandle; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use VCR\Exceptions\InvalidHostException; @@ -156,7 +157,7 @@ public function testSetCurlOptionReadFunctionToNull(): void { $request = new Request('POST', 'http://example.com'); - CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, null, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, null); $this->assertNull($request->getCurlOption(\CURLOPT_READFUNCTION)); } @@ -177,7 +178,7 @@ public function testSetCurlOptionReadFunctionMissingSize(): void $callback = function ($curlHandle, $fileHandle, $size): void { }; - CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback); CurlHelper::validateCurlPOSTBody($request, curl_init()); } @@ -188,7 +189,7 @@ public function testSetCurlOptionReadFunction(): void $test = $this; $callback = function ($curlHandle, $fileHandle, $size) use ($test, $expected) { - $test->assertIsResource($curlHandle); + $test->assertNotFalse($curlHandle); $test->assertIsResource($fileHandle); $test->assertEquals(\strlen($expected), $size); @@ -196,7 +197,7 @@ public function testSetCurlOptionReadFunction(): void }; CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_INFILESIZE, \strlen($expected)); - CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback, curl_init()); + CurlHelper::setCurlOptionOnRequest($request, \CURLOPT_READFUNCTION, $callback); CurlHelper::validateCurlPOSTBody($request, curl_init()); $this->assertEquals($expected, $request->getBody()); @@ -566,12 +567,9 @@ private function privateCurlHeaderFunction($ch, string $header): void /** * Function used for testing CURLOPT_WRITEFUNCTION. - * - * @param resource $ch */ - private function privateCurlWriteFunction($ch, string $body): int + private function privateCurlWriteFunction(CurlHandle $ch, string $body): int { - $this->assertEquals('resource', \gettype($ch)); $this->assertEquals('example response', $body); return \strlen($body); diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/VCR/Util/SoapClientTest.php index 43bc8fcc9..f1f77577b 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/VCR/Util/SoapClientTest.php @@ -60,7 +60,7 @@ public function testDoRequestOneWayEnabled(): void $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); - $this->assertNull($client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, 1)); + $this->assertNull($client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, true)); } public function testDoRequestOneWayDisabled(): void @@ -74,7 +74,7 @@ public function testDoRequestOneWayDisabled(): void $this->assertEquals( $expected, - $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, 0) + $client->__doRequest('Knorx ist groß', self::WSDL, self::ACTION, \SOAP_1_2, false) ); } @@ -160,7 +160,7 @@ public function testGetLastWhateverAfterRequest(): void $client = new SoapClient(self::WSDL); $client->setLibraryHook($hook); - $client->__doRequest($request, self::WSDL, self::ACTION, \SOAP_1_2, 0); + $client->__doRequest($request, self::WSDL, self::ACTION, \SOAP_1_2, false); $this->assertEquals($request, $client->__getLastRequest()); $this->assertEquals($response, $client->__getLastResponse()); diff --git a/tests/integration/apache/README.md b/tests/integration/apache/README.md deleted file mode 100644 index 378ef3309..000000000 --- a/tests/integration/apache/README.md +++ /dev/null @@ -1,3 +0,0 @@ -The apache integration test is here to test that Opcache does not have side-effects on PHP-VCR. - -Especially, it tests that PHP-VCR is able to instrument a file that was previously loaded in cache via Opcache. \ No newline at end of file diff --git a/tests/integration/apache/composer.json b/tests/integration/apache/composer.json deleted file mode 100644 index a31c4a30f..000000000 --- a/tests/integration/apache/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "require": { - "ext-curl": "*", - "phpunit/phpunit": "^7.4" - } -} diff --git a/tests/integration/apache/expected_cassette.yaml b/tests/integration/apache/expected_cassette.yaml deleted file mode 100644 index a1a76b3b9..000000000 --- a/tests/integration/apache/expected_cassette.yaml +++ /dev/null @@ -1,21 +0,0 @@ - -- - request: - method: GET - url: 'http://localhost/tests/integration/apache/www/target.html' - headers: - Host: localhost - response: - status: - http_version: '1.1' - code: '200' - message: OK - headers: - Date: 'Fri, 19 Oct 2018 14:13:53 GMT' - Server: 'Apache/2.4.25 (Debian)' - Last-Modified: 'Fri, 19 Oct 2018 13:54:38 GMT' - ETag: '"6-578953e8e6867"' - Accept-Ranges: bytes - Content-Length: '6' - Content-Type: text/html - body: foobar diff --git a/tests/integration/apache/phpunit.xml b/tests/integration/apache/phpunit.xml deleted file mode 100644 index 6a1d11132..000000000 --- a/tests/integration/apache/phpunit.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - ./test - - - - diff --git a/tests/integration/apache/startApache.sh b/tests/integration/apache/startApache.sh deleted file mode 100755 index 6d273ab41..000000000 --- a/tests/integration/apache/startApache.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -docker run --rm --name apache-web-server -p 8080:80 -v "$PWD/../../../":/var/www/html thecodingmachine/php:7.2-v1-apache diff --git a/tests/integration/apache/test/OpcacheTest.php b/tests/integration/apache/test/OpcacheTest.php deleted file mode 100644 index 58460ed47..000000000 --- a/tests/integration/apache/test/OpcacheTest.php +++ /dev/null @@ -1,54 +0,0 @@ -fail('Failed to start Apache server'); - } - - // Step 3: Let's perform 2 requests: one that performs a direct cURL request and THEN, one that goes through PHP-VCR - file_get_contents('http://localhost:8080/tests/integration/apache/www/performRequest.php'); - file_get_contents('http://localhost:8080/tests/integration/apache/www/performRequestWithPhpVcr.php'); - - // Step 4: cleanup - passthru('docker stop apache-web-server'); - - // Step 5: verify that the cassette contains what we want. - $cassette = file_get_contents('www/vcr.yaml'); - $this->assertContains('http://localhost/tests/integration/apache/www/target.html', $cassette); - } -} diff --git a/tests/integration/apache/www/.gitignore b/tests/integration/apache/www/.gitignore deleted file mode 100644 index 16f1ee2a0..000000000 --- a/tests/integration/apache/www/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vcr.yaml \ No newline at end of file diff --git a/tests/integration/apache/www/performRequest.php b/tests/integration/apache/www/performRequest.php deleted file mode 100644 index 2faf3c483..000000000 --- a/tests/integration/apache/www/performRequest.php +++ /dev/null @@ -1,8 +0,0 @@ -setCassettePath(__DIR__); -VCR::insertCassette('vcr.yaml'); - -require_once 'performRequest.php'; diff --git a/tests/integration/apache/www/target.html b/tests/integration/apache/www/target.html deleted file mode 100644 index f6ea04951..000000000 --- a/tests/integration/apache/www/target.html +++ /dev/null @@ -1 +0,0 @@ -foobar \ No newline at end of file diff --git a/tests/integration/guzzle/3/ExampleHttpClient.php b/tests/integration/guzzle/3/ExampleHttpClient.php deleted file mode 100644 index d5a0d2f3d..000000000 --- a/tests/integration/guzzle/3/ExampleHttpClient.php +++ /dev/null @@ -1,46 +0,0 @@ -get($url); - $response = $request->send(); - - return json_decode($response->getBody(), true); - } catch (ClientErrorResponseException $e) { - if (404 !== $e->getResponse()->getStatusCode()) { - throw $e; - } - } - - return null; - } - - public function post($url, $body) - { - $client = new Client(); - - try { - $request = $client->post($url); - $request->setBody($body, 'application/json'); - $response = $request->send(); - - return json_decode($response->getBody(), true); - } catch (ClientErrorResponseException $e) { - if (404 !== $e->getResponse()->getStatusCode()) { - throw $e; - } - } - - return null; - } -} diff --git a/tests/integration/guzzle/3/composer.json b/tests/integration/guzzle/3/composer.json deleted file mode 100644 index d871811ea..000000000 --- a/tests/integration/guzzle/3/composer.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "require": { - "guzzlehttp/guzzle": "~3.0", - "symfony/event-dispatcher": "<4.3" - } -} diff --git a/tests/integration/guzzle/3/composer.lock b/tests/integration/guzzle/3/composer.lock deleted file mode 100644 index 1416af9d7..000000000 --- a/tests/integration/guzzle/3/composer.lock +++ /dev/null @@ -1,173 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "8573d0718749797c92bc6d384e04eaff", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "v3.8.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4de0618a01b34aa1c8c33a3f13f396dcd3882eba", - "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.3", - "symfony/event-dispatcher": ">=2.1" - }, - "replace": { - "guzzle/batch": "self.version", - "guzzle/cache": "self.version", - "guzzle/common": "self.version", - "guzzle/http": "self.version", - "guzzle/inflection": "self.version", - "guzzle/iterator": "self.version", - "guzzle/log": "self.version", - "guzzle/parser": "self.version", - "guzzle/plugin": "self.version", - "guzzle/plugin-async": "self.version", - "guzzle/plugin-backoff": "self.version", - "guzzle/plugin-cache": "self.version", - "guzzle/plugin-cookie": "self.version", - "guzzle/plugin-curlauth": "self.version", - "guzzle/plugin-error-response": "self.version", - "guzzle/plugin-history": "self.version", - "guzzle/plugin-log": "self.version", - "guzzle/plugin-md5": "self.version", - "guzzle/plugin-mock": "self.version", - "guzzle/plugin-oauth": "self.version", - "guzzle/service": "self.version", - "guzzle/stream": "self.version" - }, - "require-dev": { - "doctrine/cache": "*", - "monolog/monolog": "1.*", - "phpunit/phpunit": "3.7.*", - "psr/log": "1.0.*", - "symfony/class-loader": "*", - "zendframework/zend-cache": "<2.3", - "zendframework/zend-log": "<2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.8-dev" - } - }, - "autoload": { - "psr-0": { - "Guzzle": "src/", - "Guzzle\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Guzzle Community", - "homepage": "https://github.com/guzzle/guzzle/contributors" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2014-01-28T22:29:15+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v4.1.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "conflict": { - "symfony/dependency-injection": "<3.4" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2018-07-26T09:10:45+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/tests/integration/guzzle/3/phpunit.xml b/tests/integration/guzzle/3/phpunit.xml deleted file mode 100644 index 2d6304580..000000000 --- a/tests/integration/guzzle/3/phpunit.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ../test - - - - From 77911ca3c1cc39c72c6d3ba17b8d2bd662fb49a3 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Mon, 4 Oct 2021 14:37:14 +0200 Subject: [PATCH 119/204] Workaround for broken ocular --- .github/workflows/tests.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14e48a494..59cbce33c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -85,8 +85,10 @@ jobs: - name: "Execute tests" run: "vendor/bin/phpunit --coverage-clover=coverage.clover" - - name: "Upload code coverage" - run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" guzzle: strategy: @@ -119,8 +121,10 @@ jobs: - name: "Execute tests" run: "cd tests/integration/guzzle/${{ matrix.guzzle }}/ && composer update --prefer-dist --no-interaction --no-progress && ../../../../vendor/bin/phpunit --coverage-clover=coverage.clover" - - name: "Upload code coverage" - run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" soap: strategy: @@ -151,5 +155,7 @@ jobs: - name: "Execute tests" run: "cd tests/integration/soap/ && composer update --prefer-dist --no-interaction --no-progress && ../../../vendor/bin/phpunit --coverage-clover=coverage.clover" - - name: "Upload code coverage" - run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover" + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover coverage.clover" From d65e2aa085ca5048b30e3a14042527aa9d267861 Mon Sep 17 00:00:00 2001 From: Jeroen van Oort Date: Sat, 9 Oct 2021 15:58:24 +0200 Subject: [PATCH 120/204] Major update and cleanup --- .gitignore | 3 - .php-cs-fixer.dist.php | 6 +- README.md | 2 +- composer.json | 3 +- phpstan-baseline.neon | 27 ++++ phpstan.neon | 11 +- src/VCR/Cassette.php | 79 ++---------- .../CodeTransform/AbstractCodeTransform.php | 2 + src/VCR/CodeTransform/CurlCodeTransform.php | 2 + src/VCR/CodeTransform/SoapCodeTransform.php | 2 + src/VCR/Configuration.php | 63 +-------- src/VCR/Event/AfterHttpRequestEvent.php | 20 +-- src/VCR/Event/AfterPlaybackEvent.php | 27 +--- src/VCR/Event/BeforeHttpRequestEvent.php | 13 +- src/VCR/Event/BeforePlaybackEvent.php | 19 +-- src/VCR/Event/BeforeRecordEvent.php | 27 +--- src/VCR/Event/Event.php | 2 + src/VCR/Exceptions/InvalidHostException.php | 2 + src/VCR/LibraryHooks/CurlHook.php | 85 +++---------- src/VCR/LibraryHooks/LibraryHook.php | 24 +--- src/VCR/LibraryHooks/SoapHook.php | 46 ++----- src/VCR/LibraryHooks/StreamWrapperHook.php | 40 +----- src/VCR/Request.php | 83 ++++-------- src/VCR/RequestMatcher.php | 73 +---------- src/VCR/Response.php | 40 +++--- src/VCR/Storage/AbstractStorage.php | 52 ++------ src/VCR/Storage/Blackhole.php | 2 + src/VCR/Storage/Json.php | 17 +-- src/VCR/Storage/Storage.php | 11 +- src/VCR/Storage/Yaml.php | 37 +----- src/VCR/Util/Assertion.php | 2 + src/VCR/Util/CurlException.php | 6 +- src/VCR/Util/CurlHelper.php | 10 +- src/VCR/Util/HttpClient.php | 6 +- src/VCR/Util/HttpUtil.php | 4 +- src/VCR/Util/SoapClient.php | 60 ++------- src/VCR/Util/StreamHelper.php | 6 +- src/VCR/Util/StreamProcessor.php | 37 +----- src/VCR/Util/TextUtil.php | 9 +- src/VCR/VCR.php | 2 + src/VCR/VCREvents.php | 2 + src/VCR/VCRException.php | 2 + src/VCR/VCRFactory.php | 26 +--- src/VCR/Videorecorder.php | 105 +++------------ tests/VCR/CassetteTest.php | 16 +-- .../AbstractCodeTransformTest.php | 4 +- .../CodeTransform/CurlCodeTransformTest.php | 4 +- .../CodeTransform/SoapCodeTransformTest.php | 4 +- tests/VCR/ConfigurationTest.php | 23 ++-- tests/VCR/Event/AfterHttpRequestEventTest.php | 13 +- tests/VCR/Event/AfterPlaybackEventTest.php | 15 +-- .../VCR/Event/BeforeHttpRequestEventTest.php | 11 +- tests/VCR/Event/BeforePlaybackEventTest.php | 13 +- tests/VCR/Event/BeforeRecordEventTest.php | 15 +-- tests/VCR/LibraryHooks/CurlHookTest.php | 21 +-- tests/VCR/LibraryHooks/SoapHookTest.php | 6 +- .../LibraryHooks/StreamWrapperHookTest.php | 6 +- tests/VCR/RequestMatcherTest.php | 4 +- tests/VCR/RequestTest.php | 12 +- tests/VCR/ResponseTest.php | 8 +- tests/VCR/Storage/AbstractStorageTest.php | 7 +- tests/VCR/Storage/BlackholeTest.php | 7 +- tests/VCR/Storage/JsonTest.php | 13 +- tests/VCR/Storage/YamlTest.php | 13 +- tests/VCR/Util/CurlHelperTest.php | 4 +- tests/VCR/Util/HttpClientTest.php | 4 +- tests/VCR/Util/HttpUtilTest.php | 4 +- tests/VCR/Util/SoapClientTest.php | 6 +- tests/VCR/Util/StreamHelperTest.php | 4 +- tests/VCR/Util/StreamProcessorTest.php | 7 +- tests/VCR/Util/TextUtilTest.php | 7 +- tests/VCR/VCRFactoryTest.php | 9 +- tests/VCR/VCRTest.php | 7 +- tests/VCR/VideorecorderTest.php | 7 +- tests/bootstrap.php | 2 + tests/fixtures/unittest_curl_test | 120 ++++++++++++++++++ tests/fixtures/unittest_streamwrapper_test | 62 +++++++++ .../guzzle/5/ExampleHttpClient.php | 2 + .../guzzle/6/ExampleHttpClient.php | 2 + tests/integration/guzzle/6/test/AsyncTest.php | 2 + tests/integration/guzzle/6/test/ErrorTest.php | 2 + .../VCR/Example/ExampleHttpClientTest.php | 2 + tests/integration/guzzle/test/bootstrap.php | 2 + .../src/VCR/Example/ExampleSoapClient.php | 2 + .../VCR/Example/ExampleSoapClientTest.php | 2 + tests/integration/soap/test/bootstrap.php | 2 + 86 files changed, 604 insertions(+), 969 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.gitignore b/.gitignore index 4c8dfd449..88071df64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ -*.idea* -*.sublime-* **/vendor/* coverage/* notes.md tests/fixtures/cassette* -/.php_cs.cache /.php_cs composer.lock .phpunit.result.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index cd9444abe..2733e07e9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,11 +5,9 @@ '@PSR12' => true, '@Symfony' => true, '@Symfony:risky' => true, - '@PHP73Migration' => true, - '@PHP71Migration:risky' => true, + '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, '@PHPUnit84Migration:risky' => true, - // Causes too much problems for now, fix later - 'declare_strict_types' => false, ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/README.md b/README.md index ac93babba..be1cc9da3 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ $ composer require --dev php-vcr/php-vcr PHP-VCR depends on: - * PHP 7.2+ + * PHP 8 * Curl extension * [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher) * [symfony/yaml](https://github.com/symfony/yaml) diff --git a/composer.json b/composer.json index af3e6095c..6b4b68439 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,11 @@ "symfony/event-dispatcher": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^8.4.0", + "phpunit/phpunit": "^9.5.0", "mikey179/vfsstream": "^1.6.10", "phpstan/phpstan": "^0.12.92", "phpstan/phpstan-beberlei-assert": "^0.12.0", "thecodingmachine/phpstan-strict-rules": "^0.12", - "sebastian/version": "^1.0.3|^2.0", "friendsofphp/php-cs-fixer": "^3.0", "phpstan/phpstan-phpunit": "^0.12.22", "phpstan/extension-installer": "^1.1" diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 000000000..ec2babc4b --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,27 @@ +parameters: + ignoreErrors: + - + message: "#^Access to an undefined property object\\:\\:\\$data\\.$#" + count: 2 + path: src/VCR/CodeTransform/AbstractCodeTransform.php + + - + message: "#^Access to an undefined property object\\:\\:\\$datalen\\.$#" + count: 1 + path: src/VCR/CodeTransform/AbstractCodeTransform.php + + - + message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|false given\\.$#" + count: 1 + path: src/VCR/Util/HttpUtil.php + + - + message: "#^Cannot call method record\\(\\) on VCR\\\\Cassette\\|null\\.$#" + count: 1 + path: src/VCR/Videorecorder.php + + - + message: "#^Parameter \\#3 \\$cassette of class VCR\\\\Event\\\\BeforeRecordEvent constructor expects VCR\\\\Cassette, VCR\\\\Cassette\\|null given\\.$#" + count: 1 + path: src/VCR/Videorecorder.php + diff --git a/phpstan.neon b/phpstan.neon index 10d0d03c8..4fa3f521b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,11 +1,8 @@ +includes: + - phpstan-baseline.neon + parameters: - level: 7 + level: max paths: - src - tests/VCR - ignoreErrors: - # This part of PHP is not very well documented, resulting PHPStan's definitions not being accurate - - "#Access to an undefined property object::\\$data\\.#" - - "#Access to an undefined property object::\\$datalen\\.#" - # PHPStan cannot detect that strrpos will succeed (because of Assertion above) in HttpUtil::parseStatus - - '#Parameter .* \$str(ing)? of function substr expects string, string\|false given.#' diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 8992de89b..9f7bcc708 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -1,5 +1,7 @@ $storage */ - protected $config; - - /** - * Storage used to store records and request pairs. - * - * @var Storage - */ - protected $storage; - - /** - * Creates a new cassette. - * - * @param string $name name of the cassette - * @param Configuration $config configuration to use for this cassette - * @param Storage $storage storage to use for requests and responses - * - * @throws \VCR\VCRException if cassette name is in an invalid format - */ - public function __construct(string $name, Configuration $config, Storage $storage) - { - $this->name = $name; - $this->config = $config; - $this->storage = $storage; + public function __construct( + protected string $name, + protected Configuration $config, + protected Storage $storage + ) { } - /** - * Returns true if a response was recorded for specified request. - * - * @param Request $request request to check if it was recorded - * - * @return bool true if a response was recorded for specified request - */ public function hasResponse(Request $request): bool { return null !== $this->playback($request); } - /** - * Returns a response for given request or null if not found. - * - * @param Request $request request - * - * @return Response|null response for specified request - */ public function playback(Request $request): ?Response { foreach ($this->storage as $recording) { @@ -77,48 +38,30 @@ public function playback(Request $request): ?Response return null; } - /** - * Records a request and response pair. - * - * @param Request $request request to record - * @param Response $response response to record - */ public function record(Request $request, Response $response): void { if ($this->hasResponse($request)) { return; } - $recording = [ + $this->storage->storeRecording([ 'request' => $request->toArray(), 'response' => $response->toArray(), - ]; - - $this->storage->storeRecording($recording); + ]); } - /** - * Returns the name of the current cassette. - * - * @return string current cassette name - */ public function getName(): string { return $this->name; } - /** - * Returns true if the cassette was created recently. - */ public function isNew(): bool { return $this->storage->isNew(); } /** - * Returns a list of callbacks to configured request matchers. - * - * @return callable[] list of callbacks to configured request matchers + * @return callable[] */ protected function getRequestMatchers(): array { diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 05b69dbe2..02cf23252 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -1,5 +1,7 @@ blackList = $paths; return $this; } - /** - * Returns the path to where cassettes are stored. - * - * @return string path to where cassettes are stored - */ public function getCassettePath(): string { $this->assertValidCassettePath($this->cassettePath); @@ -185,12 +168,6 @@ public function getCassettePath(): string } /** - * Sets the cassette path where a cassettes should be stored in. - * - * @param string $cassettePath path where to store cassettes - * - * @return Configuration - * * @throws VCRException if provided cassette path is invalid */ public function setCassettePath(string $cassettePath): self @@ -226,8 +203,6 @@ public function getLibraryHooks(): array * * @param string|string[] $hooks name of the LibraryHook(s) to enable * - * @return Configuration - * * @throws \InvalidArgumentException if a specified library hook doesn't exist */ public function enableLibraryHooks($hooks): self @@ -277,8 +252,6 @@ public function getRequestMatchers(): array * @param string $name name of the RequestMatcher * @param callable $callback a callback taking two Request objects as parameters and returns true if those match * - * @return Configuration - * * @throws VCRException if specified parameters are invalid */ public function addRequestMatcher(string $name, callable $callback): self @@ -294,8 +267,6 @@ public function addRequestMatcher(string $name, callable $callback): self * * @param string[] $matchers list of RequestMatcher names to enable * - * @return Configuration - * * @throws \InvalidArgumentException if a specified request matcher does not exist */ public function enableRequestMatchers(array $matchers): self @@ -310,10 +281,6 @@ public function enableRequestMatchers(array $matchers): self } /** - * Enables a storage by name. - * - * @param string $storageName name of the storage to enable - * * @throws VCRException if a invalid storage name is given */ public function setStorage(string $storageName): self @@ -325,8 +292,6 @@ public function setStorage(string $storageName): self } /** - * Returns a list of whitelisted paths. - * * @return string[] */ public function getWhiteList(): array @@ -335,32 +300,22 @@ public function getWhiteList(): array } /** - * Sets a list of paths to whitelist when processing in the StreamProcessor. - * * @param string|string[] $paths single path or list of path which are whitelisted */ public function setWhiteList($paths): self { - $paths = (\is_array($paths)) ? $paths : [$paths]; + $paths = \is_array($paths) ? $paths : [$paths]; $this->whiteList = $paths; return $this; } - /** - * Returns the current mode. - */ public function getMode(): string { return $this->mode; } - /** - * Sets the current mode. - * - * @param string $mode The mode to set VCR to - */ public function setMode(string $mode): self { Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist."); @@ -370,10 +325,6 @@ public function setMode(string $mode): self } /** - * Validates a specified cassette path. - * - * @param string $cassettePath path to a cassette - * * @throws VCRException if cassette path is invalid */ private function assertValidCassettePath(string $cassettePath): void diff --git a/src/VCR/Event/AfterHttpRequestEvent.php b/src/VCR/Event/AfterHttpRequestEvent.php index 4f0f39abf..fbbffc255 100644 --- a/src/VCR/Event/AfterHttpRequestEvent.php +++ b/src/VCR/Event/AfterHttpRequestEvent.php @@ -1,5 +1,7 @@ request = $request; - $this->response = $response; + public function __construct( + protected Request $request, + protected Response $response + ) { } public function getRequest(): Request diff --git a/src/VCR/Event/AfterPlaybackEvent.php b/src/VCR/Event/AfterPlaybackEvent.php index 56a4f4589..67e387a57 100644 --- a/src/VCR/Event/AfterPlaybackEvent.php +++ b/src/VCR/Event/AfterPlaybackEvent.php @@ -1,5 +1,7 @@ request = $request; - $this->response = $response; - $this->cassette = $cassette; + public function __construct( + protected Request $request, + protected Response $response, + protected Cassette $cassette + ) { } public function getRequest(): Request diff --git a/src/VCR/Event/BeforeHttpRequestEvent.php b/src/VCR/Event/BeforeHttpRequestEvent.php index 585f8bb1a..0f56dd262 100644 --- a/src/VCR/Event/BeforeHttpRequestEvent.php +++ b/src/VCR/Event/BeforeHttpRequestEvent.php @@ -1,19 +1,16 @@ request = $request; + public function __construct( + protected Request $request + ) { } public function getRequest(): Request diff --git a/src/VCR/Event/BeforePlaybackEvent.php b/src/VCR/Event/BeforePlaybackEvent.php index 2e9e009dc..f82d83321 100644 --- a/src/VCR/Event/BeforePlaybackEvent.php +++ b/src/VCR/Event/BeforePlaybackEvent.php @@ -1,5 +1,7 @@ request = $request; - $this->cassette = $cassette; + public function __construct( + protected Request $request, + protected Cassette $cassette + ) { } public function getRequest(): Request diff --git a/src/VCR/Event/BeforeRecordEvent.php b/src/VCR/Event/BeforeRecordEvent.php index 447c657d2..ffbf4668a 100644 --- a/src/VCR/Event/BeforeRecordEvent.php +++ b/src/VCR/Event/BeforeRecordEvent.php @@ -1,5 +1,7 @@ request = $request; - $this->response = $response; - $this->cassette = $cassette; + public function __construct( + protected Request $request, + protected Response $response, + protected Cassette $cassette + ) { } public function getRequest(): Request diff --git a/src/VCR/Event/Event.php b/src/VCR/Event/Event.php index afb917268..e6bb0c02a 100644 --- a/src/VCR/Event/Event.php +++ b/src/VCR/Event/Event.php @@ -1,5 +1,7 @@ additional curl options, which are not stored within a request */ - protected static $curlOptions = []; + protected static array $curlOptions = []; /** * @var array all curl handles which belong to curl_multi handles */ - protected static $multiHandles = []; + protected static array $multiHandles = []; /** * @var array last active curl_multi_exec() handles */ - protected static $multiExecLastChs = []; + protected static array $multiExecLastChs = []; /** * @var array return values of curl_multi responses */ - protected static $multiReturnValues = []; + protected static array $multiReturnValues = []; /** * @var CurlException[] last cURL error, as a CurlException */ - protected static $lastErrors = []; + protected static array $lastErrors = []; - /** - * @var AbstractCodeTransform - */ - private $codeTransformer; - - /** - * @var StreamProcessor - */ - private $processor; - - /** - * Creates a new cURL hook instance. - * - * @throws \BadMethodCallException in case the cURL extension is not installed - */ - public function __construct(AbstractCodeTransform $codeTransformer, StreamProcessor $processor) - { - if (!\function_exists('curl_version')) { - // @codeCoverageIgnoreStart - throw new \BadMethodCallException('cURL extension not installed, please disable the cURL library hook'); - // @codeCoverageIgnoreEnd - } - $this->processor = $processor; - $this->codeTransformer = $codeTransformer; + public function __construct( + private AbstractCodeTransform $codeTransformer, + private StreamProcessor $processor + ) { } /** @@ -93,8 +67,6 @@ public function __construct(AbstractCodeTransform $codeTransformer, StreamProces */ public function enable(\Closure $requestCallback): void { - Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); - if (self::ENABLED == static::$status) { return; } @@ -113,10 +85,6 @@ public function enable(\Closure $requestCallback): void */ public function disable(): void { - if (self::DISABLED == static::$status) { - return; - } - self::$requestCallback = null; static::$status = self::DISABLED; @@ -226,11 +194,8 @@ public static function curlExec(CurlHandle $curlHandle) * Add a normal cURL handle to a cURL multi handle. * * @see http://www.php.net/manual/en/function.curl-multi-add-handle.php - * - * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() - * @param resource $curlHandle a cURL handle returned by curl_init() */ - public static function curlMultiAddHandle($multiHandle, $curlHandle): void + public static function curlMultiAddHandle(CurlMultiHandle $multiHandle, CurlHandle $curlHandle): void { if (!isset(self::$multiHandles[(int) $multiHandle])) { self::$multiHandles[(int) $multiHandle] = []; @@ -243,11 +208,8 @@ public static function curlMultiAddHandle($multiHandle, $curlHandle): void * Remove a multi handle from a set of cURL handles. * * @see http://www.php.net/manual/en/function.curl-multi-remove-handle.php - * - * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() - * @param resource $curlHandle a cURL handle returned by curl_init() */ - public static function curlMultiRemoveHandle($multiHandle, $curlHandle): void + public static function curlMultiRemoveHandle(CurlMultiHandle $multiHandle, CurlHandle $curlHandle): void { if (isset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle])) { unset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle]); @@ -258,13 +220,8 @@ public static function curlMultiRemoveHandle($multiHandle, $curlHandle): void * Run the sub-connections of the current cURL handle. * * @see http://www.php.net/manual/en/function.curl-multi-exec.php - * - * @param resource $multiHandle a cURL multi handle returned by curl_multi_init() - * @param int $stillRunning a reference to a flag to tell whether the operations are still running - * - * @return int a cURL code defined in the cURL Predefined Constants */ - public static function curlMultiExec($multiHandle, ?int &$stillRunning): int + public static function curlMultiExec(CurlMultiHandle $multiHandle, ?int &$stillRunning): int { if (isset(self::$multiHandles[(int) $multiHandle])) { foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { @@ -305,11 +262,9 @@ public static function curlMultiInfoRead() * * @see https://www.php.net/manual/en/function.curl-multi-getcontent.php * - * @param resource $curlHandle - * * @return string|null return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set */ - public static function curlMultiGetcontent($curlHandle): ?string + public static function curlMultiGetcontent(CurlHandle $curlHandle): ?string { return self::$multiReturnValues[(int) $curlHandle] ?? null; } diff --git a/src/VCR/LibraryHooks/LibraryHook.php b/src/VCR/LibraryHooks/LibraryHook.php index 0806dfb24..277f00e4b 100644 --- a/src/VCR/LibraryHooks/LibraryHook.php +++ b/src/VCR/LibraryHooks/LibraryHook.php @@ -1,42 +1,22 @@ processor = $processor; - $this->codeTransformer = $codeTransformer; } /** @@ -92,7 +72,6 @@ public function doRequest(string $request, string $location, string $action, int */ public function enable(\Closure $requestCallback): void { - Assertion::isCallable($requestCallback, 'No valid callback for handling requests defined.'); self::$requestCallback = $requestCallback; if (self::ENABLED == $this->status) { @@ -111,10 +90,6 @@ public function enable(\Closure $requestCallback): void */ public function disable(): void { - if (!$this->isEnabled()) { - return; - } - self::$requestCallback = null; $this->status = self::DISABLED; @@ -128,11 +103,6 @@ public function isEnabled(): bool return self::ENABLED == $this->status; } - /** - * Cleanup. - * - * @return void - */ public function __destruct() { self::$requestCallback = null; diff --git a/src/VCR/LibraryHooks/StreamWrapperHook.php b/src/VCR/LibraryHooks/StreamWrapperHook.php index 19f9758a1..77e17b85a 100644 --- a/src/VCR/LibraryHooks/StreamWrapperHook.php +++ b/src/VCR/LibraryHooks/StreamWrapperHook.php @@ -1,5 +1,7 @@ response->getBody(), $this->position, $count); + $ret = substr($this->response->getBody(), $this->position ?? 0, $count); $this->position += \strlen($ret); return $ret; } /** - * Write to stream. - * * @throws \BadMethodCallException if called, because this method is not applicable for this stream * * @see http://www.php.net/manual/en/streamwrapper.stream-write.php - * - * @param string $data should be stored into the underlying stream */ public function stream_write(string $data): int { @@ -138,8 +123,6 @@ public function stream_write(string $data): int * This method is called in response to fseek() to determine the current position. * * @see http://www.php.net/manual/en/streamwrapper.stream-tell.php - * - * @return int should return the current position of the stream */ public function stream_tell(): int { @@ -150,9 +133,6 @@ public function stream_tell(): int * Tests for end-of-file on a file pointer. * * @see http://www.php.net/manual/en/streamwrapper.stream-eof.php - * - * @return bool should return TRUE if the read/write position is at the end of the stream - * and if no more data is available to be read, or FALSE otherwise */ public function stream_eof(): bool { @@ -223,15 +203,9 @@ public function stream_seek(int $offset, int $whence): bool } /** - * Change stream options. - * * @see http://www.php.net/manual/en/streamwrapper.stream-metadata.php * - * @param string $path the file path or URL to set metadata - * @param int $option one of the stream options - * @param mixed $var value depending on the option - * - * @return bool returns TRUE on success or FALSE on failure + * @param mixed $var value depending on the option */ public function stream_metadata(string $path, int $option, $var): bool { diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 05cf499cf..01b680afe 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -1,5 +1,7 @@ - */ - protected $headers = []; - /** - * @var string|null - */ - protected $body; + protected ?string $body = null; + /** * @var array> */ - protected $postFiles = []; + protected array $postFiles = []; + /** * @var array */ - protected $postFields = []; + protected array $postFields = []; + /** * @var array */ - protected $curlOptions = []; + protected array $curlOptions = []; /** * @param array $headers */ - public function __construct(string $method, ?string $url, array $headers = []) - { + public function __construct( + protected string $method, + protected ?string $url, + protected array $headers = [] + ) { $this->method = $method; $this->headers = $headers; $this->setUrl($url); } /** - * Returns true if specified request matches the current one - * with specified request matcher callbacks. - * - * @param Request $request request to check if it matches the current one * @param callable[] $requestMatchers request matcher callbacks * * @throws \BadFunctionCallException if one of the specified request matchers is not callable - * - * @return bool true if specified request matches the current one */ public function matches(self $request, array $requestMatchers): bool { @@ -76,31 +63,23 @@ public function matches(self $request, array $requestMatchers): bool } /** - * Returns an array representation of this request. - * - * @return array array representation of this request + * @return array */ public function toArray(): array { - return array_filter( - [ - 'method' => $this->getMethod(), - 'url' => $this->getUrl(), - 'headers' => $this->getHeaders(), - 'body' => $this->getBody(), - 'post_files' => $this->getPostFiles(), - 'post_fields' => $this->getPostFields(), - ] - ); + return array_filter([ + 'method' => $this->getMethod(), + 'url' => $this->getUrl(), + 'headers' => $this->getHeaders(), + 'body' => $this->getBody(), + 'post_files' => $this->getPostFiles(), + 'post_fields' => $this->getPostFields(), + ]); } /** - * Creates a new Request from a specified array. - * * @param array $request Request represented as an array. Allowed keys: "method", "url", "headers", * "post_fields", "post_files", "body" - * - * @return Request a new Request from specified array */ public static function fromArray(array $request): self { @@ -150,7 +129,7 @@ public function getMethod(): string } /** - * @return array + * @return array */ public function getHeaders(): array { @@ -210,9 +189,6 @@ public function getHost(): string return $host; } - /** - * @return string - */ public function getPath(): ?string { $url = $this->getUrl(); @@ -253,11 +229,6 @@ public function getCurlOption(int $key) return $this->curlOptions[$key]; } - /** - * Sets the request method. - * - * @param string $method HTTP request method like GET, POST, PUT, ... - */ public function setMethod(string $method): void { $this->method = strtoupper($method); @@ -284,12 +255,6 @@ public function setBody(?string $body): void $this->body = $body; } - /** - * Sets the authorization credentials as header. - * - * @param string $username username - * @param string $password password - */ public function setAuthorization(string $username, string $password): void { $this->setHeader('Authorization', 'Basic '.base64_encode($username.':'.$password)); diff --git a/src/VCR/RequestMatcher.php b/src/VCR/RequestMatcher.php index fff0a0b0c..05d85a299 100644 --- a/src/VCR/RequestMatcher.php +++ b/src/VCR/RequestMatcher.php @@ -1,59 +1,26 @@ getMethod() == $request->getMethod(); } - /** - * Returns true if the url of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the url of both specified requests match - */ public static function matchUrl(Request $storedRequest, Request $request): bool { return $storedRequest->getPath() === $request->getPath(); } - /** - * Returns true if the host of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the host of both specified requests match - */ public static function matchHost(Request $storedRequest, Request $request): bool { return $storedRequest->getHost() === $request->getHost(); } - /** - * Returns true if the headers of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the headers of both specified requests match - */ public static function matchHeaders(Request $storedRequest, Request $request): bool { // Use array_filter to ignore headers which are null. @@ -61,55 +28,27 @@ public static function matchHeaders(Request $storedRequest, Request $request): b return array_filter($storedRequest->getHeaders()) === array_filter($request->getHeaders()); } - /** - * Returns true if the body of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the body of both specified requests match - */ public static function matchBody(Request $storedRequest, Request $request): bool { return $storedRequest->getBody() === $request->getBody(); } - /** - * Returns true if the post fields of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the post fields of both specified requests match - */ public static function matchPostFields(Request $storedRequest, Request $request): bool { return $storedRequest->getPostFields() === $request->getPostFields(); } - /** - * Returns true if the query string of both specified requests match. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the query string of both specified requests match - */ public static function matchQueryString(Request $storedRequest, Request $request): bool { return $storedRequest->getQuery() === $request->getQuery(); } - /** - * Returns true if the SOAP operation of both specified requests match, or if the request is not a SOAP request. - * - * @param Request $storedRequest first request to match, coming from the cassette - * @param Request $request second request to match, the request performed by the user - * - * @return bool true if the query string of both specified requests match - */ public static function matchSoapOperation(Request $storedRequest, Request $request): bool { + if (null === $request->getBody() || null === $storedRequest->getBody()) { + return true; + } + $soapOperationRequest = preg_match('/<(.*?)>/m', $request->getBody(), $matches); if (empty($matches)) { // The request is not a SOAP request diff --git a/src/VCR/Response.php b/src/VCR/Response.php index 0618504b9..6bd342159 100644 --- a/src/VCR/Response.php +++ b/src/VCR/Response.php @@ -1,5 +1,7 @@ - */ - protected $status = [ - 'code' => null, - 'message' => '', - ]; + protected int $statusCode; + + protected string $statusMessage = ''; /** * @var array @@ -57,15 +55,24 @@ public function toArray(): array { $body = $this->getBody(); // Base64 encode when binary - if (false !== strpos($this->getContentType(), 'application/x-gzip') - || 'binary' == $this->getHeader('Content-Transfer-Encoding') + if ( + null !== $this->getContentType() + && + ( + str_contains($this->getContentType(), 'application/x-gzip') + || + 'binary' == $this->getHeader('Content-Transfer-Encoding') + ) ) { $body = base64_encode($body); } return array_filter( [ - 'status' => $this->status, + 'status' => [ + 'code' => $this->statusCode, + 'message' => $this->statusMessage, + ], 'headers' => $this->getHeaders(), 'body' => $body, 'curl_info' => $this->curlInfo, @@ -85,7 +92,7 @@ public static function fromArray(array $response): self $body = $response['body'] ?? null; $gzip = isset($response['headers']['Content-Type']) - && false !== strpos($response['headers']['Content-Type'], 'application/x-gzip'); + && str_contains($response['headers']['Content-Type'], 'application/x-gzip'); $binary = isset($response['headers']['Content-Transfer-Encoding']) && 'binary' == $response['headers']['Content-Transfer-Encoding']; @@ -131,9 +138,9 @@ public function getHeaders(): array return $this->headers; } - public function getStatusCode(): string + public function getStatusCode(): int { - return $this->status['code']; + return $this->statusCode; } public function getContentType(): ?string @@ -160,7 +167,7 @@ public function getHttpVersion() public function getStatusMessage(): string { - return $this->status['message']; + return $this->statusMessage; } /** @@ -169,13 +176,14 @@ public function getStatusMessage(): string protected function setStatus($status): void { if (\is_array($status)) { - $this->status = $status; + $this->statusCode = (int) $status['code']; + $this->statusMessage = $status['message']; if (!empty($status['http_version'])) { $this->httpVersion = $status['http_version']; } } else { Assertion::numeric($status, 'Response status must be either an array or a number.'); - $this->status['code'] = $status; + $this->statusCode = (int) $status; } } } diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index 2df29668e..e3658bb30 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -1,5 +1,7 @@ |null current parsed record */ - protected $current; + protected ?array $current = null; - /** - * @var int number of the current recording - */ - protected $position = 0; + protected int $position = 0; - /** - * @var bool true when parser is at the end of the file - */ - protected $isEOF = false; + protected bool $isEOF = false; - /** - * @var bool if the cassette file is new - */ - protected $isNew = false; + protected bool $isNew = false; - /** - * @var bool if the current position is valid - */ - protected $isValidPosition = true; + protected bool $isValidPosition = true; /** - * Creates a new file store. - * * If the cassetteName contains PATH_SEPARATORs, subfolders of the * cassettePath are autocreated when not existing. - * - * @param string $cassettePath path to the cassette directory - * @param string $cassetteName path to the cassette file, relative to the path - * @param string $defaultContent Default data for this cassette if its not existing */ public function __construct(string $cassettePath, string $cassetteName, string $defaultContent = '[]') { @@ -92,29 +73,16 @@ public function current() return $this->current; } - /** - * Returns the current key. - * - * @return int - */ - public function key() + public function key(): int { return $this->position; } - /** - * Returns true if the file did not exist and had to be created. - * - * @return bool TRUE if created, FALSE if not - */ public function isNew(): bool { return $this->isNew; } - /** - * Closes file handle. - */ public function __destruct() { if (\is_resource($this->handle)) { diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index 12503e47d..b413fe2af 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -1,5 +1,7 @@ handle); } - /** - * Parses the next record. - */ public function next(): void { $this->current = json_decode($this->readNextRecord(), true); @@ -39,8 +38,6 @@ public function next(): void /** * Returns the next record in raw format. - * - * @return string next record in raw format */ protected function readNextRecord(): string { @@ -76,9 +73,6 @@ protected function readNextRecord(): string return $record; } - /** - * Resets the storage to the beginning. - */ public function rewind(): void { rewind($this->handle); @@ -86,12 +80,7 @@ public function rewind(): void $this->position = 0; } - /** - * Returns true if the current record is valid. - * - * @return bool true if the current record is valid - */ - public function valid() + public function valid(): bool { if (null === $this->current) { $this->next(); diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index 7357dccc2..4182f33e2 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -1,5 +1,7 @@ |null> $recording array to store in storage + * @param array|null> $recording */ public function storeRecording(array $recording): void; - /** - * Returns true if the file did not exist and had to be created. - * - * @return bool TRUE if created, FALSE if not - */ public function isNew(): bool; } diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index 5af665db1..ed6be615b 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -1,5 +1,7 @@ handle); } - /** - * Parses the next record. - */ public function next(): void { $recording = $this->yamlParser->parse($this->readNextRecord()); @@ -61,8 +46,6 @@ public function next(): void /** * Returns the next record in raw format. - * - * @return string next record in raw format */ private function readNextRecord(): string { @@ -74,7 +57,7 @@ private function readNextRecord(): string $recording = ''; while (false !== ($line = fgets($this->handle))) { - $isNewArrayStart = 0 === strpos($line, '-'); + $isNewArrayStart = str_starts_with($line, '-'); if ($isInRecord && $isNewArrayStart) { fseek($this->handle, -\strlen($line), \SEEK_CUR); @@ -97,9 +80,6 @@ private function readNextRecord(): string return $recording; } - /** - * Resets the storage to the beginning. - */ public function rewind(): void { rewind($this->handle); @@ -108,11 +88,6 @@ public function rewind(): void $this->position = 0; } - /** - * Returns true if the current record is valid. - * - * @return bool true if the current record is valid - */ public function valid() { if (null === $this->current) { diff --git a/src/VCR/Util/Assertion.php b/src/VCR/Util/Assertion.php index 3cbac5372..522da3a87 100644 --- a/src/VCR/Util/Assertion.php +++ b/src/VCR/Util/Assertion.php @@ -1,5 +1,7 @@ */ - private $info; + private array $info; public static function create(CurlHandle $ch): self { @@ -20,8 +22,6 @@ public static function create(CurlHandle $ch): self } /** - * Returns the curl_info array. - * * @return array */ public function getInfo(): array diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 77d03d269..2b6b6c1f3 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -1,14 +1,13 @@ > $headers Headers as key/value pairs + * @param array|null> $headers Headers as key/value pairs * * @return string[] List of headers ['Content-Type: text/html', '...']. */ diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index b257bf134..0780795a4 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -1,5 +1,7 @@ */ - protected $options = []; + protected array $options = []; - /** - * @var string - */ - protected $response; + protected string $response; - /** - * @var string - */ - protected $request; + protected string $request; /** * @param mixed $wsdl @@ -44,30 +37,20 @@ public function __construct($wsdl, array $options = []) * Performs (and may intercepts) SOAP request over HTTP. * * Requests will be intercepted if the library hook is enabled. - * - * @param string $request the XML SOAP request - * @param string $location the URL to request - * @param string $action the SOAP action - * @param int $version the SOAP version - * - * @return string|null the XML SOAP response (or null if $one_way is set) */ - public function __doRequest($request, $location, $action, $version, bool $one_way = false) + public function __doRequest(string $request, string $location, string $action, int $version, bool $one_way = false): ?string { - // Save a copy of the request, not the request itself -- see issue #153 - $this->request = (string) $request; + $this->request = $request; $soapHook = $this->getLibraryHook(); if ($soapHook->isEnabled()) { - $response = $soapHook->doRequest($request, $location, $action, $version, $one_way, $this->options); + $this->response = $soapHook->doRequest($request, $location, $action, $version, $one_way, $this->options); } else { - $response = $this->realDoRequest($request, $location, $action, $version, $one_way); + $this->response = $this->realDoRequest($request, $location, $action, $version, $one_way); } - $this->response = $response; - - return $one_way ? null : $response; + return $one_way ? null : $this->response; } /** @@ -75,7 +58,7 @@ public function __doRequest($request, $location, $action, $version, bool $one_wa */ public function __getLastRequest(): ?string { - return $this->request; + return $this->request ?? null; } /** @@ -83,37 +66,22 @@ public function __getLastRequest(): ?string */ public function __getLastResponse(): ?string { - return $this->response; + return $this->response ?? null; } - /** - * Sets the SOAP library hook which is used to intercept SOAP requests. - * - * @param soapHook $hook SOAP library hook to use when intercepting SOAP requests - */ public function setLibraryHook(SoapHook $hook): void { $this->soapHook = $hook; } - /** - * Performs a real SOAP request over HTTP. - * - * @codeCoverageIgnore - */ protected function realDoRequest(string $request, string $location, string $action, int $version, bool $one_way = false): string { return parent::__doRequest($request, $location, $action, $version, $one_way); } - /** - * Returns currently used SOAP library hook. - * - * If no library hook is set, a new one is created. - */ protected function getLibraryHook(): SoapHook { - if (empty($this->soapHook)) { + if (!isset($this->soapHook)) { $this->soapHook = VCRFactory::get('VCR\LibraryHooks\SoapHook'); } diff --git a/src/VCR/Util/StreamHelper.php b/src/VCR/Util/StreamHelper.php index 6468c2103..a10c4b351 100644 --- a/src/VCR/Util/StreamHelper.php +++ b/src/VCR/Util/StreamHelper.php @@ -1,5 +1,7 @@ normalizePath($uri); foreach ($whiteList as $path) { - if (false !== strpos($uri, $path)) { + if (str_contains($uri, $path)) { return true; } } @@ -121,7 +114,7 @@ protected function isBlacklisted(string $uri): bool $uri = $this->normalizePath($uri); foreach (static::$configuration->getBlackList() as $path) { - if (false !== strpos($uri, $path)) { + if (str_contains($uri, $path)) { return true; } } @@ -142,19 +135,6 @@ protected function shouldProcess(string $uri): bool return $this->isWhitelisted($uri) && !$this->isBlacklisted($uri) && $this->isPhpFile($uri); } - /** - * Opens a stream and attaches registered filters. - * - * @param string $path specifies the URL that was passed to the original function - * @param string $mode the mode used to open the file, as detailed for fopen() - * @param int $options Holds additional flags set by the streams API. - * It can hold one or more of the following values OR'd together. - * @param string $openedPath if the path is opened successfully, and STREAM_USE_PATH is set in options, - * opened_path should be set to the full path of the file/resource that was - * actually opened - * - * @return bool returns TRUE on success or FALSE on failure - */ public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool { // file_exists catches paths like /dev/urandom that are missed by is_file. @@ -197,9 +177,6 @@ public function stream_close(): bool * Tests for end-of-file on a file pointer. * * @see http://www.php.net/manual/en/streamwrapper.stream-eof.php - * - * @return bool should return TRUE if the read/write position is at the end of the stream - * and if no more data is available to be read, or FALSE otherwise */ public function stream_eof(): bool { diff --git a/src/VCR/Util/TextUtil.php b/src/VCR/Util/TextUtil.php index ee7b6e995..0a87bf52f 100644 --- a/src/VCR/Util/TextUtil.php +++ b/src/VCR/Util/TextUtil.php @@ -1,20 +1,15 @@ curlMultiExec - * - * @param string $underscore lowercased text - * - * @return string lowercase camelcased version of specified text */ public static function underscoreToLowerCamelcase(string $underscore): string { diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index 70e2db77b..843a821fe 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -1,5 +1,7 @@ @@ -24,18 +23,9 @@ class VCRFactory */ protected static $instance; - /** - * Creates a new VCRFactory instance. - * - * @param Configuration $config - */ protected function __construct(Configuration $config = null) { $this->config = $config ?: $this->getOrCreate('VCR\Configuration'); - - // This constant exists only from PHP 7.3 - // Once we are no longer supporting 7.2, we can remove this - \defined('CURLPROXY_HTTPS') || \define('CURLPROXY_HTTPS', 2); } protected function createVCRVideorecorder(): Videorecorder @@ -47,9 +37,6 @@ protected function createVCRVideorecorder(): Videorecorder ); } - /** - * Provides an instance of the StreamProcessor. - */ protected function createVCRUtilStreamProcessor(): StreamProcessor { return new StreamProcessor($this->config); @@ -80,13 +67,6 @@ protected function createVCRLibraryHooksCurlHook(): CurlHook ); } - /** - * Returns the same VCRFactory instance on ever call (singleton). - * - * @param Configuration $config (Optional) configuration - * - * @return VCRFactory - */ public static function getInstance(Configuration $config = null): self { if (!self::$instance) { diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 40b60555d..265fb417e 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -1,5 +1,7 @@ config = $config; - $this->client = $client; - $this->factory = $factory; + public function __construct( + protected Configuration $config, + protected HttpClient $client, + protected VCRFactory $factory + ) { } public function setEventDispatcher(EventDispatcherInterface $dispatcher): void @@ -80,20 +51,14 @@ public function setEventDispatcher(EventDispatcherInterface $dispatcher): void public function getEventDispatcher(): EventDispatcherInterface { - if (!$this->eventDispatcher) { + if (!isset($this->eventDispatcher)) { $this->eventDispatcher = new EventDispatcher(); } return $this->eventDispatcher; } - /** - * Dispatches an event to all registered listeners. - * - * @param Event $event the event to pass to the event handlers/listeners - * @param string $eventName the name of the event to dispatch - */ - private function dispatch(Event $event, $eventName = null): Event + private function dispatch(Event $event, string $eventName = null): Event { $res = $this->getEventDispatcher()->dispatch($event, $eventName); @@ -103,10 +68,6 @@ private function dispatch(Event $event, $eventName = null): Event } /** - * Turns on this videorecorder. - * - * This enables configured library hooks. - * * @api */ public function turnOn(): void @@ -120,10 +81,6 @@ public function turnOn(): void } /** - * Turns off this videorecorder. - * - * Library hooks will be disabled and cassettes ejected. - * * @api */ public function turnOff(): void @@ -136,10 +93,6 @@ public function turnOff(): void } /** - * Eject the currently inserted cassette. - * - * Recording and playing back requests won't be possible after ejecting. - * * @api */ public function eject(): void @@ -149,13 +102,7 @@ public function eject(): void } /** - * Inserts a cassette to record responses and requests on. - * * @api - * - * @param string $cassetteName name of the cassette (used for the cassette filename) - * - * @throws VCRException if videorecorder is turned off when inserting a cassette */ public function insertCassette(string $cassetteName): void { @@ -172,11 +119,7 @@ public function insertCassette(string $cassetteName): void } /** - * Returns the current Configuration for this videorecorder. - * * @api - * - * @return Configuration configuration for this videorecorder */ public function configure(): Configuration { @@ -190,14 +133,10 @@ public function configure(): Configuration * otherwise the request is issued and it's response recorded (and returned). * * @api + * - * @param Request $request intercepted request - * - * @return Response response for the intercepted request - * - * @throws \BadMethodCallException if there was no cassette inserted - * @throws \LogicException if the mode is set to none or once and - * the cassette did not have a matching response + * @throws \LogicException if the mode is set to none or once and + * the cassette did not have a matching response */ public function handleRequest(Request $request): Response { @@ -205,15 +144,13 @@ public function handleRequest(Request $request): Response throw new \BadMethodCallException('Invalid http request. No cassette inserted. '.'Please make sure to insert a cassette in your unit test using '."VCR::insertCassette('name');"); } - $event = new BeforePlaybackEvent($request, $this->cassette); - $this->dispatch($event, VCREvents::VCR_BEFORE_PLAYBACK); + $this->dispatch(new BeforePlaybackEvent($request, $this->cassette), VCREvents::VCR_BEFORE_PLAYBACK); $response = $this->cassette->playback($request); // Playback succeeded and the recorded response can be returned. if (!empty($response)) { - $event = new AfterPlaybackEvent($request, $response, $this->cassette); - $this->dispatch($event, VCREvents::VCR_AFTER_PLAYBACK); + $this->dispatch(new AfterPlaybackEvent($request, $response, $this->cassette), VCREvents::VCR_AFTER_PLAYBACK); return $response; } @@ -242,8 +179,6 @@ public function handleRequest(Request $request): Response } /** - * Disables all library hooks. - * * @api */ protected function disableLibraryHooks(): void @@ -255,8 +190,6 @@ protected function disableLibraryHooks(): void } /** - * Enables configured library hooks. - * * @api */ protected function enableLibraryHooks(): void @@ -265,9 +198,7 @@ protected function enableLibraryHooks(): void foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); $hook->enable( - function (Request $request) use ($self) { - return $self->handleRequest($request); - } + fn (Request $request) => $self->handleRequest($request) ); } } diff --git a/tests/VCR/CassetteTest.php b/tests/VCR/CassetteTest.php index fa6b47779..c49104ef6 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/VCR/CassetteTest.php @@ -1,19 +1,15 @@ cassette->record($request, $response1); $this->cassette->record($request, $response2); - $this->assertEquals($response1->toArray(), $this->cassette->playback($request)->toArray()); + $this->assertEquals($response1->toArray(), $this->cassette->playback($request)?->toArray()); } public function testPlaybackAlreadyRecordedRequest(): void @@ -43,7 +39,7 @@ public function testPlaybackAlreadyRecordedRequest(): void $response = new Response('200', [], 'sometest'); $this->cassette->record($request, $response); - $this->assertEquals($response->toArray(), $this->cassette->playback($request)->toArray()); + $this->assertEquals($response->toArray(), $this->cassette->playback($request)?->toArray()); } public function testHasResponseNotFound(): void diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php index 379dfa521..99d69e885 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/VCR/CodeTransform/AbstractCodeTransformTest.php @@ -1,11 +1,13 @@ expectException(\VCR\VCRException::class); $this->expectExceptionMessage("A request matchers name must be at least one character long. Found ''"); - $expected = function ($first, $second) { - return true; - }; + $expected = fn ($first, $second) => true; $this->config->addRequestMatcher('', $expected); } public function testAddRequestMatchers(): void { - $expected = function () { - return true; - }; + $expected = fn () => true; $this->config->addRequestMatcher('new_matcher', $expected); $this->assertContains($expected, $this->config->getRequestMatchers()); } @@ -134,9 +129,9 @@ public function testSetStorageInvalidName(): void public function testGetStorage(): void { $class = $this->config->getStorage(); - $this->assertContains('Iterator', class_implements($class)); - $this->assertContains('Traversable', class_implements($class)); - $this->assertContains('VCR\Storage\AbstractStorage', class_parents($class)); + $this->assertContains('Iterator', (array) class_implements($class)); + $this->assertContains('Traversable', (array) class_implements($class)); + $this->assertContains('VCR\Storage\AbstractStorage', (array) class_parents($class)); } public function testWhitelist(): void diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/VCR/Event/AfterHttpRequestEventTest.php index 283ffea71..38064c294 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/VCR/Event/AfterHttpRequestEventTest.php @@ -1,17 +1,16 @@ assertInstanceOf('VCR\Request', $this->event->getRequest()); + $this->assertInstanceOf(Request::class, $this->event->getRequest()); } public function testGetResponse(): void { - $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); + $this->assertInstanceOf(Response::class, $this->event->getResponse()); } } diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/VCR/Event/AfterPlaybackEventTest.php index b365991e8..2e6b0f482 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/VCR/Event/AfterPlaybackEventTest.php @@ -1,5 +1,7 @@ assertInstanceOf('VCR\Request', $this->event->getRequest()); + $this->assertInstanceOf(Request::class, $this->event->getRequest()); } public function testGetResponse(): void { - $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); + $this->assertInstanceOf(Response::class, $this->event->getResponse()); } public function testGetCassette(): void { - $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); + $this->assertInstanceOf(Cassette::class, $this->event->getCassette()); } } diff --git a/tests/VCR/Event/BeforeHttpRequestEventTest.php b/tests/VCR/Event/BeforeHttpRequestEventTest.php index 09a66c72d..edafd283a 100644 --- a/tests/VCR/Event/BeforeHttpRequestEventTest.php +++ b/tests/VCR/Event/BeforeHttpRequestEventTest.php @@ -1,16 +1,15 @@ assertInstanceOf('VCR\Request', $this->event->getRequest()); + $this->assertInstanceOf(Request::class, $this->event->getRequest()); } } diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/VCR/Event/BeforePlaybackEventTest.php index 580a7a55a..d6c8d0b45 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/VCR/Event/BeforePlaybackEventTest.php @@ -1,5 +1,7 @@ assertInstanceOf('VCR\Request', $this->event->getRequest()); + $this->assertInstanceOf(Request::class, $this->event->getRequest()); } public function testGetCassette(): void { - $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); + $this->assertInstanceOf(Cassette::class, $this->event->getCassette()); } } diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/VCR/Event/BeforeRecordEventTest.php index 3259a8a85..66d117f48 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/VCR/Event/BeforeRecordEventTest.php @@ -1,5 +1,7 @@ assertInstanceOf('VCR\Request', $this->event->getRequest()); + $this->assertInstanceOf(Request::class, $this->event->getRequest()); } public function testGetResponse(): void { - $this->assertInstanceOf('VCR\Response', $this->event->getResponse()); + $this->assertInstanceOf(Response::class, $this->event->getResponse()); } public function testGetCassette(): void { - $this->assertInstanceOf('VCR\Cassette', $this->event->getCassette()); + $this->assertInstanceOf(Cassette::class, $this->event->getCassette()); } } diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/VCR/LibraryHooks/CurlHookTest.php index 83f136562..d5459fb69 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/VCR/LibraryHooks/CurlHookTest.php @@ -1,5 +1,7 @@ expected); - }); + return Closure::fromCallable(fn () => new Response($statusCode, [], $testClass->expected)); } } diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/VCR/LibraryHooks/SoapHookTest.php index c2b8036ba..1b4633677 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/VCR/LibraryHooks/SoapHookTest.php @@ -1,5 +1,7 @@ expected); - }); + return Closure::fromCallable(fn () => new Response('200', [], $testClass->expected)); } /** @param array $expectedHeaders */ diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php index 737cc8fac..320b96255 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/VCR/LibraryHooks/StreamWrapperHookTest.php @@ -1,5 +1,7 @@ enable(function ($request) { - return new Response('200', [], 'A Test'); - }); + $hook->enable(fn ($request) => new Response('200', [], 'A Test')); $hook->stream_open('http://example.com', 'r', 0, $openedPath); $this->assertFalse($hook->stream_seek(-1, \SEEK_SET)); diff --git a/tests/VCR/RequestMatcherTest.php b/tests/VCR/RequestMatcherTest.php index a09a123ec..eed32768b 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/VCR/RequestMatcherTest.php @@ -1,10 +1,12 @@ [ - 'http_version' => '1.1', 'code' => 200, 'message' => 'OK', ], diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/VCR/Storage/AbstractStorageTest.php index 2e158a8d0..f049cdc92 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/VCR/Storage/AbstractStorageTest.php @@ -1,15 +1,14 @@ getMockBuilder('\VCR\Util\SoapClient') + $client = $this->getMockBuilder(SoapClient::class) ->disableOriginalConstructor() ->setMethods(['realDoRequest']) ->getMock(); diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/VCR/Util/StreamHelperTest.php index a67d8ac4e..658dc3ae8 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/VCR/Util/StreamHelperTest.php @@ -1,11 +1,13 @@ */ public function streamContexts(): array diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/VCR/Util/StreamProcessorTest.php index db3f82525..74889bbfc 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/VCR/Util/StreamProcessorTest.php @@ -1,12 +1,13 @@ expectException(Warning::class); + $this->expectWarning(); $processor->url_stat('file_not_found', 0); } diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/VCR/Util/TextUtilTest.php index 9283d0a71..b19f759b5 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/VCR/Util/TextUtilTest.php @@ -1,13 +1,12 @@ setStorage($storage); VCRFactory::get('VCR\Configuration')->setCassettePath(vfsStream::url('test/')); - $instance = VCRFactory::get('Storage', [random_int(0, getrandmax())]); + $instance = VCRFactory::get('Storage', [(string) random_int(0, getrandmax())]); $this->assertInstanceOf($className, $instance); } diff --git a/tests/VCR/VCRTest.php b/tests/VCR/VCRTest.php index 1020ef49e..a35d1e71e 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/VCR/VCRTest.php @@ -1,5 +1,7 @@ */ private $events; diff --git a/tests/VCR/VideorecorderTest.php b/tests/VCR/VideorecorderTest.php index 926d4789f..f8b2b32db 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/VCR/VideorecorderTest.php @@ -1,15 +1,14 @@ \n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n" + curl_info: + url: 'http://google.com/' + content_type: 'text/html; charset=UTF-8' + http_code: 301 + header_size: 309 + request_size: 49 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.06217 + namelookup_time: 0.017595 + connect_time: 0.034427 + pretransfer_time: 0.034588 + size_upload: !!float 0 + size_download: !!float 219 + speed_download: !!float 3532 + speed_upload: !!float 0 + download_content_length: !!float 219 + upload_content_length: !!float 0 + starttransfer_time: 0.062072 + redirect_time: !!float 0 + redirect_url: 'http://www.google.com/' + primary_ip: 142.251.36.14 + certinfo: { } + primary_port: 80 + local_ip: 172.20.0.2 + local_port: 33950 + http_version: 2 + protocol: 1 + ssl_verifyresult: 0 + scheme: HTTP + appconnect_time_us: 0 + connect_time_us: 34427 + namelookup_time_us: 17595 + pretransfer_time_us: 34588 + redirect_time_us: 0 + starttransfer_time_us: 62072 + total_time_us: 62170 +- + request: + method: GET + url: 'http://google.com/' + headers: + Host: google.com + response: + status: + http_version: '1.1' + code: '301' + message: 'Moved Permanently' + headers: + Location: 'http://www.google.com/' + Content-Type: 'text/html; charset=UTF-8' + Date: 'Mon, 04 Oct 2021 14:21:19 GMT' + Expires: 'Wed, 03 Nov 2021 14:21:19 GMT' + Cache-Control: 'public, max-age=2592000' + Server: gws + Content-Length: '219' + X-XSS-Protection: '0' + X-Frame-Options: SAMEORIGIN + body: "\n301 Moved\n

301 Moved

\nThe document has moved\nhere.\r\n\r\n" + curl_info: + url: 'http://google.com/' + content_type: 'text/html; charset=UTF-8' + http_code: 301 + header_size: 309 + request_size: 49 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.04403 + namelookup_time: 0.001969 + connect_time: 0.016764 + pretransfer_time: 0.016885 + size_upload: !!float 0 + size_download: !!float 219 + speed_download: !!float 4977 + speed_upload: !!float 0 + download_content_length: !!float 219 + upload_content_length: !!float 0 + starttransfer_time: 0.043945 + redirect_time: !!float 0 + redirect_url: 'http://www.google.com/' + primary_ip: 142.251.36.14 + certinfo: { } + primary_port: 80 + local_ip: 172.20.0.2 + local_port: 33952 + http_version: 2 + protocol: 1 + ssl_verifyresult: 0 + scheme: HTTP + appconnect_time_us: 0 + connect_time_us: 16764 + namelookup_time_us: 1969 + pretransfer_time_us: 16885 + redirect_time_us: 0 + starttransfer_time_us: 43945 + total_time_us: 44030 diff --git a/tests/fixtures/unittest_streamwrapper_test b/tests/fixtures/unittest_streamwrapper_test index 5ec78271e..689b336ca 100644 --- a/tests/fixtures/unittest_streamwrapper_test +++ b/tests/fixtures/unittest_streamwrapper_test @@ -21,3 +21,65 @@ x-ec-custom-error: '1' Content-Length: '1270' body: "This is a stream wrapper test dummy." +- + request: + method: GET + url: 'http://example.com' + headers: + Host: example.com + response: + status: + http_version: '1.1' + code: '200' + message: OK + headers: + Age: '598777' + Cache-Control: max-age=604800 + Content-Type: 'text/html; charset=UTF-8' + Date: 'Mon, 04 Oct 2021 14:21:18 GMT' + Etag: '"3147526947+ident"' + Expires: 'Mon, 11 Oct 2021 14:21:18 GMT' + Last-Modified: 'Thu, 17 Oct 2019 07:18:26 GMT' + Server: 'ECS (dcb/7ECA)' + Vary: Accept-Encoding + X-Cache: HIT + Content-Length: '1256' + body: "\n\n\n Example Domain\n\n \n \n \n \n\n\n\n
\n

Example Domain

\n

This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.

\n

More information...

\n
\n\n\n" + curl_info: + url: 'http://example.com/' + content_type: 'text/html; charset=UTF-8' + http_code: 200 + header_size: 335 + request_size: 50 + filetime: -1 + ssl_verify_result: 0 + redirect_count: 0 + total_time: 0.200784 + namelookup_time: 0.000519 + connect_time: 0.098396 + pretransfer_time: 0.098542 + size_upload: !!float 0 + size_download: !!float 1256 + speed_download: !!float 6280 + speed_upload: !!float 0 + download_content_length: !!float 1256 + upload_content_length: !!float 0 + starttransfer_time: 0.20076 + redirect_time: !!float 0 + redirect_url: '' + primary_ip: 93.184.216.34 + certinfo: { } + primary_port: 80 + local_ip: 172.20.0.2 + local_port: 53712 + http_version: 2 + protocol: 1 + ssl_verifyresult: 0 + scheme: HTTP + appconnect_time_us: 0 + connect_time_us: 98396 + namelookup_time_us: 519 + pretransfer_time_us: 98542 + redirect_time_us: 0 + starttransfer_time_us: 200760 + total_time_us: 200784 diff --git a/tests/integration/guzzle/5/ExampleHttpClient.php b/tests/integration/guzzle/5/ExampleHttpClient.php index 150647d2b..75cfd589c 100644 --- a/tests/integration/guzzle/5/ExampleHttpClient.php +++ b/tests/integration/guzzle/5/ExampleHttpClient.php @@ -1,5 +1,7 @@ Date: Sat, 9 Oct 2021 17:05:58 +0200 Subject: [PATCH 121/204] Reorganised tests --- .github/workflows/tests.yml | 70 ------ composer.json | 7 +- phpstan.neon | 2 +- phpunit.xml.dist | 37 ++- .../test => Integration/Guzzle}/AsyncTest.php | 11 +- .../test => Integration/Guzzle}/ErrorTest.php | 11 +- .../Soap}/ExampleSoapClient.php | 4 +- .../Soap}/ExampleSoapClientTest.php | 39 +--- tests/{VCR => Unit}/CassetteTest.php | 9 +- .../AbstractCodeTransformTest.php | 3 +- .../CodeTransform/CurlCodeTransformTest.php | 3 +- .../CodeTransform/SoapCodeTransformTest.php | 3 +- tests/{VCR => Unit}/ConfigurationTest.php | 4 +- .../Event/AfterHttpRequestEventTest.php | 3 +- .../Event/AfterPlaybackEventTest.php | 3 +- .../Event/BeforeHttpRequestEventTest.php | 3 +- .../Event/BeforePlaybackEventTest.php | 3 +- .../Event/BeforeRecordEventTest.php | 3 +- .../LibraryHooks/CurlHookTest.php | 3 +- .../LibraryHooks/SoapHookTest.php | 14 +- .../LibraryHooks/StreamWrapperHookTest.php | 8 +- tests/{VCR => Unit}/RequestMatcherTest.php | 4 +- tests/{VCR => Unit}/RequestTest.php | 3 +- tests/{VCR => Unit}/ResponseTest.php | 3 +- .../Storage/AbstractStorageTest.php | 3 +- tests/{VCR => Unit}/Storage/BlackholeTest.php | 3 +- tests/{VCR => Unit}/Storage/JsonTest.php | 3 +- tests/{VCR => Unit}/Storage/YamlTest.php | 3 +- tests/{VCR => Unit}/Util/CurlHelperTest.php | 3 +- tests/{VCR => Unit}/Util/HttpClientTest.php | 4 +- tests/{VCR => Unit}/Util/HttpUtilTest.php | 3 +- tests/{VCR => Unit}/Util/SoapClientTest.php | 7 +- tests/{VCR => Unit}/Util/StreamHelperTest.php | 3 +- .../Util/StreamProcessorTest.php | 7 +- tests/{VCR => Unit}/Util/TextUtilTest.php | 3 +- tests/{VCR => Unit}/VCRFactoryTest.php | 3 +- tests/{VCR => Unit}/VCRTest.php | 15 +- tests/{VCR => Unit}/VideorecorderTest.php | 15 +- tests/bootstrap.php | 9 - .../guzzle/5/ExampleHttpClient.php | 45 ---- tests/integration/guzzle/5/composer.json | 5 - tests/integration/guzzle/5/composer.lock | 218 ------------------ tests/integration/guzzle/5/phpunit.xml | 14 -- .../guzzle/6/ExampleHttpClient.php | 45 ---- tests/integration/guzzle/6/composer.json | 5 - tests/integration/guzzle/6/phpunit.xml | 15 -- tests/integration/guzzle/Readme.md | 7 - .../VCR/Example/ExampleHttpClientTest.php | 107 --------- tests/integration/guzzle/test/bootstrap.php | 16 -- tests/integration/soap/composer.json | 8 - tests/integration/soap/phpunit.xml | 15 -- tests/integration/soap/test/bootstrap.php | 9 - 52 files changed, 116 insertions(+), 730 deletions(-) rename tests/{integration/guzzle/6/test => Integration/Guzzle}/AsyncTest.php (86%) rename tests/{integration/guzzle/6/test => Integration/Guzzle}/ErrorTest.php (86%) rename tests/{integration/soap/src/VCR/Example => Integration/Soap}/ExampleSoapClient.php (88%) rename tests/{integration/soap/test/VCR/Example => Integration/Soap}/ExampleSoapClientTest.php (53%) rename tests/{VCR => Unit}/CassetteTest.php (91%) rename tests/{VCR => Unit}/CodeTransform/AbstractCodeTransformTest.php (93%) rename tests/{VCR => Unit}/CodeTransform/CurlCodeTransformTest.php (97%) rename tests/{VCR => Unit}/CodeTransform/SoapCodeTransformTest.php (94%) rename tests/{VCR => Unit}/ConfigurationTest.php (98%) rename tests/{VCR => Unit}/Event/AfterHttpRequestEventTest.php (90%) rename tests/{VCR => Unit}/Event/AfterPlaybackEventTest.php (93%) rename tests/{VCR => Unit}/Event/BeforeHttpRequestEventTest.php (86%) rename tests/{VCR => Unit}/Event/BeforePlaybackEventTest.php (91%) rename tests/{VCR => Unit}/Event/BeforeRecordEventTest.php (93%) rename tests/{VCR => Unit}/LibraryHooks/CurlHookTest.php (99%) rename tests/{VCR => Unit}/LibraryHooks/SoapHookTest.php (94%) rename tests/{VCR => Unit}/LibraryHooks/StreamWrapperHookTest.php (91%) rename tests/{VCR => Unit}/RequestMatcherTest.php (99%) rename tests/{VCR => Unit}/RequestTest.php (99%) rename tests/{VCR => Unit}/ResponseTest.php (99%) rename tests/{VCR => Unit}/Storage/AbstractStorageTest.php (95%) rename tests/{VCR => Unit}/Storage/BlackholeTest.php (95%) rename tests/{VCR => Unit}/Storage/JsonTest.php (98%) rename tests/{VCR => Unit}/Storage/YamlTest.php (98%) rename tests/{VCR => Unit}/Util/CurlHelperTest.php (99%) rename tests/{VCR => Unit}/Util/HttpClientTest.php (83%) rename tests/{VCR => Unit}/Util/HttpUtilTest.php (99%) rename tests/{VCR => Unit}/Util/SoapClientTest.php (95%) rename tests/{VCR => Unit}/Util/StreamHelperTest.php (98%) rename tests/{VCR => Unit}/Util/StreamProcessorTest.php (97%) rename tests/{VCR => Unit}/Util/TextUtilTest.php (93%) rename tests/{VCR => Unit}/VCRFactoryTest.php (97%) rename tests/{VCR => Unit}/VCRTest.php (94%) rename tests/{VCR => Unit}/VideorecorderTest.php (94%) delete mode 100644 tests/integration/guzzle/5/ExampleHttpClient.php delete mode 100644 tests/integration/guzzle/5/composer.json delete mode 100644 tests/integration/guzzle/5/composer.lock delete mode 100644 tests/integration/guzzle/5/phpunit.xml delete mode 100644 tests/integration/guzzle/6/ExampleHttpClient.php delete mode 100644 tests/integration/guzzle/6/composer.json delete mode 100644 tests/integration/guzzle/6/phpunit.xml delete mode 100644 tests/integration/guzzle/Readme.md delete mode 100644 tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php delete mode 100644 tests/integration/guzzle/test/bootstrap.php delete mode 100644 tests/integration/soap/composer.json delete mode 100644 tests/integration/soap/phpunit.xml delete mode 100644 tests/integration/soap/test/bootstrap.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 59cbce33c..017138f36 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -89,73 +89,3 @@ jobs: uses: sudo-bot/action-scrutinizer@latest with: cli-args: "--format=php-clover coverage.clover" - - guzzle: - strategy: - fail-fast: true - matrix: - guzzle: ["5", "6"] - - name: "Integration test for Guzzle ${{ matrix.guzzle }}" - - runs-on: "ubuntu-latest" - - steps: - - name: "Checkout code" - uses: "actions/checkout@v2" - - - name: "Setup PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.0" - extensions: "curl, soap" - tools: "composer:v2" - coverage: "pcov" - - - name: "Check Composer configuration" - run: "composer validate --strict" - - - name: "Install dependencies" - run: "composer update --prefer-dist --no-interaction --no-progress" - - - name: "Execute tests" - run: "cd tests/integration/guzzle/${{ matrix.guzzle }}/ && composer update --prefer-dist --no-interaction --no-progress && ../../../../vendor/bin/phpunit --coverage-clover=coverage.clover" - - - name: Upload Scrutinizer coverage - uses: sudo-bot/action-scrutinizer@latest - with: - cli-args: "--format=php-clover coverage.clover" - - soap: - strategy: - fail-fast: true - - name: "SOAP integration test" - - runs-on: "ubuntu-latest" - - steps: - - name: "Checkout code" - uses: "actions/checkout@v2" - - - name: "Setup PHP" - uses: "shivammathur/setup-php@v2" - with: - php-version: "8.0" - extensions: "curl, soap" - tools: "composer:v2" - coverage: "pcov" - - - name: "Check Composer configuration" - run: "composer validate --strict" - - - name: "Install dependencies" - run: "composer update --prefer-dist --no-interaction --no-progress" - - - name: "Execute tests" - run: "cd tests/integration/soap/ && composer update --prefer-dist --no-interaction --no-progress && ../../../vendor/bin/phpunit --coverage-clover=coverage.clover" - - - name: Upload Scrutinizer coverage - uses: sudo-bot/action-scrutinizer@latest - with: - cli-args: "--format=php-clover coverage.clover" diff --git a/composer.json b/composer.json index 6b4b68439..24cd1a39f 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/event-dispatcher": "^5.0" }, "require-dev": { + "guzzlehttp/guzzle": "^7.0", "phpunit/phpunit": "^9.5.0", "mikey179/vfsstream": "^1.6.10", "phpstan/phpstan": "^0.12.92", @@ -37,8 +38,8 @@ } }, "autoload-dev": { - "classmap": [ - "tests/" - ] + "psr-4": { + "VCR\\Tests\\": "tests" + } } } diff --git a/phpstan.neon b/phpstan.neon index 4fa3f521b..d9e3594d6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,4 +5,4 @@ parameters: level: max paths: - src - - tests/VCR + - tests diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2faf7ba9..bc9de4884 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,16 @@ - - - - - - ./tests/VCR - - - - - - src - - - + + + + src + + + + + ./tests/Unit + + + ./tests/Integration + + diff --git a/tests/integration/guzzle/6/test/AsyncTest.php b/tests/Integration/Guzzle/AsyncTest.php similarity index 86% rename from tests/integration/guzzle/6/test/AsyncTest.php rename to tests/Integration/Guzzle/AsyncTest.php index cf5c7b043..6fac74c4d 100644 --- a/tests/integration/guzzle/6/test/AsyncTest.php +++ b/tests/Integration/Guzzle/AsyncTest.php @@ -2,16 +2,13 @@ declare(strict_types=1); -namespace VCR\Example; +namespace VCR\Tests\Integration\Guzzle; use GuzzleHttp\Client; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; -/** - * Tests example request. - */ -class AsyncTest extends TestCase +final class AsyncTest extends TestCase { public const TEST_GET_URL = 'https://httpbin.org/get'; public const TEST_GET_URL_2 = 'https://httpbin.org/get?foo=42'; @@ -35,12 +32,12 @@ public function testAsyncLock(): void // Let's check that we can perform 2 async request on different URLs without locking. // Solves https://github.com/php-vcr/php-vcr/issues/211 - $this->assertValidGETResponse(\GuzzleHttp\json_decode($response->getBody(), true)); + $this->assertValidGETResponse(\GuzzleHttp\json_decode($response->getBody()->getContents(), true)); \VCR\VCR::turnOff(); } - protected function assertValidGETResponse($info): void + protected function assertValidGETResponse(mixed $info): void { $this->assertIsArray($info, 'Response is not an array.'); $this->assertArrayHasKey('url', $info, 'API did not return any value.'); diff --git a/tests/integration/guzzle/6/test/ErrorTest.php b/tests/Integration/Guzzle/ErrorTest.php similarity index 86% rename from tests/integration/guzzle/6/test/ErrorTest.php rename to tests/Integration/Guzzle/ErrorTest.php index 5b5c497f0..d57d6c6c7 100644 --- a/tests/integration/guzzle/6/test/ErrorTest.php +++ b/tests/Integration/Guzzle/ErrorTest.php @@ -2,17 +2,14 @@ declare(strict_types=1); -namespace VCR\Example; +namespace VCR\Tests\Integration\Guzzle; use GuzzleHttp\Client; use GuzzleHttp\Exception\ConnectException; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; -/** - * Tests behaviour when an error occurs. - */ -class ErrorTest extends TestCase +final class ErrorTest extends TestCase { public const TEST_GET_URL = 'http://localhost:9959'; @@ -45,8 +42,4 @@ public function testConnectException(): void $this->assertTrue($catched); \VCR\VCR::turnOff(); } - - protected function assertValidGETResponse($info): void - { - } } diff --git a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php b/tests/Integration/Soap/ExampleSoapClient.php similarity index 88% rename from tests/integration/soap/src/VCR/Example/ExampleSoapClient.php rename to tests/Integration/Soap/ExampleSoapClient.php index ceef5adde..0d7c2fb17 100644 --- a/tests/integration/soap/src/VCR/Example/ExampleSoapClient.php +++ b/tests/Integration/Soap/ExampleSoapClient.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace VCR\Example; +namespace VCR\Tests\Integration\Soap; /** * Converts temperature units from webservicex. @@ -13,7 +13,7 @@ class ExampleSoapClient { public const EXAMPLE_WSDL = 'http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL'; - public function call($number = 12) + public function call(int $number = 12): string { $client = new \SoapClient(self::EXAMPLE_WSDL, ['soap_version' => \SOAP_1_2]); $response = $client->NumberToWords(['ubiNum' => $number]); diff --git a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php b/tests/Integration/Soap/ExampleSoapClientTest.php similarity index 53% rename from tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php rename to tests/Integration/Soap/ExampleSoapClientTest.php index d22390cda..67b985283 100644 --- a/tests/integration/soap/test/VCR/Example/ExampleSoapClientTest.php +++ b/tests/Integration/Soap/ExampleSoapClientTest.php @@ -2,18 +2,17 @@ declare(strict_types=1); -namespace VCR\Example; +namespace VCR\Tests\Integration\Soap; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; -use SoapFault; /** * Converts temperature units from webservicex. * * @see http://www.webservicex.net/New/Home/ServiceDetail/31 */ -class ExampleSoapClientTest extends TestCase +final class ExampleSoapClientTest extends TestCase { protected function setUp(): void { @@ -45,42 +44,14 @@ public function testCallDirectlyEqualsIntercepted(): void $this->assertEquals($this->callSoap(), $this->callSoapIntercepted()); } - /** - * This test performs a SOAP request on a buggy WSDL. - * It checks that the non instrumented code and the instrumented code return the same exception. - */ - public function testCallSoapWithError(): void - { - $nonInstrumentedException = null; - try { - $soapClient = new ExampleSoapClient(); - $soapClient->callBadUrl(); - } catch (SoapFault $e) { - $nonInstrumentedException = $e; - } - $this->assertNotNull($nonInstrumentedException); - $catched = false; - \VCR\VCR::turnOn(); - \VCR\VCR::insertCassette('test-cassette.yml'); - try { - $soapClient = new ExampleSoapClient(); - $soapClient->callBadUrl(); - } catch (SoapFault $e) { - $catched = true; - $this->assertEquals($e->getMessage(), $nonInstrumentedException->getMessage()); - } - $this->assertTrue($catched); - \VCR\VCR::turnOff(); - } - - protected function callSoap() + protected function callSoap(): mixed { $soapClient = new ExampleSoapClient(); - return $soapClient->call(12); + return $soapClient->call(); } - protected function callSoapIntercepted() + protected function callSoapIntercepted(): mixed { \VCR\VCR::turnOn(); \VCR\VCR::insertCassette('test-cassette.yml'); diff --git a/tests/VCR/CassetteTest.php b/tests/Unit/CassetteTest.php similarity index 91% rename from tests/VCR/CassetteTest.php rename to tests/Unit/CassetteTest.php index c49104ef6..fbbeb5b49 100644 --- a/tests/VCR/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -2,10 +2,15 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Cassette; +use VCR\Configuration; +use VCR\Request; +use VCR\Response; +use VCR\Storage\Yaml; final class CassetteTest extends TestCase { @@ -14,7 +19,7 @@ final class CassetteTest extends TestCase protected function setUp(): void { vfsStream::setup('test'); - $this->cassette = new Cassette('test', new Configuration(), new Storage\Yaml(vfsStream::url('test/'), 'json_test')); + $this->cassette = new Cassette('test', new Configuration(), new Yaml(vfsStream::url('test/'), 'json_test')); } public function testGetName(): void diff --git a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php b/tests/Unit/CodeTransform/AbstractCodeTransformTest.php similarity index 93% rename from tests/VCR/CodeTransform/AbstractCodeTransformTest.php rename to tests/Unit/CodeTransform/AbstractCodeTransformTest.php index 99d69e885..847ba0658 100644 --- a/tests/VCR/CodeTransform/AbstractCodeTransformTest.php +++ b/tests/Unit/CodeTransform/AbstractCodeTransformTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR\CodeTransform; +namespace VCR\Tests\Unit\CodeTransform; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\AbstractCodeTransform; final class AbstractCodeTransformTest extends TestCase { diff --git a/tests/VCR/CodeTransform/CurlCodeTransformTest.php b/tests/Unit/CodeTransform/CurlCodeTransformTest.php similarity index 97% rename from tests/VCR/CodeTransform/CurlCodeTransformTest.php rename to tests/Unit/CodeTransform/CurlCodeTransformTest.php index 97ed813ec..90671aa08 100644 --- a/tests/VCR/CodeTransform/CurlCodeTransformTest.php +++ b/tests/Unit/CodeTransform/CurlCodeTransformTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\CodeTransform; +namespace VCR\Tests\Unit\CodeTransform; use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\CurlCodeTransform; final class CurlCodeTransformTest extends TestCase { diff --git a/tests/VCR/CodeTransform/SoapCodeTransformTest.php b/tests/Unit/CodeTransform/SoapCodeTransformTest.php similarity index 94% rename from tests/VCR/CodeTransform/SoapCodeTransformTest.php rename to tests/Unit/CodeTransform/SoapCodeTransformTest.php index c1dd9570d..354e8f5d5 100644 --- a/tests/VCR/CodeTransform/SoapCodeTransformTest.php +++ b/tests/Unit/CodeTransform/SoapCodeTransformTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\CodeTransform; +namespace VCR\Tests\Unit\CodeTransform; use PHPUnit\Framework\TestCase; +use VCR\CodeTransform\SoapCodeTransform; final class SoapCodeTransformTest extends TestCase { diff --git a/tests/VCR/ConfigurationTest.php b/tests/Unit/ConfigurationTest.php similarity index 98% rename from tests/VCR/ConfigurationTest.php rename to tests/Unit/ConfigurationTest.php index a2bf0cd06..8f0405631 100644 --- a/tests/VCR/ConfigurationTest.php +++ b/tests/Unit/ConfigurationTest.php @@ -2,9 +2,11 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use PHPUnit\Framework\TestCase; +use VCR\Configuration; +use VCR\VCRException; final class ConfigurationTest extends TestCase { diff --git a/tests/VCR/Event/AfterHttpRequestEventTest.php b/tests/Unit/Event/AfterHttpRequestEventTest.php similarity index 90% rename from tests/VCR/Event/AfterHttpRequestEventTest.php rename to tests/Unit/Event/AfterHttpRequestEventTest.php index 38064c294..efa3b43a4 100644 --- a/tests/VCR/Event/AfterHttpRequestEventTest.php +++ b/tests/Unit/Event/AfterHttpRequestEventTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\Event; +namespace VCR\Tests\Unit\Event; use PHPUnit\Framework\TestCase; +use VCR\Event\AfterHttpRequestEvent; use VCR\Request; use VCR\Response; diff --git a/tests/VCR/Event/AfterPlaybackEventTest.php b/tests/Unit/Event/AfterPlaybackEventTest.php similarity index 93% rename from tests/VCR/Event/AfterPlaybackEventTest.php rename to tests/Unit/Event/AfterPlaybackEventTest.php index 2e6b0f482..71cc1e8f6 100644 --- a/tests/VCR/Event/AfterPlaybackEventTest.php +++ b/tests/Unit/Event/AfterPlaybackEventTest.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace VCR\Event; +namespace VCR\Tests\Unit\Event; use PHPUnit\Framework\TestCase; use VCR\Cassette; use VCR\Configuration; +use VCR\Event\AfterPlaybackEvent; use VCR\Request; use VCR\Response; use VCR\Storage; diff --git a/tests/VCR/Event/BeforeHttpRequestEventTest.php b/tests/Unit/Event/BeforeHttpRequestEventTest.php similarity index 86% rename from tests/VCR/Event/BeforeHttpRequestEventTest.php rename to tests/Unit/Event/BeforeHttpRequestEventTest.php index edafd283a..252302276 100644 --- a/tests/VCR/Event/BeforeHttpRequestEventTest.php +++ b/tests/Unit/Event/BeforeHttpRequestEventTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\Event; +namespace VCR\Tests\Unit\Event; use PHPUnit\Framework\TestCase; +use VCR\Event\BeforeHttpRequestEvent; use VCR\Request; final class BeforeHttpRequestEventTest extends TestCase diff --git a/tests/VCR/Event/BeforePlaybackEventTest.php b/tests/Unit/Event/BeforePlaybackEventTest.php similarity index 91% rename from tests/VCR/Event/BeforePlaybackEventTest.php rename to tests/Unit/Event/BeforePlaybackEventTest.php index d6c8d0b45..00d22d0bb 100644 --- a/tests/VCR/Event/BeforePlaybackEventTest.php +++ b/tests/Unit/Event/BeforePlaybackEventTest.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace VCR\Event; +namespace VCR\Tests\Unit\Event; use PHPUnit\Framework\TestCase; use VCR\Cassette; use VCR\Configuration; +use VCR\Event\BeforePlaybackEvent; use VCR\Request; use VCR\Storage; diff --git a/tests/VCR/Event/BeforeRecordEventTest.php b/tests/Unit/Event/BeforeRecordEventTest.php similarity index 93% rename from tests/VCR/Event/BeforeRecordEventTest.php rename to tests/Unit/Event/BeforeRecordEventTest.php index 66d117f48..59976b70c 100644 --- a/tests/VCR/Event/BeforeRecordEventTest.php +++ b/tests/Unit/Event/BeforeRecordEventTest.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace VCR\Event; +namespace VCR\Tests\Unit\Event; use PHPUnit\Framework\TestCase; use VCR\Cassette; use VCR\Configuration; +use VCR\Event\BeforeRecordEvent; use VCR\Request; use VCR\Response; use VCR\Storage; diff --git a/tests/VCR/LibraryHooks/CurlHookTest.php b/tests/Unit/LibraryHooks/CurlHookTest.php similarity index 99% rename from tests/VCR/LibraryHooks/CurlHookTest.php rename to tests/Unit/LibraryHooks/CurlHookTest.php index d5459fb69..e66d644de 100644 --- a/tests/VCR/LibraryHooks/CurlHookTest.php +++ b/tests/Unit/LibraryHooks/CurlHookTest.php @@ -2,13 +2,14 @@ declare(strict_types=1); -namespace VCR\LibraryHooks; +namespace VCR\Tests\Unit\LibraryHooks; use Assert\Assertion; use Closure; use PHPUnit\Framework\TestCase; use VCR\CodeTransform\CurlCodeTransform; use VCR\Configuration; +use VCR\LibraryHooks\CurlHook; use VCR\Request; use VCR\Response; use VCR\Util\StreamProcessor; diff --git a/tests/VCR/LibraryHooks/SoapHookTest.php b/tests/Unit/LibraryHooks/SoapHookTest.php similarity index 94% rename from tests/VCR/LibraryHooks/SoapHookTest.php rename to tests/Unit/LibraryHooks/SoapHookTest.php index 1b4633677..63f261c3d 100644 --- a/tests/VCR/LibraryHooks/SoapHookTest.php +++ b/tests/Unit/LibraryHooks/SoapHookTest.php @@ -2,31 +2,27 @@ declare(strict_types=1); -namespace VCR\LibraryHooks; +namespace VCR\Tests\Unit\LibraryHooks; use Closure; use PHPUnit\Framework\TestCase; use VCR\CodeTransform\SoapCodeTransform; use VCR\Configuration; +use VCR\LibraryHooks\SoapHook; use VCR\Request; use VCR\Response; use VCR\Util\StreamProcessor; -/** - * Test if intercepting http/https using soap works. - */ -class SoapHookTest extends TestCase +final class SoapHookTest extends TestCase { public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl'; /** @var string */ public $expected = 'true'; - /** @var Configuration */ - protected $config; + protected Configuration $config; - /** @var SoapHook */ - protected $soapHook; + protected SoapHook $soapHook; protected function setup(): void { diff --git a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php b/tests/Unit/LibraryHooks/StreamWrapperHookTest.php similarity index 91% rename from tests/VCR/LibraryHooks/StreamWrapperHookTest.php rename to tests/Unit/LibraryHooks/StreamWrapperHookTest.php index 320b96255..72fd9ca5f 100644 --- a/tests/VCR/LibraryHooks/StreamWrapperHookTest.php +++ b/tests/Unit/LibraryHooks/StreamWrapperHookTest.php @@ -2,15 +2,13 @@ declare(strict_types=1); -namespace VCR\LibraryHooks; +namespace VCR\Tests\Unit\LibraryHooks; use PHPUnit\Framework\TestCase; +use VCR\LibraryHooks\StreamWrapperHook; use VCR\Response; -/** - * Test if intercepting http/https using stream wrapper works. - */ -class StreamWrapperHookTest extends TestCase +final class StreamWrapperHookTest extends TestCase { public function testEnable(): void { diff --git a/tests/VCR/RequestMatcherTest.php b/tests/Unit/RequestMatcherTest.php similarity index 99% rename from tests/VCR/RequestMatcherTest.php rename to tests/Unit/RequestMatcherTest.php index eed32768b..58210ab8d 100644 --- a/tests/VCR/RequestMatcherTest.php +++ b/tests/Unit/RequestMatcherTest.php @@ -2,9 +2,11 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use PHPUnit\Framework\TestCase; +use VCR\Request; +use VCR\RequestMatcher; final class RequestMatcherTest extends TestCase { diff --git a/tests/VCR/RequestTest.php b/tests/Unit/RequestTest.php similarity index 99% rename from tests/VCR/RequestTest.php rename to tests/Unit/RequestTest.php index 2f26952b4..8c77dc158 100644 --- a/tests/VCR/RequestTest.php +++ b/tests/Unit/RequestTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use const CURLOPT_CUSTOMREQUEST; use PHPUnit\Framework\TestCase; +use VCR\Request; final class RequestTest extends TestCase { diff --git a/tests/VCR/ResponseTest.php b/tests/Unit/ResponseTest.php similarity index 99% rename from tests/VCR/ResponseTest.php rename to tests/Unit/ResponseTest.php index fc6a842b7..6ef39a91a 100644 --- a/tests/VCR/ResponseTest.php +++ b/tests/Unit/ResponseTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use PHPUnit\Framework\TestCase; +use VCR\Response; final class ResponseTest extends TestCase { diff --git a/tests/VCR/Storage/AbstractStorageTest.php b/tests/Unit/Storage/AbstractStorageTest.php similarity index 95% rename from tests/VCR/Storage/AbstractStorageTest.php rename to tests/Unit/Storage/AbstractStorageTest.php index f049cdc92..413a11050 100644 --- a/tests/VCR/Storage/AbstractStorageTest.php +++ b/tests/Unit/Storage/AbstractStorageTest.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace VCR\Storage; +namespace VCR\Tests\Unit\Storage; use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStreamDirectory; use PHPUnit\Framework\TestCase; +use VCR\Storage\AbstractStorage; final class AbstractStorageTest extends TestCase { diff --git a/tests/VCR/Storage/BlackholeTest.php b/tests/Unit/Storage/BlackholeTest.php similarity index 95% rename from tests/VCR/Storage/BlackholeTest.php rename to tests/Unit/Storage/BlackholeTest.php index 60b8fdeae..c6044ec7a 100644 --- a/tests/VCR/Storage/BlackholeTest.php +++ b/tests/Unit/Storage/BlackholeTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\Storage; +namespace VCR\Tests\Unit\Storage; use PHPUnit\Framework\TestCase; +use VCR\Storage\Blackhole; final class BlackholeTest extends TestCase { diff --git a/tests/VCR/Storage/JsonTest.php b/tests/Unit/Storage/JsonTest.php similarity index 98% rename from tests/VCR/Storage/JsonTest.php rename to tests/Unit/Storage/JsonTest.php index edf7cfc85..e82ec36d0 100644 --- a/tests/VCR/Storage/JsonTest.php +++ b/tests/Unit/Storage/JsonTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR\Storage; +namespace VCR\Tests\Unit\Storage; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Storage\Json; final class JsonTest extends TestCase { diff --git a/tests/VCR/Storage/YamlTest.php b/tests/Unit/Storage/YamlTest.php similarity index 98% rename from tests/VCR/Storage/YamlTest.php rename to tests/Unit/Storage/YamlTest.php index 24b66f9d1..1e5301298 100644 --- a/tests/VCR/Storage/YamlTest.php +++ b/tests/Unit/Storage/YamlTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR\Storage; +namespace VCR\Tests\Unit\Storage; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Storage\Yaml; final class YamlTest extends TestCase { diff --git a/tests/VCR/Util/CurlHelperTest.php b/tests/Unit/Util/CurlHelperTest.php similarity index 99% rename from tests/VCR/Util/CurlHelperTest.php rename to tests/Unit/Util/CurlHelperTest.php index c932150ae..8b9e81e5d 100644 --- a/tests/VCR/Util/CurlHelperTest.php +++ b/tests/Unit/Util/CurlHelperTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use CurlHandle; use org\bovigo\vfs\vfsStream; @@ -10,6 +10,7 @@ use VCR\Exceptions\InvalidHostException; use VCR\Request; use VCR\Response; +use VCR\Util\CurlHelper; final class CurlHelperTest extends TestCase { diff --git a/tests/VCR/Util/HttpClientTest.php b/tests/Unit/Util/HttpClientTest.php similarity index 83% rename from tests/VCR/Util/HttpClientTest.php rename to tests/Unit/Util/HttpClientTest.php index 342b98bb1..9a693abb6 100644 --- a/tests/VCR/Util/HttpClientTest.php +++ b/tests/Unit/Util/HttpClientTest.php @@ -2,10 +2,12 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\TestCase; use VCR\Request; +use VCR\Util\CurlException; +use VCR\Util\HttpClient; final class HttpClientTest extends TestCase { diff --git a/tests/VCR/Util/HttpUtilTest.php b/tests/Unit/Util/HttpUtilTest.php similarity index 99% rename from tests/VCR/Util/HttpUtilTest.php rename to tests/Unit/Util/HttpUtilTest.php index 51681c3c8..58f8c182f 100644 --- a/tests/VCR/Util/HttpUtilTest.php +++ b/tests/Unit/Util/HttpUtilTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\TestCase; +use VCR\Util\HttpUtil; final class HttpUtilTest extends TestCase { diff --git a/tests/VCR/Util/SoapClientTest.php b/tests/Unit/Util/SoapClientTest.php similarity index 95% rename from tests/VCR/Util/SoapClientTest.php rename to tests/Unit/Util/SoapClientTest.php index 2cc4097a2..5f03b5623 100644 --- a/tests/VCR/Util/SoapClientTest.php +++ b/tests/Unit/Util/SoapClientTest.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use VCR\LibraryHooks\SoapHook; +use VCR\Util\SoapClient; final class SoapClientTest extends TestCase { @@ -136,11 +137,11 @@ public function publicGetLibraryHook(): SoapHook } }; - $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->publicGetLibraryHook()); + $this->assertInstanceOf(SoapHook::class, $client->publicGetLibraryHook()); $client->setLibraryHook($this->getLibraryHookMock(true)); - $this->assertInstanceOf('\VCR\LibraryHooks\SoapHook', $client->publicGetLibraryHook()); + $this->assertInstanceOf(SoapHook::class, $client->publicGetLibraryHook()); } public function testGetLastWhateverBeforeRequest(): void diff --git a/tests/VCR/Util/StreamHelperTest.php b/tests/Unit/Util/StreamHelperTest.php similarity index 98% rename from tests/VCR/Util/StreamHelperTest.php rename to tests/Unit/Util/StreamHelperTest.php index 658dc3ae8..f149b6188 100644 --- a/tests/VCR/Util/StreamHelperTest.php +++ b/tests/Unit/Util/StreamHelperTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\TestCase; use VCR\Request; +use VCR\Util\StreamHelper; final class StreamHelperTest extends TestCase { diff --git a/tests/VCR/Util/StreamProcessorTest.php b/tests/Unit/Util/StreamProcessorTest.php similarity index 97% rename from tests/VCR/Util/StreamProcessorTest.php rename to tests/Unit/Util/StreamProcessorTest.php index 74889bbfc..e2edf3eee 100644 --- a/tests/VCR/Util/StreamProcessorTest.php +++ b/tests/Unit/Util/StreamProcessorTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use VCR\Util\StreamProcessor; final class StreamProcessorTest extends TestCase { @@ -166,10 +167,6 @@ public function testRename(): void public function testStreamMetadata(): void { - if (version_compare(\PHP_VERSION, '5.4.0', '<')) { - $this->markTestSkipped('Behavior is only applicable and testable for PHP 5.4+'); - } - if (!\function_exists('posix_getuid')) { $this->markTestSkipped('Requires "posix_getuid" function.'); } diff --git a/tests/VCR/Util/TextUtilTest.php b/tests/Unit/Util/TextUtilTest.php similarity index 93% rename from tests/VCR/Util/TextUtilTest.php rename to tests/Unit/Util/TextUtilTest.php index b19f759b5..479e83e29 100644 --- a/tests/VCR/Util/TextUtilTest.php +++ b/tests/Unit/Util/TextUtilTest.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace VCR\Util; +namespace VCR\Tests\Unit\Util; use PHPUnit\Framework\TestCase; +use VCR\Util\TextUtil; final class TextUtilTest extends TestCase { diff --git a/tests/VCR/VCRFactoryTest.php b/tests/Unit/VCRFactoryTest.php similarity index 97% rename from tests/VCR/VCRFactoryTest.php rename to tests/Unit/VCRFactoryTest.php index 9357e312b..a75bad419 100644 --- a/tests/VCR/VCRFactoryTest.php +++ b/tests/Unit/VCRFactoryTest.php @@ -2,10 +2,11 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\VCRFactory; final class VCRFactoryTest extends TestCase { diff --git a/tests/VCR/VCRTest.php b/tests/Unit/VCRTest.php similarity index 94% rename from tests/VCR/VCRTest.php rename to tests/Unit/VCRTest.php index a35d1e71e..75ffaf37f 100644 --- a/tests/VCR/VCRTest.php +++ b/tests/Unit/VCRTest.php @@ -2,12 +2,14 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use Assert\Assertion; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use VCR\Event\Event; +use VCR\VCR; +use VCR\VCREvents; final class VCRTest extends TestCase { @@ -116,17 +118,6 @@ public function testShouldThrowExceptionIfNoCassettePresent(): void VCR::turnOff(); } - // Useless test: already tested in VideorecorderTest::testInsertCassetteEjectExisting - /*public function testInsertMultipleCassettes() - { - $this->configureVirtualCassette(); - - VCR::turnOn(); - VCR::insertCassette('unittest_cassette1'); - VCR::insertCassette('unittest_cassette2'); - // TODO: Check of cassette was changed - }*/ - public function testDoesNotBlockThrowingExceptions(): void { $this->configureVirtualCassette(); diff --git a/tests/VCR/VideorecorderTest.php b/tests/Unit/VideorecorderTest.php similarity index 94% rename from tests/VCR/VideorecorderTest.php rename to tests/Unit/VideorecorderTest.php index f8b2b32db..487a85e0e 100644 --- a/tests/VCR/VideorecorderTest.php +++ b/tests/Unit/VideorecorderTest.php @@ -2,19 +2,26 @@ declare(strict_types=1); -namespace VCR; +namespace VCR\Tests\Unit; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; +use VCR\Cassette; +use VCR\Configuration; +use VCR\Request; +use VCR\Response; use VCR\Util\HttpClient; +use VCR\VCR; +use VCR\VCRFactory; +use VCR\Videorecorder; final class VideorecorderTest extends TestCase { public function testCreateVideorecorder(): void { $this->assertInstanceOf( - '\VCR\Videorecorder', - new Videorecorder(new Configuration(), new Util\HttpClient(), VCRFactory::getInstance()) + Videorecorder::class, + new Videorecorder(new Configuration(), new HttpClient(), VCRFactory::getInstance()) ); } @@ -26,7 +33,7 @@ public function testInsertCassetteEjectExisting(): void $configuration->setCassettePath(vfsStream::url('testDir')); $configuration->enableLibraryHooks([]); $videorecorder = $this->getMockBuilder('\VCR\Videorecorder') - ->setConstructorArgs([$configuration, new Util\HttpClient(), VCRFactory::getInstance()]) + ->setConstructorArgs([$configuration, new HttpClient(), VCRFactory::getInstance()]) ->setMethods(['eject']) ->getMock(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4614f2faa..623e17619 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,15 +2,6 @@ declare(strict_types=1); -if (!file_exists(__DIR__.'/../vendor/autoload.php')) { - exit( - "\n[ERROR] You need to run composer before running the test suite.\n". - "To do so run the following commands:\n". - " curl -s http://getcomposer.org/installer | php\n". - " php composer.phar install\n\n" - ); -} - require_once __DIR__.'/../vendor/autoload.php'; \VCR\VCR::turnOn(); diff --git a/tests/integration/guzzle/5/ExampleHttpClient.php b/tests/integration/guzzle/5/ExampleHttpClient.php deleted file mode 100644 index 75cfd589c..000000000 --- a/tests/integration/guzzle/5/ExampleHttpClient.php +++ /dev/null @@ -1,45 +0,0 @@ -get($url); - - return $response->json(); - } catch (ClientException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } - - public function post($url, $body) - { - $client = new Client(); - - try { - $response = $client->post($url, ['body' => $body]); - - return $response->json(); - } catch (ClientErrorResponseException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } -} diff --git a/tests/integration/guzzle/5/composer.json b/tests/integration/guzzle/5/composer.json deleted file mode 100644 index 255565722..000000000 --- a/tests/integration/guzzle/5/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "guzzlehttp/guzzle": "~5.0" - } -} diff --git a/tests/integration/guzzle/5/composer.lock b/tests/integration/guzzle/5/composer.lock deleted file mode 100644 index 1690aa89f..000000000 --- a/tests/integration/guzzle/5/composer.lock +++ /dev/null @@ -1,218 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "a426abfa60297f7ecc0e43c351699bf4", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "5.3.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/93bbdb30d59be6cd9839495306c65f2907370eb9", - "reference": "93bbdb30d59be6cd9839495306c65f2907370eb9", - "shasum": "" - }, - "require": { - "guzzlehttp/ringphp": "^1.1", - "php": ">=5.4.0", - "react/promise": "^2.2" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2018-07-31T13:33:10+00:00" - }, - { - "name": "guzzlehttp/ringphp", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/RingPHP.git", - "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/5e2a174052995663dd68e6b5ad838afd47dd615b", - "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b", - "shasum": "" - }, - "require": { - "guzzlehttp/streams": "~3.0", - "php": ">=5.4.0", - "react/promise": "~2.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "ext-curl": "Guzzle will use specific adapters if cURL is present" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Ring\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "time": "2018-07-31T13:22:33+00:00" - }, - { - "name": "guzzlehttp/streams", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/streams.git", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/streams/zipball/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "reference": "47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Stream\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Provides a simple abstraction over streams of data", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "Guzzle", - "stream" - ], - "time": "2014-10-12T19:18:40+00:00" - }, - { - "name": "react/promise", - "version": "v2.7.0", - "source": { - "type": "git", - "url": "https://github.com/reactphp/promise.git", - "reference": "f4edc2581617431aea50430749db55cc3fc031b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/f4edc2581617431aea50430749db55cc3fc031b3", - "reference": "f4edc2581617431aea50430749db55cc3fc031b3", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "React\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jan Sorgalla", - "email": "jsorgalla@gmail.com" - } - ], - "description": "A lightweight implementation of CommonJS Promises/A for PHP", - "keywords": [ - "promise", - "promises" - ], - "time": "2018-06-13T15:59:06+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [] -} diff --git a/tests/integration/guzzle/5/phpunit.xml b/tests/integration/guzzle/5/phpunit.xml deleted file mode 100644 index f27d64587..000000000 --- a/tests/integration/guzzle/5/phpunit.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ../test - - - - diff --git a/tests/integration/guzzle/6/ExampleHttpClient.php b/tests/integration/guzzle/6/ExampleHttpClient.php deleted file mode 100644 index 4360157bb..000000000 --- a/tests/integration/guzzle/6/ExampleHttpClient.php +++ /dev/null @@ -1,45 +0,0 @@ -get($url); - - return json_decode($response->getBody(), true); - } catch (ClientException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } - - public function post($url, $body) - { - $client = new Client(); - - try { - $response = $client->post($url, ['body' => $body]); - - return json_decode($response->getBody(), true); - } catch (ClientException $e) { - if (404 !== $e->getCode()) { - throw $e; - } - } - - return null; - } -} diff --git a/tests/integration/guzzle/6/composer.json b/tests/integration/guzzle/6/composer.json deleted file mode 100644 index 391331801..000000000 --- a/tests/integration/guzzle/6/composer.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "require": { - "guzzlehttp/guzzle": "~6.0" - } -} diff --git a/tests/integration/guzzle/6/phpunit.xml b/tests/integration/guzzle/6/phpunit.xml deleted file mode 100644 index d680e9228..000000000 --- a/tests/integration/guzzle/6/phpunit.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - ../test - test - - - - diff --git a/tests/integration/guzzle/Readme.md b/tests/integration/guzzle/Readme.md deleted file mode 100644 index 18af40f05..000000000 --- a/tests/integration/guzzle/Readme.md +++ /dev/null @@ -1,7 +0,0 @@ -Integration tests for Guzzle -============================ - -There is a folder for each major Guzzle version which includes a composer file and an example implementation -of the `ExampleHttpClient` class. - -The tests in the `./test/` folder are run for each Guzzle version. diff --git a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php b/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php deleted file mode 100644 index 40a82fd2b..000000000 --- a/tests/integration/guzzle/test/VCR/Example/ExampleHttpClientTest.php +++ /dev/null @@ -1,107 +0,0 @@ -setCassettePath(vfsStream::url('testDir')); - } - - public function testRequestGET(): void - { - \VCR\VCR::turnOn(); - \VCR\VCR::insertCassette('test-cassette.yml'); - $originalRequest = $this->requestGET(); - $this->assertValidGETResponse($originalRequest); - $interceptedRequest = $this->requestGET(); - $this->assertValidGETResponse($interceptedRequest); - $this->assertEquals($originalRequest, $interceptedRequest); - $repeatInterceptedRequest = $this->requestGET(); - $this->assertEquals($interceptedRequest, $repeatInterceptedRequest); - \VCR\VCR::turnOff(); - } - - public function testRequestPOST(): void - { - \VCR\VCR::turnOn(); - \VCR\VCR::insertCassette('test-cassette.yml'); - $originalRequest = $this->requestPOST(); - $this->assertValidPOSTResponse($originalRequest); - $interceptedRequest = $this->requestPOST(); - $this->assertValidPOSTResponse($interceptedRequest); - $this->assertEquals($originalRequest, $interceptedRequest); - $repeatInterceptedRequest = $this->requestPOST(); - $this->assertEquals($interceptedRequest, $repeatInterceptedRequest); - \VCR\VCR::turnOff(); - } - - protected function requestGET() - { - $exampleClient = new ExampleHttpClient(); - - $response = $exampleClient->get(self::TEST_GET_URL); - - return $response; - } - - protected function requestPOST() - { - $exampleClient = new ExampleHttpClient(); - - $response = $exampleClient->post(self::TEST_POST_URL, self::TEST_POST_BODY); - foreach ($this->ignoreHeaders as $header) { - unset($response['headers'][$header]); - } - unset($response['origin']); - - return $response; - } - - protected function requestPOSTIntercepted() - { - \VCR\VCR::turnOn(); - \VCR\VCR::insertCassette('test-cassette.yml'); - $info = $this->requestPOST(); - \VCR\VCR::turnOff(); - - return $info; - } - - protected function assertValidGETResponse($info): void - { - $this->assertIsArray($info, 'Response is not an array.'); - $this->assertArrayHasKey('url', $info, 'API did not return any value.'); - } - - protected function assertValidPOSTResponse($info): void - { - $this->assertIsArray($info, 'Response is not an array.'); - $this->assertArrayHasKey('url', $info, "Key 'url' not found."); - $this->assertEquals(self::TEST_POST_URL, $info['url'], "Value for key 'url' wrong."); - $this->assertArrayHasKey('headers', $info, "Key 'headers' not found."); - $this->assertIsArray($info['headers'], 'Headers is not an array.'); - $this->assertEquals(self::TEST_POST_BODY, $info['data'], 'Correct request body was not sent.'); - } -} diff --git a/tests/integration/guzzle/test/bootstrap.php b/tests/integration/guzzle/test/bootstrap.php deleted file mode 100644 index 97855d6a6..000000000 --- a/tests/integration/guzzle/test/bootstrap.php +++ /dev/null @@ -1,16 +0,0 @@ -addClassMap([ - 'VCR\\Example\\ExampleHttpClient' => 'ExampleHttpClient.php', -]); - -\VCR\VCR::turnOn(); -\VCR\VCR::turnOff(); diff --git a/tests/integration/soap/composer.json b/tests/integration/soap/composer.json deleted file mode 100644 index 3ce01e23c..000000000 --- a/tests/integration/soap/composer.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "require": { - "ext-soap": "*" - }, - "autoload": { - "classmap": ["src/"] - } -} diff --git a/tests/integration/soap/phpunit.xml b/tests/integration/soap/phpunit.xml deleted file mode 100644 index 689dc6888..000000000 --- a/tests/integration/soap/phpunit.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - ./test - - - - diff --git a/tests/integration/soap/test/bootstrap.php b/tests/integration/soap/test/bootstrap.php deleted file mode 100644 index a344b2c73..000000000 --- a/tests/integration/soap/test/bootstrap.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Thu, 9 Dec 2021 09:27:26 +0800 Subject: [PATCH 122/204] Support for Symfony 6 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 24cd1a39f..850b74375 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "php": "^8.0", "ext-curl": "*", "beberlei/assert": "^3.2.5", - "symfony/yaml": "^3.0|^4.0|^5.0", - "symfony/event-dispatcher": "^5.0" + "symfony/yaml": "^3.0|^4.0|^5.0|^6.0", + "symfony/event-dispatcher": "^5.0|^6.0" }, "require-dev": { "guzzlehttp/guzzle": "^7.0", From c064a4e90c5d86a0e94c3b9a9c1516e419be9156 Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Mon, 3 Jan 2022 21:11:24 +0100 Subject: [PATCH 123/204] Works --- src/VCR/LibraryHooks/CurlHook.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index ea2d5c73c..e2400074f 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -335,9 +335,9 @@ public static function curlGetinfo($curlHandle, int $option = 0) // Workaround for CURLINFO_PRIVATE. // It can be set AND read before the response is available, e.g by symfony/http-client. // - We return what was first set. - if ($option === CURLINFO_PRIVATE) { - return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; - } +// if ($option === CURLINFO_PRIVATE) { +// return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; +// } // if ($option === 0 && !in_array((int) $curlHandle, self::$responses, true)) { // return array_fill_keys(CurlHelper::$curlInfoList, null); From 39a8083f2db50eaf6b4cffdfc7f8ca1ab5cc7982 Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Mon, 3 Jan 2022 21:19:06 +0100 Subject: [PATCH 124/204] Works --- src/VCR/LibraryHooks/CurlHook.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index e2400074f..ea2d5c73c 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -335,9 +335,9 @@ public static function curlGetinfo($curlHandle, int $option = 0) // Workaround for CURLINFO_PRIVATE. // It can be set AND read before the response is available, e.g by symfony/http-client. // - We return what was first set. -// if ($option === CURLINFO_PRIVATE) { -// return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; -// } + if ($option === CURLINFO_PRIVATE) { + return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; + } // if ($option === 0 && !in_array((int) $curlHandle, self::$responses, true)) { // return array_fill_keys(CurlHelper::$curlInfoList, null); From 3ed4a46a47854f71219a78fba56f49f616f80c59 Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Mon, 3 Jan 2022 21:20:33 +0100 Subject: [PATCH 125/204] Works --- src/VCR/LibraryHooks/CurlHook.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index ea2d5c73c..6b65ccb93 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -339,9 +339,9 @@ public static function curlGetinfo($curlHandle, int $option = 0) return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; } -// if ($option === 0 && !in_array((int) $curlHandle, self::$responses, true)) { -// return array_fill_keys(CurlHelper::$curlInfoList, null); -// } + if ($option === 0 && !in_array((int) $curlHandle, self::$responses, true)) { + return array_fill_keys(CurlHelper::$curlInfoList, null); + } throw new \RuntimeException('Unexpected error, could not find curl_getinfo in response or errors'); } From 435e3f97ee9d2068b0439ed68961236eb31dd1fd Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Mon, 3 Jan 2022 21:23:55 +0100 Subject: [PATCH 126/204] Works --- src/VCR/LibraryHooks/CurlHook.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index 6b65ccb93..f859f4c6c 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -324,6 +324,13 @@ public static function curlMultiInfoRead() */ public static function curlGetinfo($curlHandle, int $option = 0) { + // Workaround for CURLINFO_PRIVATE. + // It can be set AND read before the response is available, e.g by symfony/http-client. + // - We return what was first set. + if ($option === CURLINFO_PRIVATE) { + return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; + } + if (isset(self::$responses[(int) $curlHandle])) { return CurlHelper::getCurlOptionFromResponse( self::$responses[(int) $curlHandle], @@ -332,13 +339,6 @@ public static function curlGetinfo($curlHandle, int $option = 0) } elseif (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getInfo(); } else { - // Workaround for CURLINFO_PRIVATE. - // It can be set AND read before the response is available, e.g by symfony/http-client. - // - We return what was first set. - if ($option === CURLINFO_PRIVATE) { - return static::$curlOptions[(int) $curlHandle][CURLOPT_PRIVATE]; - } - if ($option === 0 && !in_array((int) $curlHandle, self::$responses, true)) { return array_fill_keys(CurlHelper::$curlInfoList, null); } From e85bea14e313cffeafd9131f176e1db28c3b0a26 Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Mon, 3 Jan 2022 22:05:05 +0100 Subject: [PATCH 127/204] Works --- src/VCR/Util/HttpClient.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/VCR/Util/HttpClient.php b/src/VCR/Util/HttpClient.php index 556352732..6f57ea778 100644 --- a/src/VCR/Util/HttpClient.php +++ b/src/VCR/Util/HttpClient.php @@ -23,7 +23,9 @@ public function send(Request $request): Response { $ch = curl_init($request->getUrl()); - Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'"); + if ($ch === false) { + Assertion::isResource($ch, "Could not init curl with URL '{$request->getUrl()}'"); + } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); From 96f452c25912475686b2e7856547d2a6a1210c35 Mon Sep 17 00:00:00 2001 From: Tjeerd Bijlsma Date: Sat, 8 Jan 2022 15:02:00 +0100 Subject: [PATCH 128/204] Make SoapClient compatible again --- src/VCR/Util/SoapClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Util/SoapClient.php b/src/VCR/Util/SoapClient.php index 78a6279b1..a79690c34 100644 --- a/src/VCR/Util/SoapClient.php +++ b/src/VCR/Util/SoapClient.php @@ -54,7 +54,7 @@ public function __construct($wsdl, array $options = []) * * @return string|null the XML SOAP response (or null if $one_way is set) */ - public function __doRequest($request, $location, $action, $version, $one_way = 0) + public function __doRequest(string $request, string $location, string $action, int $version, bool $one_way = false) { // Save a copy of the request, not the request itself -- see issue #153 $this->request = (string) $request; From 783a29a53d42585dfac494f28f0914f5b0cfcb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCrtgen?= Date: Thu, 15 Dec 2022 09:50:55 +0100 Subject: [PATCH 129/204] TASK: Cleanup GitHub workflows --- .github/workflows/tests.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 017138f36..d4b9cf3fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,10 +57,15 @@ jobs: strategy: fail-fast: true matrix: - php: ["8.0"] - composer_flags: ["", "--prefer-lowest"] + php: + - "8.0" + stability: + - "stable" + dependencies: + - "lowest" + - "highest" - name: "Tests PHP ${{ matrix.php }} ${{ matrix.composer_flags}}" + name: "Tests PHP ${{ matrix.php }} ${{ matrix.stability}} ${{matrix.dependencies}}" runs-on: "ubuntu-latest" @@ -75,12 +80,18 @@ jobs: extensions: "curl, soap" tools: "composer:v2" coverage: "pcov" + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + if: "${{ matrix.stability == 'stable' }}" - name: "Check Composer configuration" run: "composer validate --strict" - name: "Install dependencies" - run: "composer update -o ${{ matrix.composer_flags }} --prefer-dist --no-interaction --no-progress" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "--prefer-dist -o" - name: "Execute tests" run: "vendor/bin/phpunit --coverage-clover=coverage.clover" From 444c810a4260e8bb5adbb612934bf1444836b037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 11:22:58 +0100 Subject: [PATCH 130/204] FIX: Allow phpstan/extension-install composer plugin --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 24cd1a39f..3e7a993d7 100644 --- a/composer.json +++ b/composer.json @@ -41,5 +41,10 @@ "psr-4": { "VCR\\Tests\\": "tests" } + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } From 87f2a5aab6b6d1aac1fb7a7006a3cfce6eaae1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCrtgen?= Date: Thu, 15 Dec 2022 09:47:39 +0100 Subject: [PATCH 131/204] Cleanup .gitattributes with export-ignore --- .gitattributes | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitattributes b/.gitattributes index 93298ab07..e69510864 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,10 @@ -/docs export-ignore -/tests export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml export-ignore -/phpunit.xml.dist export-ignore +/docs export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.dist.php export-ignore +/docker-compose.yaml export-ignore +/phpstan.neo export-ignore +/phpstan-baseline.neon export-ignore +/phpunit.xml.dist export-ignore +/resources export-ignore From 70d1623f29e38b40b5de1289e879b756f0474323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 12:02:02 +0100 Subject: [PATCH 132/204] TASK: Use composer-install action for workflows --- .github/workflows/tests.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4b9cf3fa..304df3828 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,10 @@ jobs: run: "composer validate --strict" - name: "Install dependencies" - run: "composer update --prefer-dist --no-interaction --no-progress" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + composer-options: "--prefer-dist" - name: "Execute static analysis" run: "composer run-script phpstan" @@ -48,7 +51,10 @@ jobs: run: "composer validate --strict" - name: "Install dependencies" - run: "composer update --prefer-dist --no-interaction --no-progress" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + composer-options: "--prefer-dist" - name: "Execute linting" run: "composer run-script lint" From 9c34e8d5f71f03993f41673c4e1f37ed25f460fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 12:06:00 +0100 Subject: [PATCH 133/204] TASK: Apply codestyle fixes --- .../CodeTransform/AbstractCodeTransform.php | 1 - src/VCR/Exceptions/InvalidHostException.php | 4 +-- src/VCR/LibraryHooks/CurlHook.php | 26 +++++++++---------- src/VCR/Util/CurlException.php | 4 +-- src/VCR/Util/CurlHelper.php | 13 +++++----- src/VCR/Util/StreamProcessor.php | 10 +++---- src/VCR/VCR.php | 9 ++++--- src/VCR/Videorecorder.php | 4 +-- tests/Unit/LibraryHooks/CurlHookTest.php | 5 ++-- tests/Unit/LibraryHooks/SoapHookTest.php | 9 +++---- tests/Unit/RequestTest.php | 9 +++---- tests/Unit/Util/CurlHelperTest.php | 3 +-- tests/Unit/VCRFactoryTest.php | 1 + 13 files changed, 44 insertions(+), 54 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 02cf23252..09fd4e69b 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -4,7 +4,6 @@ namespace VCR\CodeTransform; -use function stream_get_filters; use VCR\Util\Assertion; /** diff --git a/src/VCR/Exceptions/InvalidHostException.php b/src/VCR/Exceptions/InvalidHostException.php index 4623ad09d..df2abfa4e 100644 --- a/src/VCR/Exceptions/InvalidHostException.php +++ b/src/VCR/Exceptions/InvalidHostException.php @@ -4,9 +4,7 @@ namespace VCR\Exceptions; -use InvalidArgumentException; - -class InvalidHostException extends InvalidArgumentException +class InvalidHostException extends \InvalidArgumentException { public static function create(?string $url): self { diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index d2e46ee86..b6d98c29d 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -4,8 +4,6 @@ namespace VCR\LibraryHooks; -use CurlHandle; -use CurlMultiHandle; use VCR\CodeTransform\AbstractCodeTransform; use VCR\Request; use VCR\Response; @@ -137,7 +135,7 @@ public static function __callStatic($method, array $args) /** * @see http://www.php.net/manual/en/function.curl-init.php */ - public static function curlInit(?string $url = null): CurlHandle|false + public static function curlInit(?string $url = null): \CurlHandle|false { $curlHandle = curl_init($url); if (false !== $curlHandle) { @@ -151,7 +149,7 @@ public static function curlInit(?string $url = null): CurlHandle|false /** * @see http://www.php.net/manual/en/function.curl-reset.php */ - public static function curlReset(CurlHandle $curlHandle): void + public static function curlReset(\CurlHandle $curlHandle): void { curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); @@ -168,7 +166,7 @@ public static function curlReset(CurlHandle $curlHandle): void * However, if the CURLOPT_RETURNTRANSFER option is set, it will return the * result on success, FALSE on failure. */ - public static function curlExec(CurlHandle $curlHandle) + public static function curlExec(\CurlHandle $curlHandle) { try { $request = self::$requests[(int) $curlHandle]; @@ -195,7 +193,7 @@ public static function curlExec(CurlHandle $curlHandle) * * @see http://www.php.net/manual/en/function.curl-multi-add-handle.php */ - public static function curlMultiAddHandle(CurlMultiHandle $multiHandle, CurlHandle $curlHandle): void + public static function curlMultiAddHandle(\CurlMultiHandle $multiHandle, \CurlHandle $curlHandle): void { if (!isset(self::$multiHandles[(int) $multiHandle])) { self::$multiHandles[(int) $multiHandle] = []; @@ -209,7 +207,7 @@ public static function curlMultiAddHandle(CurlMultiHandle $multiHandle, CurlHand * * @see http://www.php.net/manual/en/function.curl-multi-remove-handle.php */ - public static function curlMultiRemoveHandle(CurlMultiHandle $multiHandle, CurlHandle $curlHandle): void + public static function curlMultiRemoveHandle(\CurlMultiHandle $multiHandle, \CurlHandle $curlHandle): void { if (isset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle])) { unset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle]); @@ -221,7 +219,7 @@ public static function curlMultiRemoveHandle(CurlMultiHandle $multiHandle, CurlH * * @see http://www.php.net/manual/en/function.curl-multi-exec.php */ - public static function curlMultiExec(CurlMultiHandle $multiHandle, ?int &$stillRunning): int + public static function curlMultiExec(\CurlMultiHandle $multiHandle, ?int &$stillRunning): int { if (isset(self::$multiHandles[(int) $multiHandle])) { foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { @@ -264,7 +262,7 @@ public static function curlMultiInfoRead() * * @return string|null return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set */ - public static function curlMultiGetcontent(CurlHandle $curlHandle): ?string + public static function curlMultiGetcontent(\CurlHandle $curlHandle): ?string { return self::$multiReturnValues[(int) $curlHandle] ?? null; } @@ -276,7 +274,7 @@ public static function curlMultiGetcontent(CurlHandle $curlHandle): ?string * * @return mixed */ - public static function curlGetinfo(CurlHandle $curlHandle, int $option = 0) + public static function curlGetinfo(\CurlHandle $curlHandle, int $option = 0) { if (isset(self::$responses[(int) $curlHandle])) { return CurlHelper::getCurlOptionFromResponse( @@ -297,7 +295,7 @@ public static function curlGetinfo(CurlHandle $curlHandle, int $option = 0) * * @param mixed $value the value to be set on option */ - public static function curlSetopt(CurlHandle $curlHandle, int $option, $value): bool + public static function curlSetopt(\CurlHandle $curlHandle, int $option, $value): bool { CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value); @@ -313,7 +311,7 @@ public static function curlSetopt(CurlHandle $curlHandle, int $option, $value): * * @param array $options an array specifying which options to set and their values */ - public static function curlSetoptArray(CurlHandle $curlHandle, array $options): void + public static function curlSetoptArray(\CurlHandle $curlHandle, array $options): void { foreach ($options as $option => $value) { static::curlSetopt($curlHandle, $option, $value); @@ -325,7 +323,7 @@ public static function curlSetoptArray(CurlHandle $curlHandle, array $options): * * @see https://php.net/manual/en/function.curl-error.php */ - public static function curlError(CurlHandle $curlHandle): string + public static function curlError(\CurlHandle $curlHandle): string { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getMessage(); @@ -339,7 +337,7 @@ public static function curlError(CurlHandle $curlHandle): string * * @see https://php.net/manual/en/function.curl-errno.php */ - public static function curlErrno(CurlHandle $curlHandle): int + public static function curlErrno(\CurlHandle $curlHandle): int { if (isset(self::$lastErrors[(int) $curlHandle])) { return self::$lastErrors[(int) $curlHandle]->getCode(); diff --git a/src/VCR/Util/CurlException.php b/src/VCR/Util/CurlException.php index 443e00cbe..15ce0d7f0 100644 --- a/src/VCR/Util/CurlException.php +++ b/src/VCR/Util/CurlException.php @@ -4,8 +4,6 @@ namespace VCR\Util; -use CurlHandle; - class CurlException extends \Exception { /** @@ -13,7 +11,7 @@ class CurlException extends \Exception */ private array $info; - public static function create(CurlHandle $ch): self + public static function create(\CurlHandle $ch): self { $e = new self(curl_error($ch), curl_errno($ch)); $e->info = curl_getinfo($ch); diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 2b6b6c1f3..70c95b007 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -4,7 +4,6 @@ namespace VCR\Util; -use CurlHandle; use VCR\Request; use VCR\Response; @@ -14,7 +13,7 @@ class CurlHelper * @var array list of cURL info constants */ private static $curlInfoList = [ - //"certinfo"? + // "certinfo"? \CURLINFO_HTTP_CODE => 'http_code', \CURLINFO_EFFECTIVE_URL => 'url', \CURLINFO_TOTAL_TIME => 'total_time', @@ -48,7 +47,7 @@ class CurlHelper * * @param array $curlOptions cURL options which are not stored within the Response */ - public static function handleOutput(Response $response, array $curlOptions, CurlHandle $ch): ?string + public static function handleOutput(Response $response, array $curlOptions, \CurlHandle $ch): ?string { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[\CURLOPT_HEADERFUNCTION])) { @@ -84,9 +83,9 @@ public static function handleOutput(Response $response, array $curlOptions, Curl /** * @param int $option cURL option to get * - * @throws \BadMethodCallException - * * @return mixed value of the cURL option + * + * @throws \BadMethodCallException */ public static function getCurlOptionFromResponse(Response $response, int $option = 0) { @@ -185,7 +184,7 @@ public static function setCurlOptionOnRequest(Request $request, int $option, $va * Makes sure we've properly handled the POST body, such as ensuring that * CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set. */ - public static function validateCurlPOSTBody(Request $request, CurlHandle $curlHandle = null): void + public static function validateCurlPOSTBody(Request $request, \CurlHandle $curlHandle = null): void { $readFunction = $request->getCurlOption(\CURLOPT_READFUNCTION); if (null === $readFunction) { @@ -213,7 +212,7 @@ public static function validateCurlPOSTBody(Request $request, CurlHandle $curlHa * * @return mixed value returned by the callback function */ - private static function callFunction($callback, CurlHandle $curlHandle, $argument) + private static function callFunction($callback, \CurlHandle $curlHandle, $argument) { if (!\is_callable($callback) && \is_array($callback) && 2 === \count($callback)) { // This is probably a private or protected method on an object. Try and diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index 4535648c6..e015e72ef 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -517,9 +517,9 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool case \STREAM_OPTION_READ_BUFFER: // stream_set_read_buffer returns 0 in case of success return 0 === stream_set_read_buffer($this->resource, $arg1); - // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 - /*case STREAM_OPTION_CHUNK_SIZE: - return stream_set_chunk_size($this->resource, $arg1);*/ + // STREAM_OPTION_CHUNK_SIZE does not exist at all in PHP 7 + /*case STREAM_OPTION_CHUNK_SIZE: + return stream_set_chunk_size($this->resource, $arg1);*/ } return false; @@ -528,13 +528,13 @@ public function stream_set_option(int $option, int $arg1, int $arg2): bool /** * Write to stream. * - * @throws \BadMethodCallException if called, because this method is not applicable for this stream - * * @see http://www.php.net/manual/en/streamwrapper.stream-write.php * * @param string $data should be stored into the underlying stream * * @return int|false + * + * @throws \BadMethodCallException if called, because this method is not applicable for this stream */ public function stream_write(string $data) { diff --git a/src/VCR/VCR.php b/src/VCR/VCR.php index 843a821fe..0dfef1a2a 100644 --- a/src/VCR/VCR.php +++ b/src/VCR/VCR.php @@ -10,10 +10,11 @@ * Singleton interface to a Videorecorder. * * @method static Configuration configure() - * @method static void insertCassette(string $cassetteName) - * @method static void turnOn() - * @method static void turnOff() - * @method static void eject() + * @method static void insertCassette(string $cassetteName) + * @method static void turnOn() + * @method static void turnOff() + * @method static void eject() + * * @mixin Videorecorder */ class VCR diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 265fb417e..f182b2e18 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -141,7 +141,7 @@ public function configure(): Configuration public function handleRequest(Request $request): Response { if (null === $this->cassette) { - throw new \BadMethodCallException('Invalid http request. No cassette inserted. '.'Please make sure to insert a cassette in your unit test using '."VCR::insertCassette('name');"); + throw new \BadMethodCallException('Invalid http request. No cassette inserted. Please make sure to insert a cassette in your unit test using '."VCR::insertCassette('name');"); } $this->dispatch(new BeforePlaybackEvent($request, $this->cassette), VCREvents::VCR_BEFORE_PLAYBACK); @@ -159,7 +159,7 @@ public function handleRequest(Request $request): Response || VCR::MODE_ONCE === $this->config->getMode() && false === $this->cassette->isNew() ) { - throw new \LogicException(sprintf("The request does not match a previously recorded request and the 'mode' is set to '%s'. "."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. ".'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.'."\nCassette: %s \n Request: %s", $this->config->getMode(), $this->cassette->getName(), print_r($request->toArray(), true))); + throw new \LogicException(sprintf("The request does not match a previously recorded request and the 'mode' is set to '%s'. If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. ".'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.'."\nCassette: %s \n Request: %s", $this->config->getMode(), $this->cassette->getName(), print_r($request->toArray(), true))); } $this->disableLibraryHooks(); diff --git a/tests/Unit/LibraryHooks/CurlHookTest.php b/tests/Unit/LibraryHooks/CurlHookTest.php index e66d644de..6e4183615 100644 --- a/tests/Unit/LibraryHooks/CurlHookTest.php +++ b/tests/Unit/LibraryHooks/CurlHookTest.php @@ -5,7 +5,6 @@ namespace VCR\Tests\Unit\LibraryHooks; use Assert\Assertion; -use Closure; use PHPUnit\Framework\TestCase; use VCR\CodeTransform\CurlCodeTransform; use VCR\Configuration; @@ -466,10 +465,10 @@ function (Request $request) use ($testClass) { $this->curlHook->disable(); } - protected function getTestCallback(string $statusCode = '200'): Closure + protected function getTestCallback(string $statusCode = '200'): \Closure { $testClass = $this; - return Closure::fromCallable(fn () => new Response($statusCode, [], $testClass->expected)); + return \Closure::fromCallable(fn () => new Response($statusCode, [], $testClass->expected)); } } diff --git a/tests/Unit/LibraryHooks/SoapHookTest.php b/tests/Unit/LibraryHooks/SoapHookTest.php index 63f261c3d..9ad302eba 100644 --- a/tests/Unit/LibraryHooks/SoapHookTest.php +++ b/tests/Unit/LibraryHooks/SoapHookTest.php @@ -4,7 +4,6 @@ namespace VCR\Tests\Unit\LibraryHooks; -use Closure; use PHPUnit\Framework\TestCase; use VCR\CodeTransform\SoapCodeTransform; use VCR\Configuration; @@ -95,19 +94,19 @@ public function testShouldReturnLastRequestWithTraceOn(): void $this->assertNotNull($actual, '__getLastRequest() returned NULL.'); } - protected function getContentCheckCallback(): Closure + protected function getContentCheckCallback(): \Closure { $testClass = $this; - return Closure::fromCallable(fn () => new Response('200', [], $testClass->expected)); + return \Closure::fromCallable(fn () => new Response('200', [], $testClass->expected)); } /** @param array $expectedHeaders */ - protected function getHeadersCheckCallback(array $expectedHeaders): Closure + protected function getHeadersCheckCallback(array $expectedHeaders): \Closure { $test = $this; - return Closure::fromCallable(function (Request $request) use ($test, $expectedHeaders) { + return \Closure::fromCallable(function (Request $request) use ($test, $expectedHeaders) { foreach ($expectedHeaders as $expectedHeaderName => $expectedHeader) { $test->assertEquals($expectedHeader, $request->getHeader($expectedHeaderName)); } diff --git a/tests/Unit/RequestTest.php b/tests/Unit/RequestTest.php index 8c77dc158..876e90b49 100644 --- a/tests/Unit/RequestTest.php +++ b/tests/Unit/RequestTest.php @@ -4,7 +4,6 @@ namespace VCR\Tests\Unit; -use const CURLOPT_CUSTOMREQUEST; use PHPUnit\Framework\TestCase; use VCR\Request; @@ -263,8 +262,8 @@ public function testCurlCustomRequestOverridesMethod(): void $this->assertEquals('POST', $postRequest->getMethod()); $this->assertEquals('GET', $getRequest->getMethod()); - $postRequest->setCurlOption(CURLOPT_CUSTOMREQUEST, 'PUT'); - $getRequest->setCurlOption(CURLOPT_CUSTOMREQUEST, 'POST'); + $postRequest->setCurlOption(\CURLOPT_CUSTOMREQUEST, 'PUT'); + $getRequest->setCurlOption(\CURLOPT_CUSTOMREQUEST, 'POST'); $this->assertEquals('PUT', $postRequest->getMethod()); $this->assertEquals('POST', $getRequest->getMethod()); @@ -274,8 +273,8 @@ public function testSetCurlOptions(): void { $getRequest = new Request('GET', 'http://example.com'); $getRequest->setCurlOptions([ - CURLOPT_CUSTOMREQUEST => 'PUT', + \CURLOPT_CUSTOMREQUEST => 'PUT', ]); - $this->assertEquals('PUT', $getRequest->getCurlOption(CURLOPT_CUSTOMREQUEST)); + $this->assertEquals('PUT', $getRequest->getCurlOption(\CURLOPT_CUSTOMREQUEST)); } } diff --git a/tests/Unit/Util/CurlHelperTest.php b/tests/Unit/Util/CurlHelperTest.php index 8b9e81e5d..83bdde466 100644 --- a/tests/Unit/Util/CurlHelperTest.php +++ b/tests/Unit/Util/CurlHelperTest.php @@ -4,7 +4,6 @@ namespace VCR\Tests\Unit\Util; -use CurlHandle; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; use VCR\Exceptions\InvalidHostException; @@ -571,7 +570,7 @@ private function privateCurlHeaderFunction($ch, string $header): void /** * Function used for testing CURLOPT_WRITEFUNCTION. */ - private function privateCurlWriteFunction(CurlHandle $ch, string $body): int + private function privateCurlWriteFunction(\CurlHandle $ch, string $body): int { $this->assertEquals('example response', $body); diff --git a/tests/Unit/VCRFactoryTest.php b/tests/Unit/VCRFactoryTest.php index a75bad419..ce8a8cdf1 100644 --- a/tests/Unit/VCRFactoryTest.php +++ b/tests/Unit/VCRFactoryTest.php @@ -12,6 +12,7 @@ final class VCRFactoryTest extends TestCase { /** * @dataProvider instanceProvider + * * @covers \VCR\VCRFactory::createVCRVideorecorder() * * @param class-string $instance From a78277ff683e763b543d3734261083af66909c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 12:10:47 +0100 Subject: [PATCH 134/204] FIX: Fix scrutinizer workflow action uploading --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 304df3828..3aaa16018 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -78,6 +78,8 @@ jobs: steps: - name: "Checkout code" uses: "actions/checkout@v2" + with: + fetch-depth: 10 - name: "Setup PHP" uses: "shivammathur/setup-php@v2" From 81b291785039f3957b2f8190fc293e250735514e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 11:01:05 +0100 Subject: [PATCH 135/204] TASK: Added php-xdebug ext to workspace docker container --- resources/docker/workspace/Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/docker/workspace/Dockerfile b/resources/docker/workspace/Dockerfile index 7e8595696..d52603324 100644 --- a/resources/docker/workspace/Dockerfile +++ b/resources/docker/workspace/Dockerfile @@ -8,6 +8,8 @@ RUN apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ # for soap libxml2-dev \ + # for xdebug \ + linux-headers \ && \ apk add --no-cache \ bash \ @@ -22,9 +24,12 @@ RUN apk add --no-cache --virtual .build-deps \ # pcov for coverage runs pcov && docker-php-ext-enable pcov \ && \ + # for debugging + pecl install xdebug && docker-php-ext-enable xdebug \ + && \ apk del .build-deps -COPY --from=composer /usr/bin/composer /usr/bin/composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html From de556643f963d967a095522f486c0994f24557b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 11:15:18 +0100 Subject: [PATCH 136/204] FEATURE: Allow lower versions of symfony/event-dispatcher --- composer.json | 7 ++++--- src/VCR/Event/Event.php | 4 +++- src/VCR/Videorecorder.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 3e7a993d7..858e6ccb5 100644 --- a/composer.json +++ b/composer.json @@ -15,11 +15,12 @@ } ], "require": { - "php": "^8.0", + "php": "^8", "ext-curl": "*", "beberlei/assert": "^3.2.5", - "symfony/yaml": "^3.0|^4.0|^5.0", - "symfony/event-dispatcher": "^5.0" + "symfony/yaml": "^3|^4|^5", + "symfony/event-dispatcher": "^4|^5", + "symfony/event-dispatcher-contracts": "^1|^2|^3" }, "require-dev": { "guzzlehttp/guzzle": "^7.0", diff --git a/src/VCR/Event/Event.php b/src/VCR/Event/Event.php index e6bb0c02a..f9b3de8e0 100644 --- a/src/VCR/Event/Event.php +++ b/src/VCR/Event/Event.php @@ -4,6 +4,8 @@ namespace VCR\Event; -abstract class Event extends \Symfony\Contracts\EventDispatcher\Event +use Symfony\Contracts\EventDispatcher\Event as BaseEvent; + +abstract class Event extends BaseEvent { } diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index f182b2e18..377a06592 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -5,7 +5,7 @@ namespace VCR; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use VCR\Event\AfterHttpRequestEvent; use VCR\Event\AfterPlaybackEvent; use VCR\Event\BeforeHttpRequestEvent; From 7818e1fa56b33829d476eed7977c8314d017b064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 12:33:14 +0100 Subject: [PATCH 137/204] TASK: Ignore phpstan error --- phpstan-baseline.neon | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ec2babc4b..51967e817 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,3 +25,7 @@ parameters: count: 1 path: src/VCR/Videorecorder.php + - + message: "#^Call to an undefined method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:addListener\\(\\)\\.$#" + count: 1 + path: tests/Unit/VCRTest.php From 75735a6bd6808a97d950e690d302aba9e4ba7c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 15:40:55 +0100 Subject: [PATCH 138/204] FEATURE: Upgrade phpstan --- composer.json | 8 ++++---- phpstan-baseline.neon | 29 ++++++++++++++++++++++------- phpstan.neon | 2 +- src/VCR/LibraryHooks/CurlHook.php | 4 ++-- src/VCR/Util/HttpUtil.php | 2 +- src/VCR/Util/StreamProcessor.php | 2 +- src/VCR/VCRFactory.php | 13 +++++++++++-- tests/Unit/RequestTest.php | 1 - tests/Unit/VCRTest.php | 2 +- 9 files changed, 43 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 858e6ccb5..fd59ba1b8 100644 --- a/composer.json +++ b/composer.json @@ -26,11 +26,11 @@ "guzzlehttp/guzzle": "^7.0", "phpunit/phpunit": "^9.5.0", "mikey179/vfsstream": "^1.6.10", - "phpstan/phpstan": "^0.12.92", - "phpstan/phpstan-beberlei-assert": "^0.12.0", - "thecodingmachine/phpstan-strict-rules": "^0.12", + "phpstan/phpstan": "^1", + "phpstan/phpstan-beberlei-assert": "^1", + "thecodingmachine/phpstan-strict-rules": "^1", "friendsofphp/php-cs-fixer": "^3.0", - "phpstan/phpstan-phpunit": "^0.12.22", + "phpstan/phpstan-phpunit": "^1", "phpstan/extension-installer": "^1.1" }, "autoload": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 51967e817..9176f950d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,20 +1,30 @@ parameters: ignoreErrors: - - message: "#^Access to an undefined property object\\:\\:\\$data\\.$#" - count: 2 - path: src/VCR/CodeTransform/AbstractCodeTransform.php - - - - message: "#^Access to an undefined property object\\:\\:\\$datalen\\.$#" + message: "#^Expression on left side of \\?\\? is not nullable\\.$#" count: 1 - path: src/VCR/CodeTransform/AbstractCodeTransform.php + path: src/VCR/Util/HttpUtil.php - message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|false given\\.$#" count: 1 path: src/VCR/Util/HttpUtil.php + - + message: "#^Method VCR\\\\Util\\\\SoapClient\\:\\:realDoRequest\\(\\) should return string but returns string\\|null\\.$#" + count: 1 + path: src/VCR/Util/SoapClient.php + + - + message: "#^Parameter \\#2 \\$length of function fread expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: src/VCR/Util/StreamProcessor.php + + - + message: "#^Parameter \\#2 \\$size of function ftruncate expects int\\<0, max\\>, int given\\.$#" + count: 1 + path: src/VCR/Util/StreamProcessor.php + - message: "#^Cannot call method record\\(\\) on VCR\\\\Cassette\\|null\\.$#" count: 1 @@ -25,6 +35,11 @@ parameters: count: 1 path: src/VCR/Videorecorder.php + - + message: "#^Parameter \\#2 \\$requestMatchers of method VCR\\\\Request\\:\\:matches\\(\\) expects array\\, array\\{array\\{'some', 'method'\\}\\} given\\.$#" + count: 1 + path: tests/Unit/RequestTest.php + - message: "#^Call to an undefined method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:addListener\\(\\)\\.$#" count: 1 diff --git a/phpstan.neon b/phpstan.neon index d9e3594d6..b6fbe5a16 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: max + level: 8 paths: - src - tests diff --git a/src/VCR/LibraryHooks/CurlHook.php b/src/VCR/LibraryHooks/CurlHook.php index b6d98c29d..9874bcb05 100644 --- a/src/VCR/LibraryHooks/CurlHook.php +++ b/src/VCR/LibraryHooks/CurlHook.php @@ -35,12 +35,12 @@ class CurlHook implements LibraryHook protected static array $curlOptions = []; /** - * @var array all curl handles which belong to curl_multi handles + * @var array> all curl handles which belong to curl_multi handles */ protected static array $multiHandles = []; /** - * @var array last active curl_multi_exec() handles + * @var array<\CurlHandle> last active curl_multi_exec() handles */ protected static array $multiExecLastChs = []; diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index bc4532be5..1915eae6e 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -53,7 +53,7 @@ public static function parseStatus(string $status): array $part = explode(' ', $status, 3); return [ - 'http_version' => substr(strrchr($part[0], '/'), 1), + 'http_version' => substr(strrchr($part[0], '/') ?? '', 1), 'code' => $part[1], 'message' => $part[2] ?? '', ]; diff --git a/src/VCR/Util/StreamProcessor.php b/src/VCR/Util/StreamProcessor.php index e015e72ef..1369f4b52 100644 --- a/src/VCR/Util/StreamProcessor.php +++ b/src/VCR/Util/StreamProcessor.php @@ -45,7 +45,7 @@ class StreamProcessor /** * @see http://www.php.net/manual/en/class.streamwrapper.php#streamwrapper.props.context * - * @var resource the current context, or NULL if no context was passed to the caller function + * @var resource|null the current context, or NULL if no context was passed to the caller function */ public $context; diff --git a/src/VCR/VCRFactory.php b/src/VCR/VCRFactory.php index fe36461b4..b60ef26e4 100644 --- a/src/VCR/VCRFactory.php +++ b/src/VCR/VCRFactory.php @@ -4,6 +4,7 @@ namespace VCR; +use Assert\Assertion; use VCR\LibraryHooks\CurlHook; use VCR\LibraryHooks\SoapHook; use VCR\Storage\Storage; @@ -46,9 +47,17 @@ protected function createVCRUtilStreamProcessor(): StreamProcessor protected function createStorage(string $cassetteName): Storage { $dsn = $this->config->getCassettePath(); - $class = $this->config->getStorage(); + $className = $this->config->getStorage(); + Assertion::subclassOf( + $className, + Storage::class, + sprintf('Storage class "%s" is not a subclass of "%s".', $className, Storage::class) + ); + + /** @var Storage $storage */ + $storage = new $className($dsn, $cassetteName); - return new $class($dsn, $cassetteName); + return $storage; } protected function createVCRLibraryHooksSoapHook(): SoapHook diff --git a/tests/Unit/RequestTest.php b/tests/Unit/RequestTest.php index 876e90b49..5d2ea3668 100644 --- a/tests/Unit/RequestTest.php +++ b/tests/Unit/RequestTest.php @@ -60,7 +60,6 @@ public function testMatchesThrowsExceptionIfMatcherNotFound(): void $request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']); $this->expectException(\BadFunctionCallException::class); $this->expectExceptionMessage("Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n"); - /* @phpstan-ignore-next-line */ $this->request->matches($request, [['some', 'method']]); } diff --git a/tests/Unit/VCRTest.php b/tests/Unit/VCRTest.php index 75ffaf37f..c6a6dac7e 100644 --- a/tests/Unit/VCRTest.php +++ b/tests/Unit/VCRTest.php @@ -114,7 +114,7 @@ public function testShouldThrowExceptionIfNoCassettePresent(): void VCR::configure()->enableLibraryHooks(['stream_wrapper']); VCR::turnOn(); // If there is no cassette inserted, a request should throw an exception - file_get_contents('http://example.com'); + file_get_contents('http://example.com'); // @phpstan-ignore-line VCR::turnOff(); } From 07e7beb3e688a1fa1793da319070e6c232f6da2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:01:01 +0100 Subject: [PATCH 139/204] TASK: Refactor GitHub workflow --- .github/workflows/tests.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3aaa16018..1026bd77d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,9 +102,16 @@ jobs: composer-options: "--prefer-dist -o" - name: "Execute tests" - run: "vendor/bin/phpunit --coverage-clover=coverage.clover" + run: "vendor/bin/phpunit --coverage-clover=coverage.clover --log-junit=phpunit.xml" - - name: Upload Scrutinizer coverage - uses: sudo-bot/action-scrutinizer@latest + - name: "Publish Test Report" + uses: "mikepenz/action-junit-report@v2" + if: "always()" # always run even if the previous step fails + with: + report_paths: "phpunit.xml" + + - name: "Upload Scrutinizer coverage" + uses: "sudo-bot/action-scrutinizer@latest" + if: "always()" # always run even if the previous step fails with: cli-args: "--format=php-clover coverage.clover" From 6a3ea7e1d0c7bd8713a6491fa11962ad9ab9d769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:21:42 +0100 Subject: [PATCH 140/204] FEATURE: Workspace docker image for php 8.1 added --- docker-compose.yaml | 14 ++++++- .../docker/workspace/{ => 8.0}/Dockerfile | 0 resources/docker/workspace/8.1/Dockerfile | 40 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) rename resources/docker/workspace/{ => 8.0}/Dockerfile (100%) create mode 100644 resources/docker/workspace/8.1/Dockerfile diff --git a/docker-compose.yaml b/docker-compose.yaml index ca06f8f53..f83c843d8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,9 +1,19 @@ version: "3.8" services: - workspace: + workspace80: tty: true build: - context: resources/docker/workspace + context: resources/docker/workspace/8.0 + args: + PUID: "${PUID:-1000}" + PGID: "${PGID:-1000}" + volumes: + - .:/var/www/html + - ~/.composer:/home/user/.composer + workspace81: + tty: true + build: + context: resources/docker/workspace/8.1 args: PUID: "${PUID:-1000}" PGID: "${PGID:-1000}" diff --git a/resources/docker/workspace/Dockerfile b/resources/docker/workspace/8.0/Dockerfile similarity index 100% rename from resources/docker/workspace/Dockerfile rename to resources/docker/workspace/8.0/Dockerfile diff --git a/resources/docker/workspace/8.1/Dockerfile b/resources/docker/workspace/8.1/Dockerfile new file mode 100644 index 000000000..37e39c29d --- /dev/null +++ b/resources/docker/workspace/8.1/Dockerfile @@ -0,0 +1,40 @@ +FROM php:8.1-cli-alpine + +ARG PUID=1000 +ARG PGID=1000 + +RUN apk add --no-cache --virtual .build-deps \ + # for extensions + $PHPIZE_DEPS \ + # for soap + libxml2-dev \ + # for xdebug \ + linux-headers \ + && \ + apk add --no-cache \ + bash \ + # for soap + libxml2 \ + # for composer + unzip \ + && \ + docker-php-ext-install soap \ + && \ + pecl install \ + # pcov for coverage runs + pcov && docker-php-ext-enable pcov \ + && \ + # for debugging + pecl install xdebug && docker-php-ext-enable xdebug \ + && \ + apk del .build-deps + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +# Add a non-root user to prevent files being created with root permissions on host machine. +RUN addgroup -g ${PGID} user && \ + adduser -u ${PUID} -G user -D user + +USER user From c1b28b298b75aa2d833572bc67f67aafdcf4ad2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:26:06 +0100 Subject: [PATCH 141/204] FEATURE: Test against php 8.1 with GitHub workflows --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1026bd77d..e1c95bbfe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -65,6 +65,7 @@ jobs: matrix: php: - "8.0" + - "8.1" stability: - "stable" dependencies: From f8668940b1867e10d58bfeaa01a732cc3377924c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:31:57 +0100 Subject: [PATCH 142/204] FIX: Fixed several issues with occurred with php >= 8.1 --- src/VCR/CodeTransform/AbstractCodeTransform.php | 2 +- src/VCR/Storage/AbstractStorage.php | 2 +- src/VCR/Storage/Blackhole.php | 3 +-- src/VCR/Storage/Yaml.php | 2 +- tests/Unit/Storage/AbstractStorageTest.php | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index 09fd4e69b..d2161458e 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -36,7 +36,7 @@ public function register(): void * * @see http://www.php.net/manual/en/php-user-filter.filter.php */ - public function filter($in, $out, &$consumed, $closing) + public function filter($in, $out, &$consumed, $closing): int { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = $this->transformCode($bucket->data); diff --git a/src/VCR/Storage/AbstractStorage.php b/src/VCR/Storage/AbstractStorage.php index e3658bb30..6ba79170d 100644 --- a/src/VCR/Storage/AbstractStorage.php +++ b/src/VCR/Storage/AbstractStorage.php @@ -68,7 +68,7 @@ public function __construct(string $cassettePath, string $cassetteName, string $ * * @return array|null parsed current record */ - public function current() + public function current(): ?array { return $this->current; } diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index b413fe2af..d12a21d26 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -36,9 +36,8 @@ public function key(): int } /** @return array|null */ - public function next(): ?array + public function next(): void { - return null; } public function rewind(): void diff --git a/src/VCR/Storage/Yaml.php b/src/VCR/Storage/Yaml.php index ed6be615b..f033d392e 100644 --- a/src/VCR/Storage/Yaml.php +++ b/src/VCR/Storage/Yaml.php @@ -88,7 +88,7 @@ public function rewind(): void $this->position = 0; } - public function valid() + public function valid(): bool { if (null === $this->current) { $this->next(); diff --git a/tests/Unit/Storage/AbstractStorageTest.php b/tests/Unit/Storage/AbstractStorageTest.php index 413a11050..5ed4ad188 100644 --- a/tests/Unit/Storage/AbstractStorageTest.php +++ b/tests/Unit/Storage/AbstractStorageTest.php @@ -51,7 +51,7 @@ public function next(): void { } - public function valid() + public function valid(): bool { return (bool) $this->position; } From 36f0be45ff52631c4683e39fa83413eb914d1377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:35:36 +0100 Subject: [PATCH 143/204] TASK: Disable failing fast while running phpunit tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e1c95bbfe..eb54e19bd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,7 +61,7 @@ jobs: tests: strategy: - fail-fast: true + fail-fast: false matrix: php: - "8.0" From d66f016b7e3eacaf49077533a0baa5fb7ee579e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:37:55 +0100 Subject: [PATCH 144/204] FIX: Fix phpstan issues and invalid BlackholeTest --- src/VCR/Storage/Blackhole.php | 1 - tests/Unit/Storage/BlackholeTest.php | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/VCR/Storage/Blackhole.php b/src/VCR/Storage/Blackhole.php index d12a21d26..3ddda9e08 100644 --- a/src/VCR/Storage/Blackhole.php +++ b/src/VCR/Storage/Blackhole.php @@ -35,7 +35,6 @@ public function key(): int throw new \BadMethodCallException('Not implemented'); } - /** @return array|null */ public function next(): void { } diff --git a/tests/Unit/Storage/BlackholeTest.php b/tests/Unit/Storage/BlackholeTest.php index c6044ec7a..9383d72eb 100644 --- a/tests/Unit/Storage/BlackholeTest.php +++ b/tests/Unit/Storage/BlackholeTest.php @@ -31,9 +31,12 @@ public function testStoreRecordingIsCallable(): void ]); } + /** + * @doesNotPerformAssertions + */ public function testNextIsCallable(): void { - $this->assertNull($this->storage->next()); + $this->storage->next(); } /** From 483c3aa76f58a7fb0b1d84f40622533590cec02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 16:52:46 +0100 Subject: [PATCH 145/204] FIX: Raise minimum version of phpunit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index fd59ba1b8..22a5665d3 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "symfony/event-dispatcher-contracts": "^1|^2|^3" }, "require-dev": { - "guzzlehttp/guzzle": "^7.0", - "phpunit/phpunit": "^9.5.0", + "guzzlehttp/guzzle": "^7", + "phpunit/phpunit": "^9.5.10", "mikey179/vfsstream": "^1.6.10", "phpstan/phpstan": "^1", "phpstan/phpstan-beberlei-assert": "^1", From ed9c2d06621197f08dd2358d205c0d4a0666915b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 22:53:53 +0100 Subject: [PATCH 146/204] FEATURE: Restructure GitHub Workflow --- .../{tests.yml => continuous integration.yml} | 57 +++++++++++-------- composer.json | 4 +- 2 files changed, 34 insertions(+), 27 deletions(-) rename .github/workflows/{tests.yml => continuous integration.yml} (72%) diff --git a/.github/workflows/tests.yml b/.github/workflows/continuous integration.yml similarity index 72% rename from .github/workflows/tests.yml rename to .github/workflows/continuous integration.yml index eb54e19bd..49bb1f2d0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/continuous integration.yml @@ -1,94 +1,100 @@ -name: "tests" +name: "Continuous Integration" on: push: - branches: - - "master" pull_request: jobs: phpstan: name: "PHPStan" runs-on: "ubuntu-latest" + steps: - name: "Checkout code" uses: "actions/checkout@v2" - - name: "Setup PHP" + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + - name: "Check Composer configuration" run: "composer validate --strict" - - name: "Install dependencies" + - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" - composer-options: "--prefer-dist" + composer-options: "--prefer-dist -o" - - name: "Execute static analysis" + - name: "Run PHPStan" run: "composer run-script phpstan" - lint: + codestyle: name: "PHP-CS-Fixer" runs-on: "ubuntu-latest" + steps: - name: "Checkout code" uses: "actions/checkout@v2" - - name: "Setup PHP" + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "8.0" extensions: "curl, soap" tools: "composer:v2" + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + - name: "Check Composer configuration" run: "composer validate --strict" - - name: "Install dependencies" + - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" with: dependency-versions: "highest" - composer-options: "--prefer-dist" + composer-options: "--prefer-dist -o" - - name: "Execute linting" - run: "composer run-script lint" + - name: "Run PHP-CS-Fixer" + run: "composer run-script cs" + + phpunit: + name: "PHPUnit Test" + runs-on: "ubuntu-latest" - tests: strategy: fail-fast: false matrix: php: - "8.0" - "8.1" - stability: - - "stable" dependencies: - "lowest" - "highest" - - name: "Tests PHP ${{ matrix.php }} ${{ matrix.stability}} ${{matrix.dependencies}}" - - runs-on: "ubuntu-latest" + stability: + - "stable" steps: - name: "Checkout code" uses: "actions/checkout@v2" with: - fetch-depth: 10 + fetch-depth: 2 - - name: "Setup PHP" + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php }}" extensions: "curl, soap" tools: "composer:v2" coverage: "pcov" + - name: "Enforce using stable dependencies" run: "composer config minimum-stability stable" if: "${{ matrix.stability == 'stable' }}" @@ -96,13 +102,13 @@ jobs: - name: "Check Composer configuration" run: "composer validate --strict" - - name: "Install dependencies" + - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "--prefer-dist -o" - - name: "Execute tests" + - name: "Run PHPUnit Test" run: "vendor/bin/phpunit --coverage-clover=coverage.clover --log-junit=phpunit.xml" - name: "Publish Test Report" @@ -110,8 +116,9 @@ jobs: if: "always()" # always run even if the previous step fails with: report_paths: "phpunit.xml" + check_name: "PHPUnit Test Report (${{ matrix.php }}, ${{ matrix.dependencies }}, ${{ matrix.stability }})" - - name: "Upload Scrutinizer coverage" + - name: "Publish Scrutinizer Coverage" uses: "sudo-bot/action-scrutinizer@latest" if: "always()" # always run even if the previous step fails with: diff --git a/composer.json b/composer.json index 22a5665d3..fc081d66c 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "license": "MIT", "scripts": { "test": "./vendor/bin/phpunit", - "lint": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", - "fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", + "cs": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", + "cs-fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", "phpstan": "php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon --no-progress -vvv" }, "authors": [ From e5da4cb5f9e3ece0ab8e98c408fb645372112673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 23:02:28 +0100 Subject: [PATCH 147/204] FEATURE: Added editorconfig checker --- .ecrc | 4 ++++ .editorconfig | 3 +++ .gitattributes | 1 + .github/workflows/continuous integration.yml | 14 ++++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 .ecrc diff --git a/.ecrc b/.ecrc new file mode 100644 index 000000000..474285298 --- /dev/null +++ b/.ecrc @@ -0,0 +1,4 @@ +{ + "Verbose": true, + "IgnoreDefaults": false +} diff --git a/.editorconfig b/.editorconfig index dd7983d3d..b8f667267 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ trim_trailing_whitespace = false [*.{yml,yaml,neon}] indent_size = 2 + +[.ecrc] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index e69510864..16f3cfffc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,7 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php-cs-fixer.dist.php export-ignore +/.ecrc export-ignore /docker-compose.yaml export-ignore /phpstan.neo export-ignore /phpstan-baseline.neon export-ignore diff --git a/.github/workflows/continuous integration.yml b/.github/workflows/continuous integration.yml index 49bb1f2d0..c30c86fc5 100644 --- a/.github/workflows/continuous integration.yml +++ b/.github/workflows/continuous integration.yml @@ -35,6 +35,20 @@ jobs: - name: "Run PHPStan" run: "composer run-script phpstan" + editorconfig-checker: + name: EditorConfig Checker + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install EditorConfig Checker" + uses: "editorconfig-checker/action-editorconfig-checker@main" + + - name: "Run EditorConfig Checker" + run: "editorconfig-checker" + codestyle: name: "PHP-CS-Fixer" runs-on: "ubuntu-latest" From c8a7ec1987a88bbbd59e86b97be409ff80dd263d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 23:10:50 +0100 Subject: [PATCH 148/204] FIX: Fix editorconfig violations --- .ecrc | 3 ++- .editorconfig | 12 ++++++------ LICENSE.md | 2 +- phpstan.neon | 8 ++++---- src/VCR/Util/HttpUtil.php | 4 ++-- .../Unit/CodeTransform/SoapCodeTransformTest.php | 16 ++++++++-------- tests/Unit/RequestTest.php | 2 +- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.ecrc b/.ecrc index 474285298..615bd2a6d 100644 --- a/.ecrc +++ b/.ecrc @@ -1,4 +1,5 @@ { "Verbose": true, - "IgnoreDefaults": false + "IgnoreDefaults": false, + "Exclude": ["tests/fixtures"] } diff --git a/.editorconfig b/.editorconfig index b8f667267..eda412b6c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,14 +5,14 @@ charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space -indent_size = 4 +indent_size = 2 trim_trailing_whitespace = true +[*.php] +indent_size = 4 + [*.md] trim_trailing_whitespace = false -[*.{yml,yaml,neon}] -indent_size = 2 - -[.ecrc] -indent_size = 2 +[*.neon] +indent_style = tab diff --git a/LICENSE.md b/LICENSE.md index 0d8812c51..bb5af01e3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/phpstan.neon b/phpstan.neon index b6fbe5a16..492460e87 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 8 - paths: - - src - - tests + level: 8 + paths: + - src + - tests diff --git a/src/VCR/Util/HttpUtil.php b/src/VCR/Util/HttpUtil.php index 1915eae6e..806073aae 100644 --- a/src/VCR/Util/HttpUtil.php +++ b/src/VCR/Util/HttpUtil.php @@ -121,8 +121,8 @@ public static function formatHeadersForCurl(array $headers): array public static function formatAsStatusString(Response $response): string { return 'HTTP/'.$response->getHttpVersion() - .' '.$response->getStatusCode() - .' '.$response->getStatusMessage(); + .' '.$response->getStatusCode() + .' '.$response->getStatusMessage(); } /** diff --git a/tests/Unit/CodeTransform/SoapCodeTransformTest.php b/tests/Unit/CodeTransform/SoapCodeTransformTest.php index 354e8f5d5..af43310aa 100644 --- a/tests/Unit/CodeTransform/SoapCodeTransformTest.php +++ b/tests/Unit/CodeTransform/SoapCodeTransformTest.php @@ -29,14 +29,14 @@ public function publicTransformCode(string $code): string public function codeSnippetProvider(): array { return [ - ['new \VCR\Util\SoapClient(', 'new \SoapClient('], - ['new \VCR\Util\SoapClient(', 'new SoapClient('], - ['extends \VCR\Util\SoapClient', 'extends \SoapClient'], - ["extends \\VCR\\Util\\SoapClient\n", "extends \\SoapClient\n"], - ["extends MySoapClientBuilder\n", "extends MySoapClientBuilder\n"], - ["extends SoapClientFactory\n", "extends SoapClientFactory\n"], - ['new SoapClientExtended(', 'new SoapClientExtended('], - ['new \SoapClientExtended(', 'new \SoapClientExtended('], + ['new \VCR\Util\SoapClient(', 'new \SoapClient('], + ['new \VCR\Util\SoapClient(', 'new SoapClient('], + ['extends \VCR\Util\SoapClient', 'extends \SoapClient'], + ["extends \\VCR\\Util\\SoapClient\n", "extends \\SoapClient\n"], + ["extends MySoapClientBuilder\n", "extends MySoapClientBuilder\n"], + ["extends SoapClientFactory\n", "extends SoapClientFactory\n"], + ['new SoapClientExtended(', 'new SoapClientExtended('], + ['new \SoapClientExtended(', 'new \SoapClientExtended('], ]; } } diff --git a/tests/Unit/RequestTest.php b/tests/Unit/RequestTest.php index 5d2ea3668..4d502a44c 100644 --- a/tests/Unit/RequestTest.php +++ b/tests/Unit/RequestTest.php @@ -73,7 +73,7 @@ public function testRestoreRequest(): void 'headers' => [ 'User-Agent' => 'Unit-Test', 'Host' => 'example.com', - ], + ], ], $restoredRequest->toArray() ); From d0cbc117a45f310287e61b518270a5aab7746573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Thu, 15 Dec 2022 23:32:47 +0100 Subject: [PATCH 149/204] TASK: Added .editorconfig to export-ignore via .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 16f3cfffc..85ff2cab0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,7 @@ /.gitattributes export-ignore /.gitignore export-ignore /.php-cs-fixer.dist.php export-ignore +/.editorconfig export-ignore /.ecrc export-ignore /docker-compose.yaml export-ignore /phpstan.neo export-ignore From 4ada3235edefcf044eeacbf99ae1ab5218cf5771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 14:24:22 +0100 Subject: [PATCH 150/204] FEATURE: Install editorconfig-checker wrapper for php --- .ecrc | 11 +++++++++-- composer.json | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.ecrc b/.ecrc index 615bd2a6d..9d5e86940 100644 --- a/.ecrc +++ b/.ecrc @@ -1,5 +1,12 @@ { "Verbose": true, - "IgnoreDefaults": false, - "Exclude": ["tests/fixtures"] + "IgnoreDefaults": true, + "Exclude": [ + ".phpunit.result.cache", + ".php-cs-fixer.cache", + ".idea", + ".git", + "vendor/", + "tests/fixtures" + ] } diff --git a/composer.json b/composer.json index fc081d66c..336421880 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "test": "./vendor/bin/phpunit", "cs": "./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", "cs-fix": "./vendor/bin/php-cs-fixer fix --verbose --diff", - "phpstan": "php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon --no-progress -vvv" + "phpstan": "php -d memory_limit=-1 vendor/bin/phpstan analyse -c phpstan.neon --no-progress -vvv", + "ec": "./vendor/bin/ec" }, "authors": [ { @@ -31,7 +32,8 @@ "thecodingmachine/phpstan-strict-rules": "^1", "friendsofphp/php-cs-fixer": "^3.0", "phpstan/phpstan-phpunit": "^1", - "phpstan/extension-installer": "^1.1" + "phpstan/extension-installer": "^1.1", + "editorconfig-checker/editorconfig-checker": "^10.3" }, "autoload": { "psr-4": { From 75f3e56fa8984363a2b9d7f19c0998027ddab7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 14:25:06 +0100 Subject: [PATCH 151/204] TASK: Fix export-ignore for phpstan in .gitattributes --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 85ff2cab0..0b9d70cfc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,7 @@ /.editorconfig export-ignore /.ecrc export-ignore /docker-compose.yaml export-ignore -/phpstan.neo export-ignore +/phpstan.neon export-ignore /phpstan-baseline.neon export-ignore /phpunit.xml.dist export-ignore /resources export-ignore From bf37eb24f03fb7046ff8054f26bfc1381b37ae5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 14:25:41 +0100 Subject: [PATCH 152/204] TASK: Do not exclude defaults for editorconfig checker --- .ecrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ecrc b/.ecrc index 9d5e86940..4d0f6e504 100644 --- a/.ecrc +++ b/.ecrc @@ -1,6 +1,6 @@ { "Verbose": true, - "IgnoreDefaults": true, + "IgnoreDefaults": false, "Exclude": [ ".phpunit.result.cache", ".php-cs-fixer.cache", From 7590bbc108f8c32e13eb62ad9260cee3eed8e45e Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Wed, 13 Feb 2019 11:34:10 -0800 Subject: [PATCH 153/204] Rework https://github.com/php-vcr/php-vcr/pull/161. Manage request index state in Videorecorder. Enable Cassette to playback and record request/responses at a given index. Do not require Cassette to manage index state. --- src/VCR/Cassette.php | 17 ++++++++++------- src/VCR/Request.php | 10 ++++++++++ src/VCR/Storage/Storage.php | 2 +- src/VCR/Videorecorder.php | 21 +++++++++++++++++++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 9f7bcc708..2f64f8d9b 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -21,32 +21,35 @@ public function __construct( ) { } - public function hasResponse(Request $request): bool + public function hasResponse(Request $request, int $index = 0): bool { - return null !== $this->playback($request); + return null !== $this->playback($request, $index); } - public function playback(Request $request): ?Response + public function playback(Request $request, int $index = 0): ?Response { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); - if ($storedRequest->matches($request, $this->getRequestMatchers())) { - return Response::fromArray($recording['response']); + if ($index === $recording['index']) { + if ($storedRequest->matches($request, $this->getRequestMatchers())) { + return Response::fromArray($recording['response']); + } } } return null; } - public function record(Request $request, Response $response): void + public function record(Request $request, Response $response, int $index): void { - if ($this->hasResponse($request)) { + if ($this->hasResponse($request, $index)) { return; } $this->storage->storeRecording([ 'request' => $request->toArray(), 'response' => $response->toArray(), + 'index' => $index, ]); } diff --git a/src/VCR/Request.php b/src/VCR/Request.php index 01b680afe..5a18569ae 100644 --- a/src/VCR/Request.php +++ b/src/VCR/Request.php @@ -301,4 +301,14 @@ public function addPostFile(array $file): void { $this->postFiles[] = $file; } + + /** + * Generate a string representation of the request. + * + * @return string + */ + public function getHash() + { + return md5(serialize($this->toArray())); + } } diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index 4182f33e2..839d6e0de 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -15,7 +15,7 @@ interface Storage extends \Iterator { /** - * @param array|null> $recording + * @param array|null, int> $recording */ public function storeRecording(array $recording): void; diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 377a06592..f116f3c85 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -37,6 +37,11 @@ class Videorecorder protected EventDispatcherInterface $eventDispatcher; + /** + * @var array + */ + protected array $indexTable = []; + public function __construct( protected Configuration $config, protected HttpClient $client, @@ -146,7 +151,9 @@ public function handleRequest(Request $request): Response $this->dispatch(new BeforePlaybackEvent($request, $this->cassette), VCREvents::VCR_BEFORE_PLAYBACK); - $response = $this->cassette->playback($request); + // Add an index to the request to allow recording identical requests and play them back in the same sequence. + $index = $this->iterateIndex($request); + $response = $this->cassette->playback($request, $index); // Playback succeeded and the recorded response can be returned. if (!empty($response)) { @@ -170,7 +177,7 @@ public function handleRequest(Request $request): Response $this->dispatch(new AfterHttpRequestEvent($request, $response), VCREvents::VCR_AFTER_HTTP_REQUEST); $this->dispatch(new BeforeRecordEvent($request, $response, $this->cassette), VCREvents::VCR_BEFORE_RECORD); - $this->cassette->record($request, $response); + $this->cassette->record($request, $response, $index); } finally { $this->enableLibraryHooks(); } @@ -214,4 +221,14 @@ public function __destruct() $this->turnOff(); } } + + protected function iterateIndex(Request $request): int + { + $hash = $request->getHash(); + if (!isset($this->indexTable[$hash])) { + $this->indexTable[$hash] = -1; + } + + return ++$this->indexTable[$hash]; + } } From 9f971f6a49c004453261e0e707614599677f4ada Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Wed, 13 Feb 2019 13:45:12 -0800 Subject: [PATCH 154/204] $index should not be a required parameter on record(). Avoid unecessary API changes. --- src/VCR/Cassette.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 2f64f8d9b..37c597b6a 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -40,7 +40,7 @@ public function playback(Request $request, int $index = 0): ?Response return null; } - public function record(Request $request, Response $response, int $index): void + public function record(Request $request, Response $response, int $index = 0): void { if ($this->hasResponse($request, $index)) { return; From 3aa54e82a93773ebed0155bb7603d7eaa74cdf98 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Wed, 13 Feb 2019 15:12:07 -0800 Subject: [PATCH 155/204] Ensure that the cassette indexes are reset when the cassette is ejected or inserted. --- src/VCR/Videorecorder.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index f116f3c85..789402e58 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -103,7 +103,9 @@ public function turnOff(): void public function eject(): void { Assertion::true($this->isOn, 'Please turn on VCR before ejecting a cassette, use: VCR::turnOn().'); + $this->cassette = null; + $this->resetIndex(); } /** @@ -121,6 +123,7 @@ public function insertCassette(string $cassetteName): void $this->cassette = new Cassette($cassetteName, $this->config, $storage); $this->enableLibraryHooks(); + $this->resetIndex(); } /** @@ -231,4 +234,9 @@ protected function iterateIndex(Request $request): int return ++$this->indexTable[$hash]; } + + public function resetIndex(): void + { + $this->indexTable = []; + } } From 9037b98df21119c95df81a7ad48bfdf9e6532676 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Thu, 14 Feb 2019 10:32:21 -0800 Subject: [PATCH 156/204] Use equals not identical operator when comparing the request index to the recording index. --- src/VCR/Cassette.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 37c597b6a..3111b2876 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -30,7 +30,7 @@ public function playback(Request $request, int $index = 0): ?Response { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); - if ($index === $recording['index']) { + if ($index == $recording['index']) { if ($storedRequest->matches($request, $this->getRequestMatchers())) { return Response::fromArray($recording['response']); } From d5adfb47cf6f6ea759bc7f26edde304b417c2399 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Thu, 14 Feb 2019 10:46:05 -0800 Subject: [PATCH 157/204] Spport legacy cassettes. Create a recording index of 0 if no index key exists in the cassette. --- src/VCR/Cassette.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 3111b2876..cd47a1f4e 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -30,6 +30,12 @@ public function playback(Request $request, int $index = 0): ?Response { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); + + // Support legacy cassettes which do not have the 'index' key + if (!\array_key_exists('index', $recording)) { + $recording['index'] = 0; + } + if ($index == $recording['index']) { if ($storedRequest->matches($request, $this->getRequestMatchers())) { return Response::fromArray($recording['response']); From edb27bdc4899288d8ab201c920dcecc0888cd60a Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Thu, 14 Feb 2019 11:46:15 -0800 Subject: [PATCH 158/204] Add comment punctuation. --- src/VCR/Cassette.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index cd47a1f4e..820317a13 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -31,7 +31,7 @@ public function playback(Request $request, int $index = 0): ?Response foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); - // Support legacy cassettes which do not have the 'index' key + // Support legacy cassettes which do not have the 'index' key. if (!\array_key_exists('index', $recording)) { $recording['index'] = 0; } From 074fb85e4ad09c87d22b952e62830d66f8f33e99 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Thu, 14 Feb 2019 15:50:03 -0800 Subject: [PATCH 159/204] Add testPlaybackLegacyCassette() to ensure that legacy cassettes with no index keys playback. --- tests/Unit/CassetteTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index fbbeb5b49..22c214e58 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -62,4 +62,26 @@ public function testHasResponseFound(): void $this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.'); } + + /** + * Test playback of a legacy cassette which does not have an index key. + */ + public function testPlaybackLegacyCassette(): void + { + $request = new Request('GET', 'https://example.com'); + $response = new Response(200, [], 'sometest'); + + // Create recording array with no index key. + $recording = [ + 'request' => $request->toArray(), + 'response' => $response->toArray(), + ]; + + $storage = new Storage\Yaml(vfsStream::url('test/'), 'json_test'); + $storage->storeRecording($recording); + $configuration = new Configuration(); + $cassette = new Cassette('cassette_name', $configuration, $storage); + + $this->assertEquals($response->toArray(), $cassette->playback($request)->toArray()); + } } From 1011e40a480983b0a5a4154c390a1ef6d698807a Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Thu, 14 Feb 2019 17:56:09 -0800 Subject: [PATCH 160/204] Add tests ensuring that both legacy (non-indexed) cassettes and indexed cassettes playback multiple identical requests correctly. --- tests/Unit/CassetteTest.php | 80 +++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index 22c214e58..c92cf88a3 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -77,11 +77,85 @@ public function testPlaybackLegacyCassette(): void 'response' => $response->toArray(), ]; + $cassette = $this->createCassetteWithRecordings([$recording]); + + $this->assertEquals($response->toArray(), $cassette->playback($request)->toArray()); + } + + /** + * Ensure that if a second identical request is played back from a legacy + * cassette, the first response will be returned. + */ + public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void + { + $request1 = new Request('GET', 'https://example.com'); + $response1 = new Response(200, [], 'response1'); + + $request2 = new Request('GET', 'https://example.com'); + $response2 = new Response(200, [], 'response2'); + + // These are legacy recordings with no index keys. + $recordings = [ + [ + 'request' => $request1->toArray(), + 'response' => $response1->toArray(), + ], + [ + 'request' => $request2->toArray(), + 'response' => $response2->toArray(), + ], + ]; + + $cassette = $this->createCassetteWithRecordings($recordings); + + $this->assertEquals($response1->toArray(), $cassette->playback($request1)->toArray()); + $this->assertEquals($response1->toArray(), $cassette->playback($request2)->toArray()); + } + + /** + * Ensure that if a second identical request is played back from an cassette + * with indexed recordings, the response corresponding to the recording + * index will be returned. + */ + public function testPlaybackOfIdenticalRequests(): void + { + $request1 = new Request('GET', 'https://example.com'); + $response1 = new Response(200, [], 'response1'); + + $request2 = new Request('GET', 'https://example.com'); + $response2 = new Response(200, [], 'response2'); + + // These are recordings with index keys which support playback of + // multiple identical requests. + $recordings = [ + [ + 'request' => $request1->toArray(), + 'response' => $response1->toArray(), + 'index' => 0, + ], + [ + 'request' => $request2->toArray(), + 'response' => $response2->toArray(), + 'index' => 1, + ], + ]; + + $cassette = $this->createCassetteWithRecordings($recordings); + + $this->assertEquals($response1->toArray(), $cassette->playback($request1, 0)->toArray()); + $this->assertNotEquals($response1->toArray(), $cassette->playback($request2, 1)->toArray()); + $this->assertEquals($response2->toArray(), $cassette->playback($request2, 1)->toArray()); + } + + protected function createCassetteWithRecordings(array $recordings) + { $storage = new Storage\Yaml(vfsStream::url('test/'), 'json_test'); - $storage->storeRecording($recording); + + foreach ($recordings as $recording) { + $storage->storeRecording($recording); + } $configuration = new Configuration(); - $cassette = new Cassette('cassette_name', $configuration, $storage); - $this->assertEquals($response->toArray(), $cassette->playback($request)->toArray()); + return new Cassette('cassette_name', $configuration, $storage); } } From 5cdd0a09743d693bf3c5dc88893c7e88c76a31d1 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Tue, 19 Feb 2019 10:43:18 -0800 Subject: [PATCH 161/204] Modify testInsertCassetteEjectExisting() to ensure that resetIndex() is called as part of eject() and insertCassette(). --- tests/Unit/VideorecorderTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Unit/VideorecorderTest.php b/tests/Unit/VideorecorderTest.php index 487a85e0e..337283ddf 100644 --- a/tests/Unit/VideorecorderTest.php +++ b/tests/Unit/VideorecorderTest.php @@ -34,10 +34,11 @@ public function testInsertCassetteEjectExisting(): void $configuration->enableLibraryHooks([]); $videorecorder = $this->getMockBuilder('\VCR\Videorecorder') ->setConstructorArgs([$configuration, new HttpClient(), VCRFactory::getInstance()]) - ->setMethods(['eject']) + ->setMethods(['eject', 'resetIndex']) ->getMock(); $videorecorder->expects($this->exactly(2))->method('eject'); + $videorecorder->expects($this->exactly(2))->method('resetIndex'); $videorecorder->turnOn(); $videorecorder->insertCassette('cassette1'); From 37bafc782b7984fcb99cdab4e5f3bfdb291f60b8 Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Tue, 19 Feb 2019 10:46:06 -0800 Subject: [PATCH 162/204] Remove redundant testPlaybackLegacyCassette(). --- tests/Unit/CassetteTest.php | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index c92cf88a3..06447abb6 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -63,25 +63,6 @@ public function testHasResponseFound(): void $this->assertTrue($this->cassette->hasResponse($request), 'Expected true if request was found.'); } - /** - * Test playback of a legacy cassette which does not have an index key. - */ - public function testPlaybackLegacyCassette(): void - { - $request = new Request('GET', 'https://example.com'); - $response = new Response(200, [], 'sometest'); - - // Create recording array with no index key. - $recording = [ - 'request' => $request->toArray(), - 'response' => $response->toArray(), - ]; - - $cassette = $this->createCassetteWithRecordings([$recording]); - - $this->assertEquals($response->toArray(), $cassette->playback($request)->toArray()); - } - /** * Ensure that if a second identical request is played back from a legacy * cassette, the first response will be returned. @@ -147,9 +128,9 @@ public function testPlaybackOfIdenticalRequests(): void $this->assertEquals($response2->toArray(), $cassette->playback($request2, 1)->toArray()); } - protected function createCassetteWithRecordings(array $recordings) + protected function createCassetteWithRecordings(array $recordings): Cassette { - $storage = new Storage\Yaml(vfsStream::url('test/'), 'json_test'); + $storage = new Yaml(vfsStream::url('test/'), 'json_test'); foreach ($recordings as $recording) { $storage->storeRecording($recording); From ad3568727042883d9a8c60d010eb513511209b4f Mon Sep 17 00:00:00 2001 From: Brian Wood Date: Tue, 19 Feb 2019 10:52:00 -0800 Subject: [PATCH 163/204] Fix indents. --- src/VCR/Videorecorder.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 789402e58..4225dc188 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -225,18 +225,18 @@ public function __destruct() } } - protected function iterateIndex(Request $request): int - { - $hash = $request->getHash(); - if (!isset($this->indexTable[$hash])) { - $this->indexTable[$hash] = -1; - } - - return ++$this->indexTable[$hash]; - } - - public function resetIndex(): void - { - $this->indexTable = []; - } + protected function iterateIndex(Request $request): int + { + $hash = $request->getHash(); + if (!isset($this->indexTable[$hash])) { + $this->indexTable[$hash] = -1; + } + + return ++$this->indexTable[$hash]; + } + + public function resetIndex(): void + { + $this->indexTable = []; + } } From ce1471bb54e07aa79f6b12b3afcf0d6c37acc48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 16:26:26 +0100 Subject: [PATCH 164/204] FEATURE: Added testcase for mixed cassettes (with and without legacy entries) --- tests/Unit/CassetteTest.php | 41 ++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index 06447abb6..b9352fa14 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -70,10 +70,10 @@ public function testHasResponseFound(): void public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response(200, [], 'response1'); + $response1 = new Response('200', [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response(200, [], 'response2'); + $response2 = new Response('200', [], 'response2'); // These are legacy recordings with no index keys. $recordings = [ @@ -94,17 +94,48 @@ public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void } /** - * Ensure that if a second identical request is played back from an cassette + * Ensure also mixed cassettes are working properly, if a legacy cassette has a first entry without index (should be + * 0) and a second entry for the same request with incremented index (should be 1). + */ + public function testPlaybackOfIdenticalRequestsFromLegacyCassetteWithIndexedRecords(): void + { + $request1 = new Request('GET', 'https://example.com'); + $response1 = new Response('200', [], 'response1'); + + $request2 = new Request('GET', 'https://example.com'); + $response2 = new Response('200', [], 'response2'); + + // These are legacy recordings with no index keys. + $recordings = [ + [ + 'request' => $request1->toArray(), + 'response' => $response1->toArray(), + ], + [ + 'request' => $request2->toArray(), + 'response' => $response2->toArray(), + 'index' => 1, + ], + ]; + + $cassette = $this->createCassetteWithRecordings($recordings); + + $this->assertEquals($response1->toArray(), $cassette->playback($request1, 0)->toArray()); + $this->assertEquals($response2->toArray(), $cassette->playback($request2, 1)->toArray()); + } + + /** + * Ensure that if a second identical request is played back from a cassette * with indexed recordings, the response corresponding to the recording * index will be returned. */ public function testPlaybackOfIdenticalRequests(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response(200, [], 'response1'); + $response1 = new Response('200', [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response(200, [], 'response2'); + $response2 = new Response('200', [], 'response2'); // These are recordings with index keys which support playback of // multiple identical requests. From a95298b36cea06e9304b0deecfaa60d8856191a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 16:36:37 +0100 Subject: [PATCH 165/204] FIX: Fixed remaining phpstan errors --- phpstan-baseline.neon | 5 +++++ src/VCR/Storage/Storage.php | 2 +- tests/Unit/CassetteTest.php | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9176f950d..5adfa7ce2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -35,6 +35,11 @@ parameters: count: 1 path: src/VCR/Videorecorder.php + - + message: "#^Cannot call method toArray\\(\\) on VCR\\\\Response\\|null\\.$#" + count: 7 + path: tests/Unit/CassetteTest.php + - message: "#^Parameter \\#2 \\$requestMatchers of method VCR\\\\Request\\:\\:matches\\(\\) expects array\\, array\\{array\\{'some', 'method'\\}\\} given\\.$#" count: 1 diff --git a/src/VCR/Storage/Storage.php b/src/VCR/Storage/Storage.php index 839d6e0de..c8156ba98 100644 --- a/src/VCR/Storage/Storage.php +++ b/src/VCR/Storage/Storage.php @@ -15,7 +15,7 @@ interface Storage extends \Iterator { /** - * @param array|null, int> $recording + * @param array|null> $recording */ public function storeRecording(array $recording): void; diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index b9352fa14..ecd1cd970 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -159,6 +159,9 @@ public function testPlaybackOfIdenticalRequests(): void $this->assertEquals($response2->toArray(), $cassette->playback($request2, 1)->toArray()); } + /** + * @param array|null>> $recordings + */ protected function createCassetteWithRecordings(array $recordings): Cassette { $storage = new Yaml(vfsStream::url('test/'), 'json_test'); From 457326c24959770f6291262148b487454dc4217d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 16:43:55 +0100 Subject: [PATCH 166/204] FIX: Indentions --- src/VCR/Videorecorder.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/VCR/Videorecorder.php b/src/VCR/Videorecorder.php index 4225dc188..08bc52da7 100644 --- a/src/VCR/Videorecorder.php +++ b/src/VCR/Videorecorder.php @@ -139,12 +139,11 @@ public function configure(): Configuration * * If a request was already recorded on a cassette it's response is returned, * otherwise the request is issued and it's response recorded (and returned). - * - * @api - * * @throws \LogicException if the mode is set to none or once and * the cassette did not have a matching response + * + * @api */ public function handleRequest(Request $request): Response { @@ -160,7 +159,10 @@ public function handleRequest(Request $request): Response // Playback succeeded and the recorded response can be returned. if (!empty($response)) { - $this->dispatch(new AfterPlaybackEvent($request, $response, $this->cassette), VCREvents::VCR_AFTER_PLAYBACK); + $this->dispatch( + new AfterPlaybackEvent($request, $response, $this->cassette), + VCREvents::VCR_AFTER_PLAYBACK + ); return $response; } @@ -225,18 +227,18 @@ public function __destruct() } } - protected function iterateIndex(Request $request): int - { - $hash = $request->getHash(); - if (!isset($this->indexTable[$hash])) { - $this->indexTable[$hash] = -1; - } + protected function iterateIndex(Request $request): int + { + $hash = $request->getHash(); + if (!isset($this->indexTable[$hash])) { + $this->indexTable[$hash] = -1; + } - return ++$this->indexTable[$hash]; - } + return ++$this->indexTable[$hash]; + } - public function resetIndex(): void - { - $this->indexTable = []; - } + public function resetIndex(): void + { + $this->indexTable = []; + } } From 96721547bb50ddee25ffbfb749b4df6dae7bc6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 17:45:57 +0100 Subject: [PATCH 167/204] FIX: Videorecorder always raised index for identical requests, Cassette have to handle legacy entries Because the Videorecorder increments the index for each identical requests it also passes it to the cassette, so the cassette have to handle legacy stored entries. So if no index is present while loading recorded requests we have to set the index to searched one (instead of zero) to always match (disabled the feature), when all other matchers match. --- src/VCR/Cassette.php | 13 +++++-------- tests/Unit/CassetteTest.php | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/VCR/Cassette.php b/src/VCR/Cassette.php index 820317a13..273e20935 100644 --- a/src/VCR/Cassette.php +++ b/src/VCR/Cassette.php @@ -31,15 +31,12 @@ public function playback(Request $request, int $index = 0): ?Response foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); - // Support legacy cassettes which do not have the 'index' key. - if (!\array_key_exists('index', $recording)) { - $recording['index'] = 0; - } + // Support legacy cassettes which do not have the 'index' key by setting the index to the searched one to + // always match this record if the request matches + $recording['index'] ??= $index; - if ($index == $recording['index']) { - if ($storedRequest->matches($request, $this->getRequestMatchers())) { - return Response::fromArray($recording['response']); - } + if ($storedRequest->matches($request, $this->getRequestMatchers()) && $index == $recording['index']) { + return Response::fromArray($recording['response']); } } diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index ecd1cd970..c1cf295c9 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -89,8 +89,8 @@ public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void $cassette = $this->createCassetteWithRecordings($recordings); - $this->assertEquals($response1->toArray(), $cassette->playback($request1)->toArray()); - $this->assertEquals($response1->toArray(), $cassette->playback($request2)->toArray()); + $this->assertEquals($response1->toArray(), $cassette->playback($request1, 0)->toArray()); + $this->assertEquals($response1->toArray(), $cassette->playback($request2, 1)->toArray()); } /** From 2ebf001f66694bde993263ffb50282e836044f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 17:46:21 +0100 Subject: [PATCH 168/204] Revert "FEATURE: Added testcase for mixed cassettes" This reverts commit ce1471bb54e07aa79f6b12b3afcf0d6c37acc48e. --- tests/Unit/CassetteTest.php | 41 +++++-------------------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index c1cf295c9..419250160 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -70,10 +70,10 @@ public function testHasResponseFound(): void public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response('200', [], 'response1'); + $response1 = new Response(200, [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response('200', [], 'response2'); + $response2 = new Response(200, [], 'response2'); // These are legacy recordings with no index keys. $recordings = [ @@ -94,48 +94,17 @@ public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void } /** - * Ensure also mixed cassettes are working properly, if a legacy cassette has a first entry without index (should be - * 0) and a second entry for the same request with incremented index (should be 1). - */ - public function testPlaybackOfIdenticalRequestsFromLegacyCassetteWithIndexedRecords(): void - { - $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response('200', [], 'response1'); - - $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response('200', [], 'response2'); - - // These are legacy recordings with no index keys. - $recordings = [ - [ - 'request' => $request1->toArray(), - 'response' => $response1->toArray(), - ], - [ - 'request' => $request2->toArray(), - 'response' => $response2->toArray(), - 'index' => 1, - ], - ]; - - $cassette = $this->createCassetteWithRecordings($recordings); - - $this->assertEquals($response1->toArray(), $cassette->playback($request1, 0)->toArray()); - $this->assertEquals($response2->toArray(), $cassette->playback($request2, 1)->toArray()); - } - - /** - * Ensure that if a second identical request is played back from a cassette + * Ensure that if a second identical request is played back from an cassette * with indexed recordings, the response corresponding to the recording * index will be returned. */ public function testPlaybackOfIdenticalRequests(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response('200', [], 'response1'); + $response1 = new Response(200, [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response('200', [], 'response2'); + $response2 = new Response(200, [], 'response2'); // These are recordings with index keys which support playback of // multiple identical requests. From 63de5cea1382e3ac30bebdb64195932785279fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 17:48:09 +0100 Subject: [PATCH 169/204] FIX: Fixed remaining phpstan errors --- phpstan-baseline.neon | 2 +- tests/Unit/CassetteTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5adfa7ce2..78e1d3b36 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -37,7 +37,7 @@ parameters: - message: "#^Cannot call method toArray\\(\\) on VCR\\\\Response\\|null\\.$#" - count: 7 + count: 5 path: tests/Unit/CassetteTest.php - diff --git a/tests/Unit/CassetteTest.php b/tests/Unit/CassetteTest.php index 419250160..761fc2140 100644 --- a/tests/Unit/CassetteTest.php +++ b/tests/Unit/CassetteTest.php @@ -70,10 +70,10 @@ public function testHasResponseFound(): void public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response(200, [], 'response1'); + $response1 = new Response('200', [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response(200, [], 'response2'); + $response2 = new Response('200', [], 'response2'); // These are legacy recordings with no index keys. $recordings = [ @@ -101,10 +101,10 @@ public function testPlaybackOfIdenticalRequestsFromLegacyCassette(): void public function testPlaybackOfIdenticalRequests(): void { $request1 = new Request('GET', 'https://example.com'); - $response1 = new Response(200, [], 'response1'); + $response1 = new Response('200', [], 'response1'); $request2 = new Request('GET', 'https://example.com'); - $response2 = new Response(200, [], 'response2'); + $response2 = new Response('200', [], 'response2'); // These are recordings with index keys which support playback of // multiple identical requests. From 1b53492a77b5ac2912664885df17a1a5230f88a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 19 Dec 2022 18:19:01 +0100 Subject: [PATCH 170/204] FIX: README.md badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be1cc9da3..356431c27 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![PHP-VCR](https://user-images.githubusercontent.com/133832/27151811-0d95c6c4-514c-11e7-834e-eff1eec2ea16.png) -[![Build Status](https://github.com/php-vcr/php-vcr/actions/workflows/tests.yml/badge.svg)](https://github.com/php-vcr/php-vcr/actions/workflows/tests.yml) +[![Continuous Integration](https://github.com/php-vcr/php-vcr/actions/workflows/continuous%20integration.yml/badge.svg?branch=master)](https://github.com/php-vcr/php-vcr/actions/workflows/continuous%20integration.yml) [![Code Coverage](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/coverage.png?s=15cf1644c8cf37a868e03cfba809a5e24c78f285)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/quality-score.png?s=4f638dbca5eb51fb9c87a1dd45c5df94687d85bd)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) From 1d8349f4ba9d56f28fef3dee33a301c0c0b454ee Mon Sep 17 00:00:00 2001 From: oranges13 Date: Tue, 20 Dec 2022 14:26:02 -0500 Subject: [PATCH 171/204] Add CURLINFO_APPCONNECT_TIME to CurlHelper Fixes #309 --- src/VCR/Util/CurlHelper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/VCR/Util/CurlHelper.php b/src/VCR/Util/CurlHelper.php index 70c95b007..4d772fbf4 100644 --- a/src/VCR/Util/CurlHelper.php +++ b/src/VCR/Util/CurlHelper.php @@ -35,6 +35,7 @@ class CurlHelper \CURLINFO_CONTENT_LENGTH_DOWNLOAD => 'download_content_length', \CURLINFO_CONTENT_LENGTH_UPLOAD => 'upload_content_length', \CURLINFO_CONTENT_TYPE => 'content_type', + \CURLINFO_APPCONNECT_TIME => 'appconnect_time', ]; /** @@ -106,6 +107,7 @@ public static function getCurlOptionFromResponse(Response $response, int $option $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; case \CURLPROXY_HTTPS: + case \CURLINFO_APPCONNECT_TIME: $info = ''; break; default: From 9bfb45b09c7e3206559523f4b501609ca58cfb00 Mon Sep 17 00:00:00 2001 From: oranges13 Date: Tue, 27 Dec 2022 10:34:25 -0500 Subject: [PATCH 172/204] Fix CurlHookTest.php --- tests/Unit/LibraryHooks/CurlHookTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/LibraryHooks/CurlHookTest.php b/tests/Unit/LibraryHooks/CurlHookTest.php index 6e4183615..06b9275d8 100644 --- a/tests/Unit/LibraryHooks/CurlHookTest.php +++ b/tests/Unit/LibraryHooks/CurlHookTest.php @@ -226,7 +226,7 @@ public function testShouldReturnCurlInfoAll(): void curl_close($curlHandle); $this->assertIsArray($info, 'curl_getinfo() should return an array.'); - $this->assertCount(21, $info, 'curl_getinfo() should return 21 values.'); + $this->assertCount(22, $info, 'curl_getinfo() should return 22 values.'); $this->curlHook->disable(); } From 1917d661757c8338311f606431bc1ed7941244cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Tue, 27 Dec 2022 22:30:56 +0100 Subject: [PATCH 173/204] FIX: Read the whole stream and perform code transformations First read the whole stream and afterwards perform code transformations. This will ensure to also replace code, which is divided into chunks while reading a file. Fixes #268 --- .../CodeTransform/AbstractCodeTransform.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index d2161458e..ce517726e 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -13,14 +13,19 @@ abstract class AbstractCodeTransform extends \php_user_filter { public const NAME = 'vcr_abstract_filter'; + private string $data = ''; + /** * Attaches the current filter to a stream. */ public function register(): void { - if (!\in_array(static::NAME, stream_get_filters(), true)) { + if (! \in_array(static::NAME, stream_get_filters(), true)) { $isRegistered = stream_filter_register(static::NAME, static::class); - Assertion::true($isRegistered, sprintf('Failed registering stream filter "%s" on stream "%s"', static::class, static::NAME)); + Assertion::true( + $isRegistered, + sprintf('Failed registering stream filter "%s" on stream "%s"', static::class, static::NAME) + ); } } @@ -29,21 +34,28 @@ public function register(): void * * @param resource $in * @param resource $out - * @param int $consumed - * @param bool $closing + * @param int $consumed + * @param bool $closing * * @return int PSFS_PASS_ON * * @see http://www.php.net/manual/en/php-user-filter.filter.php */ - public function filter($in, $out, &$consumed, $closing): int + public function filter($in, $out, &$consumed, bool $closing): int { - while ($bucket = stream_bucket_make_writeable($in)) { - $bucket->data = $this->transformCode($bucket->data); - $consumed += $bucket->datalen; - stream_bucket_append($out, $bucket); + while ($buffer = stream_bucket_make_writeable($in)) { + $this->data .= $buffer->data; + $consumed += $buffer->datalen; + } + + if (!$closing) { + return \PSFS_FEED_ME; } + $bucket = stream_bucket_new($this->stream, $this->transformCode($this->data)); + $this->data = ''; + stream_bucket_append($out, $bucket); + return \PSFS_PASS_ON; } From c1f3c48822e7896665e7e8e28ba17cc047c1b067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Tue, 27 Dec 2022 22:45:32 +0100 Subject: [PATCH 174/204] FIX: Codestyle --- src/VCR/CodeTransform/AbstractCodeTransform.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index ce517726e..d3ae3587b 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -20,7 +20,7 @@ abstract class AbstractCodeTransform extends \php_user_filter */ public function register(): void { - if (! \in_array(static::NAME, stream_get_filters(), true)) { + if (!\in_array(static::NAME, stream_get_filters(), true)) { $isRegistered = stream_filter_register(static::NAME, static::class); Assertion::true( $isRegistered, @@ -34,8 +34,8 @@ public function register(): void * * @param resource $in * @param resource $out - * @param int $consumed - * @param bool $closing + * @param int $consumed + * @param bool $closing * * @return int PSFS_PASS_ON * From 9871fecc6b71767b4ae1428268baee9101caa767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Tue, 27 Dec 2022 22:46:45 +0100 Subject: [PATCH 175/204] FIX: Codestyle --- src/VCR/CodeTransform/AbstractCodeTransform.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/VCR/CodeTransform/AbstractCodeTransform.php b/src/VCR/CodeTransform/AbstractCodeTransform.php index d3ae3587b..bd350a808 100644 --- a/src/VCR/CodeTransform/AbstractCodeTransform.php +++ b/src/VCR/CodeTransform/AbstractCodeTransform.php @@ -35,7 +35,6 @@ public function register(): void * @param resource $in * @param resource $out * @param int $consumed - * @param bool $closing * * @return int PSFS_PASS_ON * From 6d72376acd17bb020de1ad8b5803c1e09e59d4b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hu=CC=88rtgen?= Date: Mon, 20 Feb 2023 08:49:09 +0100 Subject: [PATCH 176/204] TASK: Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 356431c27..bae7e2488 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Disclaimer: Doing this in PHP is not as easy as in programming languages which s * Automatically records and replays your HTTP(s) interactions with minimal setup/configuration code. * Supports common http functions and extensions - * everything using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see #96) + * everything using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see [#96](https://github.com/php-vcr/php-vcr/issues/96)) * [SoapClient](http://www.php.net/manual/en/soapclient.soapclient.php) by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * curl(), by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * The same request can receive different responses in different tests -- just use different cassettes. @@ -121,7 +121,7 @@ composer test [Old changelog entries](docs/old-changelog.md) ## Copyright -Copyright (c) 2013-2016 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. +Copyright (c) 2013-2023 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. [Contributors](https://github.com/php-vcr/php-vcr/graphs/contributors)