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

Isset on parse_url returned type not working #8068

Closed
alexander-schranz opened this issue Sep 26, 2022 · 5 comments
Closed

Isset on parse_url returned type not working #8068

alexander-schranz opened this issue Sep 26, 2022 · 5 comments
Labels
Milestone

Comments

@alexander-schranz
Copy link

Bug report

The isset returns an error in phpstan on parse_url:

$urlParsed = parse_url($url);

return isset($urlParsed['path']);

I'm not understanding. Found similar issue here from @darkspock maybe he can also tell why he thought it is not an error on phpstan side.

Code snippet that reproduces the problem

https://phpstan.org/r/e895b82e-932d-43a6-b184-c6e1a20ecc4b

Expected output

No error should be returned.

Did PHPStan help you today? Did it make you happy in any way?

Adding phpstan to a external project not using static code analyse yet and see lot of things which can improve also from architecture point of view avoiding inheritance and use strict type classes.

@ondrejmirtes
Copy link
Member

Eliminate false first: https://phpstan.org/r/1e3ea302-4618-4c24-9afe-08f4ab683efb

@alexander-schranz
Copy link
Author

alexander-schranz commented Sep 26, 2022

@ondrejmirtes Thx for the rocket fast response 🚀 .

That check is not required for isset only when using array_key_exists: https://3v4l.org/W32YM

@ondrejmirtes ondrejmirtes reopened this Sep 26, 2022
@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Sep 26, 2022
@ondrejmirtes
Copy link
Member

Yeah, I guess it could be improved :)

ahmedash95 added a commit to ahmedash95/phpstan-src that referenced this issue Oct 3, 2022
ahmedash95 added a commit to ahmedash95/phpstan-src that referenced this issue Oct 3, 2022
ahmedash95 added a commit to ahmedash95/phpstan-src that referenced this issue Oct 4, 2022
ahmedash95 added a commit to ahmedash95/phpstan-src that referenced this issue Oct 4, 2022
Make array access tolerant with isset

Fixes bug phpstan/phpstan#8068
ahmedash95 added a commit to ahmedash95/phpstan-src that referenced this issue Oct 4, 2022
Make array access tolerant with isset

Fixes bug phpstan/phpstan#8068
@ondrejmirtes
Copy link
Member

Fixed by phpstan/phpstan-src#1791

@github-actions
Copy link

github-actions bot commented Nov 5, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants