PhpNamespace
final class PhpNamespace
Represents a PHP namespace with use statements and contained class-like types and functions.
Constants
| NameNormal |
|
| NameFunction |
|
| NameConstant |
|
| NAME_NORMAL |
|
| NAME_FUNCTION |
|
| NAME_CONSTANT |
|
Methods
No description
No description
No description
No description
Adds a use statement for a class, function, or constant.
Removes a use statement.
Adds a use statement for a function.
Adds a use statement for a constant.
Returns use statements, sorted alphabetically and excluding redundant aliases within the same namespace.
Resolves a relative or aliased name to its fully qualified form.
Simplifies all class/function/constant names in a type string using current use statements.
Simplifies a fully qualified name to the shortest possible form using current use statements.
Adds a class-like type or function to the namespace.
Adds an interface to the namespace.
Returns a class-like type by name.
No description
Removes a class-like type from the namespace.
Adds a function to the namespace.
Returns a function by name.
No description
Removes a function from the namespace.
No description
Details
at line 52
__construct(string $name)
No description
at line 62
string
getName()
No description
at line 71
PhpNamespace
setBracketedSyntax(bool $state = true)
| internal |
No description
at line 78
bool
hasBracketedSyntax()
No description
at line 90
PhpNamespace
addUse(string $name, string|null $alias = null, string $of = self::NameNormal)
Adds a use statement for a class, function, or constant.
Auto-generates an alias if the short name conflicts with existing names.
at line 134
void
removeUse(string $name, string $of = self::NameNormal)
Removes a use statement.
at line 147
PhpNamespace
addUseFunction(string $name, string|null $alias = null)
Adds a use statement for a function.
at line 156
PhpNamespace
addUseConstant(string $name, string|null $alias = null)
Adds a use statement for a constant.
at line 167
array
getUses(string $of = self::NameNormal)
Returns use statements, sorted alphabetically and excluding redundant aliases within the same namespace.
at line 182
string
resolveName(string $name, string $of = self::NameNormal)
Resolves a relative or aliased name to its fully qualified form.
at line 207
string
simplifyType(string $type, string $of = self::NameNormal)
Simplifies all class/function/constant names in a type string using current use statements.
at line 217
string
simplifyName(string $name, string $of = self::NameNormal)
Simplifies a fully qualified name to the shortest possible form using current use statements.
at line 265
PhpNamespace
add(GlobalFunction $item)
Adds a class-like type or function to the namespace.
at line 291
ClassType
addClass(string $name)
Adds a class to the namespace.
at line 302
InterfaceType
addInterface(string $name)
Adds an interface to the namespace.
at line 313
TraitType
addTrait(string $name)
Adds a trait to the namespace.
at line 324
EnumType
addEnum(string $name)
Adds an enum to the namespace.
at line 335
EnumType
getClass(string $name)
Returns a class-like type by name.
at line 342
array
getClasses()
No description
at line 358
PhpNamespace
removeClass(string $name)
Removes a class-like type from the namespace.
at line 369
GlobalFunction
addFunction(string $name)
Adds a function to the namespace.
at line 380
GlobalFunction
getFunction(string $name)
Returns a function by name.
at line 387
array
getFunctions()
No description
at line 401
PhpNamespace
removeFunction(string $name)
Removes a function from the namespace.
at line 414
string
__toString()
No description