mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Add Composer autoloading functions and PHPStan for testing
This commit is contained in:
parent
e198c4db65
commit
f5d7d4e02a
1518 changed files with 169063 additions and 30 deletions
39
vendor/nikic/php-parser/test/code/formatPreservation/addingPropertyType.test
vendored
Normal file
39
vendor/nikic/php-parser/test/code/formatPreservation/addingPropertyType.test
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
Adding property type
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
|
||||
public $a
|
||||
= 1;
|
||||
}
|
||||
-----
|
||||
$stmts[0]->stmts[0]->type = new Node\Identifier('string');
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
|
||||
public string $a
|
||||
= 1;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
public
|
||||
$b;
|
||||
}
|
||||
-----
|
||||
$stmts[0]->stmts[0]->type = new Node\Identifier('int');
|
||||
-----
|
||||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
public
|
||||
int $b;
|
||||
}
|
28
vendor/nikic/php-parser/test/code/formatPreservation/anonClasses.test
vendored
Normal file
28
vendor/nikic/php-parser/test/code/formatPreservation/anonClasses.test
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
Anonymous classes
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
($x)
|
||||
extends X
|
||||
{ };
|
||||
-----
|
||||
$new = $stmts[0]->expr;
|
||||
$new->class->extends = null;
|
||||
$new->args[] = new Expr\Variable('y');
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
($x, $y)
|
||||
{ };
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
{};
|
||||
-----
|
||||
// Ignore name assigned to anon class
|
||||
$new = $stmts[0]->expr;
|
||||
$new->class->name = new Node\Identifier('Anon1');
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
{};
|
190
vendor/nikic/php-parser/test/code/formatPreservation/basic.test
vendored
Normal file
190
vendor/nikic/php-parser/test/code/formatPreservation/basic.test
vendored
Normal file
|
@ -0,0 +1,190 @@
|
|||
abc1
|
||||
-----
|
||||
<?php
|
||||
echo
|
||||
1
|
||||
+
|
||||
2
|
||||
+
|
||||
3;
|
||||
-----
|
||||
$stmts[0]->exprs[0]->left->right->value = 42;
|
||||
-----
|
||||
<?php
|
||||
echo
|
||||
1
|
||||
+
|
||||
42
|
||||
+
|
||||
3;
|
||||
-----
|
||||
<?php
|
||||
function foo($a)
|
||||
{ return $a; }
|
||||
-----
|
||||
$stmts[0]->name = new Node\Identifier('bar');
|
||||
-----
|
||||
<?php
|
||||
function bar($a)
|
||||
{ return $a; }
|
||||
-----
|
||||
<?php
|
||||
function
|
||||
foo() {
|
||||
call(
|
||||
$bar
|
||||
);
|
||||
}
|
||||
-----
|
||||
// This triggers a fallback
|
||||
$stmts[0]->byRef = true;
|
||||
-----
|
||||
<?php
|
||||
function &foo()
|
||||
{
|
||||
call(
|
||||
$bar
|
||||
);
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function
|
||||
foo() {
|
||||
echo "Start
|
||||
End";
|
||||
}
|
||||
-----
|
||||
// This triggers a fallback
|
||||
$stmts[0]->byRef = true;
|
||||
-----
|
||||
<?php
|
||||
function &foo()
|
||||
{
|
||||
echo "Start
|
||||
End";
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
call1(
|
||||
$bar
|
||||
);
|
||||
}
|
||||
call2(
|
||||
$foo
|
||||
);
|
||||
-----
|
||||
$tmp = $stmts[0]->stmts[0];
|
||||
$stmts[0]->stmts[0] = $stmts[1];
|
||||
$stmts[1] = $tmp;
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
call2(
|
||||
$foo
|
||||
);
|
||||
}
|
||||
call1(
|
||||
$bar
|
||||
);
|
||||
-----
|
||||
<?php
|
||||
x;
|
||||
function test() {
|
||||
call1(
|
||||
$bar
|
||||
);
|
||||
}
|
||||
call2(
|
||||
$foo
|
||||
);
|
||||
-----
|
||||
$tmp = $stmts[1]->stmts[0];
|
||||
$stmts[1]->stmts[0] = $stmts[2];
|
||||
$stmts[2] = $tmp;
|
||||
// Same test, but also removing first statement, triggering fallback
|
||||
array_splice($stmts, 0, 1, []);
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test() {
|
||||
call2(
|
||||
$foo
|
||||
);
|
||||
}
|
||||
call1(
|
||||
$bar
|
||||
);
|
||||
-----
|
||||
<?php
|
||||
echo 1;
|
||||
-----
|
||||
$stmts[0] = new Stmt\Expression(
|
||||
new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')));
|
||||
-----
|
||||
<?php
|
||||
$a = $b;
|
||||
-----
|
||||
<?php
|
||||
echo$a;
|
||||
-----
|
||||
$stmts[0]->exprs[0] = new Expr\ConstFetch(new Node\Name('C'));
|
||||
-----
|
||||
<?php
|
||||
echo C;
|
||||
-----
|
||||
<?php
|
||||
function foo() {
|
||||
foo();
|
||||
/*
|
||||
* bar
|
||||
*/
|
||||
baz();
|
||||
}
|
||||
|
||||
{
|
||||
$x;
|
||||
}
|
||||
-----
|
||||
$tmp = $stmts[0];
|
||||
$stmts[0] = $stmts[1];
|
||||
$stmts[1] = $tmp;
|
||||
/* TODO This used to do two replacement operations, but with the node list diffing this is a
|
||||
* remove, keep, add (which probably makes more sense). As such, this currently triggers a
|
||||
* fallback. */
|
||||
-----
|
||||
<?php
|
||||
|
||||
$x;
|
||||
function foo() {
|
||||
foo();
|
||||
/*
|
||||
* bar
|
||||
*/
|
||||
baz();
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
echo "${foo}bar";
|
||||
echo "${foo['baz']}bar";
|
||||
-----
|
||||
$stmts[0]->exprs[0]->parts[0] = new Expr\Variable('bar');
|
||||
$stmts[1]->exprs[0]->parts[0] = new Expr\Variable('bar');
|
||||
-----
|
||||
<?php
|
||||
echo "{$bar}bar";
|
||||
echo "{$bar}bar";
|
||||
-----
|
||||
<?php
|
||||
[$a
|
||||
,$b
|
||||
,
|
||||
,] = $b;
|
||||
-----
|
||||
/* Nothing */
|
||||
-----
|
||||
<?php
|
||||
[$a
|
||||
,$b
|
||||
,
|
||||
,] = $b;
|
29
vendor/nikic/php-parser/test/code/formatPreservation/blockConversion.test
vendored
Normal file
29
vendor/nikic/php-parser/test/code/formatPreservation/blockConversion.test
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
It may be necessary to convert a single statement into a block
|
||||
-----
|
||||
<?php
|
||||
|
||||
if
|
||||
($a) $b;
|
||||
-----
|
||||
// TODO Avoid fallback
|
||||
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('c'));
|
||||
-----
|
||||
<?php
|
||||
|
||||
if ($a) {
|
||||
$b;
|
||||
$c;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
if
|
||||
($a) {$b;}
|
||||
-----
|
||||
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('c'));
|
||||
-----
|
||||
<?php
|
||||
|
||||
if
|
||||
($a) {$b;
|
||||
$c;}
|
52
vendor/nikic/php-parser/test/code/formatPreservation/comments.test
vendored
Normal file
52
vendor/nikic/php-parser/test/code/formatPreservation/comments.test
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
Comment changes
|
||||
-----
|
||||
<?php
|
||||
// Test
|
||||
foo();
|
||||
-----
|
||||
$stmts[0]->setAttribute('comments', []);
|
||||
-----
|
||||
<?php
|
||||
foo();
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
|
||||
|
||||
/* bar */
|
||||
$baz;
|
||||
-----
|
||||
$comments = $stmts[1]->getComments();
|
||||
$comments[] = new Comment("// foo");
|
||||
$stmts[1]->setAttribute('comments', $comments);
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
|
||||
|
||||
/* bar */
|
||||
// foo
|
||||
$baz;
|
||||
-----
|
||||
<?php
|
||||
class Test {
|
||||
/**
|
||||
* @expectedException \FooException
|
||||
*/
|
||||
public function test() {
|
||||
// some code
|
||||
}
|
||||
}
|
||||
-----
|
||||
$method = $stmts[0]->stmts[0];
|
||||
$method->setAttribute('comments', [new Comment\Doc("/**\n *\n */")]);
|
||||
-----
|
||||
<?php
|
||||
class Test {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function test() {
|
||||
// some code
|
||||
}
|
||||
}
|
67
vendor/nikic/php-parser/test/code/formatPreservation/fixup.test
vendored
Normal file
67
vendor/nikic/php-parser/test/code/formatPreservation/fixup.test
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
Fixup for precedence and some special syntax
|
||||
-----
|
||||
<?php
|
||||
$a ** $b * $c;
|
||||
$a + $b * $c;
|
||||
$a * $b + $c;
|
||||
$a ? $b : $c;
|
||||
($a ** $b) * $c;
|
||||
( $a ** $b ) * $c;
|
||||
!$a = $b;
|
||||
-----
|
||||
// Parens necessary
|
||||
$stmts[0]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
// The parens here are "correct", because add is left assoc
|
||||
$stmts[1]->expr->right = new Expr\BinaryOp\Plus(new Expr\Variable('b'), new Expr\Variable('c'));
|
||||
// No parens necessary
|
||||
$stmts[2]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
// Parens for RHS not strictly necessary due to assign speciality
|
||||
$stmts[3]->expr->cond = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[3]->expr->if = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[3]->expr->else = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
// Already has parens
|
||||
$stmts[4]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[5]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
-----
|
||||
<?php
|
||||
($a + $b) * $c;
|
||||
$a + ($b + $c);
|
||||
$a + $b + $c;
|
||||
($a = $b) ? $a = $b : ($a = $b);
|
||||
($a + $b) * $c;
|
||||
( $a + $b ) * $c;
|
||||
!$a = $b;
|
||||
-----
|
||||
<?php
|
||||
foo ();
|
||||
foo ();
|
||||
$foo -> bar;
|
||||
$foo -> bar;
|
||||
$foo -> bar;
|
||||
$foo -> bar;
|
||||
$foo -> bar;
|
||||
self :: $foo;
|
||||
self :: $foo;
|
||||
-----
|
||||
$stmts[0]->expr->name = new Expr\Variable('a');
|
||||
$stmts[1]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[2]->expr->var = new Expr\Variable('bar');
|
||||
$stmts[3]->expr->var = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[4]->expr->name = new Node\Identifier('foo');
|
||||
// In this case the braces are not strictly necessary. However, on PHP 5 they may be required
|
||||
// depending on where the property fetch node itself occurs.
|
||||
$stmts[5]->expr->name = new Expr\Variable('bar');
|
||||
$stmts[6]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
$stmts[7]->expr->name = new Node\VarLikeIdentifier('bar');
|
||||
$stmts[8]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b'));
|
||||
-----
|
||||
<?php
|
||||
$a ();
|
||||
($a . $b) ();
|
||||
$bar -> bar;
|
||||
($a . $b) -> bar;
|
||||
$foo -> foo;
|
||||
$foo -> {$bar};
|
||||
$foo -> {$a . $b};
|
||||
self :: $bar;
|
||||
self :: ${$a . $b};
|
54
vendor/nikic/php-parser/test/code/formatPreservation/inlineHtml.test
vendored
Normal file
54
vendor/nikic/php-parser/test/code/formatPreservation/inlineHtml.test
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
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 Fix broken result
|
||||
$stmts[0]->stmts[1] = $stmts[0]->stmts[2];
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test() {
|
||||
foo();<?php
|
||||
baz();
|
||||
baz();
|
||||
}
|
176
vendor/nikic/php-parser/test/code/formatPreservation/insertionOfNullable.test
vendored
Normal file
176
vendor/nikic/php-parser/test/code/formatPreservation/insertionOfNullable.test
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
Insertion of a nullable node
|
||||
-----
|
||||
<?php
|
||||
|
||||
// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
|
||||
|
||||
function
|
||||
foo(
|
||||
$x,
|
||||
&$y
|
||||
)
|
||||
{}
|
||||
|
||||
$foo
|
||||
[
|
||||
];
|
||||
|
||||
[
|
||||
$value
|
||||
];
|
||||
|
||||
function
|
||||
()
|
||||
{};
|
||||
|
||||
$x
|
||||
?
|
||||
:
|
||||
$y;
|
||||
|
||||
yield
|
||||
$v ;
|
||||
yield ;
|
||||
|
||||
break
|
||||
;
|
||||
continue
|
||||
;
|
||||
return
|
||||
;
|
||||
|
||||
class
|
||||
X
|
||||
{
|
||||
public
|
||||
function y()
|
||||
{}
|
||||
|
||||
private
|
||||
$x
|
||||
;
|
||||
}
|
||||
|
||||
foreach (
|
||||
$x
|
||||
as
|
||||
$y
|
||||
) {}
|
||||
|
||||
static
|
||||
$var
|
||||
;
|
||||
|
||||
try {
|
||||
} catch (X
|
||||
$y) {
|
||||
}
|
||||
|
||||
if ($cond) { // Foo
|
||||
} elseif ($cond2) { // Bar
|
||||
}
|
||||
-----
|
||||
$stmts[0]->returnType = new Node\Name('Foo');
|
||||
$stmts[0]->params[0]->type = new Node\Identifier('int');
|
||||
$stmts[0]->params[1]->type = new Node\Identifier('array');
|
||||
$stmts[0]->params[1]->default = new Expr\ConstFetch(new Node\Name('null'));
|
||||
$stmts[1]->expr->dim = new Expr\Variable('a');
|
||||
$stmts[2]->expr->items[0]->key = new Scalar\String_('X');
|
||||
$stmts[3]->expr->returnType = new Node\Name('Bar');
|
||||
$stmts[4]->expr->if = new Expr\Variable('z');
|
||||
$stmts[5]->expr->key = new Expr\Variable('k');
|
||||
$stmts[6]->expr->value = new Expr\Variable('v');
|
||||
$stmts[7]->num = new Scalar\LNumber(2);
|
||||
$stmts[8]->num = new Scalar\LNumber(2);
|
||||
$stmts[9]->expr = new Expr\Variable('x');
|
||||
$stmts[10]->extends = new Node\Name\FullyQualified('Bar');
|
||||
$stmts[10]->stmts[0]->returnType = new Node\Name('Y');
|
||||
$stmts[10]->stmts[1]->props[0]->default = new Scalar\DNumber(42.0);
|
||||
$stmts[11]->keyVar = new Expr\Variable('z');
|
||||
$stmts[12]->vars[0]->default = new Scalar\String_('abc');
|
||||
$stmts[13]->finally = new Stmt\Finally_([]);
|
||||
$stmts[14]->else = new Stmt\Else_([]);
|
||||
-----
|
||||
<?php
|
||||
|
||||
// TODO: The result spacing isn't always optimal. We may want to skip whitespace in some cases.
|
||||
|
||||
function
|
||||
foo(
|
||||
int $x,
|
||||
array &$y = null
|
||||
) : Foo
|
||||
{}
|
||||
|
||||
$foo
|
||||
[$a
|
||||
];
|
||||
|
||||
[
|
||||
'X' => $value
|
||||
];
|
||||
|
||||
function
|
||||
() : Bar
|
||||
{};
|
||||
|
||||
$x
|
||||
? $z
|
||||
:
|
||||
$y;
|
||||
|
||||
yield
|
||||
$k => $v ;
|
||||
yield $v ;
|
||||
|
||||
break 2
|
||||
;
|
||||
continue 2
|
||||
;
|
||||
return $x
|
||||
;
|
||||
|
||||
class
|
||||
X extends \Bar
|
||||
{
|
||||
public
|
||||
function y() : Y
|
||||
{}
|
||||
|
||||
private
|
||||
$x = 42.0
|
||||
;
|
||||
}
|
||||
|
||||
foreach (
|
||||
$x
|
||||
as
|
||||
$z => $y
|
||||
) {}
|
||||
|
||||
static
|
||||
$var = 'abc'
|
||||
;
|
||||
|
||||
try {
|
||||
} catch (X
|
||||
$y) {
|
||||
} finally {
|
||||
}
|
||||
|
||||
if ($cond) { // Foo
|
||||
} elseif ($cond2) { // Bar
|
||||
} else {
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace
|
||||
{ echo 42; }
|
||||
-----
|
||||
$stmts[0]->name = new Node\Name('Foo');
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Foo
|
||||
{ echo 42; }
|
312
vendor/nikic/php-parser/test/code/formatPreservation/listInsertion.test
vendored
Normal file
312
vendor/nikic/php-parser/test/code/formatPreservation/listInsertion.test
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
Insertion into list nodes
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
|
||||
$bar;
|
||||
-----
|
||||
$stmts[] = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
|
||||
$bar;
|
||||
$baz;
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test() {
|
||||
$foo;
|
||||
|
||||
$bar;
|
||||
}
|
||||
-----
|
||||
$stmts[0]->stmts[] = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test() {
|
||||
$foo;
|
||||
|
||||
$bar;
|
||||
$baz;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test(Foo $param1) {}
|
||||
-----
|
||||
$stmts[0]->params[] = new Node\Param(new Expr\Variable('param2'));
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test(Foo $param1, $param2) {}
|
||||
-----
|
||||
<?php
|
||||
|
||||
try {
|
||||
/* stuff */
|
||||
} catch
|
||||
(Foo $x) {}
|
||||
-----
|
||||
$stmts[0]->catches[0]->types[] = new Node\Name('Bar');
|
||||
-----
|
||||
<?php
|
||||
|
||||
try {
|
||||
/* stuff */
|
||||
} catch
|
||||
(Foo|Bar $x) {}
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test(Foo $param1) {}
|
||||
-----
|
||||
array_unshift($stmts[0]->params, new Node\Param(new Expr\Variable('param0')));
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test($param0, Foo $param1) {}
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test() {}
|
||||
-----
|
||||
$stmts[0]->params[] = new Node\Param(new Expr\Variable('param0'));
|
||||
/* Insertion into empty list not handled yet */
|
||||
-----
|
||||
<?php
|
||||
|
||||
function test($param0)
|
||||
{
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
if ($cond) {
|
||||
} elseif ($cond2) {
|
||||
}
|
||||
-----
|
||||
$stmts[0]->elseifs[] = new Stmt\ElseIf_(new Expr\Variable('cond3'), []);
|
||||
-----
|
||||
<?php
|
||||
|
||||
if ($cond) {
|
||||
} elseif ($cond2) {
|
||||
} elseif ($cond3) {
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
|
||||
try {
|
||||
} catch (Foo $foo) {
|
||||
}
|
||||
-----
|
||||
$stmts[0]->catches[] = new Stmt\Catch_([new Node\Name('Bar')], new Expr\Variable('bar'), []);
|
||||
-----
|
||||
<?php
|
||||
|
||||
try {
|
||||
} catch (Foo $foo) {
|
||||
} catch (Bar $bar) {
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
$foo; $bar;
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test')]);
|
||||
$stmts[] = $node;
|
||||
-----
|
||||
<?php
|
||||
$foo; $bar;
|
||||
// Test
|
||||
$baz;
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test'), new Comment('// Test 2')]);
|
||||
$stmts[0]->stmts[] = $node;
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
$foo; $bar;
|
||||
// Test
|
||||
// Test 2
|
||||
$baz;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
namespace
|
||||
Foo;
|
||||
-----
|
||||
$stmts[0]->name->parts[0] = 'Xyz';
|
||||
-----
|
||||
<?php
|
||||
namespace
|
||||
Xyz;
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
array_unshift($stmts[0]->stmts, $node);
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
$baz;
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test')]);
|
||||
array_unshift($stmts[0]->stmts, $node);
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
// Test
|
||||
$baz;
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test')]);
|
||||
array_unshift($stmts[0]->stmts, $node);
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Test
|
||||
$baz;
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test')]);
|
||||
array_unshift($stmts[0]->stmts, $node);
|
||||
$stmts[0]->stmts[1]->setAttribute('comments', [new Comment('// Bar foo')]);
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Test
|
||||
$baz;
|
||||
// Bar foo
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
$node = new Stmt\Expression(new Expr\Variable('baz'));
|
||||
$node->setAttribute('comments', [new Comment('// Test')]);
|
||||
array_unshift($stmts[0]->stmts, $node);
|
||||
$stmts[0]->stmts[1]->setAttribute('comments', []);
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Test
|
||||
$baz;
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
array_unshift(
|
||||
$stmts[0]->stmts,
|
||||
new Stmt\Expression(new Expr\Variable('a')),
|
||||
new Stmt\Expression(new Expr\Variable('b')));
|
||||
-----
|
||||
<?php
|
||||
function test() {
|
||||
|
||||
$a;
|
||||
$b;
|
||||
// Foo bar
|
||||
$foo; $bar;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
function test() {}
|
||||
-----
|
||||
/* Insertion into empty list not handled yet */
|
||||
$stmts[0]->stmts = [
|
||||
new Stmt\Expression(new Expr\Variable('a')),
|
||||
new Stmt\Expression(new Expr\Variable('b')),
|
||||
];
|
||||
-----
|
||||
<?php
|
||||
function test()
|
||||
{
|
||||
$a;
|
||||
$b;
|
||||
}
|
||||
-----
|
||||
<?php
|
||||
$array = [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
];
|
||||
-----
|
||||
array_unshift($stmts[0]->expr->expr->items, new Expr\ArrayItem(new Scalar\LNumber(42)));
|
||||
$stmts[0]->expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24));
|
||||
-----
|
||||
<?php
|
||||
$array = [
|
||||
42,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
24,
|
||||
];
|
||||
-----
|
||||
<?php
|
||||
$array = [
|
||||
1, 2,
|
||||
3,
|
||||
];
|
||||
-----
|
||||
$stmts[0]->expr->expr->items[] = new Expr\ArrayItem(new Scalar\LNumber(24));
|
||||
-----
|
||||
<?php
|
||||
$array = [
|
||||
1, 2,
|
||||
3, 24,
|
||||
];
|
17
vendor/nikic/php-parser/test/code/formatPreservation/listInsertionIndentation.test
vendored
Normal file
17
vendor/nikic/php-parser/test/code/formatPreservation/listInsertionIndentation.test
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
Check correct indentation use when inserting into list node
|
||||
-----
|
||||
<?php
|
||||
$this->foo = new Foo;
|
||||
$this->foo->a()
|
||||
->b();
|
||||
-----
|
||||
$outerCall = $stmts[1]->expr;
|
||||
$innerCall = $outerCall->var;
|
||||
$var = $innerCall->var;
|
||||
$stmts[1]->expr = $innerCall;
|
||||
$stmts[2] = new Stmt\Expression(new Expr\MethodCall($var, $outerCall->name));
|
||||
-----
|
||||
<?php
|
||||
$this->foo = new Foo;
|
||||
$this->foo->a();
|
||||
$this->foo->b();
|
41
vendor/nikic/php-parser/test/code/formatPreservation/listRemoval.test
vendored
Normal file
41
vendor/nikic/php-parser/test/code/formatPreservation/listRemoval.test
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
Removing from list nodes
|
||||
-----
|
||||
<?php $foo; $bar; $baz;
|
||||
-----
|
||||
array_splice($stmts, 1, 1, []);
|
||||
-----
|
||||
<?php $foo; $baz;
|
||||
-----
|
||||
<?php
|
||||
function foo(
|
||||
$a,
|
||||
$b,
|
||||
$c
|
||||
) {}
|
||||
-----
|
||||
array_pop($stmts[0]->params);
|
||||
-----
|
||||
<?php
|
||||
function foo(
|
||||
$a,
|
||||
$b
|
||||
) {}
|
||||
-----
|
||||
<?php
|
||||
function foo(
|
||||
$a,
|
||||
$b,
|
||||
$c
|
||||
) {}
|
||||
-----
|
||||
array_pop($stmts[0]->params);
|
||||
$stmts[0]->params[] = new Node\Param(new Expr\Variable('x'));
|
||||
$stmts[0]->params[] = new Node\Param(new Expr\Variable('y'));
|
||||
-----
|
||||
<?php
|
||||
function foo(
|
||||
$a,
|
||||
$b,
|
||||
$x,
|
||||
$y
|
||||
) {}
|
33
vendor/nikic/php-parser/test/code/formatPreservation/modifierChange.test
vendored
Normal file
33
vendor/nikic/php-parser/test/code/formatPreservation/modifierChange.test
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
Modifier change
|
||||
-----
|
||||
<?php
|
||||
class Foo {}
|
||||
abstract class Bar {
|
||||
const
|
||||
FOO = 42;
|
||||
|
||||
var $foo
|
||||
= 24;
|
||||
|
||||
public function
|
||||
foo() {}
|
||||
}
|
||||
-----
|
||||
$stmts[0]->flags = Stmt\Class_::MODIFIER_ABSTRACT;
|
||||
$stmts[1]->flags = 0;
|
||||
$stmts[1]->stmts[0]->flags = Stmt\Class_::MODIFIER_PRIVATE;
|
||||
$stmts[1]->stmts[1]->flags = Stmt\Class_::MODIFIER_PROTECTED;
|
||||
$stmts[1]->stmts[2]->flags |= Stmt\Class_::MODIFIER_FINAL;
|
||||
-----
|
||||
<?php
|
||||
abstract class Foo {}
|
||||
class Bar {
|
||||
private const
|
||||
FOO = 42;
|
||||
|
||||
protected $foo
|
||||
= 24;
|
||||
|
||||
public final function
|
||||
foo() {}
|
||||
}
|
11
vendor/nikic/php-parser/test/code/formatPreservation/nopCommentAtEnd.test
vendored
Normal file
11
vendor/nikic/php-parser/test/code/formatPreservation/nopCommentAtEnd.test
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
Nop statement with comment at end (#513)
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
$bar;
|
||||
-----
|
||||
$stmts[1] = new Stmt\Nop(['comments' => [new Comment('//Some comment here')]]);
|
||||
-----
|
||||
<?php
|
||||
$foo;
|
||||
//Some comment here
|
194
vendor/nikic/php-parser/test/code/formatPreservation/removalViaNull.test
vendored
Normal file
194
vendor/nikic/php-parser/test/code/formatPreservation/removalViaNull.test
vendored
Normal file
|
@ -0,0 +1,194 @@
|
|||
Removing subnodes by setting them to null
|
||||
-----
|
||||
<?php
|
||||
function
|
||||
foo (
|
||||
Bar $foo
|
||||
= null,
|
||||
Foo $bar) : baz
|
||||
{}
|
||||
|
||||
function
|
||||
()
|
||||
: int
|
||||
{};
|
||||
|
||||
class
|
||||
Foo
|
||||
extends
|
||||
Bar
|
||||
{
|
||||
public
|
||||
function
|
||||
foo() : ?X {}
|
||||
|
||||
public
|
||||
$prop = 'x'
|
||||
;
|
||||
|
||||
use T {
|
||||
T
|
||||
::
|
||||
x
|
||||
as
|
||||
public
|
||||
y
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$foo [ $bar ];
|
||||
exit ( $bar );
|
||||
$foo
|
||||
? $bar :
|
||||
$baz;
|
||||
[ $a => $b
|
||||
, $c => $d];
|
||||
|
||||
yield
|
||||
$foo
|
||||
=>
|
||||
$bar;
|
||||
yield
|
||||
$bar;
|
||||
|
||||
break
|
||||
2
|
||||
;
|
||||
continue
|
||||
2
|
||||
;
|
||||
|
||||
foreach(
|
||||
$array
|
||||
as
|
||||
$key
|
||||
=>
|
||||
$value
|
||||
) {}
|
||||
|
||||
if
|
||||
($x)
|
||||
{
|
||||
}
|
||||
|
||||
else {}
|
||||
|
||||
return
|
||||
$val
|
||||
;
|
||||
static
|
||||
$x
|
||||
=
|
||||
$y
|
||||
;
|
||||
|
||||
try {} catch
|
||||
(X $y)
|
||||
{}
|
||||
finally
|
||||
{}
|
||||
-----
|
||||
$stmts[0]->returnType = null;
|
||||
$stmts[0]->params[0]->default = null;
|
||||
$stmts[0]->params[1]->type = null;
|
||||
$stmts[1]->expr->returnType = null;
|
||||
$stmts[2]->extends = null;
|
||||
$stmts[2]->stmts[0]->returnType = null;
|
||||
$stmts[2]->stmts[1]->props[0]->default = null;
|
||||
$stmts[2]->stmts[2]->adaptations[0]->newName = null;
|
||||
$stmts[3]->expr->dim = null;
|
||||
$stmts[4]->expr->expr = null;
|
||||
$stmts[5]->expr->if = null;
|
||||
$stmts[6]->expr->items[1]->key = null;
|
||||
$stmts[7]->expr->key = null;
|
||||
$stmts[8]->expr->value = null;
|
||||
$stmts[9]->num = null;
|
||||
$stmts[10]->num = null;
|
||||
$stmts[11]->keyVar = null;
|
||||
$stmts[12]->else = null;
|
||||
$stmts[13]->expr = null;
|
||||
$stmts[14]->vars[0]->default = null;
|
||||
$stmts[15]->finally = null;
|
||||
-----
|
||||
<?php
|
||||
function
|
||||
foo (
|
||||
Bar $foo,
|
||||
$bar)
|
||||
{}
|
||||
|
||||
function
|
||||
()
|
||||
{};
|
||||
|
||||
class
|
||||
Foo
|
||||
{
|
||||
public
|
||||
function
|
||||
foo() {}
|
||||
|
||||
public
|
||||
$prop
|
||||
;
|
||||
|
||||
use T {
|
||||
T
|
||||
::
|
||||
x
|
||||
as
|
||||
public
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
$foo [];
|
||||
exit ();
|
||||
$foo
|
||||
?:
|
||||
$baz;
|
||||
[ $a => $b
|
||||
, $d];
|
||||
|
||||
yield
|
||||
$bar;
|
||||
yield;
|
||||
|
||||
break;
|
||||
continue;
|
||||
|
||||
foreach(
|
||||
$array
|
||||
as
|
||||
$value
|
||||
) {}
|
||||
|
||||
if
|
||||
($x)
|
||||
{
|
||||
}
|
||||
|
||||
return;
|
||||
static
|
||||
$x
|
||||
;
|
||||
|
||||
try {} catch
|
||||
(X $y)
|
||||
{}
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace
|
||||
A
|
||||
{
|
||||
}
|
||||
-----
|
||||
$stmts[0]->name = null;
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace
|
||||
{
|
||||
}
|
22
vendor/nikic/php-parser/test/code/formatPreservation/removingPropertyType.test
vendored
Normal file
22
vendor/nikic/php-parser/test/code/formatPreservation/removingPropertyType.test
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
Removing property type
|
||||
-----
|
||||
<?php
|
||||
|
||||
class B
|
||||
{
|
||||
|
||||
public
|
||||
?float
|
||||
$b;
|
||||
}
|
||||
-----
|
||||
$stmts[0]->stmts[0]->type = null;
|
||||
-----
|
||||
<?php
|
||||
|
||||
class B
|
||||
{
|
||||
|
||||
public
|
||||
$b;
|
||||
}
|
19
vendor/nikic/php-parser/test/code/formatPreservation/traitAlias.test
vendored
Normal file
19
vendor/nikic/php-parser/test/code/formatPreservation/traitAlias.test
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Trait alias
|
||||
-----
|
||||
<?php
|
||||
class X {
|
||||
use T {
|
||||
exit
|
||||
as die;
|
||||
}
|
||||
}
|
||||
-----
|
||||
/* do nothing */
|
||||
-----
|
||||
<?php
|
||||
class X {
|
||||
use T {
|
||||
exit
|
||||
as die;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue