123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- --TEST--
- AST pretty-peinter
- --INI--
- zend.assertions=1
- assert.exception=0
- --FILE--
- <?php
- assert(0 && ($a = function () {
- global $a, $$b;
- static $c, $d = 0;
- unset($e);
- $x = isset($a) && !empty($b) || eval($c);
- $x = $a ? $b : $c;
- $x = $a ?: $c;
- $x = $a ?? $b;
- list($a, $b, $c) = [1, 2=>'x', 'z'=>'c'];
- @foo();
- $y = clone $x;
- yield 1 => 2;
- yield from $x;
- }));
- assert(0 && ($a = function &(array &$a, ?X $b = null) use ($c,&$d) : ?X {
- abstract class A extends B implements C, D {
- const X = 12;
- const Y = self::X, Z = "aaa";
- public $a = 1, $b;
- protected $c;
- static private $d = null;
- abstract function foo();
- static private function f1() {
- for ($i = 0, $j = 100; $i < $j; $i++, --$j) {
- $s[$i] = $a[$j];
- }
- foreach ($a as $key => &$val) {
- print "$key => $val\n";
- }
- while ($s[$i]) {
- $i++;
- }
- do {
- $i--;
- } while ($s[$i]);
- $x = foo($a + 1, 4, ...[1,2,3]);
- $x = ${$a . "_1"}();
- $x = A::foo();
- $x = ${$a . "_1"}::foo();
- $x = A::${$a . "_1"}();
- $x = $x->foo();
- $x = ${$a . "_1"}->foo();
- $x = $x->{$a . "_1"}();
- $x->a = C::C;
- ${$a . "_1"}->a = ${$a . "_1"}::C;
- $x->{a . "_1"} = C::C;
- $x = C::$z;
- $x = ${$a . "_1"}::$z;
- $x = C::${$z . "_1"};
- $x?->y;
- $x?->y();
- foo(bar: $x);
- }
- }
- }));
- assert(0 && ($a = function &(array &$a, X $b = null, int|float $c) use ($c,&$d) : X {
- final class A {
- final protected function f2() {
- if (!$x) {
- return 0;
- }
- if ($x == 1) {
- return 1;
- } else if ($x == 2) {
- return 2;
- } else if ($x == 3) {
- return 3;
- } else {
- if ($x == 9) {
- return 9;
- }
- L0:
- do {
- switch ($x) {
- case 4: break;
- case 5: continue;
- case 6: break 2;
- case 7: continue 2;
- case 8: goto L0;
- default: return;
- }
- } while (0);
- }
- }
- }
- }));
- assert(0 && ($a = function &(?array &$a, X $b = null) use ($c,&$d) : X {
- class A {
- use T1, T2 {
- T1::foo insteadof foo;
- T2::foo as bar;
- baz as public;
- ops as protected x;
- }
- use T3;
- }
- }));
- assert(0 && ($a = function &(array &...$a) {
- declare(A=1,B=2);
- try {
- $i++;
- } catch (MyException $e) {
- echo 1;
- } catch (Exception $e) {
- echo 2;
- } finally {
- echo 3;
- }
- }));
- assert(0 && ($a = function (): ?static {
- declare(C=1) { echo 1; }
- $x = '\'"`$a';
- $x = "'\"`$a";
- $x = `'"\`$a`;
- $x = "{$a}b";
- $x = "${a}b";
- $x = " {$foo->bar} ${$foo->bar} ";
- $x = " ${'---'} ";
- foo();
- \foo();
- namespace\foo();
- $x = foo;
- $x = \foo;
- $x = namespace\foo;
- $x = new foo();
- $x = new \foo();
- $x = new namespace\foo();
- if ($a) {
- } elseif ($b) {
- }
- if ($a); else;
- }));
- ?>
- --EXPECTF--
- Warning: assert(): assert(0 && ($a = function () {
- global $a;
- global $$b;
- static $c;
- static $d = 0;
- unset($e);
- $x = isset($a) && !empty($b) || eval($c);
- $x = $a ? $b : $c;
- $x = $a ?: $c;
- $x = $a ?? $b;
- [$a, $b, $c] = [1, 2 => 'x', 'z' => 'c'];
- @foo();
- $y = clone $x;
- yield 1 => 2;
- yield from $x;
- })) failed in %s on line %d
- Warning: assert(): assert(0 && ($a = function &(array &$a, ?X $b = null) use($c, &$d): ?X {
- abstract class A extends B implements C, D {
- public const X = 12;
- public const Y = self::X, Z = 'aaa';
- public $a = 1, $b;
- protected $c;
- private static $d = null;
- public abstract function foo();
- private static function f1() {
- for ($i = 0, $j = 100; $i < $j; $i++, --$j) {
- $s[$i] = $a[$j];
- }
- foreach ($a as $key => &$val) {
- print "$key => $val\n";
- }
- while ($s[$i]) {
- $i++;
- }
- do {
- $i--;
- } while ($s[$i]);
- $x = foo($a + 1, 4, ...[1, 2, 3]);
- $x = ${$a . '_1'}();
- $x = A::foo();
- $x = ${$a . '_1'}::foo();
- $x = A::${$a . '_1'}();
- $x = $x->foo();
- $x = ${$a . '_1'}->foo();
- $x = $x->{$a . '_1'}();
- $x->a = C::C;
- ${$a . '_1'}->a = ${$a . '_1'}::C;
- $x->{a . '_1'} = C::C;
- $x = C::$z;
- $x = ${$a . '_1'}::$z;
- $x = C::${$z . '_1'};
- $x?->y;
- $x?->y();
- foo(bar: $x);
- }
- }
- })) failed in %s on line %d
- Warning: assert(): assert(0 && ($a = function &(array &$a, X $b = null, int|float $c) use($c, &$d): X {
- final class A {
- protected final function f2() {
- if (!$x) {
- return 0;
- }
- if ($x == 1) {
- return 1;
- } else if ($x == 2) {
- return 2;
- } else if ($x == 3) {
- return 3;
- } else {
- if ($x == 9) {
- return 9;
- }
- L0:
- do {
- switch ($x) {
- case 4:
- break;
- case 5:
- continue;
- case 6:
- break 2;
- case 7:
- continue 2;
- case 8:
- goto L0;
- default:
- return;
- }
- } while (0);
- }
- }
- }
- })) failed in %s on line %d
- Warning: assert(): assert(0 && ($a = function &(?array &$a, X $b = null) use($c, &$d): X {
- class A {
- use T1, T2 {
- T1::foo insteadof foo;
- T2::foo as bar;
- baz as public;
- ops as protected x;
- }
- use T3;
- }
- })) failed in %s on line %d
- Warning: assert(): assert(0 && ($a = function &(array &...$a) {
- declare(A = 1, B = 2);
- try {
- $i++;
- } catch (MyException $e) {
- echo 1;
- } catch (Exception $e) {
- echo 2;
- } finally {
- echo 3;
- }
- })) failed in %s on line %d
- Warning: assert(): assert(0 && ($a = function (): ?static {
- declare(C = 1) {
- echo 1;
- }
- $x = '\'"`$a';
- $x = "'\"`$a";
- $x = `'"\`$a`;
- $x = "{$a}b";
- $x = "{$a}b";
- $x = " {$foo->bar} {${$foo->bar}} ";
- $x = " ${---} ";
- foo();
- \foo();
- namespace\foo();
- $x = foo;
- $x = \foo;
- $x = namespace\foo;
- $x = new foo();
- $x = new \foo();
- $x = new namespace\foo();
- if ($a) {
- } elseif ($b) {
- }
- if ($a) {
- } else {
- }
- })) failed in %s on line %d
|