2011-05-27 18:20:44 +02:00
|
|
|
<?php
|
|
|
|
|
2011-05-30 17:29:10 +02:00
|
|
|
/**
|
2011-10-28 19:06:24 +02:00
|
|
|
* @property string $name Name
|
|
|
|
* @property PHPParser_Node_Name[] $extends Extended interfaces
|
|
|
|
* @property PHPParser_Node[] $stmts Statements
|
2011-05-30 17:29:10 +02:00
|
|
|
*/
|
2011-06-05 18:40:04 +02:00
|
|
|
class PHPParser_Node_Stmt_Interface extends PHPParser_Node_Stmt
|
2011-05-27 18:20:44 +02:00
|
|
|
{
|
2011-11-27 12:53:48 +01:00
|
|
|
protected static $specialNames = array(
|
2011-10-28 19:06:24 +02:00
|
|
|
'self' => true,
|
|
|
|
'parent' => true,
|
|
|
|
'static' => true,
|
|
|
|
);
|
2011-08-04 12:03:34 +02:00
|
|
|
|
2011-10-28 19:06:24 +02:00
|
|
|
/**
|
|
|
|
* Constructs a class node.
|
|
|
|
*
|
2012-04-29 23:32:09 +02:00
|
|
|
* @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
|
2011-10-28 19:06:24 +02:00
|
|
|
*/
|
2012-04-29 23:32:09 +02:00
|
|
|
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
2011-10-28 19:06:24 +02:00
|
|
|
parent::__construct(
|
|
|
|
$subNodes + array(
|
|
|
|
'extends' => array(),
|
|
|
|
'stmts' => array(),
|
|
|
|
),
|
2012-04-29 23:32:09 +02:00
|
|
|
$attributes
|
2011-10-28 19:06:24 +02:00
|
|
|
);
|
|
|
|
$this->name = $name;
|
|
|
|
|
2011-11-27 12:53:48 +01:00
|
|
|
if (isset(self::$specialNames[(string) $this->name])) {
|
2011-10-28 19:06:24 +02:00
|
|
|
throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $this->name));
|
2011-08-04 12:03:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->extends as $interface) {
|
2011-11-27 12:53:48 +01:00
|
|
|
if (isset(self::$specialNames[(string) $interface])) {
|
2011-08-04 12:03:34 +02:00
|
|
|
throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $interface));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-27 18:20:44 +02:00
|
|
|
}
|