diff --git a/phpstan.neon b/phpstan.neon index 3175989..8809a2e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,10 +6,3 @@ parameters: paths: - bootstrap.php - src/ - ignoreErrors: - - - path: src/GetPostDynamicFunctionReturnTypeExtension.php - message: "#^Strict comparison using === between 'OBJECT'\\|PhpParser\\\\Node\\\\Expr and '(ARRAY_N|ARRAY_A|OBJECT)' will always evaluate to false\\.$#" - - - path: src/GetPostDynamicFunctionReturnTypeExtension.php - message: "#^Strict comparison using !== between PhpParser\\\\Node\\\\Expr and 'OBJECT' will always evaluate to true\\.$#" diff --git a/src/GetPostDynamicFunctionReturnTypeExtension.php b/src/GetPostDynamicFunctionReturnTypeExtension.php index 4098d55..e533a29 100644 --- a/src/GetPostDynamicFunctionReturnTypeExtension.php +++ b/src/GetPostDynamicFunctionReturnTypeExtension.php @@ -8,6 +8,7 @@ namespace PHPStan\WordPress; +use PhpParser\Node\Expr\ConstFetch; use PhpParser\Node\Expr\FuncCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\FunctionReflection; @@ -31,9 +32,8 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type { $output = 'OBJECT'; - $argsCount = count($functionCall->args); - if ($argsCount >= 2 && $functionCall->args[1]->value !== 'OBJECT') { - $output = $functionCall->args[1]->value; + if (count($functionCall->args) >= 2 && $functionCall->args[1]->value instanceof ConstFetch) { + $output = $functionCall->args[1]->value->name->getLast(); } if ($output === 'ARRAY_A') { return TypeCombinator::union(new ArrayType(new StringType(), new MixedType()), new NullType());