Install phan/phpstan local

This commit is contained in:
Clemens Schwaighofer
2023-02-08 12:02:18 +09:00
parent 53eef03387
commit f94b350ba4
1166 changed files with 298568 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?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\MissingToken;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\UseVariableNameList;
use Microsoft\PhpParser\Token;
class AnonymousFunctionUseClause extends Node {
/** @var Token */
public $useKeyword;
/** @var Token */
public $openParen;
/** @var UseVariableNameList|MissingToken */
public $useVariableNameList;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'useKeyword',
'openParen',
'useVariableNameList',
'closeParen'
];
}

View File

@@ -0,0 +1,36 @@
<?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 ArrayElement extends Node {
/** @var Expression|null */
public $elementKey;
/** @var Token|null */
public $arrowToken;
/** @var Token|null */
public $byRef;
/** @var Token|null if this is set for PHP 7.4's array spread operator, then other preceding tokens aren't */
public $dotDotDot;
/** @var Expression */
public $elementValue;
const CHILD_NAMES = [
'elementKey',
'arrowToken',
'byRef',
'dotDotDot',
'elementValue'
];
}

View File

@@ -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'
];
}

View File

@@ -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'
];
}

View File

@@ -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;
use Microsoft\PhpParser\Token;
class CaseStatementNode extends Node {
/** @var Token */
public $caseKeyword;
/** @var Expression */
public $expression;
/** @var Token */
public $defaultLabelTerminator;
/** @var StatementNode[] */
public $statementList;
const CHILD_NAMES = [
'caseKeyword',
'expression',
'defaultLabelTerminator',
'statementList'
];
}

View File

@@ -0,0 +1,36 @@
<?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\QualifiedNameList;
use Microsoft\PhpParser\MissingToken;
use Microsoft\PhpParser\Token;
class CatchClause extends Node {
/** @var Token */
public $catch;
/** @var Token */
public $openParen;
/** @var QualifiedNameList[]|MissingToken */
public $qualifiedNameList;
/** @var Token|null */
public $variableName;
/** @var Token */
public $closeParen;
/** @var StatementNode */
public $compoundStatement;
const CHILD_NAMES = [
'catch',
'openParen',
'qualifiedNameList',
'variableName',
'closeParen',
'compoundStatement'
];
}

View File

@@ -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\Token;
class ClassBaseClause extends Node {
/** @var Token */
public $extendsKeyword;
/** @var QualifiedName */
public $baseClass;
const CHILD_NAMES = [
'extendsKeyword',
'baseClass'
];
}

View File

@@ -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\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class ClassConstDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token[] */
public $modifiers;
/** @var Token */
public $constKeyword;
/** @var DelimitedList\ConstElementList */
public $constElements;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'attributes',
'modifiers',
'constKeyword',
'constElements',
'semicolon'
];
}

View File

@@ -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\Token;
class ClassInterfaceClause extends Node {
/** @var Token */
public $implementsKeyword;
/** @var DelimitedList\QualifiedNameList|null */
public $interfaceNameList;
const CHILD_NAMES = [
'implementsKeyword',
'interfaceNameList'
];
}

View File

@@ -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 ClassMembersNode extends Node {
/** @var Token */
public $openBrace;
/** @var Node[] */
public $classMemberDeclarations;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'openBrace',
'classMemberDeclarations',
'closeBrace'
];
}

View File

@@ -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\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class ConstElement extends Node implements NamespacedNameInterface {
use NamespacedNameTrait;
/** @var Token */
public $name;
/** @var Token */
public $equalsToken;
/** @var Expression */
public $assignment;
const CHILD_NAMES = [
'name',
'equalsToken',
'assignment'
];
public function getNameParts() : array {
return [$this->name];
}
public function getName() {
return $this->name->getText($this->getFileContents());
}
}

View File

@@ -0,0 +1,25 @@
<?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 DeclareDirective extends Node {
/** @var Token */
public $name;
/** @var Token */
public $equals;
/** @var Token */
public $literal;
const CHILD_NAMES = [
'name',
'equals',
'literal'
];
}

View File

@@ -0,0 +1,25 @@
<?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 DefaultStatementNode extends Node {
/** @var Token */
public $defaultKeyword;
/** @var Token */
public $defaultLabelTerminator;
/** @var StatementNode[] */
public $statementList;
const CHILD_NAMES = [
'defaultKeyword',
'defaultLabelTerminator',
'statementList'
];
}

View File

