PhpNamespace
final class PhpNamespace
Definition of a PHP namespace.
Generates:
- namespace statement
- variable amount of use statements
- one or more class declarations
Constants
| NameNormal |
|
| NameFunction |
|
| NameConstant |
|
| NAME_NORMAL |
|
| NAME_FUNCTION |
|
| NAME_CONSTANT |
|
Methods
No description
No description
No description
No description
Adds a use statement to the namespace for class, function or constant.
No description
Adds a use statement to the namespace for function.
Adds a use statement to the namespace for constant.
No description
Resolves relative name to full name.
Simplifies type hint with relative names.
Simplifies the full name of a class, function, or constant to a relative name.
Adds a class-like type or function to the namespace. If it already exists, throws an exception.
Adds a class to the namespace. If it already exists, throws an exception.
Adds an interface to the namespace. If it already exists, throws an exception.
Adds a trait to the namespace. If it already exists, throws an exception.
Adds an enum to the namespace. If it already exists, throws an exception.
Returns a class-like type from the namespace.
Returns all class-like types in the namespace.
Removes a class-like type from namespace.
Adds a function to the namespace. If it already exists, throws an exception.
Returns a function from the namespace.
Returns all functions in the namespace.
Removes a function type from namespace.
No description
Details
at line 58
__construct(string $name)
No description
at line 68
string
getName()
No description
at line 77
PhpNamespace
setBracketedSyntax(bool $state = true)
| internal |
No description
at line 84
bool
hasBracketedSyntax()
No description
at line 95
PhpNamespace
addUse(string $name, string|null $alias = null, string $of = self::NameNormal)
Adds a use statement to the namespace for class, function or constant.
at line 136
void
removeUse(string $name, string $of = self::NameNormal)
No description
at line 149
PhpNamespace
addUseFunction(string $name, string|null $alias = null)
Adds a use statement to the namespace for function.
at line 158
PhpNamespace
addUseConstant(string $name, string|null $alias = null)
Adds a use statement to the namespace for constant.
at line 168
array
getUses(string $of = self::NameNormal)
No description
at line 183
string
resolveName(string $name, string $of = self::NameNormal)
Resolves relative name to full name.
at line 208
string
simplifyType(string $type, string $of = self::NameNormal)
Simplifies type hint with relative names.
at line 218
string
simplifyName(string $name, string $of = self::NameNormal)
Simplifies the full name of a class, function, or constant to a relative name.
at line 265
PhpNamespace
add(GlobalFunction $item)
Adds a class-like type or function to the namespace. If it already exists, throws an exception.
at line 290
ClassType
addClass(string $name)
Adds a class to the namespace. If it already exists, throws an exception.
at line 300
InterfaceType
addInterface(string $name)
Adds an interface to the namespace. If it already exists, throws an exception.
at line 310
TraitType
addTrait(string $name)
Adds a trait to the namespace. If it already exists, throws an exception.
at line 320
EnumType
addEnum(string $name)
Adds an enum to the namespace. If it already exists, throws an exception.
at line 330
EnumType
getClass(string $name)
Returns a class-like type from the namespace.
at line 340
array
getClasses()
Returns all class-like types in the namespace.
at line 356
PhpNamespace
removeClass(string $name)
Removes a class-like type from namespace.
at line 366
GlobalFunction
addFunction(string $name)
Adds a function to the namespace. If it already exists, throws an exception.
at line 376
GlobalFunction
getFunction(string $name)
Returns a function from the namespace.
at line 386
array
getFunctions()
Returns all functions in the namespace.
at line 400
PhpNamespace
removeFunction(string $name)
Removes a function type from namespace.
at line 413
string
__toString()
No description