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.

BindAnnotationHandler   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 11

Test Coverage

Coverage 76.32%

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 29
cts 38
cp 0.7632
rs 10
c 0
b 0
f 0
wmc 10
lcom 0
cbo 11

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 49 10
1
<?php
2
3
namespace PhpBoot\Controller\Annotations;
4
5
use PhpBoot\Annotation\AnnotationBlock;
6
use PhpBoot\Annotation\AnnotationTag;
7
use PhpBoot\Controller\ControllerContainer;
8
use PhpBoot\Entity\ContainerFactory;
9
use PhpBoot\Entity\EntityContainerBuilder;
10
use PhpBoot\Exceptions\AnnotationSyntaxException;
11
use PhpBoot\Metas\ReturnMeta;
12
use PhpBoot\Utils\AnnotationParams;
13
use PhpBoot\Utils\Logger;
14
15
class BindAnnotationHandler
16
{
17
    /**
18
     * @param ControllerContainer $container
19
     * @param AnnotationBlock|AnnotationTag $ann
20
     * @param EntityContainerBuilder $entityBuilder
21
     */
22 3
    public function __invoke(ControllerContainer $container, $ann, EntityContainerBuilder $entityBuilder)
23
    {
24 3
        if(!$ann->parent || !$ann->parent->parent){
25
            Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()} should be used with parent param/return");
26
            return;
27
        }
28 3
        $target = $ann->parent->parent->name;
29 3
        $route = $container->getRoute($target);
30 3
        if(!$route){
31
            Logger::debug("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target should be used with parent param/return");
32
            return ;
33
        }
34
35 3
        $params = new AnnotationParams($ann->description, 2);
36
37 3
        $params->count()>0 or \PhpBoot\abort(new AnnotationSyntaxException("The annotation \"@{$ann->name} {$ann->description}\" of {$container->getClassName()}::$target require 1 param, {$params->count()} given"));
38
39 3
        $handler = $route->getResponseHandler();
40
41 3
        if ($ann->parent->name == 'return'){
42
            list($target, $return) = $handler->getMappingBySource('return');
43
            if($return){
44
                $handler->eraseMapping($target);
45
                $handler->setMapping($params[0], $return);
46
            }
47
48 3
        }elseif($ann->parent->name == 'param'){
49 3
            list($paramType, $paramName, $paramDoc) = ParamAnnotationHandler::getParamInfo($ann->parent->description);
0 ignored issues
show
Unused Code introduced by
The assignment to $paramType is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
50
51 3
            $paramMeta = $route->getRequestHandler()->getParamMeta($paramName);
52 3
            if($paramMeta->isPassedByReference){
53 3
                list($target, $ori) = $handler->getMappingBySource('params.'.$paramName);
54 3
                if($ori){
55 3
                    $handler->eraseMapping($target);
56 3
                }
57
                //输出绑定
58 3
                $handler->setMapping(
59 3
                    $params[0],
60 3
                    new ReturnMeta(
61 3
                        'params.'.$paramMeta->name,
62 3
                        $paramMeta->type, $paramDoc,
63 3
                        ContainerFactory::create($entityBuilder, $paramMeta->type)
64 3
                    )
65 3
                );
66 3
            }else{
67 3
                $paramMeta->source = $params[0];
68
            }
69 3
        }
70
    }
71
}