First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,67 @@
Comments
-----
<?php
function justForIndentation()
{
// Some text
# Some text
/* Some text */
/** Some text */
/**
* Some text.
* Some more text.
*/
/*
* Some text.
* Some more text.
*/
/*
Some text.
Some more text.
*/
/* Some text.
More text. */
/* Some text.
More text.
Even more text. */
$foo;
}
-----
function justForIndentation()
{
// Some text
# Some text
/* Some text */
/** Some text */
/**
* Some text.
* Some more text.
*/
/*
* Some text.
* Some more text.
*/
/*
Some text.
Some more text.
*/
/* Some text.
More text. */
/* Some text.
More text.
Even more text. */
$foo;
}
-----
<?php
function test()
{
// empty
}
-----
function test()
{
// empty
}

View file

@ -0,0 +1,53 @@
Comments in arrays and function calls
-----
<?php
$arr = [
// Foo
$foo,
// Bar
$bar,
// Discarded
];
[
// Foo
$foo,
,
// Bar
$bar,
] = $arr;
foo(
// Foo
$foo,
// Bar
$bar
);
new Foo(
// Foo
$foo
);
-----
!!php7
$arr = [
// Foo
$foo,
// Bar
$bar,
];
[
// Foo
$foo,
,
// Bar
$bar,
] = $arr;
foo(
// Foo
$foo,
// Bar
$bar
);
new Foo(
// Foo
$foo
);

View file

@ -0,0 +1,27 @@
Anonymous classes
-----
<?php
new class {};
new class extends A implements B, C {};
new class($a) extends A {
private $a;
public function __construct($a) {
$this->a = $a;
}
};
-----
new class
{
};
new class extends A implements B, C
{
};
new class($a) extends A
{
private $a;
public function __construct($a)
{
$this->a = $a;
}
};

View file

@ -0,0 +1,14 @@
Array destructuring
-----
<?php
[$a, $b] = [$c, $d];
[, $a, , , $b, ,] = $foo;
[, [[$a]], $b] = $bar;
['a' => $b, 'b' => $a] = $baz;
-----
!!php7
[$a, $b] = [$c, $d];
[, $a, , , $b, ] = $foo;
[, [[$a]], $b] = $bar;
['a' => $b, 'b' => $a] = $baz;

View file

@ -0,0 +1,13 @@
Calls
-----
<?php
f($a);
f(&$a);
f(...$a);
f($a, &$b, ...$c);
-----
f($a);
f(&$a);
f(...$a);
f($a, &$b, ...$c);

View file

@ -0,0 +1,18 @@
Closures
-----
<?php
$closureWithArgs = function ($arg1, $arg2) {
$comment = 'closure body';
};
$closureWithArgsAndVars = function ($arg1, $arg2) use($var1, $var2) {
$comment = 'closure body';
};
-----
$closureWithArgs = function ($arg1, $arg2) {
$comment = 'closure body';
};
$closureWithArgsAndVars = function ($arg1, $arg2) use($var1, $var2) {
$comment = 'closure body';
};

View file

@ -0,0 +1,13 @@
Constant/literal dereferencing
-----
<?php
FOO[0];
FOO::BAR[0];
'FOO'[0];
array(FOO)[0];
-----
FOO[0];
FOO::BAR[0];
'FOO'[0];
array(FOO)[0];

View file

@ -0,0 +1,86 @@
Literals
-----
<?php
<<<'STR'
STR;
<<<STR
STR;
<<<'STR'
A
B
STR;
<<<STR
A
B
STR;
<<<'STR'
a\nb$c
STR;
<<<STR
a\\nb\$c
STR;
<<<STR
a$b
{$c->d}
STR;
call(
<<<STR
A
STR
, <<<STR
B
STR
);
function test() {
<<<STR
Foo
STR;
<<<STR
Bar
STR;
}
-----
<<<'STR'
STR;
<<<STR
STR;
<<<'STR'
A
B
STR;
<<<STR
A
B
STR;
<<<'STR'
a\nb$c
STR;
<<<STR
a\\nb\$c
STR;
<<<STR
a{$b}
{$c->d}
STR;
call(<<<STR
A
STR
, <<<STR
B
STR
);
function test()
{
<<<STR
Foo
STR;
<<<STR
Bar
STR;
}

