.. _php-nativeclasstypecompatibility: .. _php-native-class-type-compatibility: PHP Native Class Type Compatibility +++++++++++++++++++++++++++++++++++ PHP enforces the method compatibility with native classes and interfaces. This means that classes that extends native PHP classes or interfaces must declare compatible types. They can't omit typing, like it was the case until PHP 8.0. This is needed for compatibility with PHP 8.0. This is probably good for older versions too, although it is not reported. The `attribute `_ ``ReturnTypeWillChange`` is taken into account by this rule. Note that it is not detected when auditing with PHP < 8.0, so it won't have effect until this version. The `attribute `_ was declared in PHP 8.1, though it is also taken into account when auditing with PHP 8.0. .. code-block:: php See also method-compatibility. Related PHP errors ------------------- + `0 `_ Connex PHP features ------------------- + `returntypewillchange `_ + `type-covariance `_ + `type-contravariance `_ Suggestions ___________ * Make sure the methods are compatible or identical to the parent's method signature. Specs _____ +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Short name | Php/NativeClassTypeCompatibility | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Analyze `, :ref:`Changed Behavior `, :ref:`CompatibilityPHP81 ` | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 2.2.4 | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Severity | Major | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Precision | High | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+