Skip to content

Commit d3ff2a9

Browse files
committed
Fix reading of constant names
1 parent cd99188 commit d3ff2a9

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

phpstan.neon

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,3 @@ parameters:
66
paths:
77
- bootstrap.php
88
- src/
9-
ignoreErrors:
10-
-
11-
path: src/GetPostDynamicFunctionReturnTypeExtension.php
12-
message: "#^Strict comparison using === between 'OBJECT'\\|PhpParser\\\\Node\\\\Expr and '(ARRAY_N|ARRAY_A|OBJECT)' will always evaluate to false\\.$#"
13-
-
14-
path: src/GetPostDynamicFunctionReturnTypeExtension.php
15-
message: "#^Strict comparison using !== between PhpParser\\\\Node\\\\Expr and 'OBJECT' will always evaluate to true\\.$#"

src/GetPostDynamicFunctionReturnTypeExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace PHPStan\WordPress;
1010

11+
use PhpParser\Node\Expr\ConstFetch;
1112
use PhpParser\Node\Expr\FuncCall;
1213
use PHPStan\Analyser\Scope;
1314
use PHPStan\Reflection\FunctionReflection;
@@ -31,9 +32,8 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
3132
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
3233
{
3334
$output = 'OBJECT';
34-
$argsCount = count($functionCall->args);
35-
if ($argsCount >= 2 && $functionCall->args[1]->value !== 'OBJECT') {
36-
$output = $functionCall->args[1]->value;
35+
if (count($functionCall->args) >= 2 && $functionCall->args[1]->value instanceof ConstFetch) {
36+
$output = $functionCall->args[1]->value->name->getLast();
3737
}
3838
if ($output === 'ARRAY_A') {
3939
return TypeCombinator::union(new ArrayType(new StringType(), new MixedType()), new NullType());

0 commit comments

Comments
 (0)