#Reclassified engine warnings RFC
Lots of errors that previously only triggered warnings or notices, have been converted to proper errors. The following warnings were changed.
- Undefined variable:
Error
exception instead of notice - Undefined array index: warning instead of notice
- Division by zero:
DivisionByZeroError
exception instead of warning - Attempt to increment/decrement property ‘%s’ of non-object:
Error
exception instead of warning - Attempt to modify property ‘%s’ of non-object:
Error
exception instead of warning - Attempt to assign property ‘%s’ of non-object:
Error
exception instead of warning - Creating default object from empty value:
Error
exception instead of warning - Trying to get property ‘%s’ of non-object: warning instead of notice
- Undefined property: %s::$%s: warning instead of notice
- Cannot add element to the array as the next element is already occupied:
Error
exception instead of warning - Cannot unset offset in a non-array variable:
Error
exception instead of warning - Cannot use a scalar value as an array:
Error
exception instead of warning - Only arrays and
Traversables
can be unpacked:TypeError
exception instead of warning - Invalid argument supplied for foreach():
TypeError
exception instead of warning - Illegal offset type:
TypeError
exception instead of warning - Illegal offset type in isset or empty:
TypeError
exception instead of warning - Illegal offset type in unset:
TypeError
exception instead of warning - Array to string conversion: warning instead of notice
- Resource ID#%d used as offset, casting to integer (%d): warning instead of notice
- String offset cast occurred: warning instead of notice
- Uninitialized string offset: %d: warning instead of notice
- Cannot assign an empty string to a string offset:
Error
exception instead of warning
#Default error reporting level
It’s now E_ALL
instead of everything but E_NOTICE
and E_DEPRECATED
. This means that many errors might pop up which were previously silently ignored, though probably already existent before PHP 8.
#The @ operator no longer silences fatal errors
It’s possible that this change might reveal errors that again were hidden before PHP 8. Make sure to set display_errors=Off
on your production servers!
#Concatenation precedence RFC
While already deprecated in PHP 7.4, this change is now taken into effect. If you’d write something like this:
echo "sum: " . $a + $b;
PHP would previously interpret it like this:
echo ("sum: " . $a) + $b;
PHP 8 will make it so that it’s interpreted like this:
echo "sum: " . ($a + $b);