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 ( 316d38...a6fddc )
by SignpostMarv
02:47
created

ClassReflectionExtension::MethodNameFromProperty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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 BadMethodCallException;
12
use PHPStan\Broker\Broker;
13
use PHPStan\Reflection\BrokerAwareExtension;
14
use PHPStan\Reflection\ClassReflection;
15
use PHPStan\Reflection\PropertiesClassReflectionExtension;
16
use PHPStan\Reflection\PropertyReflection;
17
use SignpostMarv\DaftObject\DaftObject;
18
use SignpostMarv\DaftObject\TypeUtilities;
19
20
class ClassReflectionExtension implements BrokerAwareExtension, PropertiesClassReflectionExtension
21
{
22
    const BOOL_SETNOTGET_SETTER = true;
23
24
    const BOOL_SETNOTGET_GETTER = false;
25
26
    /**
27
    * @var Broker|null
28
    */
29
    private $broker;
30
31
    public function setBroker(Broker $broker) : void
32
    {
33
        $this->broker = $broker;
34
    }
35
36
    public function hasProperty(ClassReflection $classReflection, string $propertyName) : bool
37
    {
38
        $className = $classReflection->getName();
39
40
        $property = ucfirst($propertyName);
41
        $getter = TypeUtilities::MethodNameFromProperty($property, self::BOOL_SETNOTGET_GETTER);
42
        $setter = TypeUtilities::MethodNameFromProperty($property, self::BOOL_SETNOTGET_SETTER);
43
44
        return
45
            TypeUtilities::IsThingStrings($className, DaftObject::class) &&
46
            (
47
                $classReflection->getNativeReflection()->hasMethod($getter) ||
48
                $classReflection->getNativeReflection()->hasMethod($setter)
49
            );
50
    }
51
52
    public function getProperty(ClassReflection $ref, string $propertyName) : PropertyReflection
53
    {
54
        if ( ! ($this->broker instanceof Broker)) {
55
            throw new BadMethodCallException(
56
                'Broker expected to be specified when calling ' .
57
                __METHOD__
58
            );
59
        }
60
61
        return new PropertyReflectionExtension($ref, $this->broker, $propertyName);
62
    }
63
}
64