Skip to content

Commit

Permalink
Build fixes because of arginfo changes in PHP 7.1.17 and PHP 7.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed May 8, 2018
1 parent 68ebc69 commit 5fd0ecf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion stub/DateTime.stub
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion stub/DateTimeImmutable.stub
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DateTimeImmutable implements DateTimeInterface
{

public function __construct($time = 'now', $object = null)
public function __construct($time = 'now', $timezone = null)
{
}

Expand Down
36 changes: 31 additions & 5 deletions test/unit/SourceLocator/Type/PhpInternalSourceLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5fd0ecf

Please sign in to comment.