note 129344 added to migration80.incompatible
| From: | bieronski.dev@gmail.com | Date: | Fri, 22 Mar 2024 13:09:47 +0000 |
| Subject: | note 129344 added to migration80.incompatible | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221250@lists.php.net to get a copy of this message | ||
The most significant issue is the "String to Number Comparison."
It appears that the negation operator, such as $a != $b, is just syntactic sugar over !($a == $b).
Therefore, it shares the same incompatibility as described in the manual.
However, the in_array and switch constructs are likely incompatible too, probably for the same
reason. For example:
```
switch (123) {
case '123 x': echo "\n123 = '123x'"; // PHP7.4 true / PHP8
false
case ' x': echo "\n123 = ' x'"; // PHP7.4 true / PHP8
false
}
switch (0) {
case '': echo "\n0 = ''"; // PHP7.4 true / PHP8
false
}
```
If there were a simple way to add an event when an incompatible comparison takes place (and log it),
it would be much easier. But now upgrading an old project to PHP 8 is extremely time-consuming and
error-prone.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 89.64.110.12)
----
Manual Page -- https://php.net/manual/en/migration80.incompatible.php
Edit -- https://main.php.net/note/edit/129344
Del: integrated -- https://main.php.net/note/delete/129344/integrated
Del: useless -- https://main.php.net/note/delete/129344/useless
Del: bad code -- https://main.php.net/note/delete/129344/bad+code
Del: spam -- https://main.php.net/note/delete/129344/spam
Del: non-english -- https://main.php.net/note/delete/129344/non-english
Del: in docs -- https://main.php.net/note/delete/129344/in+docs
Del: other reasons-- https://main.php.net/note/delete/129344
Reject -- https://main.php.net/note/reject/129344
Search -- https://main.php.net/manage/user-notes.php