@@ -0,0 +1,51 @@
<?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;
use Microsoft\PhpParser\TokenKind;
abstract class DelimitedList extends Node {
/** @var Token[]|Node[] */
public $children;
const CHILD_NAMES = [
'children'
];
const DELIMITERS = [TokenKind::CommaToken, TokenKind::BarToken, TokenKind::SemicolonToken];
public function getElements() : \Generator {
foreach ($this->children as $child) {
if ($child instanceof Node) {
yield $child;
} elseif ($child instanceof Token && !\in_array($child->kind, self::DELIMITERS)) {
yield $child;
}
}
}
public function getValues() {
foreach ($this->children as $idx=>$value) {
if ($idx % 2 == 0) {
yield $value;
}
}
}
public function addElement($node) {
if ($node === null) {
return;
}
if ($this->children === null) {
$this->children = [$node];
return;
}
$this->children[] = $node;
}
}

View File

@@ -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 ArgumentExpressionList extends DelimitedList {
}

View File

@@ -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 ArrayElementList extends DelimitedList {
}

View File

@@ -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 {
}

View File

@@ -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 ConstElementList extends DelimitedList {
}

View File

@@ -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 {
}

View File

@@ -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 ExpressionList extends DelimitedList {
}

View File

@@ -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 ListExpressionList extends DelimitedList {
}

View File

@@ -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 {
}

View File

@@ -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 {
}

View File

@@ -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 NamespaceUseClauseList extends DelimitedList {
}

View File

@@ -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 NamespaceUseGroupClauseList extends DelimitedList {
}

View File

@@ -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 ParameterDeclarationList extends DelimitedList {
}

View File

@@ -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 QualifiedNameList extends DelimitedList {
}

View File

@@ -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 QualifiedNameParts extends DelimitedList {
}

View File

@@ -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 StaticVariableNameList extends DelimitedList {
}

View File

@@ -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 TraitSelectOrAliasClauseList extends DelimitedList {
}

View File

@@ -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 UseVariableNameList extends DelimitedList {
}

View File

@@ -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 VariableNameList extends DelimitedList {
}

View File

@@ -0,0 +1,25 @@
<?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 ElseClauseNode extends Node {
/** @var Token */
public $elseKeyword;
/** @var Token */
public $colon;
/** @var StatementNode|StatementNode[] */
public $statements;
const CHILD_NAMES = [
'elseKeyword',
'colon',
'statements'
];
}

View File

@@ -0,0 +1,34 @@
<?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 ElseIfClauseNode extends Node {
/** @var Token */
public $elseIfKeyword;
/** @var Token */
public $openParen;
/** @var Expression */
public $expression;
/** @var Token */
public $closeParen;
/** @var Token|null */
public $colon;
/** @var StatementNode|StatementNode[] */
public $statements;
const CHILD_NAMES = [
'elseIfKeyword',
'openParen',
'expression',
'closeParen',
'colon',
'statements'
];
}

View File

@@ -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',
];
}

View File

@@ -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',
];
}

View File

@@ -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;
use Microsoft\PhpParser\Node;
abstract class Expression extends Node {
}

View File

@@ -0,0 +1,46 @@
<?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\FunctionLike;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\FunctionBody;
use Microsoft\PhpParser\Node\FunctionHeader;
use Microsoft\PhpParser\Node\FunctionReturnType;
use Microsoft\PhpParser\Node\FunctionUseClause;
use Microsoft\PhpParser\Token;
class AnonymousFunctionCreationExpression extends Expression implements FunctionLike {
/** @var Token|null */
public $staticModifier;
use FunctionHeader, FunctionUseClause, FunctionReturnType, FunctionBody;
const CHILD_NAMES = [
'attributes',
'staticModifier',
// FunctionHeader
'functionKeyword',
'byRefToken',
'name',
'openParen',
'parameters',
'closeParen',
// FunctionUseClause
'anonymousFunctionUseClause',
// FunctionReturnType
'colonToken',
'questionToken',
'returnTypeList',
// FunctionBody
'compoundStatementOrSemicolon'
];
}

View File

@@ -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\Expression;
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 $colonToken;
/** @var Token|null */
public $dotDotDotToken;
/** @var Expression|null null for first-class callable syntax */
public $expression;
const CHILD_NAMES = [
'name',
'colonToken',
'dotDotDotToken',
'expression'
];
}

View File

@@ -0,0 +1,33 @@
<?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\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class ArrayCreationExpression extends Expression {
/** @var Token|null */
public $arrayKeyword;
/** @var Token */
public $openParenOrBracket;
/** @var DelimitedList\ArrayElementList */
public $arrayElements;
/** @var Token */
public $closeParenOrBracket;
const CHILD_NAMES = [
'arrayKeyword',
'openParenOrBracket',
'arrayElements',
'closeParenOrBracket'
];
}

View File

