Completed
Push — 1.x ( e42f79...4120cd )
by Alexander
02:50
created

DynamicClosureSplatMethodInvocation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 32
wmc 4
lcom 1
cbo 1
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B proceed() 0 24 4
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Aop\Framework;
12
13
class DynamicClosureSplatMethodInvocation extends DynamicClosureMethodInvocation
14
{
15
    /**
16
     * Invokes original method and return result from it
17
     *
18
     * @return mixed
19
     */
20 6
    public function proceed()
21
    {
22 6
        if (isset($this->advices[$this->current])) {
23
            /** @var $currentInterceptor \Go\Aop\Intercept\Interceptor */
24 1
            $currentInterceptor = $this->advices[$this->current++];
25
26 1
            return $currentInterceptor->invoke($this);
27
        }
28
29
        // Fill the closure only once if it's empty
30 6
        if (!$this->closureToCall) {
31 6
            $this->closureToCall = $this->reflectionMethod->getClosure($this->instance);
32
        }
33
34
        // Rebind the closure if instance was changed since last time
35 6
        if ($this->previousInstance !== $this->instance) {
36 6
            $this->closureToCall    = $this->closureToCall->bindTo($this->instance, $this->reflectionMethod->class);
37 6
            $this->previousInstance = $this->instance;
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->instance of type object is incompatible with the declared type null of property $previousInstance.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
        }
39
40 6
        $closureToCall = $this->closureToCall;
41
42 6
        return $closureToCall(...$this->arguments);
43
    }
44
}
45