View file

@ -0,0 +1,7 @@
Include
-----
<?php
(include $foo) && (include $bar);
-----
(include $foo) && (include $bar);

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]);
exit;
exit;
exit(1);
die;
die;
die('foo');
clone $foo;
eval('str');

View file

@ -0,0 +1,19 @@
list()
-----
<?php
list() = $a;
list($a) = $b;
list($a, $b, $c) = $d;
list(, $a) = $b;
list(, , $a, , $b) = $c;
list(list($a)) = $b;
list(, list(, list(, $a), $b)) = $c;
-----
list() = $a;
list($a) = $b;
list($a, $b, $c) = $d;
list(, $a) = $b;
list(, , $a, , $b) = $c;
list(list($a)) = $b;
list(, list(, list(, $a), $b)) = $c;

View file

@ -0,0 +1,154 @@
Literals
-----
<?php
// magic constants
__LINE__;
__FILE__;
__DIR__;
__FUNCTION__;
__CLASS__;
__TRAIT__;
__METHOD__;
__NAMESPACE__;
// not actually literals, but close
null;
true;
false;
NULL;
TRUE;
FALSE;
// integers (normalized to decimal)
0;
11;
011;
0x11;
0b11;
// floats (normalized to ... something)
0.;
.0;
0.0;
0e1000;
1.0;
1e100;
1e1000;
1E-100;
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
378282246310005.0;
10000000000000002.0;
// strings (single quoted)
'a';
'a
b';
"a";
"a\nb";
'a\'b';
// strings (double quoted)
"a'b";
"a\b";
"$a";
"a$b";
"$a$b";
"$a $b";
"a${b}c";
"a{$b}c";
"a$a[b]c";
"\{$A}";
"\{ $A }";
"\\{$A}";
"\\{ $A }";
"{$$A}[B]";
"$$A[B]";
// make sure indentation doesn't mess anything up
function foo()
{
"a\nb";
'a
b';
'a
b';
}
// shell exec (similar to double quoted string)
`foo`;
`foo$a`;
`foo{$a}bar`;
`\`\'\"`;
-----
// magic constants
__LINE__;
__FILE__;
__DIR__;
__FUNCTION__;
__CLASS__;
__TRAIT__;
__METHOD__;
__NAMESPACE__;
// not actually literals, but close
null;
true;
false;
NULL;
TRUE;
FALSE;
// integers (normalized to decimal)
0;
11;
011;
0x11;
0b11;
// floats (normalized to ... something)
0.0;
0.0;
0.0;
0.0;
1.0;
1.0E+100;
\INF;
1.0E-100;
1.0E+84;
378282246310005.0;
10000000000000002.0;
// strings (single quoted)
'a';
'a
b';
"a";
"a\nb";
'a\'b';
// strings (double quoted)
"a'b";
"a\\b";
"{$a}";
"a{$b}";
"{$a}{$b}";
"{$a} {$b}";
"a{$b}c";
"a{$b}c";
"a{$a['b']}c";
"\\{{$A}}";
"\\{ {$A} }";
"\\{$A}";
"\\{ {$A} }";
"{${$A}}[B]";
"\${$A['B']}";
// make sure indentation doesn't mess anything up
function foo()
{
"a\nb";
'a
b';
'a
b';
}
// shell exec (similar to double quoted string)
`foo`;
`foo{$a}`;
`foo{$a}bar`;
`\`\\'\\"`;

View file

@ -0,0 +1,35 @@
Number literals
-----
<?php
0;
+0;
-0;
0.0;
-0.0;
42;
-42;
42.0;
-42.0;
42.5;
-42.5;
1e42;
-1e42;
1e1000;
-1e1000;
-----
0;
+0;
-0;
0.0;
-0.0;
42;
-42;
42.0;
-42.0;
42.5;
-42.5;
1.0E+42;
-1.0E+42;
\INF;
-\INF;

View file