@@ -0,0 +1,49 @@
<?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\FunctionLike;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\FunctionHeader;
use Microsoft\PhpParser\Node\FunctionReturnType;
use Microsoft\PhpParser\Token;
class ArrowFunctionCreationExpression extends Expression implements FunctionLike {
/** @var Token|null */
public $staticModifier;
use FunctionHeader, FunctionReturnType;
/** @var Token `=>` */
public $arrowToken;
/** @var Node|Token */
public $resultExpression;
const CHILD_NAMES = [
'attributes',
'staticModifier',
// FunctionHeader
'functionKeyword',
'byRefToken',
'name',
'openParen',
'parameters',
'closeParen',
// FunctionReturnType
'colonToken',
'questionToken',
'returnTypeList',
// body
'arrowToken',
'resultExpression',
];
}

View File

@@ -0,0 +1,32 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class AssignmentExpression extends BinaryExpression {
/** @var Expression */
public $leftOperand;
/** @var Token */
public $operator;
/** @var Token */
public $byRef;
/** @var Expression */
public $rightOperand;
const CHILD_NAMES = [
'leftOperand',
'operator',
'byRef',
'rightOperand'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class BinaryExpression extends Expression {
/** @var Expression */
public $leftOperand;
/** @var Token */
public $operator;
/** @var Expression */
public $rightOperand;
const CHILD_NAMES = [
'leftOperand',
'operator',
'rightOperand'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class BracedExpression extends Expression {
/** @var Token */
public $openBrace;
/** @var Expression */
public $expression;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'openBrace',
'expression',
'closeBrace'
];
}

View File

@@ -0,0 +1,32 @@
<?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\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class CallExpression extends Expression {
/** @var Expression */
public $callableExpression;
/** @var Token */
public $openParen;
/** @var DelimitedList\ArgumentExpressionList|null */
public $argumentExpressionList;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'callableExpression',
'openParen',
'argumentExpressionList',
'closeParen'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Token;
class CastExpression extends UnaryExpression {
/** @var Token */
public $openParen;
/** @var Token */
public $castType;
/** @var Token */
public $closeParen;
/** @var Variable */
public $operand;
const CHILD_NAMES = [
'openParen',
'castType',
'closeParen',
'operand'
];
}

View File

@@ -0,0 +1,24 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class CloneExpression extends Expression {
/** @var Token */
public $cloneKeyword;
/** @var Expression */
public $expression;
const CHILD_NAMES = [
'cloneKeyword',
'expression'
];
}

View File

@@ -0,0 +1,32 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class EmptyIntrinsicExpression extends Expression {
/** @var Token */
public $emptyKeyword;
/** @var Token */
public $openParen;
/** @var Expression */
public $expression;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'emptyKeyword',
'openParen',
'expression',
'closeParen'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Token;
class ErrorControlExpression extends UnaryExpression {
/** @var Token */
public $operator;
/** @var UnaryExpression */
public $operand;
const CHILD_NAMES = [
'operator',
'operand'
];
}

View File

@@ -0,0 +1,32 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class EvalIntrinsicExpression extends Expression {
/** @var Token */
public $evalKeyword;
/** @var Token */
public $openParen;
/** @var Expression */
public $expression;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'evalKeyword',
'openParen',
'expression',
'closeParen'
];
}

View File

@@ -0,0 +1,32 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class ExitIntrinsicExpression extends Expression {
/** @var Token */
public $exitOrDieKeyword;
/** @var Token|null */
public $openParen;
/** @var Expression|null */
public $expression;
/** @var Token|null */
public $closeParen;
const CHILD_NAMES = [
'exitOrDieKeyword',
'openParen',
'expression',
'closeParen'
];
}

View File

@@ -0,0 +1,33 @@
<?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\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class IssetIntrinsicExpression extends Expression {
/** @var Token */
public $issetKeyword;
/** @var Token */
public $openParen;
/** @var DelimitedList\ExpressionList */
public $expressions;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'issetKeyword',
'openParen',
'expressions',
'closeParen'
];
}

View File

@@ -0,0 +1,33 @@
<?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\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class ListIntrinsicExpression extends Expression {
/** @var Token */
public $listKeyword;
/** @var Token */
public $openParen;
/** @var DelimitedList\ListExpressionList */
public $listElements;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'listKeyword',
'openParen',
'listElements',
'closeParen'
];
}

View File

@@ -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',
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class MemberAccessExpression extends Expression {
/** @var Expression */
public $dereferencableExpression;
/** @var Token */
public $arrowToken;
/** @var Token */
public $memberName;
const CHILD_NAMES = [
'dereferencableExpression',
'arrowToken',
'memberName'
];
}

View File

@@ -0,0 +1,58 @@
<?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\AttributeGroup;
use Microsoft\PhpParser\Node\ClassBaseClause;
use Microsoft\PhpParser\Node\ClassInterfaceClause;
use Microsoft\PhpParser\Node\ClassMembersNode;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\QualifiedName;
use Microsoft\PhpParser\Token;
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;
/** @var Token|null */
public $openParen;
/** @var DelimitedList\ArgumentExpressionList|null */
public $argumentExpressionList;
/** @var Token|null */
public $closeParen;
/** @var ClassBaseClause|null */
public $classBaseClause;
/** @var ClassInterfaceClause|null */
public $classInterfaceClause;
/** @var ClassMembersNode|null */
public $classMembers;
const CHILD_NAMES = [
'newKeword',
'attributes',
'classTypeDesignator',
'openParen',
'argumentExpressionList',
'closeParen',
'classBaseClause',
'classInterfaceClause',
'classMembers'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class ParenthesizedExpression extends Expression {
/** @var Token */
public $openParen;
/** @var Expression */
public $expression;
/** @var Token */
public $closeParen;
const CHILD_NAMES = [
'openParen',
'expression',
'closeParen'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class PostfixUpdateExpression extends Expression {
/** @var Variable */
public $operand;
/** @var Token */
public $incrementOrDecrementOperator;
const CHILD_NAMES = [
'operand',
'incrementOrDecrementOperator'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Token;
class PrefixUpdateExpression extends UnaryExpression {
/** @var Token */
public $incrementOrDecrementOperator;
/** @var Variable */
public $operand;
const CHILD_NAMES = [
'incrementOrDecrementOperator',
'operand'
];
}

View File

@@ -0,0 +1,24 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class PrintIntrinsicExpression extends Expression {
/** @var Token */
public $printKeyword;
/** @var Expression */
public $expression;
const CHILD_NAMES = [
'printKeyword',
'expression'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\QualifiedName;
use Microsoft\PhpParser\Token;
class ScopedPropertyAccessExpression extends Expression {
/** @var Expression|QualifiedName|Token */
public $scopeResolutionQualifier;
/** @var Token */
public $doubleColon;
/** @var Token|Variable */
public $memberName;
const CHILD_NAMES = [
'scopeResolutionQualifier',
'doubleColon',
'memberName'
];
}

View File

@@ -0,0 +1,22 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class ScriptInclusionExpression extends Expression {
/** @var Token */
public $requireOrIncludeKeyword;
/** @var Expression */
public $expression;
const CHILD_NAMES = [
'requireOrIncludeKeyword',
'expression'
];
}

View File

@@ -0,0 +1,32 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class SubscriptExpression extends Expression {
/** @var Expression */
public $postfixExpression;
/** @var Token */
public $openBracketOrBrace;
/** @var Expression */
public $accessExpression;
/** @var Token */
public $closeBracketOrBrace;
const CHILD_NAMES = [
'postfixExpression',
'openBracketOrBrace',
'accessExpression',
'closeBracketOrBrace'
];
}

View File

@@ -0,0 +1,36 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class TernaryExpression extends Expression {
/** @var Expression|Token (only a token when token before '?' is invalid/missing) */
public $condition;
/** @var Token */
public $questionToken;
/** @var Expression */
public $ifExpression;
/** @var Token */
public $colonToken;
/** @var Expression */
public $elseExpression;
const CHILD_NAMES = [
'condition',
'questionToken',
'ifExpression',
'colonToken',
'elseExpression'
];
}

View File

@@ -0,0 +1,22 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class ThrowExpression extends Expression {
/** @var Token */
public $throwKeyword;
/** @var Expression */
public $expression;
const CHILD_NAMES = [
'throwKeyword',
'expression',
];
}

View File

@@ -0,0 +1,18 @@
<?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\Expression;
class UnaryExpression extends Expression {
/** @var UnaryExpression|Variable */
public $operand;
const CHILD_NAMES = [
'operand'
];
}

View File

@@ -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\Expression;
use Microsoft\PhpParser\Token;
class UnaryOpExpression extends UnaryExpression {
/** @var Token */
public $operator;
/** @var UnaryExpression */
public $operand;
const CHILD_NAMES = [
'operator',
'operand'
];
}

View File

@@ -0,0 +1,33 @@
<?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\Expression;
use Microsoft\PhpParser\Token;
class Variable extends Expression {
/** @var Token */
public $dollar;
/** @var Token|Variable|BracedExpression */
public $name;
const CHILD_NAMES = [
'dollar',
'name'
];
public function getName() {
if (
$this->name instanceof Token &&
$name = ltrim($this->name->getText($this->getFileContents()), '$')
) {
return $name;
}
return null;
}
}

View File

@@ -0,0 +1,21 @@
<?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\ArrayElement;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Token;
class YieldExpression extends Expression {
/** @var Token */
public $yieldOrYieldFromKeyword;
/** @var ArrayElement */
public $arrayElement;
const CHILD_NAMES = ['yieldOrYieldFromKeyword', 'arrayElement'];
}

View File

@@ -0,0 +1,22 @@
<?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 FinallyClause extends Node {
/** @var Token */
public $finallyToken;
/** @var StatementNode */
public $compoundStatement;
const CHILD_NAMES = [
'finallyToken',
'compoundStatement'
];
}

View File

@@ -0,0 +1,22 @@
<?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 ForeachKey extends Node {
/** @var Expression */
public $expression;
/** @var Token */
public $arrow;
const CHILD_NAMES = [
'expression',
'arrow'
];
}

View File

@@ -0,0 +1,22 @@
<?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 ForeachValue extends Node {
/** @var Token|null */
public $ampersand;
/** @var Expression */
public $expression;
const CHILD_NAMES = [
'ampersand',
'expression'
];
}

View File

@@ -0,0 +1,15 @@
<?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\Statement\CompoundStatementNode;
use Microsoft\PhpParser\Token;
trait FunctionBody {
/** @var CompoundStatementNode|Token */
public $compoundStatementOrSemicolon;
}

View File

@@ -0,0 +1,26 @@
<?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\Token;
trait FunctionHeader {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $functionKeyword;
/** @var Token */
public $byRefToken;
/** @var null|Token */
public $name;
/** @var Token */
public $openParen;
/** @var DelimitedList\ParameterDeclarationList */
public $parameters;
/** @var Token */
public $closeParen;
}

View File

@@ -0,0 +1,19 @@
<?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\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 DelimitedList\QualifiedNameList|null */
public $returnTypeList;
}

View File

@@ -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;
trait FunctionUseClause {
/** @var AnonymousFunctionUseClause|null */
public $anonymousFunctionUseClause;
}

View File

@@ -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\Token;
class InterfaceBaseClause extends Node {
/** @var Token */
public $extendsKeyword;
/** @var DelimitedList\QualifiedNameList */
public $interfaceNameList;
const CHILD_NAMES = [
'extendsKeyword',
'interfaceNameList'
];
}

View File

@@ -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 InterfaceMembers extends Node {
/** @var Token */
public $openBrace;
/** @var Node[] */
public $interfaceMemberDeclarations;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'openBrace',
'interfaceMemberDeclarations',
'closeBrace'
];
}

View File

@@ -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',
];
}

View File

@@ -0,0 +1,130 @@
<?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\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, ModifiedTypeInterface {
use FunctionHeader, FunctionReturnType, FunctionBody, ModifiedTypeTrait;
const CHILD_NAMES = [
'attributes',
'modifiers',
// FunctionHeader
'functionKeyword',
'byRefToken',
'name',
'openParen',
'parameters',
'closeParen',
// FunctionReturnType
'colonToken',
'questionToken',
'returnTypeList',
// FunctionBody
'compoundStatementOrSemicolon'
];
/**
* Returns the name of the method.
*
* @return string
*/
public function getName(): string {
return $this->name->getText($this->getFileContents());
}
/**
* @return Diagnostic|null - Callers should use DiagnosticsProvider::getDiagnostics instead
* @internal
* @override
*/
public function getDiagnosticForNode() {
foreach ($this->modifiers as $modifier) {
if ($modifier->kind === TokenKind::VarKeyword) {
return new Diagnostic(
DiagnosticKind::Error,
"Unexpected modifier '" . DiagnosticsProvider::getTextForTokenKind($modifier->kind) . "'",
$modifier->start,
$modifier->length
);
}
}
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;
}
}

View File

@@ -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',
];
}

View File

@@ -0,0 +1,32 @@
<?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\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
class MissingMemberDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @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 DelimitedList\QualifiedNameList|null */
public $typeDeclarationList;
const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclarationList',
];
}

View File

@@ -0,0 +1,22 @@
<?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 NamespaceAliasingClause extends Node {
/** @var Token */
public $asKeyword;
/** @var Token */
public $name;
const CHILD_NAMES = [
'asKeyword',
'name'
];
}

View File

@@ -0,0 +1,32 @@
<?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;
use Microsoft\PhpParser\Token;
class NamespaceUseClause extends Node {
/** @var QualifiedName */
public $namespaceName;
/** @var NamespaceAliasingClause */
public $namespaceAliasingClause;
/** @var Token|null */
public $openBrace;
/** @var DelimitedList\NamespaceUseGroupClauseList|null */
public $groupClauses;
/** @var Token|null */
public $closeBrace;
const CHILD_NAMES = [
'namespaceName',
'namespaceAliasingClause',
'openBrace',
'groupClauses',
'closeBrace'
];
}

View File

@@ -0,0 +1,26 @@
<?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 NamespaceUseGroupClause extends Node {
/** @var Token */
public $functionOrConst;
/** @var QualifiedName */
public $namespaceName;
/** @var NamespaceAliasingClause */
public $namespaceAliasingClause;
const CHILD_NAMES = [
'functionOrConst',
'namespaceName',
'namespaceAliasingClause'
];
}

View File

@@ -0,0 +1,18 @@
<?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\Token;
class NumericLiteral extends Expression {
/** @var Token */
public $children;
const CHILD_NAMES = [
'children'
];
}

View File

@@ -0,0 +1,61 @@
<?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\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 DelimitedList\QualifiedNameList|MissingToken|null */
public $typeDeclarationList;
/** @var Token|null */
public $byRefToken;
/** @var Token|null */
public $dotDotDotToken;
/** @var Token */
public $variableName;
/** @var Token|null */
public $equalsToken;
/** @var null|Expression */
public $default;
const CHILD_NAMES = [
'attributes',
'visibilityToken',
'modifiers',
'questionToken',
'typeDeclarationList',
'byRefToken',
'dotDotDotToken',
'variableName',
'equalsToken',
'default'
];
public function isVariadic() {
return $this->byRefToken !== null;
}
public function getName() {
if (
$this->variableName instanceof Token &&
$name = substr($this->variableName->getText($this->getFileContents()), 1)
) {
return $name;
}
return null;
}
}

