This rule relates to how static methods are referenced within a class in PHP. The self keyword is used to refer to the same class in which the new keyword is being used. However, when dealing with static methods, it’s considered best practice to use the static keyword instead of self.
The reason for this preference lies in the late static binding concept of PHP. If a child class inherits a static method from a parent class and you use self to reference it, it will call the parent’s version of the method. But if you use static, it will call the child’s version if it exists, providing more flexibility and correctly implementing the behavior of inheritance in object-oriented programming.
To adhere to this rule, always use static instead of self when referencing static methods within the same class. For instance, instead of self::print(), use static::print(). This practice ensures that your code is more robust and adaptable to changes in class hierarchy.