@ -0,0 +1,144 @@
Basic operators
-----
<?php
$a ** $b;
++$a;
--$a;
$a++;
$a--;
@$a;
~$a;
-$a;
+$a;
(int) $a;
(integer) $a;
(float) $a;
(double) $a;
(real) $a;
(string) $a;
(binary) $a;
(array) $a;
(object) $a;
(bool) $a;
(boolean) $a;
(unset) $a;
$a * $b;
$a / $b;
$a % $b;
$a + $b;
$a - $b;
$a . $b;
$a << $b;
$a >> $b;
$a < $b;
$a <= $b;
$a > $b;
$a >= $b;
$a == $b;
$a != $b;
$a <> $b;
$a === $b;
$a !== $b;
$a <=> $b;
$a & $b;
$a ^ $b;
$a | $b;
$a && $b;
$a || $b;
$a ? $b : $c;
$a ?: $c;
$a ?? $c;
$a = $b;
$a **= $b;
$a *= $b;
$a /= $b;
$a %= $b;
$a += $b;
$a -= $b;
$a .= $b;
$a <<= $b;
$a >>= $b;
$a &= $b;
$a ^= $b;
$a |= $b;
$a =& $b;
$a and $b;
$a xor $b;
$a or $b;
$a instanceof Foo;
$a instanceof $b;
-----
$a ** $b;
++$a;
--$a;
$a++;
$a--;
@$a;
~$a;
-$a;
+$a;
(int) $a;
(int) $a;
(double) $a;
(double) $a;
(double) $a;
(string) $a;
(string) $a;
(array) $a;
(object) $a;
(bool) $a;
(bool) $a;
(unset) $a;
$a * $b;
$a / $b;
$a % $b;
$a + $b;
$a - $b;
$a . $b;
$a << $b;
$a >> $b;
$a < $b;
$a <= $b;
$a > $b;
$a >= $b;
$a == $b;
$a != $b;
$a != $b;
$a === $b;
$a !== $b;
$a <=> $b;
$a & $b;
$a ^ $b;
$a | $b;
$a && $b;
$a || $b;
$a ? $b : $c;
$a ?: $c;
$a ?? $c;
$a = $b;
$a **= $b;
$a *= $b;
$a /= $b;
$a %= $b;
$a += $b;
$a -= $b;
$a .= $b;
$a <<= $b;
$a >>= $b;
$a &= $b;
$a ^= $b;
$a |= $b;
$a =& $b;
$a and $b;
$a xor $b;
$a or $b;
$a instanceof Foo;
$a instanceof $b;

View file

@ -0,0 +1,77 @@
Pretty printer generates least-parentheses output
-----
<?php
echo 'abc' . 'cde' . 'fgh';
echo 'abc' . ('cde' . 'fgh');
echo 'abc' . 1 + 2 . 'fgh';
echo 'abc' . (1 + 2) . 'fgh';
echo 1 * 2 + 3 / 4 % 5 . 6;
echo 1 * (2 + 3) / (4 % (5 . 6));
$a = $b = $c = $d = $f && true;
($a = $b = $c = $d = $f) && true;
$a = $b = $c = $d = $f and true;
$a = $b = $c = $d = ($f and true);
$a ? $b : $c ? $d : $e ? $f : $g;
$a ? $b : ($c ? $d : ($e ? $f : $g));
$a ? $b ? $c : $d : $f;
$a ?? $b ?? $c;
($a ?? $b) ?? $c;
$a ?? ($b ? $c : $d);
$a || ($b ?? $c);
(1 > 0) > (1 < 0);
++$a + $b;
$a + $b++;
$a ** $b ** $c;
($a ** $b) ** $c;
-1 ** 2;
yield from $a and yield from $b;
yield from ($a and yield from $b);
print ($a and print $b);
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
// and incdec only work on variables.
!$a = $b;
++$a ** $b;
$a ** $b++;
-----
echo 'abc' . 'cde' . 'fgh';
echo 'abc' . ('cde' . 'fgh');
echo 'abc' . 1 + 2 . 'fgh';
echo 'abc' . (1 + 2) . 'fgh';
echo 1 * 2 + 3 / 4 % 5 . 6;
echo 1 * (2 + 3) / (4 % (5 . 6));
$a = $b = $c = $d = $f && true;
($a = $b = $c = $d = $f) && true;
$a = $b = $c = $d = $f and true;
$a = $b = $c = $d = ($f and true);
$a ? $b : $c ? $d : $e ? $f : $g;
$a ? $b : ($c ? $d : ($e ? $f : $g));
$a ? $b ? $c : $d : $f;
$a ?? $b ?? $c;
($a ?? $b) ?? $c;
$a ?? ($b ? $c : $d);
$a || ($b ?? $c);
(1 > 0) > (1 < 0);
++$a + $b;
$a + $b++;
$a ** $b ** $c;
($a ** $b) ** $c;
-1 ** 2;
yield from $a and yield from $b;
yield from ($a and yield from $b);
print ($a and print $b);
// The following will currently add unnecessary parentheses, because the pretty printer is not aware that assignment
// and incdec only work on variables.
!($a = $b);
(++$a) ** $b;
$a ** ($b++);