View File

@@ -0,0 +1,42 @@
<?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\MissingToken;
use Microsoft\PhpParser\ModifiedTypeInterface;
use Microsoft\PhpParser\ModifiedTypeTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\DelimitedList\QualifiedNameList;
use Microsoft\PhpParser\Token;
class PropertyDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token|null question token for PHP 7.4 type declaration */
public $questionToken;
/** @var QualifiedNameList|MissingToken|null */
public $typeDeclarationList;
/** @var DelimitedList\ExpressionList */
public $propertyElements;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclarationList',
'propertyElements',
'semicolon'
];
}

View File

@@ -0,0 +1,192 @@
<?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\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\Expression\AnonymousFunctionCreationExpression;
use Microsoft\PhpParser\Node\Expression\ArrowFunctionCreationExpression;
use Microsoft\PhpParser\Node\Expression\CallExpression;
use Microsoft\PhpParser\Node\Expression\ObjectCreationExpression;
use Microsoft\PhpParser\ResolvedName;
use Microsoft\PhpParser\Token;
use Microsoft\PhpParser\TokenKind;
class QualifiedName extends Node implements NamespacedNameInterface {
use NamespacedNameTrait;
/** @var Token */
public $globalSpecifier; // \_opt
/** @var RelativeSpecifier */
public $relativeSpecifier; // namespace\
/** @var array */
public $nameParts;
const CHILD_NAMES = [
'globalSpecifier',
'relativeSpecifier',
'nameParts'
];
/**
* Checks whether a QualifiedName is prefixed with a backslash global specifier.
* @return bool
*/
public function isFullyQualifiedName() : bool {
return isset($this->globalSpecifier);
}
/**
* Checks whether a QualifiedName begins with a "namespace" keyword
* @return bool
*/
public function isRelativeName() : bool {
return isset($this->relativeSpecifier);
}
/**
* Checks whether a Name includes at least one namespace separator (and is neither fully-qualified nor relative)
* @return bool
*/
public function isQualifiedName() : bool {
return
!$this->isFullyQualifiedName() &&
!$this->isRelativeName() &&
\count($this->nameParts) > 1; // at least one namespace separator
}
/**
* Checks whether a name is does not include a namespace separator.
* @return bool
*/
public function isUnqualifiedName() : bool {
return !($this->isFullyQualifiedName() || $this->isRelativeName() || $this->isQualifiedName());
}
/**
* Gets resolved name based on name resolution rules defined in:
* http://php.net/manual/en/language.namespaces.rules.php
*
* Returns null if one of the following conditions is met:
* - name resolution is not valid for this element (e.g. part of the name in a namespace definition)
* - name cannot be resolved (unqualified namespaced function/constant names that are not explicitly imported.)
*
* @return null|string|ResolvedName
* @throws \Exception
*/
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->getStartPosition() === $this->getStartPosition()) ||
$this->parent instanceof Node\Statement\NamespaceUseDeclaration ||
$this->parent instanceof Node\NamespaceUseClause ||
$this->parent instanceof Node\NamespaceUseGroupClause ||
$this->parent->parent instanceof Node\TraitUseClause ||
$this->parent instanceof Node\TraitSelectOrAliasClause ||
($this->parent instanceof TraitSelectOrAliasClause &&
($this->parent->asOrInsteadOfKeyword == null || $this->parent->asOrInsteadOfKeyword->kind === TokenKind::AsKeyword))
) {
return null;
}
if (in_array($lowerText = strtolower($this->getText()), ["self", "static", "parent"])) {
return $lowerText;
}
// FULLY QUALIFIED NAMES
// - resolve to the name without leading namespace separator.
if ($this->isFullyQualifiedName()) {
return ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
// RELATIVE NAMES
// - resolve to the name with namespace replaced by the current namespace.
// - if current namespace is global, strip leading namespace\ prefix.
if ($this->isRelativeName()) {
return $this->getNamespacedName();
}
[$namespaceImportTable, $functionImportTable, $constImportTable] = $this->getImportTablesForCurrentScope();
// QUALIFIED NAMES
// - first segment of the name is translated according to the current class/namespace import table.
// - If no import rule applies, the current namespace is prepended to the name.
if ($this->isQualifiedName()) {
return $this->tryResolveFromImportTable($namespaceImportTable) ?? $this->getNamespacedName();
}
// UNQUALIFIED NAMES
// - translated according to the current import table for the respective symbol type.
// (class-like => namespace import table, constant => const import table, function => function import table)
// - if no import rule applies:
// - all symbol types: if current namespace is global, resolve to global namespace.
// - class-like symbols: resolve from current namespace.
// - function or const: resolved at runtime (from current namespace, with fallback to global namespace).
if ($this->isConstantName()) {
$resolvedName = $this->tryResolveFromImportTable($constImportTable, /* case-sensitive */ true);
$namespaceDefinition = $this->getNamespaceDefinition();
if ($namespaceDefinition !== null && $namespaceDefinition->name === null) {
$resolvedName = $resolvedName ?? ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
return $resolvedName;
} elseif ($this->parent instanceof CallExpression) {
$resolvedName = $this->tryResolveFromImportTable($functionImportTable);
if (($namespaceDefinition = $this->getNamespaceDefinition()) === null || $namespaceDefinition->name === null) {
$resolvedName = $resolvedName ?? ResolvedName::buildName($this->nameParts, $this->getFileContents());
}
return $resolvedName;
}
return $this->tryResolveFromImportTable($namespaceImportTable) ?? $this->getNamespacedName();
}
public function getLastNamePart() {
$parts = $this->nameParts;
for ($i = \count($parts) - 1; $i >= 0; $i--) {
// TODO - also handle reserved word tokens
if ($parts[$i]->kind === TokenKind::Name) {
return $parts[$i];
}
}
return null;
}
/**
* @param ResolvedName[] $importTable
* @param bool $isCaseSensitive
* @return string|null
*/
private function tryResolveFromImportTable($importTable, bool $isCaseSensitive = false) {
$content = $this->getFileContents();
$index = $this->nameParts[0]->getText($content);
// if (!$isCaseSensitive) {
// $index = strtolower($index);
// }
if(isset($importTable[$index])) {
$resolvedName = $importTable[$index];
$resolvedName->addNameParts(\array_slice($this->nameParts, 1), $content);
return $resolvedName;
}
return null;
}
private function isConstantName() : bool {
return
($this->parent instanceof Node\Statement\ExpressionStatement || $this->parent instanceof Expression) &&
!(
$this->parent instanceof Node\Expression\MemberAccessExpression || $this->parent instanceof CallExpression ||
$this->parent instanceof ObjectCreationExpression ||
$this->parent instanceof Node\Expression\ScopedPropertyAccessExpression || $this->parent instanceof AnonymousFunctionCreationExpression ||
$this->parent instanceof ArrowFunctionCreationExpression ||
($this->parent instanceof Node\Expression\BinaryExpression && $this->parent->operator->kind === TokenKind::InstanceOfKeyword)
);
}
public function getNameParts() : array {
return $this->nameParts;
}
}

