PhpInterface
class PhpInterface extends AbstractPhpStruct implements GenerateableInterface, ConstantsInterface
Represents a PHP interface.
Traits
Methods
Sets the description, which will also be used when generating a docblock
Sets the long description
In contrast to setName(), this method accepts the fully qualified name including the namespace.
Create a new PHP interface
Adds a use statement with an optional alias
Declares a "use $fullClassName" with " as $alias" if $alias is available, and returns its alias (or not qualified classname) to be used in your actual php code.
Returns whether the given use statement is present
Returns the usable alias for a qualified name
No description
Adds a constant
Creates a PHP interface from file
Details
in AbstractModel at line line 19
string
getDescription()
Returns this description
in AbstractModel at line line 29
$this
setDescription(string|array $description)
Sets the description, which will also be used when generating a docblock
in DocblockPart at line line 24
$this
setDocblock(Docblock|string $doc)
Sets the docblock
in DocblockPart at line line 39
Docblock
getDocblock()
Returns the docblock
in LongDescriptionPart at line line 21
string
getLongDescription()
Returns the long description
in LongDescriptionPart at line line 31
$this
setLongDescription(string $longDescription)
Sets the long description
in NamePart at line line 22
$this
setName(string $name)
Sets the name
in NamePart at line line 33
string
getName()
Returns the name
in QualifiedNamePart at line line 24
$this
setNamespace(string $namespace)
Sets the namespace
in QualifiedNamePart at line line 37
$this
setQualifiedName(string $name)
In contrast to setName(), this method accepts the fully qualified name including the namespace.
in QualifiedNamePart at line line 56
string
getNamespace()
Returns the namespace
in QualifiedNamePart at line line 65
string
getQualifiedName()
Returns the qualified name
in AbstractPhpStruct at line line 53
static AbstractPhpStruct
create(string $name = null)
Creates a new struct
at line line 54
__construct(string $name = null)
Create a new PHP interface
in AbstractPhpStruct at line line 76
$this
setRequiredFiles(array $files)
Sets requried files
in AbstractPhpStruct at line line 88
$this
addRequiredFile(string $file)
Adds a new required file
in AbstractPhpStruct at line line 99
Set
getRequiredFiles()
Returns required files
in AbstractPhpStruct at line line 111
$this
setUseStatements(array $useStatements)
Sets use statements
in InterfacesPart at line line 30
abstract $this
addUseStatement(string $qualifiedName, null|string $alias = null)
Adds a use statement with an optional alias
in AbstractPhpStruct at line line 146
$this
clearUseStatements()
Clears all use statements
in AbstractPhpStruct at line line 158
$this
declareUses()
Declares multiple use statements at once.
in AbstractPhpStruct at line line 176
string
declareUse(string $qualifiedName, null|string $alias = null)
Declares a "use $fullClassName" with " as $alias" if $alias is available, and returns its alias (or not qualified classname) to be used in your actual php code.
If the class has already been declared you get only the set alias.
in AbstractPhpStruct at line line 190
bool
hasUseStatement(string $qualifiedName)
Returns whether the given use statement is present
in AbstractPhpStruct at line line 200
string
getUseAlias(string $qualifiedName)
Returns the usable alias for a qualified name
in InterfacesPart at line line 38
abstract $this
removeUseStatement(string $qualifiedName)
Removes a use statement
in AbstractPhpStruct at line line 220
Map
getUseStatements()
Returns all use statements
in AbstractPhpStruct at line line 230
$this
setMethods(array $methods)
Sets a collection of methods
in AbstractPhpStruct at line line 249
$this
setMethod(PhpMethod $method)
Adds a method
in AbstractPhpStruct at line line 263
$this
removeMethod(string|PhpMethod $nameOrMethod)
Removes a method
in AbstractPhpStruct at line line 284
bool
hasMethod(string|PhpMethod $nameOrMethod)
Checks whether a method exists or not
in AbstractPhpStruct at line line 299
PhpMethod
getMethod(string $nameOrMethod)
Returns a method
in AbstractPhpStruct at line line 316
Map
getMethods()
Returns all methods
in AbstractPhpStruct at line line 325
Set
getMethodNames()
Returns all method names
in AbstractPhpStruct at line line 334
$this
clearMethods()
Clears all methods
at line line 63
$this
generateDocblock()
in ConstantsPart at line line 30
$this
setConstants(array $constants)
Sets a collection of constants
in ConstantsPart at line line 56
$this
setConstant($nameOrConstant, $value = null, $isExpression = false)
Adds a constant
in ConstantsPart at line line 77
$this
removeConstant(string|PhpConstant $nameOrConstant)
Removes a constant
in ConstantsPart at line line 97
bool
hasConstant(string|PhpConstant $nameOrConstant)
Checks whether a constant exists
in ConstantsPart at line line 112
PhpConstant
getConstant(string|PhpConstant $nameOrConstant)
Returns a constant.
in ConstantsPart at line line 129
Map
getConstants()
Returns all constants
in ConstantsPart at line line 138
Set
getConstantNames()
Returns all constant names
in ConstantsPart at line line 147
$this
clearConstants()
Clears all constants
in InterfacesPart at line line 56
$this
addInterface(PhpInterface|string $interface)
Adds an interface.
If the interface is passed as PhpInterface object, the interface is also added as use statement.
in InterfacesPart at line line 79
Set
getInterfaces()
Returns the interfaces
in InterfacesPart at line line 88
bool
hasInterfaces()
Checks whether interfaces exists
in InterfacesPart at line line 98
bool
hasInterface(PhpInterface|string $interface)
Checks whether an interface exists
in InterfacesPart at line line 116
$this
removeInterface(PhpInterface|string $interface)
Removes an interface.
If the interface is passed as PhpInterface object, the interface is also remove from the use statements.
in InterfacesPart at line line 137
$this
setInterfaces(array $interfaces)
Sets a collection of interfaces
at line line 28
static PhpInterface
fromReflection(ReflectionClass $ref)
deprecated
deprecated
Creates a PHP interface from reflection
at line line 38
static PhpInterface
fromFile(string $filename)
Creates a PHP interface from file