1 | <?php |
||
31 | class MissingImport extends AbstractRule implements MethodAware, FunctionAware |
||
32 | { |
||
33 | /** |
||
34 | * @var array Self reference class names. |
||
35 | */ |
||
36 | protected $selfReferences = array('self', 'static'); |
||
37 | |||
38 | /** |
||
39 | * Checks for missing class imports and warns about it |
||
40 | * |
||
41 | * @param AbstractNode $node The node to check upon. |
||
42 | * @return void |
||
43 | */ |
||
44 | 7 | public function apply(AbstractNode $node) |
|
71 | 5 | ||
72 | /** |
||
73 | 5 | * Check whether a given class node is a self reference |
|
74 | * |
||
75 | * @param ASTNode $classNode A class node to check. |
||
76 | * @return bool Whether the given class node is a self reference. |
||
77 | */ |
||
78 | protected function isSelfReference(ASTNode $classNode) |
||
82 | |||
83 | /** |
||
84 | * Check whether a given class node is in the global namespace |
||
85 | * |
||
86 | * @param ASTNode $classNode A class node to check. |
||
87 | * @return bool Whether the given class node is in the global namespace. |
||
88 | */ |
||
89 | protected function isGlobalNamespace(ASTNode $classNode) |
||
93 | } |
||
94 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: