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
13 changes: 13 additions & 0 deletions src/FunctionLike.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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;

/**
* Interface for recognizing functions easily.
* Each Node that implements this interface can be considered a function.
*/
interface FunctionLike {}
3 changes: 2 additions & 1 deletion src/Node/Expression/AnonymousFunctionCreationExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

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 {
class AnonymousFunctionCreationExpression extends Expression implements FunctionLike {
/** @var Token | null */
public $staticModifier;

Expand Down
3 changes: 2 additions & 1 deletion src/Node/MethodDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

namespace Microsoft\PhpParser\Node;

use Microsoft\PhpParser\FunctionLike;
use Microsoft\PhpParser\Node;
use Microsoft\PhpParser\Token;
use Microsoft\PhpParser\TokenKind;

class MethodDeclaration extends Node {
class MethodDeclaration extends Node implements FunctionLike {
/** @var Token[] */
public $modifiers;

Expand Down
3 changes: 2 additions & 1 deletion src/Node/Statement/FunctionDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

namespace Microsoft\PhpParser\Node\Statement;

use Microsoft\PhpParser\FunctionLike;
use Microsoft\PhpParser\NamespacedNameInterface;
use Microsoft\PhpParser\NamespacedNameTrait;
use Microsoft\PhpParser\Node\FunctionBody;
use Microsoft\PhpParser\Node\FunctionHeader;
use Microsoft\PhpParser\Node\FunctionReturnType;
use Microsoft\PhpParser\Node\StatementNode;

class FunctionDeclaration extends StatementNode implements NamespacedNameInterface {
class FunctionDeclaration extends StatementNode implements NamespacedNameInterface, FunctionLike {
use FunctionHeader, FunctionReturnType, FunctionBody;
use NamespacedNameTrait;

Expand Down