mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-02-24 02:42:40 +01:00
In the past, single-line comments were stored together with the trailing newline. Later we switched to the PHP8 comment representation, where the trailing newline is not part of the comment anymore. As such, there is also no need to trim here. This is split out from GH-867.
78 lines
1.3 KiB
Plaintext
78 lines
1.3 KiB
Plaintext
Adding statement to Class Method containing Nop
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
// I'm just a comment
|
|
}
|
|
}
|
|
-----
|
|
$stmts[0]->stmts[0]->stmts[] = new Stmt\Expression(new Node\Expr\Variable('foo'));
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
// I'm just a comment
|
|
$foo;
|
|
}
|
|
}
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
/* I'm just a comment */
|
|
}
|
|
}
|
|
-----
|
|
$stmts[0]->stmts[0]->stmts[] = new Stmt\Expression(new Node\Expr\Variable('foo'));
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
/* I'm just a comment */
|
|
$foo;
|
|
}
|
|
}
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
/* I'm just a comment */
|
|
}
|
|
}
|
|
-----
|
|
$stmts[0]->stmts[0]->stmts[0]->setAttribute('comments', [new Comment("/* I'm a new comment */")]);
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
/* I'm a new comment */
|
|
|
|
}
|
|
}
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
// I'm just a comment
|
|
}
|
|
}
|
|
-----
|
|
$stmts[0]->stmts[0]->stmts[0]->setAttribute('comments', [new Comment("// I'm a new comment")]);
|
|
-----
|
|
<?php
|
|
class Foo {
|
|
public function __construct()
|
|
{
|
|
// I'm a new comment
|
|
|
|
}
|
|
}
|