1 | <?php |
||
25 | class ServiceMethod implements ActionReferenceInterface, ContainerAwareInterface |
||
26 | { |
||
27 | /** |
||
28 | * Service id of the object which method is used as an action |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $serviceId; |
||
33 | |||
34 | /** |
||
35 | * Method name used as action |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $methodName; |
||
40 | |||
41 | /** |
||
42 | * Action type |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $type; |
||
47 | |||
48 | /** |
||
49 | * Action method reflection |
||
50 | * |
||
51 | * @var ReflectionMethod |
||
52 | */ |
||
53 | private $reflectionMethod; |
||
54 | |||
55 | /** |
||
56 | * Target object object which method is used as an action |
||
57 | * Used internally to invoke action |
||
58 | * |
||
59 | * @var object |
||
60 | */ |
||
61 | private $object; |
||
62 | |||
63 | /** |
||
64 | * DI Container instance |
||
65 | * |
||
66 | * @var ContainerInterface |
||
67 | */ |
||
68 | private $container; |
||
69 | |||
70 | /** |
||
71 | * ActionReference constructor. |
||
72 | * |
||
73 | * @param string $methodName method name |
||
74 | * @param int $serviceId service id which method is used as an action |
||
75 | * @param string $type action reference type |
||
76 | */ |
||
77 | public function __construct($methodName, $serviceId, $type = self::TYPE_REGULAR) |
||
83 | |||
84 | /** |
||
85 | * Returns action type |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getType() |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function setContainer(ContainerInterface $container = null) |
||
101 | |||
102 | /** |
||
103 | * Invokes action |
||
104 | * |
||
105 | * @param array $args action args |
||
106 | * |
||
107 | * @return mixed |
||
108 | */ |
||
109 | public function invoke(array $args) |
||
113 | |||
114 | /** |
||
115 | * Returns reflection method |
||
116 | * |
||
117 | * @return ReflectionMethod |
||
118 | */ |
||
119 | private function getReflectionMethod() |
||
127 | |||
128 | /** |
||
129 | * Returns service object |
||
130 | * |
||
131 | * @return object |
||
132 | */ |
||
133 | private function getObject() |
||
145 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.