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
Push — master ( 3e29f4...a0257c )
by Gytis
03:40 queued 11s
created

FqcnConstSniff::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gskema\TypeSniff\Sniffs\CodeElement;
4
5
use Gskema\TypeSniff\Core\DocBlock\Tag\VarTag;
6
use Gskema\TypeSniff\Inspection\DocTypeInspector;
7
use Gskema\TypeSniff\Inspection\Subject\ConstTypeSubject;
8
use PHP_CodeSniffer\Files\File;
9
use Gskema\TypeSniff\Core\CodeElement\Element\AbstractFqcnConstElement;
10
use Gskema\TypeSniff\Core\CodeElement\Element\ClassConstElement;
11
use Gskema\TypeSniff\Core\CodeElement\Element\CodeElementInterface;
12
use Gskema\TypeSniff\Core\CodeElement\Element\InterfaceConstElement;
13
14
class FqcnConstSniff implements CodeElementSniffInterface
15
{
16
    protected const CODE = 'FqcnConstSniff';
17
18
    /**
19
     * @inheritDoc
20
     */
21 6
    public function configure(array $config): void
22
    {
23
        // nothing to do
24 6
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 6
    public function register(): array
30
    {
31
        return [
32 6
            ClassConstElement::class,
33
            InterfaceConstElement::class,
34
        ];
35
    }
36
37
    /**
38
     * @inheritDoc
39
     *
40
     * @param AbstractFqcnConstElement $const
41
     */
42 2
    public function process(File $file, CodeElementInterface $const): void
43
    {
44 2
        $subject = ConstTypeSubject::fromElement($const);
45
46 2
        DocTypeInspector::reportMandatoryTypes($subject);
47 2
        DocTypeInspector::reportReplaceableTypes($subject);
48
49 2
        DocTypeInspector::reportRemovableTypes($subject);
50 2
        DocTypeInspector::reportMissingOrWrongTypes($subject);
51
52 2
        static::reportUselessDocBlock($subject);
53
54 2
        $subject->writeWarningsTo($file, static::CODE);
55 2
    }
56
57 2
    protected static function reportUselessDocBlock(ConstTypeSubject $subject): void
58
    {
59 2
        if (!$subject->hasDefinedDocBlock()) {
60 1
            return;
61
        }
62
63
        /** @var VarTag|null $varTag */
64 2
        $varTag = $subject->getDocBlock()->getTagsByName('var')[0] ?? null;
65
66 2
        $isUseful = $subject->getDocBlock()->hasDescription()
67 2
            || ($varTag && $varTag->hasDescription())
68 2
            || ($varTag && $varTag->getType() != $subject->getValueType());
69
70 2
        if (!$isUseful) {
71 1
            $subject->addFnTypeWarning('Useless PHPDoc');
72
        }
73 2
    }
74
}
75