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 ( 0268aa...3ec9bd )
by cao
05:24
created

ConsoleContainerBuilder::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 4
dl 14
loc 14
ccs 6
cts 8
cp 0.75
crap 2.0625
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: caoyangmin
5
 * Date: 2018/6/14
6
 * Time: δΈ‹εˆ2:10
7
 */
8
9
namespace PhpBoot\Console;
10
11
12
use DI\FactoryInterface;
13
use Doctrine\Common\Cache\Cache;
14
use PhpBoot\Annotation\ContainerBuilder;
15
use DI\InvokerInterface as DIInvokerInterface;
16
use PhpBoot\Console\Annotations\ClassAnnotationHandler;
17
use PhpBoot\Console\Annotations\CommandAnnotationHandler;
18
use PhpBoot\Console\Annotations\CommandNameAnnotationHandler;
19
use PhpBoot\Console\Annotations\ParamAnnotationHandler;
20
use PhpBoot\Console\Annotations\ValidateAnnotationHandler;
21
22
class ConsoleContainerBuilder extends ContainerBuilder
23
{
24
    static $DEFAULT_ANNOTATIONS=[
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $DEFAULT_ANNOTATIONS.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
25
        [ClassAnnotationHandler::class, 'class'],
26
        [CommandNameAnnotationHandler::class, "class.children[?name=='command']"],
27
        [CommandAnnotationHandler::class, "methods.*.children[?name=='command'][]"],
28
        [ParamAnnotationHandler::class, "methods.*.children[?name=='param'][]"],
29
        [ValidateAnnotationHandler::class, "methods.*.children[].children[?name=='v'][]"],
30
    ];
31
    /**
32
     * @var FactoryInterface
33
     */
34
    private $factory;
35
    /**
36
     * @var DIInvokerInterface
37
     */
38
    private $diInvoker;
39
40 1 View Code Duplication
    public function __construct(FactoryInterface $factory,
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
                                DIInvokerInterface $diInvoker,
42
                                Cache $cache,
43
                                array $annotations = null
44
    )
45
    {
46 1
        if($annotations){
47
            parent::__construct($annotations, $cache);
48
        }else{
49 1
            parent::__construct(self::$DEFAULT_ANNOTATIONS, $cache);
50
        }
51 1
        $this->factory = $factory;
52 1
        $this->diInvoker = $diInvoker;
53 1
    }
54
55
    /**
56
     * @param string $className
57
     * @return ConsoleContainer
58
     */
59 1
    protected function createContainer($className)
60
    {
61 1
        return $this->factory->make(ConsoleContainer::class, ['className'=>$className]);
62
    }
63
64 1
    protected function handleAnnotation($handlerName, $container, $ann)
65
    {
66 1
        $handler = $this->factory->make($handlerName);
67 1
        return $this->diInvoker->call($handler, [$container, $ann]);
0 ignored issues
show
Documentation introduced by
$handler is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68
    }
69
70 1
    protected function postCreateContainer($object)
71
    {
72 1
        parent::postCreateContainer($object);
73
        /**@var ConsoleContainer $object*/
74 1
        $object->postCreate();
75
    }
76
}