1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Update doc comments to be more specific

Now $stmts arrays really only contains Stmt nodes.
This commit is contained in:
Nikita Popov 2017-01-19 22:46:28 +01:00
parent 7623d20f69
commit ced914a3b7
20 changed files with 48 additions and 43 deletions

View File

@ -6,6 +6,11 @@ Upgrading from PHP-Parser 3.x to 4.0
PHP-Parser now requires PHP 5.6 or newer to run. It is however still possible to *parse* PHP 5.2-5.5
source code, while running on a newer version.
### Changes to the node structure
* Expression statements (`expr;`) are now represented using a `Stmt\Expression` node. Previously
these statements were directly represented as their constituent expression.
### Removed functionality
* Removed `type` subnode on `Class`, `ClassMethod` and `Property` nodes. Use `flags` instead.

View File

@ -18,7 +18,7 @@ class Closure extends Expr implements FunctionLike
public $uses;
/** @var null|string|Node\Name|Node\NullableType Return type */
public $returnType;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -8,14 +8,14 @@ class Case_ extends Node\Stmt
{
/** @var null|Node\Expr $cond Condition (null for default) */
public $cond;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs a case node.
*
* @param null|Node\Expr $cond Condition (null for default)
* @param Node[] $stmts Statements
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct($cond, array $stmts = array(), array $attributes = array()) {

View File

@ -10,7 +10,7 @@ class Catch_ extends Node\Stmt
public $types;
/** @var string Variable for exception */
public $var;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
@ -18,7 +18,7 @@ class Catch_ extends Node\Stmt
*
* @param Node\Name[] $types Types of exceptions to catch
* @param string $var Variable for exception
* @param Node[] $stmts Statements
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(array $types, $var, array $stmts = array(), array $attributes = array()) {

View File

@ -7,7 +7,7 @@ use PhpParser\Node;
abstract class ClassLike extends Node\Stmt {
/** @var string|null Name */
public $name;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -17,7 +17,7 @@ class ClassMethod extends Node\Stmt implements FunctionLike
public $params;
/** @var null|string|Node\Name|Node\NullableType Return type */
public $returnType;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -8,14 +8,14 @@ class Declare_ extends Node\Stmt
{
/** @var DeclareDeclare[] List of declares */
public $declares;
/** @var Node[] Statements */
/** @var Node\Stmt[]|null Statements */
public $stmts;
/**
* Constructs a declare node.
*
* @param DeclareDeclare[] $declares List of declares
* @param Node[]|null $stmts Statements
* @param Node\Stmt[]|null $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(array $declares, array $stmts = null, array $attributes = array()) {

View File

@ -6,7 +6,7 @@ use PhpParser\Node;
class Do_ extends Node\Stmt
{
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/** @var Node\Expr Condition */
public $cond;
@ -14,9 +14,9 @@ class Do_ extends Node\Stmt
/**
* Constructs a do while node.
*
* @param Node\Expr $cond Condition
* @param Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -8,15 +8,15 @@ class ElseIf_ extends Node\Stmt
{
/** @var Node\Expr Condition */
public $cond;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs an elseif node.
*
* @param Node\Expr $cond Condition
* @param Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -6,14 +6,14 @@ use PhpParser\Node;
class Else_ extends Node\Stmt
{
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs an else node.
*
* @param Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -6,14 +6,14 @@ use PhpParser\Node;
class Finally_ extends Node\Stmt
{
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs a finally node.
*
* @param Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -12,7 +12,7 @@ class For_ extends Node\Stmt
public $cond;
/** @var Node\Expr[] Loop expressions */
public $loop;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -14,7 +14,7 @@ class Foreach_ extends Node\Stmt
public $byRef;
/** @var Node\Expr Variable to assign value to */
public $valueVar;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -15,7 +15,7 @@ class Function_ extends Node\Stmt implements FunctionLike
public $params;
/** @var null|string|Node\Name|Node\NullableType Return type */
public $returnType;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**

View File

@ -8,7 +8,7 @@ class If_ extends Node\Stmt
{
/** @var Node\Expr Condition expression */
public $cond;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/** @var ElseIf_[] Elseif clauses */
public $elseifs;

View File

@ -8,15 +8,15 @@ class Namespace_ extends Node\Stmt
{
/** @var null|Node\Name Name */
public $name;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs a namespace node.
*
* @param null|Node\Name $name Name
* @param null|Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param null|Node\Name $name Name
* @param null|Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(Node\Name $name = null, $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -6,7 +6,7 @@ use PhpParser\Node;
class TryCatch extends Node\Stmt
{
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/** @var Catch_[] Catches */
public $catches;
@ -16,7 +16,7 @@ class TryCatch extends Node\Stmt
/**
* Constructs a try catch node.
*
* @param Node[] $stmts Statements
* @param Node\Stmt[] $stmts Statements
* @param Catch_[] $catches Catches
* @param null|Finally_ $finally Optionaly finally node
* @param array|null $attributes Additional attributes

View File

@ -8,15 +8,15 @@ class While_ extends Node\Stmt
{
/** @var Node\Expr Condition */
public $cond;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
* Constructs a while node.
*
* @param Node\Expr $cond Condition
* @param Node[] $stmts Statements
* @param array $attributes Additional attributes
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
*/
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
parent::__construct($attributes);

View File

@ -10,8 +10,8 @@ interface Parser {
* @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults
* to ErrorHandler\Throwing.
*
* @return Node[]|null Array of statements (or null if the 'throwOnError' option is disabled and the parser was
* unable to recover from an error).
* @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
* the parser was unable to recover from an error).
*/
public function parse($code, ErrorHandler $errorHandler = null);
}

View File

@ -157,8 +157,8 @@ abstract class ParserAbstract implements Parser
* @param ErrorHandler|null $errorHandler Error handler to use for lexer/parser errors, defaults
* to ErrorHandler\Throwing.
*
* @return Node[]|null Array of statements (or null if the 'throwOnError' option is disabled and the parser was
* unable to recover from an error).
* @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
* the parser was unable to recover from an error).
*/
public function parse($code, ErrorHandler $errorHandler = null) {
$this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing;
@ -445,8 +445,8 @@ abstract class ParserAbstract implements Parser
/**
* Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.
*
* @param Node[] $stmts
* @return Node[]
* @param Node\Stmt[] $stmts
* @return Node\Stmt[]
*/
protected function handleNamespaces(array $stmts) {
$hasErrored = false;