View File

@@ -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\Token;
class RelativeSpecifier extends Node {
/** @var Token */
public $namespaceKeyword;
/** @var Token */
public $backslash;
const CHILD_NAMES = [
'namespaceKeyword',
'backslash'
];
}

View File

@@ -0,0 +1,18 @@
<?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\Token;
class ReservedWord extends Expression {
/** @var Token */
public $children;
const CHILD_NAMES = [
'children'
];
}

View File

@@ -0,0 +1,26 @@
<?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 SourceFileNode extends Node {
/** @var string */
public $fileContents;
/** @var string */
public $uri;
/** @var Node[] */
public $statementList;
/** @var Token */
public $endOfFileToken;
const CHILD_NAMES = ['statementList', 'endOfFileToken'];
}

View File

@@ -0,0 +1,73 @@
<?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\Diagnostic;
use Microsoft\PhpParser\DiagnosticKind;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\Expression;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
use Microsoft\PhpParser\TokenKind;
class BreakOrContinueStatement extends StatementNode {
/** @var Token */
public $breakOrContinueKeyword;
/** @var Expression|null */
public $breakoutLevel;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'breakOrContinueKeyword',
'breakoutLevel',
'semicolon'
];
/**
* @return Diagnostic|null - Callers should use DiagnosticsProvider::getDiagnostics instead
* @internal
* @override
*/
public function getDiagnosticForNode() {
if ($this->breakoutLevel === null) {
return null;
}
$breakoutLevel = $this->breakoutLevel;
while ($breakoutLevel instanceof Node\Expression\ParenthesizedExpression) {
$breakoutLevel = $breakoutLevel->expression;
}
if (
$breakoutLevel instanceof Node\NumericLiteral
&& $breakoutLevel->children->kind === TokenKind::IntegerLiteralToken
) {
$literalString = $breakoutLevel->getText();
$firstTwoChars = \substr($literalString, 0, 2);
if ($firstTwoChars === '0b' || $firstTwoChars === '0B') {
if (\bindec(\substr($literalString, 2)) > 0) {
return null;
}
}
else if (\intval($literalString, 0) > 0) {
return null;
}
}
$start = $breakoutLevel->getStartPosition();
$end = $breakoutLevel->getEndPosition();
return new Diagnostic(
DiagnosticKind::Error,
"Positive integer literal expected.",
$start,
$end - $start
);
}
}

