Skip to content

Commit

Permalink
fix static
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Mar 24, 2022
1 parent 6a20ab8 commit 17dfd86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php
Expand Up @@ -131,7 +131,7 @@ private function narrowTypeForJsonDecode(FuncCall $funcCall, Scope $scope): Type
}

// fallback type
if ($isArrayWithoutStdClass) {
if ($isArrayWithoutStdClass === true) {
return new MixedType(true, new ObjectType(stdClass::class));
}

Expand Down Expand Up @@ -164,7 +164,7 @@ private function isForceArrayWithoutStdClass(FuncCall $funcCall, Scope $scope):
// @see https://www.php.net/manual/en/json.constants.php#constant.json-object-as-array
$thirdArgValue = $args[3]->value;
$resolvedThirdArgValue = $this->resolveMaskValue($thirdArgValue, $scope);
if ($resolvedThirdArgValue & JSON_OBJECT_AS_ARRAY) {
if (($resolvedThirdArgValue & JSON_OBJECT_AS_ARRAY) !== 0) {
return true;
}
}
Expand All @@ -180,6 +180,9 @@ private function resolveConstantStringType(ConstantStringType $constantStringTyp
return ConstantTypeHelper::getTypeFromValue($decodedValue);
}

/**
* @return mixed
*/
private function resolveMaskValue(Expr $expr, Scope $scope)
{
$thirdArgValueType = $scope->getType($expr);
Expand Down

0 comments on commit 17dfd86

Please sign in to comment.