diff --git a/src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php b/src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php index 127c34125b2..8337f9bf1e5 100644 --- a/src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php +++ b/src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php @@ -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)); } @@ -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; } } @@ -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);