|
| 1 | +ReflectionFileNamespace |
| 2 | +============== |
| 3 | + |
| 4 | +The `ReflectionFileNamespace` class reports an information about a namespace in the single file. This class is not available in the standard PHP |
| 5 | + |
| 6 | +API |
| 7 | +--- |
| 8 | + |
| 9 | +```php |
| 10 | +class ReflectionFileNamespace |
| 11 | +{ |
| 12 | + public function __construct($fileName, $namespaceName, Namespace_ $namespaceNode = null) {} |
| 13 | + public function getClass($className) {} |
| 14 | + public function getClasses() {} |
| 15 | + public function getConstant($constantName) {} |
| 16 | + public function getConstants() {} |
| 17 | + public function getDocComment() {} |
| 18 | + public function getEndLine() {} |
| 19 | + public function getFileName() {} |
| 20 | + public function getFunction($functionName) {} |
| 21 | + public function getFunctions() {} |
| 22 | + public function getName() {} |
| 23 | + public function getNamespaceAliases() {} |
| 24 | + public function getStartLine() {} |
| 25 | + public function hasClass($className) {} |
| 26 | + public function hasConstant($constantName) {} |
| 27 | + public function hasFunction($functionName) {} |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +Methods |
| 32 | +------- |
| 33 | + |
| 34 | +- `ReflectionFileNamespace::__construct($fileName, $namespaceName, Namespace_ $namespaceNode = null)` |
| 35 | + |
| 36 | + Constructs an instance of `ReflectionFileNamespace` object for given `fileName` and `namespaceName`. Can accept custom `Namespace_` node as optional parameter. |
| 37 | + |
| 38 | +- `ReflectionFileNamespace::getClass($className)` |
| 39 | + |
| 40 | + Returns the concrete [`ReflectionClass`][0] from the file namespace or `false` if there is no such a class in the current namespace |
| 41 | + |
| 42 | +- `ReflectionFileNamespace::getClasses()` |
| 43 | + |
| 44 | + Returns an array with available classes in the namespace. Each class/trait/interface definition will be represented as a single instance of [`ReflectionClass`][0] in this list. |
| 45 | + |
| 46 | +- `ReflectionFileNamespace::getConstant($constantName)` |
| 47 | + |
| 48 | + Returns a value for the constant with name `$constantName` in the file namespace or `false` if there is no such a constant in the current namespace. |
| 49 | + |
| 50 | +- `ReflectionFileNamespace::getConstants()` |
| 51 | + |
| 52 | + Returns an array with all available constants in the namespace. |
| 53 | + |
| 54 | +- `ReflectionFileNamespace::getDocComment()` |
| 55 | + |
| 56 | + Returns a doc-block section for file namespace if present, otherwise `false` |
| 57 | + |
| 58 | +- `ReflectionFileNamespace::getEndLine()` |
| 59 | + |
| 60 | + Returns a end line for the namespace. Be careful, this value is not correct for simple `namespace Name;` definitions. |
| 61 | + |
| 62 | +- `ReflectionFileNamespace::getFileName()` |
| 63 | + |
| 64 | + Returns a string with the name of file |
| 65 | + |
| 66 | +- `ReflectionFileNamespace::getFunction($functionName)` |
| 67 | + |
| 68 | + Returns the concrete [`ReflectionFunction`][1] from the file namespace or `false` if there is no such a function in the current namespace |
| 69 | + |
| 70 | +- `ReflectionFileNamespace::getFunctions()` |
| 71 | + |
| 72 | + Returns an array with available functions in the namespace. Each function definition will be represented as a single instance of [`ReflectionFunction`][1] in this list. |
| 73 | + |
| 74 | +- `ReflectionFile::getName()` |
| 75 | + |
| 76 | + Returns a string with the name of current file namespace |
| 77 | + |
| 78 | +- `ReflectionFileNamespace::getNamespaceAliases()` |
| 79 | + |
| 80 | + Returns an array with all imported class namespaces and aliases for them in the current namespace. |
| 81 | + |
| 82 | +- `ReflectionFileNamespace::getStartLine()` |
| 83 | + |
| 84 | + Returns a start line for the namespace. |
| 85 | + |
| 86 | +- `ReflectionFileNamespace::hasClass($className)` |
| 87 | + |
| 88 | + Checks if the requested class is present in the file namespace or not. Returns `true` if present. |
| 89 | + |
| 90 | +- `ReflectionFileNamespace::hasConstant($constantName)` |
| 91 | + |
| 92 | + Checks if the requested constant is present in the file namespace or not. Returns `true` if present. |
| 93 | + |
| 94 | +- `ReflectionFileNamespace::hasFunction($functionName)` |
| 95 | + |
| 96 | + Checks if the requested function is present in the file namespace or not. Returns `true` if present. |
| 97 | + |
| 98 | +[0]: reflection_class.md |
| 99 | +[1]: reflection_function.md |
0 commit comments