View file

@ -0,0 +1,11 @@
Short array syntax
-----
<?php
[];
array(1, 2, 3);
['a' => 'b', 'c' => 'd'];
-----
[];
array(1, 2, 3);
['a' => 'b', 'c' => 'd'];

View file

@ -0,0 +1,23 @@
Escape sequences in double-quoted strings
-----
<?php
"\n\r\t\f\v\$\"\\";
"@@{ implode(range("\0", "\37")) }@@";
"\0000\0001";
<<<DOC
\n\r\t\f\v\$\"\\
@@{ implode(range("\0", "\37")) }@@
\0000\0001
DOC;
-----
"\n\r\t\f\v\$\"\\";
"\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37";
"\0000\0001";
<<<DOC
@@{ "\n\r" }@@\t\f\v\$\\"\\
\0\1\2\3\4\5\6\7\10\t@@{ "\n" }@@\v\f@@{ "\r" }@@\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37
\0000\0001
DOC
;

View file

@ -0,0 +1,23 @@
Uniform variable syntax
-----
<?php
(function() {})();
array('a', 'b')()();
A::$b::$c;
$A::$b[$c]();
$A::{$b[$c]}();
A::$$b[$c]();
($a->b)();
(A::$b)();
-----
!!php7
(function () {
})();
array('a', 'b')()();
A::$b::$c;
$A::$b[$c]();
$A::{$b[$c]}();
A::${$b}[$c]();
($a->b)();
(A::$b)();

View file

@ -0,0 +1,73 @@
Variables
-----
<?php
$a;
$$a;
${$a};
$a->b;
$a->b();
$a->b($c);
$a->$b();
$a->{$b}();
$a->$b[$c]();
$$a->b;
$a[$b];
$a[$b]();
$$a[$b];
$a::B;
$a::$b;
$a::b();
$a::b($c);
$a::$b();
$a::$b[$c];
$a::$b[$c]($d);
$a::{$b[$c]}($d);
$a::{$b->c}();
A::$$b[$c]();
a();
$a();
$a()[$b];
$a->b()[$c];
$a::$b()[$c];
(new A)->b;
(new A())->b();
(new $$a)[$b];
(new $a->b)->c;
global $a, $$a, $$a[$b], $$a->b;
-----
!!php5
$a;
${$a};
${$a};
$a->b;
$a->b();
$a->b($c);
$a->{$b}();
$a->{$b}();
$a->{$b[$c]}();
${$a}->b;
$a[$b];
$a[$b]();
${$a[$b]};
$a::B;
$a::$b;
$a::b();
$a::b($c);
$a::$b();
$a::$b[$c];
$a::{$b[$c]}($d);
$a::{$b[$c]}($d);
$a::{$b->c}();
A::${$b[$c]}();
a();
$a();
$a()[$b];
$a->b()[$c];
$a::$b()[$c];
(new A())->b;
(new A())->b();
(new ${$a}())[$b];
(new $a->b())->c;
global $a, ${$a}, ${$a[$b]}, ${$a->b};

View file

@ -0,0 +1,46 @@
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);
}
// TODO Get rid of parens for cases 2 and 3
-----
<?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);
}
// TODO Get rid of parens for last case

View file

@ -0,0 +1,58 @@
File containing both inline HTML and PHP
-----
HTML
<?php
echo 'PHP';
-----
HTML
<?php
echo 'PHP';
-----
<?php
echo 'PHP';
?>
HTML
-----
<?php
echo 'PHP';
?>
HTML
-----
HTML
<?php
echo 'PHP';
?>
HTML
-----
HTML
<?php
echo 'PHP';
?>
HTML
-----
HTML
<?php
echo 'PHP';
?>
HTML
<?php
echo 'PHP';
?>
HTML
-----
HTML
<?php
echo 'PHP';
?>
HTML
<?php
echo 'PHP';
?>
HTML
-----
HTML<?php echo 'PHP'; ?>HTML
-----
HTML<?php
echo 'PHP';
?>HTML

