Currently, I am sitting on PHP5.6 and would be updating to PHP8 soon. I used PHPCS to check the compatibility issues and was able to fix them before upgrading to PHP8.
However, I found some issues related to type juggling in the code during testing such as:
$x = "";
$x['test'] = "xyz";
print_r($x); //Warning: Only the first byte will be assigned to the string offset in /tmp/8dw2cmkrbq0pcq/tester.php on line 4 Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /tmp/8dw2cmkrbq0pcq/tester.php:4 Stack trace: #0 {main} thrown in /tmp/8dw2cmkrbq0pcq/tester.php on line 4
This piece of code worked well in PHP5.6.
Unfortunately, the issue was not detected by PHPCS and now I am wondering if there are more issues like this in the product.
Now, I want to know if there is a way to detect such issues before I upgrade to PHP8? It would be really helpful if I could get a hint on how to find such issues before I upgrade to PHP8.