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
Cannot combine generic key types when @template is limited to array-key #10871
@@ @@
19: Call to function is_string() with 'foo' will always evaluate to true.
20: Call to function is_int() with 0 will always evaluate to true.
-PHP 7.3 – 7.4 (4 errors)+PHP 7.2 – 7.4 (4 errors)
==========
8: Function foo() uses native union types but they're supported only on PHP 8.0 and later.
9: Dumped type: non-empty-array<T of (int|string) (function foo(), argument), mixed>
-19: Call to function is_string() with 'foo' will always evaluate to true.-20: Call to function is_int() with 0 will always evaluate to true.--PHP 7.2 (6 errors)-==========-- 8: Function foo() uses native union types but they're supported only on PHP 8.0 and later.- 9: Dumped type: non-empty-array<T of (int|string) (function foo(), argument), mixed>-11: Function array_key_first not found.-13: Function array_key_first not found.
19: Call to function is_string() with 'foo' will always evaluate to true.
20: Call to function is_int() with 0 will always evaluate to true.
Full report
PHP 8.0 – 8.3 (3 errors)
Line
Error
9
`Dumped type: non-empty-array<T of (int
19
Call to function is_string() with 'foo' will always evaluate to true.
20
Call to function is_int() with 0 will always evaluate to true.
PHP 7.2 – 7.4 (4 errors)
Line
Error
8
Function foo() uses native union types but they're supported only on PHP 8.0 and later.
9
`Dumped type: non-empty-array<T of (int
19
Call to function is_string() with 'foo' will always evaluate to true.
20
Call to function is_int() with 0 will always evaluate to true.
@@ @@
19: Call to function is_string() with 'foo' will always evaluate to true.
20: Call to function is_int() with 0 will always evaluate to true.
-PHP 7.3 – 7.4 (5 errors)+PHP 7.2 – 7.4 (5 errors)
==========
8: Function foo() uses native union types but they're supported only on PHP 8.0 and later.
9: Dumped type: non-empty-array<T of int|string (function foo(), argument), mixed>
11: Parameter #1 $param of function int_only expects int, T of int|string given.
-19: Call to function is_string() with 'foo' will always evaluate to true.-20: Call to function is_int() with 0 will always evaluate to true.--PHP 7.2 (6 errors)-==========-- 8: Function foo() uses native union types but they're supported only on PHP 8.0 and later.- 9: Dumped type: non-empty-array<T of int|string (function foo(), argument), mixed>-11: Function array_key_first not found.-13: Function array_key_first not found.
19: Call to function is_string() with 'foo' will always evaluate to true.
20: Call to function is_int() with 0 will always evaluate to true.
Full report
PHP 8.0 – 8.3 (4 errors)
Line
Error
9
`Dumped type: non-empty-array<T of int
11
`Parameter #1 $param of function int_only expects int, T of int
19
Call to function is_string() with 'foo' will always evaluate to true.
20
Call to function is_int() with 0 will always evaluate to true.
PHP 7.2 – 7.4 (5 errors)
Line
Error
8
Function foo() uses native union types but they're supported only on PHP 8.0 and later.
9
`Dumped type: non-empty-array<T of int
11
`Parameter #1 $param of function int_only expects int, T of int
19
Call to function is_string() with 'foo' will always evaluate to true.
20
Call to function is_int() with 0 will always evaluate to true.
Activity
SerethiX commentedon Jul 23, 2024
The type checking also seems to stop, once array-key is used.
This example failes to detect the possible type error, while
int|stringcorrectly detects it: https://phpstan.org/r/8213d7d7-f36c-4e34-8fbf-64976a1dcde0phpstan-bot commentedon Feb 21, 2025
@SerethiX After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.3 (3 errors)
Call to function is_string() with 'foo' will always evaluate to true.Call to function is_int() with 0 will always evaluate to true.PHP 7.2 – 7.4 (4 errors)
Function foo() uses native union types but they're supported only on PHP 8.0 and later.Call to function is_string() with 'foo' will always evaluate to true.Call to function is_int() with 0 will always evaluate to true.phpstan-bot commentedon Feb 21, 2025
@SerethiX After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
Full report
PHP 8.0 – 8.3 (4 errors)
Call to function is_string() with 'foo' will always evaluate to true.Call to function is_int() with 0 will always evaluate to true.PHP 7.2 – 7.4 (5 errors)
Function foo() uses native union types but they're supported only on PHP 8.0 and later.Call to function is_string() with 'foo' will always evaluate to true.Call to function is_int() with 0 will always evaluate to true.phpstan-bot commentedon Sep 9, 2026
Closed via merging phpstan/phpstan-src#6376
github-actions commentedon Oct 11, 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.