1 | <?php |
||
35 | abstract class AbstractInterceptor implements InterceptorInterface |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * The key of the servlet request in the method invocation parameters. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | const SERVLET_REQUEST = 'servletRequest'; |
||
44 | |||
45 | /** |
||
46 | * The key of the servlet response in the method invocation parameters. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | const SERVLET_RESPONSE = 'servletResponse'; |
||
51 | |||
52 | /** |
||
53 | * The intercepted action instance. |
||
54 | * |
||
55 | * @var \AppserverIo\Routlt\ActionInterface |
||
56 | */ |
||
57 | protected $action; |
||
58 | |||
59 | /** |
||
60 | * Sets the actual action instance. |
||
61 | * |
||
62 | * @param \AppserverIo\Routlt\ActionInterface $action The actual action instance |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | 8 | public function setAction(ActionInterface $action) |
|
67 | { |
||
68 | 8 | $this->action = $action; |
|
69 | 8 | } |
|
70 | |||
71 | /** |
||
72 | * Returns the actual action instance. |
||
73 | * |
||
74 | * @return \AppserverIo\Routlt\ActionInterface The actual action instance |
||
75 | */ |
||
76 | 7 | public function getAction() |
|
77 | { |
||
78 | 7 | return $this->action; |
|
79 | } |
||
80 | |||
81 | /** |
||
82 | * The parameters of the actual method invocation. |
||
83 | * |
||
84 | * @var \AppserverIo\Psr\Servlet\ServletRequestInterface |
||
85 | */ |
||
86 | protected $parameters = array(); |
||
87 | |||
88 | /** |
||
89 | * Sets the method invocation parameters. |
||
90 | * |
||
91 | * @param array $parameters The method invocation parameters |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | 10 | public function setParameters(array $parameters) |
|
96 | { |
||
97 | 10 | $this->parameters = $parameters; |
|
|
|||
98 | 10 | } |
|
99 | |||
100 | /** |
||
101 | * Returns the requsted method invocation parameter. |
||
102 | * |
||
103 | * @param string $name Name of the parameter to return |
||
104 | * |
||
105 | * @return mixed|null The requested parameter if available |
||
106 | */ |
||
107 | 7 | public function getParameter($name) |
|
108 | { |
||
109 | 7 | if (isset($this->parameters[$name])) { |
|
110 | 6 | return $this->parameters[$name]; |
|
111 | } |
||
112 | 1 | } |
|
113 | |||
114 | /** |
||
115 | * Returns the instance of the actual servlet request. |
||
116 | * |
||
117 | * @return \AppserverIo\Psr\Servlet\ServletRequestInterface|null The actual servlet request instance |
||
118 | */ |
||
119 | 5 | public function getServletRequest() |
|
120 | { |
||
121 | 5 | return $this->getParameter(AbstractInterceptor::SERVLET_REQUEST); |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Returns the instance of the actual servlet response. |
||
126 | * |
||
127 | * @return \AppserverIo\Psr\Servlet\ServletResponseInterface|null The actual servlet response instance |
||
128 | */ |
||
129 | 1 | public function getServletResponse() |
|
130 | { |
||
131 | 1 | return $this->getParameter(AbstractInterceptor::SERVLET_RESPONSE); |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * Returns the public methods of the actual action instance. |
||
136 | * |
||
137 | * @return array|null The public methods |
||
138 | */ |
||
139 | 3 | public function getActionMethods() |
|
140 | { |
||
141 | 3 | if (($action = $this->getAction()) != null) { |
|
142 | 2 | return get_class_methods($action); |
|
143 | } |
||
144 | 1 | } |
|
145 | |||
146 | /** |
||
147 | * Executes the custom interceptor functionality. |
||
148 | * |
||
149 | * @param \AppserverIo\Psr\MetaobjectProtocol\Aop\MethodInvocationInterface $methodInvocation Initially invoked method |
||
150 | * |
||
151 | * @return mixed The interceptors return value |
||
152 | */ |
||
153 | abstract protected function execute(MethodInvocationInterface $methodInvocation); |
||
154 | |||
155 | /** |
||
156 | * Method that implements the interceptors functionality. |
||
157 | * |
||
158 | * @param \AppserverIo\Psr\MetaobjectProtocol\Aop\MethodInvocationInterface $methodInvocation Initially invoked method |
||
159 | * |
||
160 | * @return string|null The action result |
||
161 | */ |
||
162 | 7 | public function intercept(MethodInvocationInterface $methodInvocation) |
|
183 | } |
||
184 |
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..