mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-06-20 06:47:56 +02:00
If dropping a node would drop PHP tags, bail out of formatting
preservation. This will lose formatting, but at least produce
legal code.
Closes GH-884.
(cherry picked from commit b0edd4c411
)
113 lines
1.2 KiB
Plaintext
113 lines
1.2 KiB
Plaintext
Handling of inline HTML
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
?>Foo<?php
|
|
}
|
|
-----
|
|
$stmts[0]->setAttribute('origNode', null);
|
|
-----
|
|
<?php
|
|
|
|
function test()
|
|
{
|
|
?>Foo<?php
|
|
}
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
// TODO Fix broken result
|
|
$stmts[0]->stmts[2] = $stmts[0]->stmts[1];
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
Bar
|
|
}
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
// TODO Preserve formatting
|
|
$stmts[0]->stmts[1] = $stmts[0]->stmts[2];
|
|
-----
|
|
<?php
|
|
|
|
function test()
|
|
{
|
|
foo();
|
|
baz();
|
|
baz();
|
|
}
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
// TODO Preserve formatting
|
|
unset($stmts[0]->stmts[2]);
|
|
-----
|
|
<?php
|
|
|
|
function test()
|
|
{
|
|
foo();
|
|
?>Bar<?php
|
|
}
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
// TODO Preserve formatting
|
|
array_splice($stmts[0]->stmts, 0, 1, []);
|
|
-----
|
|
<?php
|
|
|
|
function test()
|
|
{
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
<?php
|
|
|
|
function test() {
|
|
foo();
|
|
?>Bar<?php
|
|
baz();
|
|
}
|
|
-----
|
|
// TODO Preserve formatting
|
|
array_splice($stmts[0]->stmts, 1, 1, []);
|
|
-----
|
|
<?php
|
|
|
|
function test()
|
|
{
|
|
foo();
|
|
baz();
|
|
}
|