Skip to content

Commit

Permalink
PHP 8 stubs - parameter name array has always type array
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 12, 2020
1 parent e1a8a49 commit b87dba1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Reflection/SignatureMap/Php8SignatureMapProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
use PHPStan\PhpDoc\Tag\ParamTag;
use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher;
use PHPStan\Reflection\PassedByReference;
use PHPStan\Type\ArrayType;
use PHPStan\Type\FileTypeMapper;
use PHPStan\Type\MixedType;
use PHPStan\Type\ParserNodeTypeToPHPStanType;
use PHPStan\Type\Type;
use PHPStan\Type\TypehintHelper;
Expand Down Expand Up @@ -284,7 +286,11 @@ private function getSignature(
if (!$name instanceof Variable || !is_string($name->name)) {
throw new \PHPStan\ShouldNotHappenException();
}
$parameterType = ParserNodeTypeToPHPStanType::resolve($param->type, null);
if ($name->name === 'array') {
$parameterType = new ArrayType(new MixedType(), new MixedType());
} else {
$parameterType = ParserNodeTypeToPHPStanType::resolve($param->type, null);
}
$parameters[] = new ParameterSignature(
$name->name,
$param->default !== null || $param->variadic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ public function dataFunctions(): array
]),
false,
],
[
'end',
[
[
'name' => 'array',
'optional' => false,
'type' => new ArrayType(new MixedType(), new MixedType()),
'nativeType' => new ArrayType(new MixedType(), new MixedType()),
'passedByReference' => PassedByReference::createReadsArgument(),
'variadic' => false,
],
],
new MixedType(true),
new MixedType(true),
false,
],
];
}

Expand Down

0 comments on commit b87dba1

Please sign in to comment.