Skip to content
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

remove old types when both side of a ternary reassign a variable #6384

Closed
orklah opened this issue Sep 1, 2021 · 1 comment · Fixed by #6420
Closed

remove old types when both side of a ternary reassign a variable #6384

orklah opened this issue Sep 1, 2021 · 1 comment · Fixed by #6420

Comments

@orklah
Copy link
Collaborator

orklah commented Sep 1, 2021

https://psalm.dev/r/198b6a7c3a
$_a in this example should not contain null

https://psalm.dev/r/705d3062f6
This edge case could be interesting to check also

PHPStan infers the correct type

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/198b6a7c3a
<?php
$_a = null;
$b = rand(0,1) ? '' : 'true';
$b === 'true' ? $_a = 'Y' : $_a = 'N';

/** @psalm-trace $_a */
Psalm output (using commit eb973ab):

INFO: Trace - 6:24 - $_a: "N"|"Y"|null
https://psalm.dev/r/705d3062f6
<?php
$_a = rand(0,1) ? '' : 'true';
$_a === 'true' ? $_a = 'Y' : $_a = 'N';

/** @psalm-trace $_a */
Psalm output (using commit eb973ab):

INFO: Trace - 5:24 - $_a: ""|"N"|"Y"|"true"

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

Successfully merging a pull request may close this issue.

1 participant