PhpStorm 2021.1 Help

Code Inspection: Old style constructor

Reports old-style constructor declarations (ClassName()) and suggests replacing them with new-style constructors (__construct() ).

Using old-style constructors is highly discouraged. In PHP 7, such usages will raise an E_DEPRECATED notice. In future PHP versions, support for old-style constructors will be removed. In the following example, the constructor for class Example is defined in the old form.

class Example { public function Example() {} }
class Example { public function __construct() {} }

Suppress an inspection in the editor

  1. Position the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 08 March 2021