Warnings converted to error exceptions
There are a large number of PHP warnings that have been changed to error exceptions in PHP 8.
Error level changes unrelated to RFC’s
The following warnings have been converted to errors probably related to deprecations in PHP 7.x versions:
- Attempting to write to a property of a non-object. Previously this implicitly created an stdClass object for null, false and empty strings.
- Attempting to append an element to an array for which the PHP_INT_MAX key is already used.
- Attempting to use an invalid type (array or object) as an array key or string offset.
- Attempting to write to an array index of a scalar value.
- Attempting to unpack a non-array/Traversable.
Reclassified engine warnings
Lots of errors that previously only triggered warnings or notices, have been converted to errors. The following were changed:
- Undefined variable: Warning 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
- Supplied resource is not a valid stream resource: TypeError exception instead of warning
- #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!
Fatal error for incompatible method signatures
Inheritance errors due to incompatible method signatures between two classes will now throw a fatal error instead of a warning.
Default error reporting level
With PHP 8 the default error reporting level is changed to E_ALL instead of everything but E_NOTICE and E_DEPRECATED. This means that many errors will start showing up which were previously silently ignored.
7.x deprecations
During the PHP 7.x release cycle, each version introduced new deprecations, which have now been finalized as feature removals in PHP 8. This also applies to some deprecation which were already put in place in PHP 5.x, but weren’t removed in the PHP 7.0 release.
Most notably, the following, already deprecated features, have been removed in PHP 8:
- $php_errormsg
- create_function()
- mbstring.func_overload
- parse_str() without second argument
- each()
- assert() with string argument
- $errcontext argument of error handler
- String search functions with integer needle
- Defining a free-standing assert() function
- The real type (alias for float)
- Magic quotes legacy
- array_key_exists() with objects
- Reflection export() methods
- implode() parameter order mix
- Unbinding $this from non-static closures
- restore_include_path() function
- allow_url_include ini directive
No comments:
Post a Comment