The ReturnTypeWillChange attributeIntroduction
Most non-final internal methods now require overriding methods to declare
a compatible return type, otherwise a deprecated notice is emitted during
inheritance validation. This introduces a tentative return type phase:
the engine emits a deprecation notice instead of a fatal error when return
types are incompatible, before they become enforced in a future version.
In case the return type cannot be declared for an overriding method due to
PHP cross-version compatibility concerns,
a Warning
The ReturnTypeWillChange attribute suppresses deprecation warnings during the tentative return type phase only. It has no effect when overriding methods defined in user-defined classes. Once internal methods adopt strict types, mismatches in overriding method signatures will cause a fatal error and this attribute will no longer have any effect. Class synopsis
#[\Attribute]
final
ReturnTypeWillChange
/* Methods */
public __construct()
See Also
|