Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/FunctionLike.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

namespace Microsoft\PhpParser;

use Microsoft\PhpParser\Node\AttributeGroup;

/**
* Interface for recognizing functions easily.
* Each Node that implements this interface can be considered a function.
*
* @property AttributeGroup[] $attributes
*/
interface FunctionLike {}
31 changes: 31 additions & 0 deletions src/Node/Attribute.php
Original file line number Diff line number Diff line change
@@ -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'
];
}
28 changes: 28 additions & 0 deletions src/Node/AttributeGroup.php
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions src/Node/ClassConstDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
class ClassConstDeclaration extends Node implements ModifiedTypeInterface {
use ModifiedTypeTrait;

/** @var AttributeGroup[]|null */
public $attributes;

/** @var Token[] */
public $modifiers;

/** @var Token */
public $constKeyword;

Expand All @@ -24,6 +30,7 @@ class ClassConstDeclaration extends Node implements ModifiedTypeInterface {
public $semicolon;

const CHILD_NAMES = [
'attributes',
'modifiers',
'constKeyword',
'constElements',
Expand Down
12 changes: 12 additions & 0 deletions src/Node/DelimitedList/AttributeElementList.php
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AnonymousFunctionCreationExpression extends Expression implements Function
use FunctionHeader, FunctionUseClause, FunctionReturnType, FunctionBody;

const CHILD_NAMES = [
'attributes',
'staticModifier',

// FunctionHeader
Expand Down
1 change: 1 addition & 0 deletions src/Node/Expression/ArrowFunctionCreationExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ArrowFunctionCreationExpression extends Expression implements FunctionLike
public $resultExpression;

const CHILD_NAMES = [
'attributes',
'staticModifier',

// FunctionHeader
Expand Down
2 changes: 2 additions & 0 deletions src/Node/FunctionHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Microsoft\PhpParser\Token;

trait FunctionHeader {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token */
public $functionKeyword;
/** @var Token */
Expand Down
1 change: 1 addition & 0 deletions src/Node/MethodDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MethodDeclaration extends Node implements FunctionLike, ModifiedTypeInterf
use FunctionHeader, FunctionReturnType, FunctionBody, ModifiedTypeTrait;

const CHILD_NAMES = [
'attributes',
'modifiers',

// FunctionHeader
Expand Down
23 changes: 23 additions & 0 deletions src/Node/MissingDeclaration.php
Original file line number Diff line number Diff line change
@@ -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',
];
}
4 changes: 4 additions & 0 deletions src/Node/MissingMemberDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
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;

Expand All @@ -24,6 +27,7 @@ class MissingMemberDeclaration extends Node implements ModifiedTypeInterface {
public $otherTypeDeclarations;

const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclaration',
Expand Down
3 changes: 3 additions & 0 deletions src/Node/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Microsoft\PhpParser\Token;

class Parameter extends Node {
/** @var AttributeGroup[]|null */
public $attributes;
/** @var Token|null */
public $visibilityToken;
/** @var Token|null */
Expand All @@ -33,6 +35,7 @@ class Parameter extends Node {
public $default;

const CHILD_NAMES = [
'attributes',
'visibilityToken',
'questionToken',
'typeDeclaration',
Expand Down
4 changes: 4 additions & 0 deletions src/Node/PropertyDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
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;

Expand All @@ -33,6 +36,7 @@ class PropertyDeclaration extends Node implements ModifiedTypeInterface {
public $semicolon;

const CHILD_NAMES = [
'attributes',
'modifiers',
'questionToken',
'typeDeclaration',
Expand Down
5 changes: 5 additions & 0 deletions src/Node/Statement/ClassDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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;
Expand All @@ -18,6 +19,9 @@
class ClassDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike {
use NamespacedNameTrait;

/** @var AttributeGroup[]|null */
public $attributes;

/** @var Token */
public $abstractOrFinalModifier;

Expand All @@ -37,6 +41,7 @@ class ClassDeclaration extends StatementNode implements NamespacedNameInterface,
public $classMembers;

const CHILD_NAMES = [
'attributes',
'abstractOrFinalModifier',
'classKeyword',
'name',
Expand Down
1 change: 1 addition & 0 deletions src/Node/Statement/FunctionDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FunctionDeclaration extends StatementNode implements NamespacedNameInterfa

const CHILD_NAMES = [
// FunctionHeader
'attributes',
'functionKeyword',
'byRefToken',
'name',
Expand Down
Loading