phpstan
phpstan copied to clipboard
concat of numeric constant string and int should lead to numeric-string
Bug report
see also https://3v4l.org/EQADV
Code snippet that reproduces the problem
https://phpstan.org/r/a7e508c0-f23c-47d2-a69f-e7d761bff096
Expected output
no error
Did PHPStan help you today? Did it make you happy in any way?
No response
@staabm I dunno if PHPStan can resolve this and I feel like it's explained by https://phpstan.org/r/dc7df350-d283-4426-83be-a24af019c18d
The first '0' . $positiveInt is understood as numeric-string
But then '0' . $numericString is not a numeric-string anymore. '0' . '-0' is not for instance.
While phpstan has positive-int type ; there is no positive-numeric-string.
@staabm After the latest push in 2.1.x, PHPStan now reports different result with your code snippet:
@@ @@
+PHP 8.5 (2 errors)
+==========
+
+10: Cannot use ++ on 0|float|non-falsy-string.
+10: Only numeric types are allowed in pre-increment, float|int|string given.
+
+PHP 7.2 – 8.4 (1 error)
+==========
+
10: Only numeric types are allowed in pre-increment, float|int|string given.
Full report
PHP 8.5 (2 errors)
| Line | Error |
|---|---|
| 10 | `Cannot use ++ on 0 |
| 10 | `Only numeric types are allowed in pre-increment, float |
PHP 7.2 – 8.4 (1 error)
| Line | Error |
|---|---|
| 10 | `Only numeric types are allowed in pre-increment, float |