nelmio / NelmioSecurityBundle

Adds extra security-related features in your Symfony application
https://symfony.com/bundles/NelmioSecurityBundle/
MIT License
651 stars 85 forks source link

Make data array variable type within `Report` more precise #332

Closed fritzmg closed 3 months ago

fritzmg commented 10 months ago

Just a minor issue that PHP stan found in our project:

Error: Parameter #1 $data of class Nelmio\SecurityBundle\ContentSecurityPolicy\Violation\Report constructor expects array<string, string>, array<string, int|string> given.
 ------ ---------------------------------------------------------------------- 
  Line   core-bundle/tests/EventListener/CspReportListenerTest.php             
 ------ ---------------------------------------------------------------------- 
  47     Parameter #1 $data of class                                           
         Nelmio\SecurityBundle\ContentSecurityPolicy\Violation\Report          
         constructor expects array<string, string>, array<string, int|string>  
         given.                                                                
 ------ ---------------------------------------------------------------------- 

The JSON data sent by the browser can in fact also have integers for the following keys:

codecov-commenter commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (da7cc88) 96.93% compared to head (f7a2bde) 96.93%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #332 +/- ## ========================================= Coverage 96.93% 96.93% Complexity 429 429 ========================================= Files 52 52 Lines 1923 1923 ========================================= Hits 1864 1864 Misses 59 59 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fritzmg commented 10 months ago

Not sure how to fix the other issues reported by PHP stan. These methods do in fact only ever return a string or null.