MyProxiedClass::sayHello()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace StaticAnalysis\AccessInterceptorScopeLocalizer;
4
5
use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
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 AccessInterceptorScopeLocalizerFactory())
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
    $localizedAccessInterceptor = (new AccessInterceptorScopeLocalizerFactory())
50
        ->createProxy(new MyProxiedClass());
51
52
    $localizedAccessInterceptor->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
    $localizedAccessInterceptor->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 $localizedAccessInterceptor->sayHello();
81
})();
82