X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fnikic%2Fphp-parser%2Ftest%2Fcode%2FformatPreservation%2FlistInsertion.test;fp=vendor%2Fnikic%2Fphp-parser%2Ftest%2Fcode%2FformatPreservation%2FlistInsertion.test;h=b23bfd58139e7de465bdd67b1b58c548a886e7bd;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/nikic/php-parser/test/code/formatPreservation/listInsertion.test b/vendor/nikic/php-parser/test/code/formatPreservation/listInsertion.test new file mode 100644 index 000000000..b23bfd581 --- /dev/null +++ b/vendor/nikic/php-parser/test/code/formatPreservation/listInsertion.test @@ -0,0 +1,312 @@ +Insertion into list nodes +----- +stmts[] = new Stmt\Expression(new Expr\Variable('baz')); +----- +params[] = new Node\Param(new Expr\Variable('param2')); +----- +catches[0]->types[] = new Node\Name('Bar'); +----- +params, new Node\Param(new Expr\Variable('param0'))); +----- +params[] = new Node\Param(new Expr\Variable('param0')); +/* Insertion into empty list not handled yet */ +----- +elseifs[] = new Stmt\ElseIf_(new Expr\Variable('cond3'), []); +----- +catches[] = new Stmt\Catch_([new Node\Name('Bar')], new Expr\Variable('bar'), []); +----- +setAttribute('comments', [new Comment('// Test')]); +$stmts[] = $node; +----- +setAttribute('comments', [new Comment('// Test'), new Comment('// Test 2')]); +$stmts[0]->stmts[] = $node; +----- +name->parts[0] = 'Xyz'; +----- +stmts, $node); +----- +setAttribute('comments', [new Comment('// Test')]); +array_unshift($stmts[0]->stmts, $node); +----- +setAttribute('comments', [new Comment('// Test')]); +array_unshift($stmts[0]->stmts, $node); +----- +setAttribute('comments', [new Comment('// Test')]); +array_unshift($stmts[0]->stmts, $node); +$stmts[0]->stmts[1]->setAttribute('comments', [new Comment('// Bar foo')]); +----- +setAttribute('comments', [new Comment('// Test')]); +array_unshift($stmts[0]->stmts, $node); +$stmts[0]->stmts[1]->setAttribute('comments', []); +----- +stmts, + new Stmt\Expression(new Expr\Variable('a')), + new Stmt\Expression(new Expr\Variable('b'))); +----- +stmts = [ + new Stmt\Expression(new Expr\Variable('a')), + new Stmt\Expression(new Expr\Variable('b')), +]; +----- +expr->expr->items, new Expr\ArrayItem(new Scalar\LNumber(42))); +$stmts[0]->expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24)); +----- +expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24)); +----- +