Dep: update

주로 PHAN
This commit is contained in:
2021-08-06 22:39:09 +09:00
parent 5310c2e7f6
commit b306601c72
1098 changed files with 92137 additions and 33228 deletions
@@ -6,6 +6,7 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\UseVariableNameList;
use Microsoft\PhpParser\Token;
@@ -17,7 +18,7 @@ class AnonymousFunctionUseClause extends Node {
/** @var Token */
public $openParen;
/** @var UseVariableNameList */
/** @var UseVariableNameList|MissingToken */
public $useVariableNameList;
/** @var Token */
@@ -0,0 +1,31 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class Attribute extends Node {
/** @var Token|Node */
public $name;
/** @var Token|null */
public $openParen;
/** @var DelimitedList\ArgumentExpressionList|null */
public $argumentExpressionList;
/** @var Token|null */
public $closeParen;
const CHILD_NAMES = [
'name',
'openParen',
'argumentExpressionList',
'closeParen'
];
}
@@ -0,0 +1,28 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\AttributeElementList;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class AttributeGroup extends Node {
/** @var Token */
public $startToken;
/** @var AttributeElementList */
public $attributes;
/** @var Token */
public $endToken;
const CHILD_NAMES = [
'startToken',
'attributes',
'endToken'
];
}
@@ -7,6 +7,8 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\QualifiedNameList;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Token;
class CatchClause extends Node {
@@ -14,17 +16,9 @@ class CatchClause extends Node {
public $catch;
/** @var Token */
public $openParen;
/** @var QualifiedName */
public $qualifiedName;
/**
* @var QualifiedName[]|Token[] Remaining tokens and qualified names in the catch clause
* (e.g. `catch (FirstException|SecondException $x)` would contain
* the representation of `|SecondException`)
*
* TODO: In the next backwards incompatible release, replace qualifiedName with qualifiedNameList?
*/
public $otherQualifiedNameList;
/** @var Token */
/** @var QualifiedNameList[]|MissingToken */
public $qualifiedNameList;
/** @var Token|null */
public $variableName;
/** @var Token */
public $closeParen;
@@ -34,8 +28,7 @@ class CatchClause extends Node {
const CHILD_NAMES = [
'catch',
'openParen',
'qualifiedName',
'otherQualifiedNameList',
'qualifiedNameList',
'variableName',
'closeParen',
'compoundStatement'
@@ -6,10 +6,16 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class ClassConstDeclaration extends Node {
class ClassConstDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token[] */
public $modifiers;
@@ -24,6 +30,7 @@ class ClassConstDeclaration extends Node {
public $semicolon;
const CHILD_NAMES = [
'attributes',
'modifiers',
'constKeyword',
'constElements',
@@ -0,0 +1,12 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\DelimitedList;
class AttributeElementList extends DelimitedList {
}
@@ -0,0 +1,12 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\DelimitedList;
class DeclareDirectiveList extends DelimitedList {
}
@@ -0,0 +1,12 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\DelimitedList;
class MatchArmConditionList extends DelimitedList {
}
@@ -0,0 +1,12 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\DelimitedList;
class MatchExpressionArmList extends DelimitedList {
}
@@ -0,0 +1,39 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class EnumCaseDeclaration extends Node {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $caseKeyword;
/** @var QualifiedName */
public $name;
/** @var Token|null */
public $equalsToken;
/** @var Token|Node|null */
public $assignment;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'attributes',
'caseKeyword',
'name',
'equalsToken',
'assignment',
'semicolon',
];
}
@@ -0,0 +1,27 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class EnumMembers extends Node {
/** @var Token */
public $openBrace;
/** @var Node[] */
public $enumMemberDeclarations;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'openBrace',
'enumMemberDeclarations',
'closeBrace',
];
}
@@ -21,6 +21,7 @@ class AnonymousFunctionCreationExpression extends Expression implements Function
use FunctionHeader, FunctionUseClause, FunctionReturnType, FunctionBody;
const CHILD_NAMES = [
'attributes',
'staticModifier',
// FunctionHeader
@@ -37,8 +38,7 @@ class AnonymousFunctionCreationExpression extends Expression implements Function
// FunctionReturnType
'colonToken',
'questionToken',
'returnType',
'otherReturnTypes',
'returnTypeList',
// FunctionBody
'compoundStatementOrSemicolon'
@@ -10,17 +10,21 @@ use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class ArgumentExpression extends Expression {
/** @var Token|null for php named arguments. If this is set, dotDotDotToken will not be set. */
public $name;
/** @var Token|null */
public $byRefToken; // TODO removed in newer versions of PHP. Also only accept variable, not expression if byRef
public $colonToken;
/** @var Token|null */
public $dotDotDotToken;
/** @var Expression */
/** @var Expression|null null for first-class callable syntax */
public $expression;
const CHILD_NAMES = [
'byRefToken',
'name',
'colonToken',
'dotDotDotToken',
'expression'
];
@@ -26,6 +26,7 @@ class ArrowFunctionCreationExpression extends Expression implements FunctionLike
public $resultExpression;
const CHILD_NAMES = [
'attributes',
'staticModifier',
// FunctionHeader
@@ -39,8 +40,7 @@ class ArrowFunctionCreationExpression extends Expression implements FunctionLike
// FunctionReturnType
'colonToken',
'questionToken',
'returnType',
'otherReturnTypes',
'returnTypeList',
// body
'arrowToken',
@@ -0,0 +1,47 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\MatchExpressionArmList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class MatchExpression extends Expression {
/** @var Token `match` */
public $matchToken;
/** @var Token */
public $openParen;
/** @var Node|null */
public $expression;
/** @var Token */
public $closeParen;
/** @var Token */
public $openBrace;
/** @var MatchExpressionArmList|null */
public $arms;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'matchToken',
'openParen',
'expression',
'closeParen',
'openBrace',
'arms',
'closeBrace',
];
}
@@ -6,6 +6,7 @@
namespace Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\AttributeGroup;
use Microsoft\PhpParser\Node\ClassBaseClause;
use Microsoft\PhpParser\Node\ClassInterfaceClause;
use Microsoft\PhpParser\Node\ClassMembersNode;
@@ -19,6 +20,9 @@ class ObjectCreationExpression extends Expression {
/** @var Token */
public $newKeword;
/** @var AttributeGroup[]|null optional attributes of an anonymous class. */
public $attributes;
/** @var QualifiedName|Variable|Token */
public $classTypeDesignator;
@@ -41,7 +45,8 @@ class ObjectCreationExpression extends Expression {
public $classMembers;
const CHILD_NAMES = [
'newKeword', // TODO
'newKeword',
'attributes',
'classTypeDesignator',
'openParen',
'argumentExpressionList',
@@ -4,23 +4,19 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Statement;
namespace Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class ThrowStatement extends StatementNode {
class ThrowExpression extends Expression {
/** @var Token */
public $throwKeyword;
/** @var Expression */
public $expression;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'throwKeyword',
'expression',
'semicolon'
];
}
@@ -9,6 +9,8 @@ namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
trait FunctionHeader {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $functionKeyword;
/** @var Token */
@@ -11,10 +11,9 @@ use Microsoft\PhpParser\Token;
trait FunctionReturnType {
/** @var Token */
public $colonToken;
// TODO: This may be the wrong choice if ?type can ever be mixed with other types in union types
/** @var Token|null */
public $questionToken;
/** @var Token|QualifiedName */
public $returnType;
/** @var DelimitedList\QualifiedNameList|null TODO: Merge with returnType in a future backwards incompatible release */
public $otherReturnTypes;
/** @var DelimitedList\QualifiedNameList|null */
public $returnTypeList;
}
@@ -0,0 +1,29 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\MatchArmConditionList;
use Microsoft\PhpParser\Token;
class MatchArm extends Node {
/** @var MatchArmConditionList */
public $conditionList;
/** @var Token */
public $arrowToken;
/** @var Expression */
public $body;
const CHILD_NAMES = [
'conditionList',
'arrowToken',
'body',
];
}
@@ -10,17 +10,17 @@ use Microsoft\PhpParser\Diagnostic;
use Microsoft\PhpParser\DiagnosticKind;
use Microsoft\PhpParser\DiagnosticsProvider;
use Microsoft\PhpParser\FunctionLike;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
use Microsoft\PhpParser\TokenKind;
class MethodDeclaration extends Node implements FunctionLike {
/** @var Token[] */
public $modifiers;
use FunctionHeader, FunctionReturnType, FunctionBody;
class MethodDeclaration extends Node implements FunctionLike, ModifiedTypeInterface {
use FunctionHeader, FunctionReturnType, FunctionBody, ModifiedTypeTrait;
const CHILD_NAMES = [
'attributes',
'modifiers',
// FunctionHeader
@@ -34,30 +34,18 @@ class MethodDeclaration extends Node implements FunctionLike {
// FunctionReturnType
'colonToken',
'questionToken',
'returnType',
'otherReturnTypes',
'returnTypeList',
// FunctionBody
'compoundStatementOrSemicolon'
];
public function hasModifier(int $targetModifier) : bool {
if ($this->modifiers === null) {
return false;
}
foreach ($this->modifiers as $modifier) {
if ($modifier->kind === $targetModifier) {
return true;
}
}
return false;
}
public function isStatic() : bool {
return $this->hasModifier(TokenKind::StaticKeyword);
}
public function getName() {
/**
* Returns the name of the method.
*
* @return string
*/
public function getName(): string {
return $this->name->getText($this->getFileContents());
}
@@ -79,4 +67,64 @@ class MethodDeclaration extends Node implements FunctionLike {
}
return null;
}
/**
* Returns the signature parts as an array. Use $this::getSignatureFormatted for a user-friendly string version.
*
* @return array
*/
private function getSignatureParts(): array {
$parts = [];
foreach ($this->getChildNodesAndTokens() as $i => $child) {
if ($i === "compoundStatementOrSemicolon") {
return $parts;
}
$parts[] = $child instanceof Token
? $child->getText($this->getFileContents())
: $child->getText();
};
return $parts;
}
/**
* Returns the signature of the method as a formatted string.
*
* @return string
*/
public function getSignatureFormatted(): string {
$signature = implode(" ", $this->getSignatureParts());
return $signature;
}
/**
* Returns the description part of the doc string.
*
* @return string
*/
public function getDescriptionFormatted(): string {
$comment = trim($this->getLeadingCommentAndWhitespaceText(), "\r\n");
$commentParts = explode("\n", $comment);
$description = [];
foreach ($commentParts as $i => $part) {
$part = trim($part, "*\r\t /");
if (strlen($part) <= 0) {
continue;
}
if ($part[0] === "@") {
break;
}
$description[] = $part;
}
$descriptionFormatted = implode(" ", $description);
return $descriptionFormatted;
}
}
@@ -0,0 +1,23 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
class MissingDeclaration extends Node {
/** @var AttributeGroup[] */
public $attributes;
/** @var MissingToken needed for emitting diagnostics */
public $declaration;
const CHILD_NAMES = [
'attributes',
'declaration',
];
}
@@ -6,27 +6,27 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class MissingMemberDeclaration extends Node {
class MissingMemberDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var Token[] */
public $modifiers;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token|null needed along with typeDeclaration for what looked like typed property declarations but was missing VariableName */
public $questionToken;
/** @var QualifiedName|Token|null */
public $typeDeclaration;
/** @var DelimitedList\QualifiedNameList|null */
public $otherTypeDeclarations;
public $typeDeclarationList;
const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclaration',
'otherTypeDeclarations',
'typeDeclarationList',
];
}
+13 -9
View File
@@ -6,19 +6,21 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class Parameter extends Node {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token|null */
public $visibilityToken;
/** @var Token[]|null */
public $modifiers;
/** @var Token|null */
public $questionToken;
/** @var QualifiedName|Token|null */
public $typeDeclaration;
/**
* @var DelimitedList\QualifiedNameList a list of other types, to support php 8 union types while remaining backwards compatible.
* TODO: Merge with typeDeclaration in a future backwards incompatible release.
*/
public $otherTypeDeclarations;
/** @var DelimitedList\QualifiedNameList|MissingToken|null */
public $typeDeclarationList;
/** @var Token|null */
public $byRefToken;
/** @var Token|null */
@@ -31,9 +33,11 @@ class Parameter extends Node {
public $default;
const CHILD_NAMES = [
'attributes',
'visibilityToken',
'modifiers',
'questionToken',
'typeDeclaration',
'otherTypeDeclarations',
'typeDeclarationList',
'byRefToken',
'dotDotDotToken',
'variableName',
@@ -6,26 +6,24 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\QualifiedNameList;
use Microsoft\PhpParser\Token;
use Microsoft\PhpParser\TokenKind;
class PropertyDeclaration extends Node {
class PropertyDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var Token[] */
public $modifiers;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token|null question token for PHP 7.4 type declaration */
public $questionToken;
/** @var QualifiedName|Token|null */
public $typeDeclaration;
/**
* @var DelimitedList\QualifiedNameList|null
* TODO: Unify with typeDeclaration in a future backwards incompatible release
*/
public $otherTypeDeclarations;
/** @var QualifiedNameList|MissingToken|null */
public $typeDeclarationList;
/** @var DelimitedList\ExpressionList */
public $propertyElements;
@@ -34,23 +32,11 @@ class PropertyDeclaration extends Node {
public $semicolon;
const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclaration',
'otherTypeDeclarations',
'typeDeclarationList',
'propertyElements',
'semicolon'
];
public function isStatic() : bool {
if ($this->modifiers === null) {
return false;
}
foreach ($this->modifiers as $modifier) {
if ($modifier->kind === TokenKind::StaticKeyword) {
return true;
}
}
return false;
}
}
@@ -81,7 +81,7 @@ class QualifiedName extends Node implements NamespacedNameInterface {
*/
public function getResolvedName($namespaceDefinition = null) {
// Name resolution not applicable to constructs that define symbol names or aliases.
if (($this->parent instanceof Node\Statement\NamespaceDefinition && $this->parent->name->getStart() === $this->getStart()) ||
if (($this->parent instanceof Node\Statement\NamespaceDefinition && $this->parent->name->getStartPosition() === $this->getStartPosition()) ||
$this->parent instanceof Node\Statement\NamespaceUseDeclaration ||
$this->parent instanceof Node\NamespaceUseClause ||
$this->parent instanceof Node\NamespaceUseGroupClause ||
@@ -110,7 +110,7 @@ class QualifiedName extends Node implements NamespacedNameInterface {
return $this->getNamespacedName();
}
list($namespaceImportTable, $functionImportTable, $constImportTable) = $this->getImportTablesForCurrentScope();
[$namespaceImportTable, $functionImportTable, $constImportTable] = $this->getImportTablesForCurrentScope();
// QUALIFIED NAMES
// - first segment of the name is translated according to the current class/namespace import table.
@@ -60,12 +60,7 @@ class BreakOrContinueStatement extends StatementNode {
}
}
if ($breakoutLevel instanceof Token) {
$start = $breakoutLevel->getStartPosition();
}
else {
$start = $breakoutLevel->getStart();
}
$start = $breakoutLevel->getStartPosition();
$end = $breakoutLevel->getEndPosition();
return new Diagnostic(
@@ -9,6 +9,7 @@ namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\ClassLike;
use Microsoft\PhpParser\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node\AttributeGroup;
use Microsoft\PhpParser\Node\ClassBaseClause;
use Microsoft\PhpParser\Node\ClassInterfaceClause;
use Microsoft\PhpParser\Node\ClassMembersNode;
@@ -18,6 +19,9 @@ use Microsoft\PhpParser\Token;
class ClassDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $abstractOrFinalModifier;
@@ -37,6 +41,7 @@ class ClassDeclaration extends StatementNode implements NamespacedNameInterface,
public $classMembers;
const CHILD_NAMES = [
'attributes',
'abstractOrFinalModifier',
'classKeyword',
'name',
@@ -6,7 +6,8 @@
namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
@@ -15,8 +16,9 @@ class DeclareStatement extends StatementNode {
public $declareKeyword;
/** @var Token */
public $openParen;
/** @var Node */
public $declareDirective;
// TODO Maybe create a delimited list with a missing token instead? Probably more consistent.
/** @var DelimitedList\DeclareDirectiveList|MissingToken */
public $declareDirectiveList;
/** @var Token */
public $closeParen;
/** @var Token|null */
@@ -31,7 +33,7 @@ class DeclareStatement extends StatementNode {
const CHILD_NAMES = [
'declareKeyword',
'openParen',
'declareDirective',
'declareDirectiveList',
'closeParen',
'colon',
'statements',
@@ -4,20 +4,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Expression;
namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Node\DelimitedList\ExpressionList;
use Microsoft\PhpParser\Token;
/**
* This represents either a literal echo expression (`echo expr`)
* This represents either a literal echo statement (`echo expr`)
* or a short echo tag (`<?= expr...`)
*
* TODO: An echo statement cannot be used as an expression.
* Consider refactoring this to become EchoStatement in a future backwards incompatible release.
*/
class EchoExpression extends Expression {
class EchoStatement extends StatementNode {
/**
* @var Token|null this is null if generated from `<?=`
@@ -27,8 +24,12 @@ class EchoExpression extends Expression {
/** @var ExpressionList */
public $expressions;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'echoKeyword',
'expressions'
'expressions',
'semicolon',
];
}
@@ -0,0 +1,50 @@
<?php
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\ClassLike;
use Microsoft\PhpParser\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node\AttributeGroup;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Node\EnumMembers;
use Microsoft\PhpParser\Token;
class EnumDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $enumKeyword;
/** @var Token */
public $name;
/** @var Token|null */
public $colonToken;
/** @var Token|null */
public $enumType;
/** @var EnumMembers */
public $enumMembers;
const CHILD_NAMES = [
'attributes',
'enumKeyword',
'name',
'colonToken',
'enumType',
'enumMembers',
];
public function getNameParts() : array {
return [$this->name];
}
}
@@ -20,6 +20,7 @@ class FunctionDeclaration extends StatementNode implements NamespacedNameInterfa
const CHILD_NAMES = [
// FunctionHeader
'attributes',
'functionKeyword',
'byRefToken',
'name',
@@ -30,8 +31,7 @@ class FunctionDeclaration extends StatementNode implements NamespacedNameInterfa
// FunctionReturnType
'colonToken',
'questionToken',
'returnType',
'otherReturnTypes',
'returnTypeList',
// FunctionBody
'compoundStatementOrSemicolon'
@@ -9,6 +9,7 @@ namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\ClassLike;
use Microsoft\PhpParser\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node\AttributeGroup;
use Microsoft\PhpParser\Node\InterfaceBaseClause;
use Microsoft\PhpParser\Node\InterfaceMembers;
use Microsoft\PhpParser\Node\StatementNode;
@@ -17,6 +18,9 @@ use Microsoft\PhpParser\Token;
class InterfaceDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $interfaceKeyword;
@@ -30,6 +34,7 @@ class InterfaceDeclaration extends StatementNode implements NamespacedNameInterf
public $interfaceMembers;
const CHILD_NAMES = [
'attributes',
'interfaceKeyword',
'name',
'interfaceBaseClause',
@@ -14,12 +14,9 @@ class NamedLabelStatement extends StatementNode {
public $name;
/** @var Token */
public $colon;
/** @var StatementNode */
public $statement;
const CHILD_NAMES = [
'name',
'colon',
'statement'
];
}
@@ -9,6 +9,7 @@ namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\ClassLike;
use Microsoft\PhpParser\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node\AttributeGroup;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Node\TraitMembers;
use Microsoft\PhpParser\Token;
@@ -16,6 +17,9 @@ use Microsoft\PhpParser\Token;
class TraitDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $traitKeyword;
@@ -26,6 +30,7 @@ class TraitDeclaration extends StatementNode implements NamespacedNameInterface,
public $traitMembers;
const CHILD_NAMES = [
'attributes',
'traitKeyword',
'name',
'traitMembers'
@@ -4,13 +4,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
namespace Microsoft\PhpParser\Node\Expression;
namespace Microsoft\PhpParser\Node\Statement;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class UnsetIntrinsicExpression extends Expression {
class UnsetStatement extends Expression {
/** @var Token */
public $unsetKeyword;
@@ -24,10 +24,14 @@ class UnsetIntrinsicExpression extends Expression {
/** @var Token */
public $closeParen;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'unsetKeyword',
'openParen',
'expressions',
'closeParen'
'closeParen',
'semicolon',
];
}
@@ -6,42 +6,30 @@
namespace Microsoft\PhpParser\Node;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\QualifiedNameList;
use Microsoft\PhpParser\Token;
class TraitSelectOrAliasClause extends Node {
class TraitSelectOrAliasClause extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var QualifiedName|Node\Expression\ScopedPropertyAccessExpression */
public $name;
/** @var Token */
public $asOrInsteadOfKeyword;
/** @var Token[] */
public $modifiers;
/** @var QualifiedName|Node\Expression\ScopedPropertyAccessExpression */
public $targetName;
/**
* @var Token[]|QualifiedName[]|null
*
* This is set if $asOrInsteadOfKeyword is an insteadof keyword.
* (E.g. for parsing `use T1, T2, T3{T1::foo insteadof T2, T3}`
*
* NOTE: This was added as a separate property to minimize
* backwards compatibility breaks in applications using this file.
*
* TODO: Use a more consistent design such as either of the following:
* 1. Combine targetName and remainingTargetNames into a DelimitedList
* 2. Use two distinct properties for the targets of `as` and `insteadof`
* @var QualifiedNameList|QualifiedName depends on the keyword
*/
public $remainingTargetNames;
public $targetNameList;
const CHILD_NAMES = [
'name',
'asOrInsteadOfKeyword',
'modifiers',
'targetName',
'remainingTargetNames',
'targetNameList',
];
}