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

Pretty printer test coverage

Our output for yield / yield from is currently not very nice, but
also not easy to change.
This commit is contained in:
Nikita Popov 2016-02-20 18:55:48 +01:00
parent 1fe8f09caa
commit a73aa7eec1
7 changed files with 127 additions and 3 deletions

View File

@ -0,0 +1,29 @@
isset, empty, unset, exit, die, clone, eval
-----
<?php
isset($a, $a[$b]);
empty($a);
empty('foo');
unset($a, $a[$b]);
exit;
exit();
exit(1);
die;
die();
die("foo");
clone $foo;
eval('str');
-----
isset($a, $a[$b]);
empty($a);
empty('foo');
unset($a, $a[$b]);
die;
die;
die(1);
die;
die;
die('foo');
clone $foo;
eval('str');

View File

@ -81,6 +81,12 @@ b';
'a
b';
}
// shell exec (similar to double quoted string)
`foo`;
`foo$a`;
`foo{$a}bar`;
`\`\'\"`;
-----
// magic constants
__LINE__;
@ -153,3 +159,8 @@ b';
'a
b';
}
// shell exec (similar to double quoted string)
`foo`;
`foo{$a}`;
`foo{$a}bar`;
`\`\\'\\"`;

View File

@ -0,0 +1,44 @@
Yield
-----
<?php
function gen()
{
yield;
yield $a;
yield $a => $b;
$a = yield;
$a = (yield $b);
$a = (yield $b => $c);
}
// TODO Get rid of parens for cases 2 and 3
-----
function gen()
{
yield;
(yield $a);
(yield $a => $b);
$a = yield;
$a = (yield $b);
$a = (yield $b => $c);
}
-----
<?php
function gen()
{
$a = yield $b;
$a = yield $b => $c;
yield from $a;
$a = yield from $b;
}
// TODO Get rid of parens for last case
-----
!!php7
function gen()
{
$a = (yield $b);
$a = (yield $b => $c);
yield from $a;
$a = (yield from $b);
}

View File

@ -8,4 +8,9 @@ echo 'Bar Foo';
<?php
echo 'Foo Bar';
echo 'Bar Foo';
echo 'Bar Foo';
-----
<?php
// avoid trim
-----
<?php

View File

@ -2,7 +2,7 @@ Class
-----
<?php
class Foo
class Foo extends Bar implements ABC, \DEF, namespace\GHI
{
var $a = 'foo';
private $b = 'bar';
@ -17,8 +17,15 @@ class Foo
public function foo() {}
abstract static function bar() {}
}
trait Bar
{
function test()
{
}
}
-----
class Foo
class Foo extends Bar implements ABC, \DEF, namespace\GHI
{
var $a = 'foo';
private $b = 'bar';
@ -37,4 +44,10 @@ class Foo
static abstract function bar()
{
}
}
trait Bar
{
function test()
{
}
}

View File

@ -0,0 +1,11 @@
Constant declarations
-----
<?php
const FOO = 'BAR';
const FOO = 1 + 1;
const FOO = BAR, BAR = FOO;
-----
const FOO = 'BAR';
const FOO = 1 + 1;
const FOO = BAR, BAR = FOO;

View File

@ -0,0 +1,11 @@
Global and static variables
-----
<?php
global $a, $$a, ${$a[$a]};
static $a, $b;
static $a = 'foo', $b = 'bar';
-----
global $a, ${$a}, ${$a[$a]};
static $a, $b;
static $a = 'foo', $b = 'bar';