From 68ebc69e2f5e80e0739970d64282c4df3c08b903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Hansl=C3=ADk?= Date: Tue, 8 May 2018 09:36:31 +0200 Subject: [PATCH 1/2] Fixed CS broken in #404 --- src/SourceLocator/Ast/Locator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SourceLocator/Ast/Locator.php b/src/SourceLocator/Ast/Locator.php index fa3c3ccdb..d83b068c5 100644 --- a/src/SourceLocator/Ast/Locator.php +++ b/src/SourceLocator/Ast/Locator.php @@ -13,6 +13,7 @@ use Roave\BetterReflection\SourceLocator\Ast\Strategy\NodeToReflection; use Roave\BetterReflection\SourceLocator\Located\LocatedSource; use Throwable; +use function strtolower; /** * @internal From 5fd0ecfeeef5743d065275e093b1b1ac84ea9575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Hansl=C3=ADk?= Date: Tue, 8 May 2018 10:14:13 +0200 Subject: [PATCH 2/2] Build fixes because of arginfo changes in PHP 7.1.17 and PHP 7.2.5 --- stub/DateTime.stub | 2 +- stub/DateTimeImmutable.stub | 2 +- .../Type/PhpInternalSourceLocatorTest.php | 36 ++++++++++++++++--- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/stub/DateTime.stub b/stub/DateTime.stub index 61fca4f08..0823a44ed 100644 --- a/stub/DateTime.stub +++ b/stub/DateTime.stub @@ -27,7 +27,7 @@ class DateTime implements DateTimeInterface const W3C = 'Y-m-d\\TH:i:sP'; - public function __construct($time = 'now', $object = null) + public function __construct($time = 'now', $timezone = null) { } diff --git a/stub/DateTimeImmutable.stub b/stub/DateTimeImmutable.stub index 0af78e495..ec1b8534e 100644 --- a/stub/DateTimeImmutable.stub +++ b/stub/DateTimeImmutable.stub @@ -1,7 +1,7 @@ class DateTimeImmutable implements DateTimeInterface { - public function __construct($time = 'now', $object = null) + public function __construct($time = 'now', $timezone = null) { } diff --git a/test/unit/SourceLocator/Type/PhpInternalSourceLocatorTest.php b/test/unit/SourceLocator/Type/PhpInternalSourceLocatorTest.php index d3e986b90..ecbd88862 100644 --- a/test/unit/SourceLocator/Type/PhpInternalSourceLocatorTest.php +++ b/test/unit/SourceLocator/Type/PhpInternalSourceLocatorTest.php @@ -337,16 +337,30 @@ function (ReflectionParameter $parameter) : string { $stubbed->getParameters() ); + $methodName = sprintf('%s#%s', $original->getDeclaringClass()->getName(), $original->getName()); + if (count($originalParameterNames) > count($stubParameterNames)) { self::markTestIncomplete(sprintf( - 'New parameters found in method "%s#%s": %s', - $original->getDeclaringClass()->getName(), - $original->getName(), + 'New parameters found in method "%s": %s', + $methodName, "\n" . implode("\n", array_diff($originalParameterNames, $stubParameterNames)) )); } - self::assertSame($originalParameterNames, $stubParameterNames); + if ((PHP_VERSION_ID < 70117 || (PHP_VERSION_ID >= 70200 && PHP_VERSION_ID < 70205)) + && in_array( + $methodName, + [ + 'DateTime#__construct', + 'DateTimeImmutable#__construct', + ], + true + ) + ) { + self::markTestSkipped('Argument name was changed in PHP 7.1.17 and 7.2.5 for ' . $methodName); + } else { + self::assertSame($originalParameterNames, $stubParameterNames); + } foreach ($original->getParameters() as $parameter) { $this->assertSameParameterAttributes( @@ -387,7 +401,19 @@ private function assertSameParameterAttributes( self::markTestSkipped('New type hints were introduced in PHP 7.2 for ' . $parameterName); } - self::assertSame($original->getName(), $stubbed->getName(), $parameterName); + if (in_array( + $parameterName, + [ + 'DateTime#__construct.object', + 'DateTimeImmutable#__construct.object', + ], + true + )) { + self::markTestSkipped('Argument name was changed in PHP 7.1.17 and 7.2.5 for ' . $parameterName); + } else { + self::assertSame($original->getName(), $stubbed->getName(), $parameterName); + } + self::assertSame($original->isArray(), $stubbed->isArray(), $parameterName); if (! ($original->getDeclaringClass()->getName() === Closure::class && $originalMethod->getName() === 'fromCallable')) { // Bug in PHP: https://3v4l.org/EeHXS