mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-12-12 09:09:41 +01:00
1c8481bff6
Conflicts: lib/PhpParser/Lexer.php lib/PhpParser/Node/Stmt/Class.php lib/PhpParser/Node/Stmt/ClassMethod.php lib/PhpParser/Node/Stmt/Interface.php lib/PhpParser/Node/Stmt/Namespace.php lib/PhpParser/Node/Stmt/UseUse.php lib/PhpParser/Parser.php
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace PhpParser\Node\Stmt;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Error;
|
|
|
|
/**
|
|
* @property string $name Name
|
|
* @property Node\Name[] $extends Extended interfaces
|
|
* @property Node[] $stmts Statements
|
|
*/
|
|
class Interface_ extends Node\Stmt
|
|
{
|
|
protected static $specialNames = array(
|
|
'self' => true,
|
|
'parent' => true,
|
|
'static' => true,
|
|
);
|
|
|
|
/**
|
|
* Constructs a class node.
|
|
*
|
|
* @param string $name Name
|
|
* @param array $subNodes Array of the following optional subnodes:
|
|
* 'extends' => array(): Name of extended interfaces
|
|
* 'stmts' => array(): Statements
|
|
* @param array $attributes Additional attributes
|
|
*/
|
|
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
|
parent::__construct(
|
|
$subNodes + array(
|
|
'extends' => array(),
|
|
'stmts' => array(),
|
|
),
|
|
$attributes
|
|
);
|
|
$this->name = $name;
|
|
|
|
if (isset(self::$specialNames[(string) $this->name])) {
|
|
throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
|
|
}
|
|
|
|
foreach ($this->extends as $interface) {
|
|
if (isset(self::$specialNames[(string) $interface])) {
|
|
throw new Error(sprintf('Cannot use \'%s\' as interface name as it is reserved', $interface));
|
|
}
|
|
}
|
|
}
|
|
}
|