1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Joas Schilling <[email protected]> |
4
|
|
|
* @author Morris Jobke <[email protected]> |
5
|
|
|
* @author Olivier Paroz <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
8
|
|
|
* @license AGPL-3.0 |
9
|
|
|
* |
10
|
|
|
* This code is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
12
|
|
|
* as published by the Free Software Foundation. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU Affero General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
21
|
|
|
* |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace OCP\AppFramework\Utility; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Interface ControllerMethodReflector |
28
|
|
|
* |
29
|
|
|
* Reads and parses annotations from doc comments |
30
|
|
|
* |
31
|
|
|
* @package OCP\AppFramework\Utility |
32
|
|
|
* @since 8.0.0 |
33
|
|
|
*/ |
34
|
|
|
interface IControllerMethodReflector { |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param object $object an object or classname |
38
|
|
|
* @param string $method the method which we want to inspect |
39
|
|
|
* @return void |
40
|
|
|
* @since 8.0.0 |
41
|
|
|
*/ |
42
|
|
|
public function reflect($object, $method); |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Inspects the PHPDoc parameters for types |
46
|
|
|
* |
47
|
|
|
* @param string $parameter the parameter whose type comments should be |
48
|
|
|
* parsed |
49
|
|
|
* @return string|null type in the type parameters (@param int $something) |
|
|
|
|
50
|
|
|
* would return int or null if not existing |
51
|
|
|
* @since 8.0.0 |
52
|
|
|
*/ |
53
|
|
|
public function getType($parameter); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return array the arguments of the method with key => default value |
57
|
|
|
* @since 8.0.0 |
58
|
|
|
*/ |
59
|
|
|
public function getParameters(); |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Check if a method contains an annotation |
63
|
|
|
* |
64
|
|
|
* @param string $name the name of the annotation |
65
|
|
|
* @return bool true if the annotation is found |
66
|
|
|
* @since 8.0.0 |
67
|
|
|
*/ |
68
|
|
|
public function hasAnnotation($name); |
69
|
|
|
} |
70
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.