1.2.748. Must Call Parent Constructor

Some PHP native classes require a call to parent\:\:`__construct() <https://www.php.net/manual/en/language.oop5.decon.php>`_ to be stable.

As of PHP 7.3, two classes currently need that call : SplTempFileObject and SplFileObject.

The error is only emitted if the class is instantiated, and a parent class is called.

<?php

class mySplFileObject extends \SplFileObject {
    public function __construct()    {
        // Forgottent call to parent::__construct()
    }
}

(new mySplFileObject())->passthru();
?>

See also Why, php? WHY???.

1.2.748.2. Connex PHP features

1.2.748.2.1. Suggestions

  • Add a call to the parent’s constructor

  • Remove the extension of the parent class

1.2.748.2.2. Specs

Short name

Php/MustCallParentConstructor

Rulesets

All, Analyze, Changed Behavior

Exakat since

1.4.1

PHP Version

All

Severity

Major

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud