Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected build failures caused by ext/date-time upgrades in PHP 7.2 #422

Merged
merged 2 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SourceLocator/Ast/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Roave\BetterReflection\SourceLocator\Ast\Strategy\NodeToReflection;
use Roave\BetterReflection\SourceLocator\Located\LocatedSource;
use Throwable;
use function strtolower;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, missed that one thanks!


/**
* @internal
Expand Down
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the beautiful PHP consistency!

$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