SingletonClass::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace TestNamespace;
4
5
/**
6
 * Generated Class
7
 */
8
class SingletonClass
9
{
10
    /**
11
     * Singleton instance
12
     *
13
     * @var TestNamespace\SingletonClass
14
     */
15
    protected static $instance;
16
17
    /**
18
     * Singleton NO THREAD SAFE!
19
     *
20
     * @return TestNamespace\SingletonClass|null
21
     */
22
    final public static function getInstance()
23
    {
24
        if (is_null(self::$instance)) {
25
            self::$instance = new self();
0 ignored issues
show
Documentation Bug introduced by
It seems like new self() of type object<TestNamespace\SingletonClass> is incompatible with the declared type object<TestNamespace\Tes...mespace\SingletonClass> of property $instance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
26
        }
27
28
        return self::$instance;
29
    }
30
}
31