View File

@@ -0,0 +1,56 @@
<?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\ClassBaseClause;
use Microsoft\PhpParser\Node\ClassInterfaceClause;
use Microsoft\PhpParser\Node\ClassMembersNode;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class ClassDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $abstractOrFinalModifier;
/** @var Token */
public $classKeyword;
/** @var Token */
public $name;
/** @var ClassBaseClause */
public $classBaseClause;
/** @var ClassInterfaceClause */
public $classInterfaceClause;
/** @var ClassMembersNode */
public $classMembers;
const CHILD_NAMES = [
'attributes',
'abstractOrFinalModifier',
'classKeyword',
'name',
'classBaseClause',
'classInterfaceClause',
'classMembers'
];
public function getNameParts() : array {
return [$this->name];
}
}

View File

@@ -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\Statement;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class CompoundStatementNode extends StatementNode {
/** @var Token */
public $openBrace;
/** @var array|Node[] */
public $statements;
/** @var Token */
public $closeBrace;
const CHILD_NAMES = [
'openBrace',
'statements',
'closeBrace'
];
}

View File

@@ -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\Statement;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class ConstDeclaration extends StatementNode {
/** @var Token */
public $constKeyword;
/** @var DelimitedList\ConstElementList */
public $constElements;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'constKeyword',
'constElements',
'semicolon'
];
}

