GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#65)
by
unknown
02:16
created

DynamicType::getType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Minime\Annotations\Types;
4
5
class DynamicType extends AbstractType
6
{
7
    /**
8
     * @var TypeInterface
9
     */
10
    private static $instance;
11
12
    public static function getType()
13
    {
14
        if (!isset(self::$instance)) {
15
            self::$instance = new DynamicType();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Minime\Annotations\Types\DynamicType() of type object<Minime\Annotations\Types\DynamicType> is incompatible with the declared type object<Minime\Annotations\Types\TypeInterface> 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...
16
        }
17
18
        return self::$instance;
0 ignored issues
show
Bug Compatibility introduced by
The expression self::$instance; of type Minime\Annotations\Types...ons\Types\TypeInterface adds the type Minime\Annotations\Types\TypeInterface to the return on line 18 which is incompatible with the return type declared by the abstract method Minime\Annotations\Types\AbstractType::getType of type Minime\Annotations\Interfaces\TypeInterface.
Loading history...
19
    }
20
21
    /**
22
     * Parse a given undefined type value
23
     *
24
     * @param  string $value
25
     * @param  null   $annotation Unused
26
     * @return mixed
27
     */
28
    public function parse($value, $annotation = null)
29
    {
30
        if ('' === $value) return true; // implicit boolean
31
32
        $json = JsonType::jsonDecode($value);
33
34
        if (JSON_ERROR_NONE === json_last_error()) {
35
            return $json;
36
        }
37
        elseif (false !== ($int = filter_var($value, FILTER_VALIDATE_INT))) {
38
            return $int;
39
        }
40
        elseif (false !== ($float = filter_var($value, FILTER_VALIDATE_FLOAT))) {
41
            return $float;
42
        }
43
44
        return $value;
45
    }
46
47
}
48