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