MyProxiedClass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A sayHello() 0 4 1
1
<?php
2
3
namespace StaticAnalysis\AccessInterceptorValueHolder;
4
5
use ProxyManager\Factory\AccessInterceptorValueHolderFactory;
6
7
require_once __DIR__ . '/../../vendor/autoload.php';
8
9
class MyProxiedClass
10
{
11
    public function sayHello() : string
12
    {
13
        return 'Hello!';
14
    }
15
}
16
17
(static function () : void {
18
    echo (new AccessInterceptorValueHolderFactory())
19
        ->createProxy(
20
            new MyProxiedClass(),
21
            [
22
                'sayHello' => static function (
23
                    object $proxy,
0 ignored issues
show
Unused Code introduced by
The parameter $proxy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
                    MyProxiedClass $realInstance,
0 ignored issues
show
Unused Code introduced by
The parameter $realInstance is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
                    string $method,
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
                    array $parameters,
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
27
                    bool & $returnEarly
0 ignored issues
show
Unused Code introduced by
The parameter $returnEarly is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
                ) {
29
                    echo 'pre-';
30
                },
31
            ],
32
            [
33
                'sayHello' =>
34
                /** @param mixed $returnValue */
35
                    static function (
36
                        object $proxy,
0 ignored issues
show
Unused Code introduced by
The parameter $proxy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
                        MyProxiedClass $realInstance,
0 ignored issues
show
Unused Code introduced by
The parameter $realInstance is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
                        string $method,
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
                        array $parameters,
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
                        & $returnValue,
0 ignored issues
show
Unused Code introduced by
The parameter $returnValue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
                        bool & $overrideReturnValue
0 ignored issues
show
Unused Code introduced by
The parameter $overrideReturnValue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
                    ) {
43
                        echo 'post-';
44
                    },
45
            ]
46
        )
47
        ->sayHello();
48
49
    $valueHolderInterceptor = (new AccessInterceptorValueHolderFactory())
50
        ->createProxy(new MyProxiedClass());
51
52
    $valueHolderInterceptor->setMethodPrefixInterceptor(
53
        'sayHello',
54
        static function (
55
            object $proxy,
0 ignored issues
show
Unused Code introduced by
The parameter $proxy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
            MyProxiedClass $realInstance,
0 ignored issues
show
Unused Code introduced by
The parameter $realInstance is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
            string $method,
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
            array $parameters,
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
            bool & $returnEarly
0 ignored issues
show
Unused Code introduced by
The parameter $returnEarly is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
        ) {
61
            echo 'pre-';
62
        }
63
    );
64
65
    $valueHolderInterceptor->setMethodSuffixInterceptor(
66
        'sayHello',
67
        /** @param mixed $returnValue */
68
        static function (
69
            object $proxy,
0 ignored issues
show
Unused Code introduced by
The parameter $proxy is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
70
            MyProxiedClass $realInstance,
0 ignored issues
show
Unused Code introduced by
The parameter $realInstance is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
            string $method,
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
            array $parameters,
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
73
            & $returnValue,
0 ignored issues
show
Unused Code introduced by
The parameter $returnValue is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
            bool & $returnEarly
0 ignored issues
show
Unused Code introduced by
The parameter $returnEarly is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
        ) {
76
            echo 'post-';
77
        }
78
    );
79
80
    echo $valueHolderInterceptor->sayHello();
81
82
    $interceptedValue = $valueHolderInterceptor
83
        ->getWrappedValueHolderValue();
84
85
    assert($interceptedValue !== null);
86
87
    echo $interceptedValue->sayHello();
88
})();
89