You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Internal error Int_::__construct(): Argument #1 ($value) must be of type int, float given when assigning an array literal with key 9223372036854775807 followed by a keyless or unpacked item #15248
Internal error: PhpParser\Node\Scalar\Int_::__construct(): Argument #1 ($value) must be of type int, float given, called in src/Analyser/ExprHandler/AssignHandler.php
Mechanism (line numbers from 2.3.x):
AssignHandler calls processArrayByRefItems() for every $variable = [array literal] assignment, not only for literals that contain &$ref items (AssignHandler.php:1342).
For each item, the method computes the key the item will get. After an explicit constant integer key it sets $implicitIndex = $keyValue + 1; (L2529). For PHP_INT_MAX that overflows to a float.
The next item without a key gets new Node\Scalar\Int_($implicitIndex) (L2540), which throws the TypeError.
Unpacked items (...$rest) also go through this branch, because their key is null.
This is separate from the DuplicateKeysInLiteralArraysRule crash on [9223372036854775807 => 1, 2]. That rule stops tracking implicit keys at the $key item, whose key type has no constant value. Returning the same literal directly (return [9223372036854775807 => 1, $key => 2, ...$rest];) is analysed without errors. Only the assignment crashes.
The same code is in 2.2.x, so the crash also reproduces on the playground.
With these two changes the snippet above is analysed without errors. So is the runtime-invalid $a = [9223372036854775807 => 1, $key => 2, 3];, which crashes in the same place today.
Did PHPStan help you today? Did it make you happy in any way?
@@ @@--1: PhpParser\Node\Scalar\Int_::__construct(): Argument #1 ($value) must be of type int, float given, called in phar:///var/task/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/ExprHandler/AssignHandler.php on line 1773+PHP 8.1 – 8.6+==========++No errors++PHP 7.2 – 8.0 (1 error)+==========++ 9: Array unpacking cannot be used on an array with string keys: array<string, int>
Full report
PHP 8.1 – 8.6
No errors
PHP 7.2 – 8.0 (1 error)
Line
Error
9
Array unpacking cannot be used on an array with string keys: array<string, int>
Activity
phpstan-bot commentedon Sep 17, 2026
@ondrejmirtes After the latest push in 2.3.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.1 – 8.6
No errors
PHP 7.2 – 8.0 (1 error)
Array unpacking cannot be used on an array with string keys: array<string, int>phpstan-bot commentedon Sep 17, 2026
Closed via merging phpstan/phpstan-src#6464
github-actions commentedon Oct 19, 2026
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.