Skip to content

Commit

Permalink
Fix InputBagTypeSpecifyingExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and ondrejmirtes committed Sep 26, 2024
1 parent 51ab243 commit f7d5782
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Type/Symfony/InputBagTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getClass(): string

public function isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context): bool
{
return $methodReflection->getName() === self::HAS_METHOD_NAME && !$context->null();
return $methodReflection->getName() === self::HAS_METHOD_NAME && $context->false();
}

public function specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
Expand Down
3 changes: 2 additions & 1 deletion tests/Type/Symfony/data/input_bag.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
assertType('bool|float|int|string|null', $bag->get('foo'));

if ($bag->has('foo')) {
assertType('bool|float|int|string', $bag->get('foo'));
// Because `has` rely on `array_key_exists` we can still have set the NULL value.
assertType('bool|float|int|string|null', $bag->get('foo'));
assertType('bool|float|int|string|null', $bag->get('bar'));
} else {
assertType('null', $bag->get('foo'));
Expand Down

0 comments on commit f7d5782

Please sign in to comment.