View file

@ -0,0 +1,19 @@
File containing only inline HTML
-----
Hallo World
Foo Bar
Bar Foo
World Hallo
-----
Hallo World
Foo Bar
Bar Foo
World Hallo
-----
Test
-----
Test

View file

@ -0,0 +1,16 @@
File containing only PHP
-----
<?php
echo 'Foo Bar';
echo 'Bar Foo';
-----
<?php
echo 'Foo Bar';
echo 'Bar Foo';
-----
<?php
-----
<?php

View file

@ -0,0 +1,20 @@
Aliases (namespacing)
-----
<?php
use A\B;
use C\D as E;
use F\G as H, J;
use function foo\bar;
use function foo\bar as baz;
use const foo\BAR;
use const foo\BAR as BAZ;
-----
use A\B;
use C\D as E;
use F\G as H, J;
use function foo\bar;
use function foo\bar as baz;
use const foo\BAR;
use const foo\BAR as BAZ;

View file

@ -0,0 +1,13 @@
break/continue
-----
<?php
continue;
continue 2;
break;
break 2;
-----
continue;
continue 2;
break;
break 2;

View file

@ -0,0 +1,53 @@
Class
-----
<?php
class Foo extends Bar implements ABC, \DEF, namespace\GHI
{
var $a = 'foo';
private $b = 'bar';
static $c = 'baz';
function test()
{
$this->a = 'bar';
echo 'test';
}
protected function baz() {}
public function foo() {}
abstract static function bar() {}
}
trait Bar
{
function test()
{
}
}
-----
class Foo extends Bar implements ABC, \DEF, namespace\GHI
{
var $a = 'foo';
private $b = 'bar';
static $c = 'baz';
function test()
{
$this->a = 'bar';
echo 'test';
}
protected function baz()
{
}
public function foo()
{
}
static abstract function bar()
{
}
}
trait Bar
{
function test()
{
}
}

View file

@ -0,0 +1,20 @@
Class constants
-----
<?php
class Foo
{
const A = 1, B = 2;
public const C = 3, D = 4;
protected const E = 5, F = 6;
private const G = 7, H = 8;
}
-----
!!php7
class Foo
{
const A = 1, B = 2;
public const C = 3, D = 4;
protected const E = 5, F = 6;
private const G = 7, H = 8;
}

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,17 @@
declare
-----
<?php
declare (strict_types=1);
declare (ticks=1) {
foo();
}
declare (ticks=2) {
}
-----
declare (strict_types=1);
declare (ticks=1) {
foo();
}
declare (ticks=2) {
}

View file

@ -0,0 +1,10 @@
doWhile
-----
<?php
do {
} while (true);
-----
do {
} while (true);

View file

@ -0,0 +1,28 @@
for
-----
<?php
for ($i = 0; $i < 10; $i++) {
}
for ($i = 0,$j = 0; $i < 10; $i++) {
}
for ($i = 0; $i < 10;) {
}
for (;;) {
}
-----
for ($i = 0; $i < 10; $i++) {
}
for ($i = 0, $j = 0; $i < 10; $i++) {
}
for ($i = 0; $i < 10;) {
}
for (;;) {
}

View file

@ -0,0 +1,28 @@
foreach
-----
<?php
foreach ($arr as $val) {
}
foreach ($arr as &$val) {
}
foreach ($arr as $key => $val) {
}
foreach ($arr as $key => &$val) {
}
-----
foreach ($arr as $val) {
}
foreach ($arr as &$val) {
}
foreach ($arr as $key => $val) {
}
foreach ($arr as $key => &$val) {
}

View file

