class PhpInterface extends AbstractPhpStruct implements GenerateableInterface, ConstantsInterface

Represents a PHP interface.

Traits

Constants part
Interfaces part
Docblock Part
Long description part
Qualified name part
Name part

Methods

string
getDescription()

Returns this description

$this
setDescription(string|array $description)

Sets the description, which will also be used when generating a docblock

$this
setDocblock(Docblock|string $doc)

Sets the docblock

Docblock
getDocblock()

Returns the docblock

string
getLongDescription()

Returns the long description

$this
setLongDescription(string $longDescription)

Sets the long description

$this
setName(string $name)

Sets the name

from NamePart
string
getName()

Returns the name

from NamePart
$this
setNamespace(string $namespace)

Sets the namespace

$this
setQualifiedName(string $name)

In contrast to setName(), this method accepts the fully qualified name including the namespace.

string
getNamespace()

Returns the namespace

string
getQualifiedName()

Returns the qualified name

create(string $name = null)

Creates a new struct

__construct(string $name = null)

Create a new PHP interface

$this
setRequiredFiles(array $files)

Sets requried files

$this
addRequiredFile(string $file)

Adds a new required file

Set
getRequiredFiles()

Returns required files

$this
setUseStatements(array $useStatements)

Sets use statements

$this
addUseStatement(string $qualifiedName, null|string $alias = null)

Adds a use statement with an optional alias

$this
clearUseStatements()

Clears all use statements

$this
declareUses()

Declares multiple use statements at once.

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.

bool
hasUseStatement(string $qualifiedName)

Returns whether the given use statement is present

string
getUseAlias(string $qualifiedName)

Returns the usable alias for a qualified name

$this
removeUseStatement(string $qualifiedName)

Removes a use statement

Map
getUseStatements()

Returns all use statements

$this
setMethods(array $methods)

Sets a collection of methods

$this
setMethod(PhpMethod $method)

Adds a method

$this
removeMethod(string|PhpMethod $nameOrMethod)

Removes a method

bool
hasMethod(string|PhpMethod $nameOrMethod)

Checks whether a method exists or not

getMethod(string $nameOrMethod)

Returns a method

Map
getMethods()

Returns all methods

Set
getMethodNames()

Returns all method names

$this
clearMethods()

Clears all methods

$this
generateDocblock()

No description

$this
setConstants(array $constants)

Sets a collection of constants

$this
setConstant($nameOrConstant, $value = null, $isExpression = false)

Adds a constant

$this
removeConstant(string|PhpConstant $nameOrConstant)

Removes a constant

bool
hasConstant(string|PhpConstant $nameOrConstant)

Checks whether a constant exists

getConstant(string|PhpConstant $nameOrConstant)

Returns a constant.

Map
getConstants()

Returns all constants

Set
getConstantNames()

Returns all constant names

$this
clearConstants()

Clears all constants

$this
addInterface(PhpInterface|string $interface)

Adds an interface.

Set
getInterfaces()

Returns the interfaces

bool
hasInterfaces()

Checks whether interfaces exists

bool
hasInterface(PhpInterface|string $interface)

Checks whether an interface exists

$this
removeInterface(PhpInterface|string $interface)

Removes an interface.

$this
setInterfaces(array $interfaces)

Sets a collection of interfaces

static PhpInterface
fromReflection(ReflectionClass $ref) deprecated

Creates a PHP interface from reflection

static PhpInterface
fromFile(string $filename)

Creates a PHP interface from file

Details

in AbstractModel at line line 19
string getDescription()

Returns this description

Return Value

string

in AbstractModel at line line 29
$this setDescription(string|array $description)

Sets the description, which will also be used when generating a docblock

Parameters

string|array $description

Return Value

$this

in DocblockPart at line line 24
$this setDocblock(Docblock|string $doc)

Sets the docblock

Parameters

Docblock|string $doc

Return Value

$this

in DocblockPart at line line 39
Docblock getDocblock()

Returns the docblock

Return Value

Docblock

in LongDescriptionPart at line line 21
string getLongDescription()

Returns the long description

Return Value

string

in LongDescriptionPart at line line 31
$this setLongDescription(string $longDescription)

Sets the long description

Parameters

string $longDescription

Return Value

$this

in NamePart at line line 22
$this setName(string $name)

Sets the name

Parameters

string $name

Return Value

$this

in NamePart at line line 33
string getName()

Returns the name

Return Value

string

in QualifiedNamePart at line line 24
$this setNamespace(string $namespace)

Sets the namespace

Parameters

string $namespace

Return Value

$this

in QualifiedNamePart at line line 37
$this setQualifiedName(string $name)

In contrast to setName(), this method accepts the fully qualified name including the namespace.

Parameters

string $name

Return Value

$this

in QualifiedNamePart at line line 56
string getNamespace()

Returns the namespace

Return Value

string

in QualifiedNamePart at line line 65
string getQualifiedName()

Returns the qualified name

Return Value

string

in AbstractPhpStruct at line line 53
static AbstractPhpStruct create(string $name = null)

Creates a new struct

Parameters

string $name the fqcn

Return Value

AbstractPhpStruct

at line line 54
__construct(string $name = null)

Create a new PHP interface

Parameters

string $name the fqcn

in AbstractPhpStruct at line line 76
$this setRequiredFiles(array $files)

Sets requried files

Parameters

array $files

Return Value

$this

in AbstractPhpStruct at line line 88
$this addRequiredFile(string $file)

Adds a new required file

Parameters

string $file

Return Value

