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.
Test Failed
Push — master ( c776f5...aa6284 )
by SignpostMarv
07:23
created

ClassReflectionExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperty() 0 8 1
A MethodNameFromProperty() 0 5 1
A hasProperty() 0 13 3
A setBroker() 0 3 1
1
<?php
2
/**
3
* Base daft objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject\PHPStan;
10
11
use PHPStan\Broker\Broker;
12
use PHPStan\Reflection\BrokerAwareExtension;
13
use PHPStan\Reflection\ClassReflection;
14
use PHPStan\Reflection\PropertiesClassReflectionExtension;
15
use PHPStan\Reflection\PropertyReflection;
16
use SignpostMarv\DaftObject\DaftObject;
17
use SignpostMarv\DaftObject\TypeUtilities;
18
19
class ClassReflectionExtension implements BrokerAwareExtension, PropertiesClassReflectionExtension
20
{
21
    /**
22
    * @var Broker|null
23
    */
24
    private $broker;
25
26
    public function setBroker(Broker $broker) : void
27
    {
28
        $this->broker = $broker;
29
    }
30
31
    public function hasProperty(ClassReflection $classReflection, string $propertyName) : bool
32
    {
33
        $className = $classReflection->getName();
34
35
        $property = ucfirst($propertyName);
36
        $getter = static::MethodNameFromProperty($property);
37
        $setter = static::MethodNameFromProperty($property, true);
38
39
        return
40
            is_a($className, DaftObject::class, true) &&
41
            (
42
                $classReflection->getNativeReflection()->hasMethod($getter) ||
43
                $classReflection->getNativeReflection()->hasMethod($setter)
44
            );
45
    }
46
47
    public function getProperty(ClassReflection $ref, string $propertyName) : PropertyReflection
48
    {
49
        /**
50
        * @var Broker $broker
51
        */
52
        $broker = $this->broker;
53
54
        return new PropertyReflectionExtension($ref, $broker, $propertyName);
55
    }
56
57
    protected static function MethodNameFromProperty(
58
        string $prop,
59
        bool $SetNotGet = false
60
    ) : string {
61
        return TypeUtilities::MethodNameFromProperty($prop, $SetNotGet);
62
    }
63
}
64