Skip to content

min() and max() do not return false on php8#2161

Merged
ondrejmirtes merged 1 commit intophpstan:1.9.xfrom
staabm:minmax-php8
Jan 4, 2023
Merged

min() and max() do not return false on php8#2161
ondrejmirtes merged 1 commit intophpstan:1.9.xfrom
staabm:minmax-php8

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 3, 2023

refs phpstan/phpstan#7239 (comment)

bottom line: in php8 min() and max() do no longer return false
https://www.php.net/manual/en/function.max.php

Copy link
Contributor Author

@staabm staabm Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turned the existing assertions into a php<8 case (minmax-arrays.php)

copied the existing assertion files and adjusted them for php8+ (minmax-php8.php) - meaning turn false into *ERROR*

extracted the assertions which are php version independent into minmax.php

@staabm
Copy link
Contributor Author

staabm commented Jan 3, 2023

the build error is legit: we no longer trigger the false-positive

Error: Ignored error pattern #^Parameter \#2 \$length of function str_pad expects int, int\<0, max\>\|false given\.$# in path /home/runner/work/phpstan-src/phpstan-src/e2e/integration/repo/src/TextUI/DefaultResultPrinter.php was not matched in reported errors.
 ------ ----------------------------------------------------------------------- 
  Line   src/TextUI/DefaultResultPrinter.php                                    
 ------ ----------------------------------------------------------------------- 
         Ignored error pattern #^Parameter \#2 \$length of function str_pad     
         expects int, int<0, max>\|false given\.$# in path                      
         /home/runner/work/phpstan-src/phpstan-src/e2e/integration/repo/src/Te  
         xtUI/DefaultResultPrinter.php was not matched in reported errors.      
 ------ ----------------------------------------------------------------------- 

in https://github.com/sebastianbergmann/phpunit/blob/93d4bf4c37aec6384bb9e5d390d9049a463a7256/src/TextUI/DefaultResultPrinter.php#L541-L547

@staabm staabm marked this pull request as ready for review January 3, 2023 16:10
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 02753c6 into phpstan:1.9.x Jan 4, 2023
@ondrejmirtes
Copy link
Member

Thank you.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants