class Method
Same name in this branch
- 11.1.x vendor/phpunit/php-code-coverage/src/Report/Xml/Method.php \SebastianBergmann\CodeCoverage\Report\Xml\Method
- 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php \PhpParser\Node\Scalar\MagicConst\Method
- 11.1.x vendor/google/protobuf/src/Google/Protobuf/Method.php \Google\Protobuf\Method
- 11.1.x vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Method.php \phpDocumentor\Reflection\DocBlock\Tags\Method
Hierarchy
- class \PhpParser\Builder\Declaration implements \PhpParser\Builder
- class \PhpParser\Builder\FunctionLike extends \PhpParser\Builder\Declaration
- class \PhpParser\Builder\Method extends \PhpParser\Builder\FunctionLike
- class \PhpParser\Builder\FunctionLike extends \PhpParser\Builder\Declaration
Expanded class hierarchy of Method
26 string references to 'Method'
- Alias::getSubNodeNames in vendor/
nikic/ php-parser/ lib/ PhpParser/ Node/ Stmt/ TraitUseAdaptation/ Alias.php - AnnotationParser::forMethod in vendor/
phpunit/ phpunit/ src/ Metadata/ Parser/ AnnotationParser.php - @psalm-param class-string $className @psalm-param non-empty-string $methodName
- AttributeAutoconfigurationPass::process in vendor/
symfony/ dependency-injection/ Compiler/ AttributeAutoconfigurationPass.php - You can modify the container here before it is dumped to PHP code.
- ClassTagRetriever::getTagList in vendor/
phpspec/ prophecy/ src/ Prophecy/ PhpDocumentor/ ClassTagRetriever.php - Clover::process in vendor/
phpunit/ php-code-coverage/ src/ Report/ Clover.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Builder/ Method.php, line 11
Namespace
PhpParser\BuilderView source
class Method extends FunctionLike {
protected string $name;
protected int $flags = 0;
/** @var list<Stmt>|null */
protected ?array $stmts = [];
/** @var list<Node\AttributeGroup> */
protected array $attributeGroups = [];
/**
* Creates a method builder.
*
* @param string $name Name of the method
*/
public function __construct(string $name) {
$this->name = $name;
}
/**
* Makes the method public.
*
* @return $this The builder instance (for fluid interface)
*/
public function makePublic() {
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC);
return $this;
}
/**
* Makes the method protected.
*
* @return $this The builder instance (for fluid interface)
*/
public function makeProtected() {
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED);
return $this;
}
/**
* Makes the method private.
*
* @return $this The builder instance (for fluid interface)
*/
public function makePrivate() {
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE);
return $this;
}
/**
* Makes the method static.
*
* @return $this The builder instance (for fluid interface)
*/
public function makeStatic() {
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC);
return $this;
}
/**
* Makes the method abstract.
*
* @return $this The builder instance (for fluid interface)
*/
public function makeAbstract() {
if (!empty($this->stmts)) {
throw new \LogicException('Cannot make method with statements abstract');
}
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT);
$this->stmts = null;
// abstract methods don't have statements
return $this;
}
/**
* Makes the method final.
*
* @return $this The builder instance (for fluid interface)
*/
public function makeFinal() {
$this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL);
return $this;
}
/**
* Adds a statement.
*
* @param Node|PhpParser\Builder $stmt The statement to add
*
* @return $this The builder instance (for fluid interface)
*/
public function addStmt($stmt) {
if (null === $this->stmts) {
throw new \LogicException('Cannot add statements to an abstract method');
}
$this->stmts[] = BuilderHelpers::normalizeStmt($stmt);
return $this;
}
/**
* Adds an attribute group.
*
* @param Node\Attribute|Node\AttributeGroup $attribute
*
* @return $this The builder instance (for fluid interface)
*/
public function addAttribute($attribute) {
$this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
return $this;
}
/**
* Returns the built method node.
*
* @return Stmt\ClassMethod The built method node
*/
public function getNode() : Node {
return new Stmt\ClassMethod($this->name, [
'flags' => $this->flags,
'byRef' => $this->returnByRef,
'params' => $this->params,
'returnType' => $this->returnType,
'stmts' => $this->stmts,
'attrGroups' => $this->attributeGroups,
], $this->attributes);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
Declaration::$attributes | protected | property | @var array<string, mixed> | |
Declaration::addStmts | public | function | Adds multiple statements. | |
Declaration::setDocComment | public | function | Sets doc comment for the declaration. | |
FunctionLike::$params | protected | property | @var Node\Param[] | |
FunctionLike::$returnByRef | protected | property | ||
FunctionLike::$returnType | protected | property | @var Node\Identifier|Node\Name|Node\ComplexType|null | |
FunctionLike::addParam | public | function | Adds a parameter. | |
FunctionLike::addParams | public | function | Adds multiple parameters. | |
FunctionLike::makeReturnByRef | public | function | Make the function return by reference. | |
FunctionLike::setReturnType | public | function | Sets the return type for PHP 7. | |
Method::$attributeGroups | protected | property | @var list<Node\AttributeGroup> | |
Method::$flags | protected | property | ||
Method::$name | protected | property | ||
Method::$stmts | protected | property | @var list<Stmt>|null | |
Method::addAttribute | public | function | Adds an attribute group. | |
Method::addStmt | public | function | Adds a statement. | Overrides Declaration::addStmt |
Method::getNode | public | function | Returns the built method node. | Overrides Builder::getNode |
Method::makeAbstract | public | function | Makes the method abstract. | |
Method::makeFinal | public | function | Makes the method final. | |
Method::makePrivate | public | function | Makes the method private. | |
Method::makeProtected | public | function | Makes the method protected. | |
Method::makePublic | public | function | Makes the method public. | |
Method::makeStatic | public | function | Makes the method static. | |
Method::__construct | public | function | Creates a method builder. |