1.2.95. Calling Static Trait Method

Calling directly a static method, defined in a trait is deprecated. It emits a deprecation notice in PHP 8.1. Calling the same method, from the class point of view is valid.

<?php

trait T {
    public static function t() {
        //
    }
}

T::t();

?>

See also PHP RFC: Deprecations for PHP 8.1.

1.2.95.2. Connex PHP features

1.2.95.2.1. Suggestions

  • Call the method from one of the class using the trait

  • Move the method to a class

1.2.95.2.2. Specs

Short name

Php/CallingStaticTraitMethod

Rulesets

All, Changed Behavior, CompatibilityPHP81, Deprecated

Exakat since

2.2.5

PHP Version

With PHP 8.1 and older

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Medium

Available in

Entreprise Edition, Exakat Cloud