1 | <?php |
||
9 | abstract class AbstractConfirmationToken { |
||
10 | |||
11 | /** |
||
12 | * The validated and checked token for this parameter |
||
13 | * |
||
14 | * @var string|null A string value, or null if either not provided or invalid |
||
15 | */ |
||
16 | protected $token = null; |
||
17 | |||
18 | /** |
||
19 | * What to use instead of BASE_URL. Must not contain protocol or host. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | public static $alternateBaseURL = null; |
||
24 | |||
25 | /** |
||
26 | * Given a list of token names, suppress all tokens that have not been validated, and |
||
27 | * return the non-validated token with the highest priority |
||
28 | * |
||
29 | * @param array $keys List of token keys in ascending priority (low to high) |
||
30 | * @return static The token container for the unvalidated $key given with the highest priority |
||
31 | */ |
||
32 | public static function prepare_tokens($keys) { |
||
44 | |||
45 | /** |
||
46 | * Generate a local filesystem path to store a token |
||
47 | * |
||
48 | * @param $token |
||
49 | * @return string |
||
50 | */ |
||
51 | protected function pathForToken($token) { |
||
54 | |||
55 | /** |
||
56 | * Generate a new random token and store it |
||
57 | * |
||
58 | * @return string Token name |
||
59 | */ |
||
60 | protected function genToken() { |
||
72 | |||
73 | /** |
||
74 | * Is the necessary token provided for this parameter? |
||
75 | * A value must be provided for the token |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | public function tokenProvided() { |
||
82 | |||
83 | /** |
||
84 | * Validate a token |
||
85 | * |
||
86 | * @param string $token |
||
87 | * @return boolean True if the token is valid |
||
88 | */ |
||
89 | protected function checkToken($token) { |
||
104 | |||
105 | /** |
||
106 | * Get redirect url, excluding querystring |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | protected function currentAbsoluteURL() { |
||
159 | |||
160 | /** |
||
161 | * Forces a reload of the request with the token included |
||
162 | */ |
||
163 | public function reloadWithToken() { |
||
181 | |||
182 | /** |
||
183 | * Is this parameter requested without a valid token? |
||
184 | * |
||
185 | * @return bool True if the parameter is given without a valid token |
||
186 | */ |
||
187 | abstract public function reloadRequired(); |
||
188 | |||
189 | /** |
||
190 | * Suppress the current parameter for the duration of this request |
||
191 | */ |
||
192 | abstract public function suppress(); |
||
193 | |||
194 | /** |
||
195 | * Determine the querystring parameters to include |
||
196 | * |
||
197 | * @param bool $includeToken Include the token value? |
||
198 | * @return array List of querystring parameters, possibly including token parameter |
||
199 | */ |
||
200 | abstract public function params($includeToken = true); |
||
201 | |||
202 | /** |
||
203 | * @return string |
||
204 | */ |
||
205 | abstract public function getRedirectUrlBase(); |
||
206 | |||
207 | /** |
||
208 | * @return array |
||
209 | */ |
||
210 | abstract public function getRedirectUrlParams(); |
||
211 | |||
212 | /** |
||
213 | * Get redirection URL |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | abstract protected function redirectURL(); |
||
218 | } |
||
219 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.