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

TypeError: Argument 1 passed to PhpParser\Node\Scalar\LNumber::__construct() must be of the type int, float given #1484

Closed
DeepDiver1975 opened this issue Feb 20, 2021 · 5 comments · Fixed by #1486
Labels
Milestone

Comments

@DeepDiver1975
Copy link
Contributor

Question Answer
Infection version 0.21.0
Test Framework version PHPUnit 9.5.2
PHP version 7.4.15
Platform Debian
Github Repo -
Output with issue

Running initial test suite...

PHPUnit version: 9.5.2

318 [============================] 7 mins

Generate mutants...

Processing source code files: 214/305PHP Fatal error: Uncaught TypeError: Argument 1 passed to PhpParser\Node\Scalar\LNumber::__construct() must be of the type int, float given, called in /home/deepdiver/Development/......../vendor/infection/infection/src/Mutator/Number/IncrementInteger.php on line 81 and defined in /home/deepdiver/Development/......../vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php:25
Stack trace:
#0 /home/deepdiver/Development/......../vendor/infection/infection/src/Mutator/Number/IncrementInteger.php(81): PhpParser\Node\Scalar\LNumber->__construct()
#1 /home/deepdiver/Development/......./vendor/infection/infection/src/Mutator/NodeMutationGenerator.php(143): Infection\Mutator\Number\IncrementInteger->mutate()
#2 /home/deepdiver/Development/......./vendor/infection/infection/src/Mutator/NodeMutationGenerator.php(112): Infection\Mutator\NodeMutationGenerator->generateForMutator()
#3 /home/deepdiver/Development/......../vendor/infection/infection/src/PhpParser/Visitor/MutationC in /home/deepdiver/Development/......../vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php on line 25

@sidz
Copy link
Member

sidz commented Feb 20, 2021

@DeepDiver1975 could you please provide code sample which produces this issue? At the first glance I do not see the reason why it may happens.

@DeepDiver1975
Copy link
Contributor Author

Quite hard with the hugh codebase at hand.
Let's see if I can debug this further.

@DeepDiver1975
Copy link
Contributor Author

could you please provide code sample which produces this issue?

            $value[] = random_int(10000000, 9223372036854775807);

When incrementing this max int by one it is not longer an int but a float ..... funny ...

@sidz
Copy link
Member

sidz commented Feb 22, 2021

Thanks for the code sample.

So

PHP can only represent big integer values as real integers on systems with a 64-bit architecture and would fall back to approximated float values.

explanation from Doctrine documentation.

also some information you may find here https://www.xspdf.com/resolution/50024441.html

@maks-rafalko maks-rafalko added this to the 0.22.0 milestone Feb 22, 2021
@maks-rafalko
Copy link
Member

maks-rafalko commented Feb 22, 2021

@DeepDiver1975 in case you didn't mention in the issue template, we have a Playground that can be used for reproducers, here is the one for the issue you found: https://infection-php.dev/r/v1r1

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants