Skip to content

Commit

Permalink
Merge pull request #726 from michaeljoelphillips/phpstorm-stubs-faili…
Browse files Browse the repository at this point in the history
…ng-tests

Upgrade PHPStorm Stubs
  • Loading branch information
Ocramius committed Jan 7, 2021
2 parents a5a2581 + 2541ec6 commit 0c79e56
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -5,7 +5,7 @@
"require": {
"php": ">=7.4.1,<7.5.0",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "2019.3",
"jetbrains/phpstorm-stubs": "2020.2",
"nikic/php-parser": "^4.10.4",
"phpdocumentor/reflection-docblock": "^5.2.2",
"phpdocumentor/type-resolver": "^1.4.0",
Expand Down
19 changes: 10 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions test/unit/Reflection/ReflectionPropertyTest.php
Expand Up @@ -14,7 +14,6 @@
use PhpParser\PrettyPrinter\Standard as StandardPrettyPrinter;
use PHPUnit\Framework\TestCase;
use Reflection;
use ReflectionFunctionAbstract;
use ReflectionProperty as CoreReflectionProperty;
use Roave\BetterReflection\Reflection\Exception\ClassDoesNotExist;
use Roave\BetterReflection\Reflection\Exception\NoObjectProvided;
Expand Down Expand Up @@ -57,10 +56,10 @@ public function setUp(): void

public function testCreateFromName(): void
{
$property = ReflectionProperty::createFromName(ReflectionFunctionAbstract::class, 'name');
$property = ReflectionProperty::createFromName(ReflectionProperty::class, 'node');

self::assertInstanceOf(ReflectionProperty::class, $property);
self::assertSame('name', $property->getName());
self::assertSame('node', $property->getName());
}

public function testCreateFromInstance(): void
Expand Down
Expand Up @@ -67,7 +67,7 @@ public function testInternalClassToString(): void
$classReflection = $reflector->reflect(Exception::class);
// phpcs:enable

self::assertStringStartsWith('Class [ <internal:Core> class Exception implements Throwable ]', (string) $classReflection);
self::assertStringStartsWith('Class [ <internal:Core> class Exception implements Throwable, Stringable ]', (string) $classReflection);
}

public function testInterfaceToString(): void
Expand Down
Expand Up @@ -24,6 +24,7 @@
use function array_filter;
use function array_map;
use function array_merge;
use function array_values;
use function get_declared_classes;
use function get_declared_interfaces;
use function get_declared_traits;
Expand Down Expand Up @@ -136,6 +137,16 @@ private function assertSameInterfaces(CoreReflectionClass $original, ReflectionC
sort($originalInterfacesNames);
sort($stubbedInterfacesNames);

// Skip assertions for new interfaces added in PHP8
if (PHP_VERSION_ID < 80000) {
$stubbedInterfacesNames = array_values(array_filter(
$stubbedInterfacesNames,
static function (string $interfaceName): bool {
return $interfaceName !== 'Stringable';
},
));
}

self::assertSame($originalInterfacesNames, $stubbedInterfacesNames);
}

Expand Down Expand Up @@ -364,8 +375,11 @@ public function testInternalFunctions(string $functionName): void
return;
}

self::assertSame($originalReflection->getNumberOfParameters(), $stubbedReflection->getNumberOfParameters());
self::assertSame($originalReflection->getNumberOfRequiredParameters(), $stubbedReflection->getNumberOfRequiredParameters());
// The number of arguments in the signature of this function changed in PHP8
if ($originalReflection->getName() !== 'debug_zval_dump' && PHP_VERSION_ID < 80000) {
self::assertSame($originalReflection->getNumberOfParameters(), $stubbedReflection->getNumberOfParameters());
self::assertSame($originalReflection->getNumberOfRequiredParameters(), $stubbedReflection->getNumberOfRequiredParameters());
}

$stubbedReflectionParameters = $stubbedReflection->getParameters();
foreach ($originalReflection->getParameters() as $parameterNo => $originalReflectionParameter) {
Expand Down

0 comments on commit 0c79e56

Please sign in to comment.