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

Regression with ArrayObjects in version 0.12.53 #4056

Closed
dunglas opened this issue Nov 5, 2020 · 6 comments
Closed

Regression with ArrayObjects in version 0.12.53 #4056

dunglas opened this issue Nov 5, 2020 · 6 comments

Comments

@dunglas
Copy link
Contributor

dunglas commented Nov 5, 2020

Bug report

Hi, first of all thanks for this great project. It helps us a lot improving the quality of API Platform.

Since the release of the last version, a strange error occurs where we instantiate \ArrayObject objects:

  Line   tests/Swagger/Serializer/ApiGatewayNormalizerTest.php                                                                                                                                    
 ------ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  137    Parameter #1 $input of class ArrayObject constructor expects array<string, ArrayObject<string, array<string, array<string,                                                               
         'integer'|'string'|true>&nonEmpty>&nonEmpty>|ArrayObject<string, array<string, (array<string, 'integer'|'string'|true>&nonEmpty)|ArrayObject<string,                                     
         string>>&nonEmpty>|ArrayObject<string, (array<string, ArrayObject<string, bool|string>|ArrayObject<string, string>>&nonEmpty)|string>|ArrayObject<string, (array<string,                 
         ArrayObject<string, string>>&nonEmpty)|string>>|object, array('Dummy' => ArrayObject<string, array<string, array(?'readOnly' => true, 'type' => 'integer'|'string')>&nonEmpty>,          
         'Dummy-list' => ArrayObject<string, array<string, array(?'readOnly' => true, 'type' => 'integer'|'string')>&nonEmpty>, 'Dummy-list_details' => ArrayObject<string, array<string,         
         array(?'readOnly' => true, 'type' => 'integer'|'string')|ArrayObject<string, string>>&nonEmpty>, 'Dummy:OutputDto' => ArrayObject<string, (array<string, ArrayObject<string,             
         bool|string>|ArrayObject<string, string>>&nonEmpty)|string>, 'Dummy:InputDto' => ArrayObject<string, (array<string, ArrayObject<string, string>>&nonEmpty)|string>,                      
         'RelatedDummy-list_details' => ArrayObject<string, (array<string, ArrayObject<string, string>>&nonEmpty)|string>) given.

The error wasn't present with 0.12.52, so it looks like a regression. (I can try to run git bisect if it helps.)

Code snippet that reproduces the problem

https://github.com/api-platform/core/blob/master/tests/Swagger/Serializer/ApiGatewayNormalizerTest.php#L137

The problem occurs at other places in our code base, but not everywhere. For instance, it doesn't occur some lines below (https://github.com/api-platform/core/blob/master/tests/Swagger/Serializer/ApiGatewayNormalizerTest.php#L270).

Expected output

No errors should be reported.

@mergeable
Copy link

mergeable bot commented Nov 5, 2020

This bug report is missing a link to reproduction on phpstan.org.
It will most likely be closed after manual review.

@dunglas
Copy link
Contributor Author

dunglas commented Nov 5, 2020

I tried to reproduce on phpstan.org but I didn't managed to do it. However, this is easy to reproduce on the the API Platform repo (just clone the repo and run vendor/bin/phpstan analyse).

@ondrejmirtes
Copy link
Member

hi, thank you :) Reproduced pretty easily: https://phpstan.org/r/66a61090-70ad-4fa6-a1eb-4bcc21c60b0a

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@fc052c4

BTW Did you know I just launched PHPStan Pro? A way to support open-source PHPStan development and get premium PHPStan experience:

  • Web UI for browsing found errors, you can click and open your editor of choice on the offending line.
  • Continuous analysis (watch mode): scans changed files in the background, refreshes the UI automatically.
  • Interactive fixer: lets you choose the right fix for found errors 😊

Try it on PHPStan 0.12.45 or later by running it with the --pro option.

After 30-day free trial period it costs 7 EUR for individuals monthly, 70 EUR for teams (up to 25 members). If you’re using PHPStan at your job to prevent bugs reaching production, please consider paying for PHPStan Pro, 70 EUR monthly is less than a man-day 😊

You can read more about it on the blog: https://phpstan.org/blog/introducing-phpstan-pro

I’m looking forward to your feedback!

@dunglas
Copy link
Contributor Author

dunglas commented Nov 5, 2020

Wow, that was fast, thanks! I'll take a look to PHPStan Pro. Best regards.

@github-actions
Copy link

github-actions bot commented May 9, 2021

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 9, 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

2 participants