@ -0,0 +1,43 @@
Function signatures
-----
<?php
interface A
{
function f1();
function f2($a, $b);
function f3(&$a);
function f4(A\B $a);
function f4(array $a);
function f5(callable $a);
function f6(&$a);
function f7(...$a);
function f8(&...$a);
function f9(A &$a);
function f10(A ...$a);
function f11(A &$a);
function f12(A &...$a);
function f13($a) : array;
function f14($a) : callable;
function f15($a) : B\C;
}
-----
interface A
{
function f1();
function f2($a, $b);
function f3(&$a);
function f4(A\B $a);
function f4(array $a);
function f5(callable $a);
function f6(&$a);
function f7(...$a);
function f8(&...$a);
function f9(A &$a);
function f10(A ...$a);
function f11(A &$a);
function f12(A &...$a);
function f13($a) : array;
function f14($a) : callable;
function f15($a) : B\C;
}

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';

View file

@ -0,0 +1,9 @@
goto
-----
<?php
marker:
goto marker;
-----
marker:
goto marker;

View file

@ -0,0 +1,16 @@
Group use declaration
-----
<?php
use A\{B};
use A\{B\C, D};
use A\B\{C\D, E};
use function A\{b\c, d};
use const A\{B\C, D};
use A\B\{C\D, function b\c, const D};
-----
use A\{B};
use A\{B\C, D};
use A\B\{C\D, E};
use function A\{b\c, d};
use const A\{B\C, D};
use A\B\{C\D, function b\c, const D};

View file

@ -0,0 +1,27 @@
__halt_compiler
-----
<?php
echo 'foo';
__halt_compiler();
!!!
???
-----
<?php
echo 'foo';
__halt_compiler();
!!!
???
-----
<?php
echo 'foo';
__halt_compiler();
<?php
-----
<?php
echo 'foo';
__halt_compiler();
<?php

View file

@ -0,0 +1,16 @@
if/elseif/else
-----
<?php
if ($expr) {
} elseif ($expr2) {
} else {
}
-----
if ($expr) {
} elseif ($expr2) {
} else {
}

View file

@ -0,0 +1,19 @@
Multi catch
-----
<?php
try {
$x;
} catch (X|Y $e1) {
$y;
} catch (\A|B\C $e2) {
$z;
}
-----
!!php7
try {
$x;
} catch (X|Y $e1) {
$y;
} catch (\A|B\C $e2) {
$z;
}

View file

@ -0,0 +1,50 @@
Namespaces
-----
<?php
namespace Foo;
function foo()
{
}
namespace Bar;
function bar()
{
}
-----
namespace Foo;
function foo()
{
}
namespace Bar;
function bar()
{
}
-----
<?php
namespace Foo {
function foo()
{
}
}
namespace {
function glob() {
}
}
-----
namespace Foo {
function foo()
{
}
}
namespace {
function glob()
{
}
}

View file

@ -0,0 +1,11 @@
Nullable types
-----
<?php
function test(?Foo $bar, ?string $foo, ?\Xyz $zyx) : ?Baz
{
}
-----
!!php7
function test(?Foo $bar, ?string $foo, ?\Xyz $zyx) : ?Baz
{
}

View file

@ -0,0 +1,35 @@
switch/case/default
-----
<?php
switch ($expr) {
case 0:
echo 'First case, with a break';
break;
case 1:
echo 'Second case, which falls through';
case 2:
case 3:
case 4:
echo 'Third case, return instead of break';
return;
default:
echo 'Default case';
break;
}
-----
switch ($expr) {
case 0:
echo 'First case, with a break';
break;
case 1:
echo 'Second case, which falls through';
case 2:
case 3:
case 4:
echo 'Third case, return instead of break';
return;
default:
echo 'Default case';
break;
}

View file

@ -0,0 +1,7 @@
throw
-----
<?php
throw $e;
-----
throw $e;

View file

@ -0,0 +1,25 @@
Trait uses and adaptations
-----
<?php
class A
{
use B, C, D {
f as g;
f as private;
f as private g;
B::f as g;
B::f insteadof C, D;
}
}
-----
class A
{
use B, C, D {
f as g;
f as private;
f as private g;
B::f as g;
B::f insteadof C, D;
}
}

View file

@ -0,0 +1,24 @@
tryCatch
-----
<?php
try {
} catch (Exception $e) {
}
try {
} catch (Exception $e) {
} finally {
}
-----
try {
} catch (Exception $e) {
}
try {
} catch (Exception $e) {
} finally {
}

View file

@ -0,0 +1,10 @@
while
-----
<?php
while (true) {
}
-----
while (true) {
}