1.2.1255. Unfinished Object

Some of the properties are not assigned a value before or at constructor time. Then, they might be called when one of the other public method is called, and yield a fatal error.

<?php

class x {
    private $p;
    private $p2;

    function __construct($p) {
        $this->p = $p;
        // $p2 is not assigned
    }

    function foo() {
        $this->p->goo();
        // This is not valid
        $this->p2->goo();
    }
}

?>

See also Compulsory parameters should be required in your constructor.

1.2.1255.1. Suggestions

  • Make sure the object is finished at construction time

1.2.1255.2. Specs

Short name

Classes/UnfinishedObject

Rulesets

All, Analyze, Class Review

Exakat since

2.3.6

PHP Version

All

Severity

Major

Time To Fix

Slow (1 hour)

Precision

High

Features

object, constructor

Available in

Entreprise Edition, Exakat Cloud