Skip to content

Commit

Permalink
Merge branch '1.5.x' into 1.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Apr 21, 2022
2 parents f13c2c7 + 820a728 commit 750eeb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/Type/Php/JsonThrowOnErrorDynamicReturnTypeExtension.php
Expand Up @@ -58,9 +58,8 @@ public function getTypeFromFunctionCall(
}

$optionsExpr = $functionCall->getArgs()[$argumentPosition]->value;
$constrictedReturnType = TypeCombinator::remove($defaultReturnType, new ConstantBooleanType(false));
if ($this->bitwiseFlagAnalyser->bitwiseOrContainsConstant($optionsExpr, $scope, 'JSON_THROW_ON_ERROR')->yes()) {
return $constrictedReturnType;
if ($functionReflection->getName() === 'json_encode' && $this->bitwiseFlagAnalyser->bitwiseOrContainsConstant($optionsExpr, $scope, 'JSON_THROW_ON_ERROR')->yes()) {
return TypeCombinator::remove($defaultReturnType, new ConstantBooleanType(false));
}

return $defaultReturnType;
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Analyser/LegacyNodeScopeResolverTest.php
Expand Up @@ -8703,11 +8703,11 @@ public function dataPhp73Functions(): array
'json_decode($mixed)',
],
[
'mixed~false',
'mixed',
'json_decode($mixed, false, 512, JSON_THROW_ON_ERROR | JSON_NUMERIC_CHECK)',
],
[
'mixed~false',
'mixed',
'json_decode($mixed, false, 512, $integer | JSON_THROW_ON_ERROR | JSON_NUMERIC_CHECK)',
],
[
Expand Down

0 comments on commit 750eeb4

Please sign in to comment.