mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
parent
df64d86cf4
commit
8b1c9c0409
@ -1,7 +1,16 @@
|
||||
Version 4.0.3-dev
|
||||
-----------------
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed possible undefined offset notice in formatting-preserving printer. (#513)
|
||||
|
||||
### Added
|
||||
|
||||
* Improved error recovery inside arrays.
|
||||
* Preserve trailing comment inside classes. **Note:** This change is possibly BC breaking if your
|
||||
code validates that classes can only contain certain statement types. After this change, classes
|
||||
can also contain Nop statements, while this was not previously possible. (#509)
|
||||
|
||||
Version 4.0.2 (2018-06-03)
|
||||
--------------------------
|
||||
|
@ -454,11 +454,17 @@ static_var:
|
||||
| plain_variable '=' static_scalar { $$ = Stmt\StaticVar[$1, $3]; }
|
||||
;
|
||||
|
||||
class_statement_list:
|
||||
class_statement_list class_statement { push($1, $2); }
|
||||
class_statement_list_ex:
|
||||
class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } }
|
||||
| /* empty */ { init(); }
|
||||
;
|
||||
|
||||
class_statement_list:
|
||||
class_statement_list_ex
|
||||
{ makeNop($nop, $this->lookaheadStartAttributes, $this->endAttributes);
|
||||
if ($nop !== null) { $1[] = $nop; } $$ = $1; }
|
||||
;
|
||||
|
||||
class_statement:
|
||||
variable_modifiers property_declaration_list ';'
|
||||
{ $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); }
|
||||
|
@ -522,11 +522,17 @@ static_var:
|
||||
| plain_variable '=' expr { $$ = Stmt\StaticVar[$1, $3]; }
|
||||
;
|
||||
|
||||
class_statement_list:
|
||||
class_statement_list class_statement { if ($2 !== null) { push($1, $2); } }
|
||||
class_statement_list_ex:
|
||||
class_statement_list_ex class_statement { if ($2 !== null) { push($1, $2); } }
|
||||
| /* empty */ { init(); }
|
||||
;
|
||||
|
||||
class_statement_list:
|
||||
class_statement_list_ex
|
||||
{ makeNop($nop, $this->lookaheadStartAttributes, $this->endAttributes);
|
||||
if ($nop !== null) { $1[] = $nop; } $$ = $1; }
|
||||
;
|
||||
|
||||
class_statement:
|
||||
variable_modifiers property_declaration_list ';'
|
||||
{ $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); }
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
37
test/code/parser/commentAtEndOfClass.test
Normal file
37
test/code/parser/commentAtEndOfClass.test
Normal file
@ -0,0 +1,37 @@
|
||||
Comment at end of class (#509)
|
||||
-----
|
||||
<?php
|
||||
class MyClass {
|
||||
protected $a;
|
||||
// my comment
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Stmt_Class(
|
||||
flags: 0
|
||||
name: Identifier(
|
||||
name: MyClass
|
||||
)
|
||||
extends: null
|
||||
implements: array(
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PROTECTED (2)
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
name: a
|
||||
)
|
||||
default: null
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Nop(
|
||||
comments: array(
|
||||
0: // my comment
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@ -222,6 +222,11 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
8: Stmt_Nop(
|
||||
comments: array(
|
||||
0: // __halt_compiler does not work
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Expression(
|
||||
|
Loading…
Reference in New Issue
Block a user