View File

@@ -0,0 +1,43 @@
<?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\MissingToken;
use Microsoft\PhpParser\Node\DelimitedList;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class DeclareStatement extends StatementNode {
/** @var Token */
public $declareKeyword;
/** @var Token */
public $openParen;
// 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 */
public $colon;
/** @var StatementNode|StatementNode[] */
public $statements;
/** @var Token|null */
public $enddeclareKeyword;
/** @var Token|null */
public $semicolon;
const CHILD_NAMES = [
'declareKeyword',
'openParen',
'declareDirectiveList',
'closeParen',
'colon',
'statements',
'enddeclareKeyword',
'semicolon'
];
}

View File

@@ -0,0 +1,38 @@
<?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\Node\Expression;
use Microsoft\PhpParser\Node\StatementNode;
use Microsoft\PhpParser\Token;
class DoStatement extends StatementNode {
/** @var Token */
public $do;
/** @var StatementNode */
public $statement;
/** @var Token */
public $whileToken;
/** @var Token */
public $openParen;
/** @var Expression */
public $expression;
/** @var Token */
public $closeParen;
/** @var Token|null */
public $semicolon;
const CHILD_NAMES = [
'do',
'statement',
'whileToken',
'openParen',
'expression',
'closeParen',
'semicolon'
];
}

View File

@@ -0,0 +1,35 @@
<?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\Node\StatementNode;
use Microsoft\PhpParser\Node\DelimitedList\ExpressionList;
use Microsoft\PhpParser\Token;
/**
* This represents either a literal echo statement (`echo expr`)
* or a short echo tag (`<?= expr...`)
*/
class EchoStatement extends StatementNode {
/**
* @var Token|null this is null if generated from `<?=`
*/
public $echoKeyword;
/** @var ExpressionList */
public $expressions;
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'echoKeyword',
'expressions',
'semicolon',
];
}

View File

@@ -0,0 +1,19 @@
<?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\Node\StatementNode;
use Microsoft\PhpParser\Token;
class EmptyStatement extends StatementNode {
/** @var Token */
public $semicolon;
const CHILD_NAMES = [
'semicolon'
];
}

Some files were not shown because too many files have changed in this diff Show More