Support has also been added for named parameters. This has two major implications:
Renaming parameters becomes a breaking change. If a parameter is renamed then anywhere that function is called with named parameters will break.
The behaviour of call_user_func_array() changes. Previously call_user_func_array() could be called with an associative array. Now passing an associative array will be interpreted as using named parameters, which will cause an Exception to be thrown, if any of the named parameters do not exist.
API changes which could lead to type errors
Below we’ve compiled a list with some examples of API changes that will lead to type or argument errors where there were no indications as such in previous PHP versions.
mktime() and gmmktime() now require at least one argument. time() can be used to get the current timestamp.
spl_autoload_register() will now always throw a TypeError on invalid arguments, therefore the second argument $do_throw is ignored and a notice will be emitted if it is set to false.
assert() will no longer evaluate string arguments, instead they will be treated like any other argument. assert($a == $b) should be used instead assert('$a == $b'). The assert.quiet_eval ini directive and the ASSERT_QUIET_EVAL constant have also been removed, as they will no longer have any effect.
The $args argument of vsprintf(), vfprintf(), and vprintf() must now be an array. Previously any type was accepted.
Arguments with a default value that resolves to null at runtime will no longer implicitly mark the argument type as nullable. Either use an explicit nullable type, or an explicit null default value instead.
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.
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:
This list serves as an overview of the potential issues that cannot yet be ruled out that may affect the PM code base. Most should not be an issue.
Many pulled from: https://developer.yoast.com/blog/the-2020-wordpress-and-php-8-compatibility-report/
Named parameters
Support has also been added for named parameters. This has two major implications:
API changes which could lead to type errors
Below we’ve compiled a list with some examples of API changes that will lead to type or argument errors where there were no indications as such in previous PHP versions.
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:
Reclassified engine warnings
Lots of errors that previously only triggered warnings or notices, have been converted to errors. The following were changed:
The @ operator no longer silences fatal errors
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.
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: