1 | <?php |
||
23 | trait NamespaceBacktracerTrait |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * Get the caller from debug_backtrace() info. |
||
28 | * |
||
29 | * This traverses the call stack until it finds the first function that is |
||
30 | * not a method of an ignored class/interface. |
||
31 | * You should pass in the output of |
||
32 | * `debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)`. |
||
33 | * |
||
34 | * @since 0.1.0 |
||
35 | * |
||
36 | * @param array|null $debugInfo Optional. Output of `debug_backtrace()` function. |
||
37 | * |
||
38 | * @return string Fully qualified name of the calling object/function. |
||
39 | */ |
||
40 | 8 | protected function getCaller($debugInfo = null) |
|
85 | |||
86 | /** |
||
87 | * Get the caller's namespace from debug_backtrace() info. |
||
88 | * |
||
89 | * This traverses the call stack until it finds the first function that is |
||
90 | * not a method of an ignored class/interface. |
||
91 | * You should pass in the output of |
||
92 | * `debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)`. |
||
93 | * |
||
94 | * @since 0.1.0 |
||
95 | * |
||
96 | * @param array|null $debugInfo Optional. Output of `debug_backtrace()` function. |
||
97 | * |
||
98 | * @return string Namespace of the calling object. |
||
99 | */ |
||
100 | 4 | protected function getCallingNamespace($debugInfo = null) |
|
113 | |||
114 | /** |
||
115 | * Extract the namespace from a fully qualified class name. |
||
116 | * |
||
117 | * @since 0.1.0 |
||
118 | * |
||
119 | * @param string $class Fully qualified class name. |
||
120 | * |
||
121 | * @return string Namespace of the class. Empty string if none. |
||
122 | */ |
||
123 | 4 | protected function extractNamespace($class) |
|
132 | |||
133 | /** |
||
134 | * Get an array of interfaces/classes to ignore while fetching a namespace. |
||
135 | * |
||
136 | * Override this method to adapt the output to your specific environment. |
||
137 | * |
||
138 | * @since 0.1.0 |
||
139 | * |
||
140 | * @return array Array of interface/class names. |
||
141 | */ |
||
142 | protected function getIgnoredInterfaces() |
||
146 | |||
147 | /** |
||
148 | * Get an array of functions to ignore while fetching a namespace. |
||
149 | * |
||
150 | * Override this method to adapt the output to your specific environment. |
||
151 | * |
||
152 | * @since 0.1.0 |
||
153 | * |
||
154 | * @return array Array of function names. |
||
|
|||
155 | */ |
||
156 | protected function getIgnoredFunctions() |
||
162 | |||
163 | /** |
||
164 | * Get the string that is returned when the global namespace was hit. |
||
165 | * |
||
166 | * Override this method to adapt the output to your specific environment. |
||
167 | * |
||
168 | * @since 0.1.0 |
||
169 | * |
||
170 | * @return string String that represents the global namespace. |
||
171 | */ |
||
172 | protected function getGlobalNamespace() |
||
176 | } |
||
177 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.