$this

in AbstractPhpStruct at line line 99
Set getRequiredFiles()

Returns required files

Return Value

Set collection of filenames

in AbstractPhpStruct at line line 111
$this setUseStatements(array $useStatements)

Sets use statements

Parameters

array $useStatements

Return Value

$this

See also

#addUseStatement
#declareUses()

in InterfacesPart at line line 30
abstract $this addUseStatement(string $qualifiedName, null|string $alias = null)

Adds a use statement with an optional alias

Parameters

string $qualifiedName
null|string $alias

Return Value

$this

in AbstractPhpStruct at line line 146
$this clearUseStatements()

Clears all use statements

Return Value

$this

in AbstractPhpStruct at line line 158
$this declareUses()

Declares multiple use statements at once.

Return Value

$this

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.

Parameters

string $qualifiedName
null|string $alias

Return Value

string the used alias

in AbstractPhpStruct at line line 190
bool hasUseStatement(string $qualifiedName)

Returns whether the given use statement is present

Parameters

string $qualifiedName

Return Value

bool

in AbstractPhpStruct at line line 200
string getUseAlias(string $qualifiedName)

Returns the usable alias for a qualified name

Parameters

string $qualifiedName

Return Value

string the alias

in InterfacesPart at line line 38
abstract $this removeUseStatement(string $qualifiedName)

Removes a use statement

Parameters

string $qualifiedName

Return Value

$this

in AbstractPhpStruct at line line 220
Map getUseStatements()

Returns all use statements

Return Value

Map collection of use statements

in AbstractPhpStruct at line line 230
$this setMethods(array $methods)

Sets a collection of methods

Parameters

array $methods

Return Value

$this

in AbstractPhpStruct at line line 249
$this setMethod(PhpMethod $method)

Adds a method

Parameters

PhpMethod $method

Return Value

$this

in AbstractPhpStruct at line line 263
$this removeMethod(string|PhpMethod $nameOrMethod)

Removes a method

Parameters

string|PhpMethod $nameOrMethod method name or Method instance

Return Value

$this

Exceptions

InvalidArgumentException if the method cannot be found

in AbstractPhpStruct at line line 284
bool hasMethod(string|PhpMethod $nameOrMethod)

Checks whether a method exists or not

Parameters

string|PhpMethod $nameOrMethod method name or Method instance

Return Value

bool true if it exists and false if not

in AbstractPhpStruct at line line 299
PhpMethod getMethod(string $nameOrMethod)

Returns a method

Parameters

string $nameOrMethod the methods name

Return Value

PhpMethod

Exceptions

InvalidArgumentException if the method cannot be found

in AbstractPhpStruct at line line 316
Map getMethods()

Returns all methods

Return Value

Map collection of methods

in AbstractPhpStruct at line line 325
Set getMethodNames()

Returns all method names

Return Value

Set

in AbstractPhpStruct at line line 334
$this clearMethods()

Clears all methods

Return Value

$this

at line line 63
$this generateDocblock()

Return Value

$this

in ConstantsPart at line line 30
$this setConstants(array $constants)

Sets a collection of constants

Parameters

array $constants

Return Value

$this

in ConstantsPart at line line 56
$this setConstant($nameOrConstant, $value = null, $isExpression = false)

Adds a constant

Parameters

$nameOrConstant
$value
$isExpression

Return Value

$this

in ConstantsPart at line line 77
$this removeConstant(string|PhpConstant $nameOrConstant)

Removes a constant

Parameters

string|PhpConstant $nameOrConstant constant name

Return Value

$this

Exceptions

InvalidArgumentException If the constant cannot be found

in ConstantsPart at line line 97
bool hasConstant(string|PhpConstant $nameOrConstant)

Checks whether a constant exists

Parameters

string|PhpConstant $nameOrConstant

Return Value

bool

in ConstantsPart at line line 112
PhpConstant getConstant(string|PhpConstant $nameOrConstant)

Returns a constant.

Parameters

string|PhpConstant $nameOrConstant

Return Value

PhpConstant

Exceptions

InvalidArgumentException If the constant cannot be found

in ConstantsPart at line line 129
Map getConstants()

Returns all constants

Return Value

Map

in ConstantsPart at line line 138
Set getConstantNames()

Returns all constant names

Return Value

Set

in ConstantsPart at line line 147
$this clearConstants()

Clears all constants

Return Value

$this

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.

Parameters

PhpInterface|string $interface interface or qualified name

Return Value

$this

in InterfacesPart at line line 79
Set getInterfaces()

Returns the interfaces

Return Value

Set

in InterfacesPart at line line 88
bool hasInterfaces()

Checks whether interfaces exists

Return Value

bool true if interfaces are available and false if not

in InterfacesPart at line line 98
bool hasInterface(PhpInterface|string $interface)

Checks whether an interface exists

Parameters

PhpInterface|string $interface interface name or instance

Return Value

bool

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.

Parameters

PhpInterface|string $interface interface or qualified name

Return Value

$this

in InterfacesPart at line line 137
$this setInterfaces(array $interfaces)

Sets a collection of interfaces

Parameters

array $interfaces

Return Value

$this

at line line 28
static PhpInterface fromReflection(ReflectionClass $ref) deprecated

deprecated Use fromFile() instead

Creates a PHP interface from reflection

Parameters

ReflectionClass $ref

Return Value

PhpInterface

at line line 38
static PhpInterface fromFile(string $filename)

Creates a PHP interface from file

Parameters

string $filename

Return Value

PhpInterface