Innovate faster and cut risk with PHP experts from Zend Services.
Explore Services
Beginning to advanced PHP classes to learn and earn global certification.
Help me choose >
Explore Training
Submit support requests and browse self-service resources.
Explore Support
PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors.Found
If you use PHPStorm, you can automatically fix this issue. Follow the Auto-Fix Inspection in PHPStorm guide.
If you don't use PHPStorm, you can follow the guide below to make those changes manually.
class A extends B { function A() { $this->B(); } } class B { function B() { } } $var = new A();
class A extends B { function __construct() { B::__construct(); } } class B { function __construct() { } } $var = new A();
Do not merely use parent::__construct, as that can overlook an edge case that was only possible with the PHP 4 style constructors. Consider the following code:
parent::__construct
class A extends B { function A() { $this->C(); } } class B extends C { function B() { throw new Exception('This should never be called'); } } class C { function C() { } } $var = new A();
If we were to replace $this->C() with merely parent::__construct, then we'd be executing the wrong constructor and alter the original logic. This is why we need to call the specific class' constructor using A::__construct. PHPStorm's replacement is therefore the correct one.
$this->C()
A::__construct
Increase security and cut risk by simplifying PHP application upgrades and migrations.
Long Term Support buys organizations time to migrate.