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

Non-literal parameter default parsing incorrectly adding NULL to parameter types #3629

Closed
dktapps opened this issue Jul 19, 2020 · 8 comments

Comments

@dktapps
Copy link
Contributor

dktapps commented Jul 19, 2020

Bug report

Code snippet that reproduces the problem

A new issue cropped up since you updated the stubs that I can't make sense of, other than perhaps PHPStan is incorrectly parsing the $options default from the stubs: https://phpstan.org/r/eb28e725-c7ba-4f56-9dde-fe948c3f2d56

Since there's nowhere that says that this accepts null (not native reflection, and not stubs either, I cross-checked this everywhereI could think of to try and figure out where the null was coming from), it's my belief that PHPStan is incorrectly interpreting the default value to be NULL and therefore showing this problem.

Expected output

No error.

@dktapps
Copy link
Contributor Author

dktapps commented Jul 19, 2020

Changing the default in the phpstorm stubs to a literal (f.e. 0) makes the problem go away, so it's definitely something to do with the default value parsing.

@ADmad
Copy link
Contributor

ADmad commented Jul 21, 2020

@ondrejmirtes
Copy link
Member

@ADmad This doesn’t tell me the error, can you show me what conflicting method is there and how the error looks like?

@ADmad
Copy link
Contributor

ADmad commented Jul 21, 2020

@ondrejmirtes If you are using a desktop browser that link should scroll the page to the exact location where error message is shown.

Parameter #2 $type (int) of method Cake\Collection\Collection::max() is not compatible with parameter #2 $type (int|null) of method Cake\Collection\CollectionInterface::max().

Methods in question:

https://github.com/cakephp/cakephp/blob/47912247fa64dc35066c8fe74d24bee38480d4b6/src/Collection/CollectionTrait.php#L192

https://github.com/cakephp/cakephp/blob/47912247fa64dc35066c8fe74d24bee38480d4b6/src/Collection/CollectionInterface.php#L263

@ADmad
Copy link
Contributor

ADmad commented Jul 21, 2020

Sorry, it seems the links behaves differently for those who don't have commit access to the repo.

@dktapps dktapps changed the title pthreads Thread::start() parameter type incorrectly int|null, despite all data sources saying only int Non-literal parameter default parsing incorrectly adding NULL to parameter types Jul 21, 2020
@drupol
Copy link

drupol commented Jul 25, 2020

@ADmad This doesn’t tell me the error, can you show me what conflicting method is there and how the error looks like?

Dear @ondrejmirtes, does this helps you ? https://phpstan.org/r/ffbb5a78-a8b2-46d9-9f45-aa264ed74d94

@ondrejmirtes
Copy link
Member

@github-actions
Copy link

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 May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants