Skip to content

Remove nullable type on InputBag::get() after InputBag::has() call #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2022

Conversation

franmomu
Copy link
Contributor

@franmomu franmomu commented Feb 2, 2022

I've used https://github.com/phpstan/phpstan-symfony/blob/df5ce326a8935bf400eb59f7080e568c20ef6246/src/Type/Symfony/RequestTypeSpecifyingExtension.php as example.

Update: maybe we could change it to a HasGetTypeSpecifyingExtension and pass the className so it can be reused for other classes as well.

@franmomu franmomu marked this pull request as draft February 2, 2022 21:06
@franmomu franmomu marked this pull request as ready for review February 2, 2022 22:00
@lookyman
Copy link
Collaborator

lookyman commented Feb 2, 2022

👍

@ondrejmirtes ondrejmirtes merged commit 173610b into phpstan:master Feb 3, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@franmomu franmomu deleted the input_has branch February 3, 2022 15:24
@VincentLanglet
Copy link
Contributor

VincentLanglet commented May 30, 2023

Hi @franmomu, I'm not sure this DynamicReturnExtension is correct,

The has method is using the array_key_exists check
https://github.com/symfony/symfony/blob/6.3/src/Symfony/Component/HttpFoundation/ParameterBag.php#L99

Which means that we can have

$bag->set('foo', null);
$bag->has('foo'); // true
$bag->get('foo'); // null

If so, I'm affraid we'll have to remove this DynamicReturnExtension :(
WDYT ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants