Why is this an issue?

Using a function in PHP with the same name as the nesting class was historically used to declare a class constructor. However, as of PHP 8.0.0, this declaration is discouraged and will provoke an E_DEPRECATED error, albeit it functions as a constructor.

Instead, users should explicitly define the constructor by declaring a __construct(…​) function. However, if both styles are present in the same class, PHP will treat the __construct function as the class constructor, which can cause unintended behavior.

Adhering to this convention improves readability and maintainability by ensuring that the constructor declaration is named uniformly throughout the codebase.

Noncompliant code example

class Foo {
  function Foo() {...}
}

Compliant solution

class Foo {
  function __construct() {...}
}

Resources

Documentation