2018-09-25 23:52:27 +02:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2018-10-26 06:59:14 +02:00
|
|
|
use PhpParser;
|
|
|
|
|
2018-09-25 23:52:27 +02:00
|
|
|
class FileDiffTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider getChanges
|
|
|
|
*
|
|
|
|
* @param string $a
|
|
|
|
* @param string $b
|
|
|
|
* @param string[] $same_methods
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-26 23:54:08 +02:00
|
|
|
public function testCode(
|
|
|
|
string $a,
|
|
|
|
string $b,
|
|
|
|
array $same_methods,
|
|
|
|
array $same_signatures,
|
|
|
|
array $changed_methods,
|
|
|
|
array $diff_map_offsets
|
|
|
|
) {
|
2018-09-25 23:52:27 +02:00
|
|
|
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
|
|
|
|
$this->markTestSkipped();
|
|
|
|
}
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$a_stmts = \Psalm\Internal\Provider\StatementsProvider::parseStatements($a);
|
|
|
|
$b_stmts = \Psalm\Internal\Provider\StatementsProvider::parseStatements($b);
|
2018-09-25 23:52:27 +02:00
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$diff = \Psalm\Internal\Diff\FileStatementsDiffer::diff($a_stmts, $b_stmts, $a, $b);
|
2018-09-25 23:52:27 +02:00
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$same_methods,
|
|
|
|
$diff[0]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$same_signatures,
|
|
|
|
$diff[1]
|
|
|
|
);
|
2018-09-26 22:33:59 +02:00
|
|
|
|
2018-09-26 23:54:08 +02:00
|
|
|
$this->assertSame(
|
|
|
|
$changed_methods,
|
|
|
|
$diff[2]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame(count($diff_map_offsets), count($diff[3]));
|
2018-09-26 22:33:59 +02:00
|
|
|
|
|
|
|
$found_offsets = array_map(
|
|
|
|
/**
|
|
|
|
* @param array{0: int, 1: int, 2: int, 3: int} $arr
|
|
|
|
*
|
|
|
|
* @return array{0: int, 1: int}
|
|
|
|
*/
|
|
|
|
function (array $arr) {
|
|
|
|
return [$arr[2], $arr[3]];
|
|
|
|
},
|
2018-09-26 23:54:08 +02:00
|
|
|
$diff[3]
|
2018-09-26 22:33:59 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame($diff_map_offsets, $found_offsets);
|
2018-09-25 23:52:27 +02:00
|
|
|
}
|
|
|
|
|
2018-10-26 06:59:14 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider getChanges
|
|
|
|
*
|
|
|
|
* @param string $a
|
|
|
|
* @param string $b
|
|
|
|
* @param string[] $same_methods
|
2019-02-23 22:22:39 +01:00
|
|
|
* @param string[] $same_signatures
|
|
|
|
* @param string[] $changed_methods
|
|
|
|
* @param array<array-key,array{int,int}> $diff_map_offsets
|
2018-10-26 06:59:14 +02:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testPartialAstDiff(
|
|
|
|
string $a,
|
|
|
|
string $b,
|
|
|
|
array $same_methods,
|
|
|
|
array $same_signatures,
|
|
|
|
array $changed_methods,
|
|
|
|
array $diff_map_offsets
|
|
|
|
) {
|
|
|
|
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
|
|
|
|
$this->markTestSkipped();
|
|
|
|
}
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$file_changes = \Psalm\Internal\Diff\FileDiffer::getDiff($a, $b);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$a_stmts = \Psalm\Internal\Provider\StatementsProvider::parseStatements($a);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$traverser = new PhpParser\NodeTraverser;
|
2018-11-06 03:57:36 +01:00
|
|
|
$traverser->addVisitor(new \Psalm\Internal\Visitor\CloningVisitor);
|
2018-10-26 06:59:14 +02:00
|
|
|
// performs a deep clone
|
|
|
|
/** @var array<int, PhpParser\Node\Stmt> */
|
|
|
|
$a_stmts_copy = $traverser->traverse($a_stmts);
|
|
|
|
|
|
|
|
$this->assertTreesEqual($a_stmts, $a_stmts_copy);
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$b_stmts = \Psalm\Internal\Provider\StatementsProvider::parseStatements($b, null, $a, $a_stmts_copy, $file_changes);
|
|
|
|
$b_clean_stmts = \Psalm\Internal\Provider\StatementsProvider::parseStatements($b);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$this->assertTreesEqual($b_clean_stmts, $b_stmts);
|
|
|
|
|
2018-11-06 03:57:36 +01:00
|
|
|
$diff = \Psalm\Internal\Diff\FileStatementsDiffer::diff($a_stmts, $b_clean_stmts, $a, $b);
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$same_methods,
|
|
|
|
$diff[0]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$same_signatures,
|
|
|
|
$diff[1]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$changed_methods,
|
|
|
|
$diff[2]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame(count($diff_map_offsets), count($diff[3]));
|
|
|
|
|
|
|
|
$found_offsets = array_map(
|
|
|
|
/**
|
|
|
|
* @param array{0: int, 1: int, 2: int, 3: int} $arr
|
|
|
|
*
|
|
|
|
* @return array{0: int, 1: int}
|
|
|
|
*/
|
|
|
|
function (array $arr) {
|
|
|
|
return [$arr[2], $arr[3]];
|
|
|
|
},
|
|
|
|
$diff[3]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertSame($diff_map_offsets, $found_offsets);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<int, PhpParser\Node\Stmt> $a
|
|
|
|
* @param array<int, PhpParser\Node\Stmt> $b
|
2019-03-23 19:27:54 +01:00
|
|
|
*
|
2018-10-26 06:59:14 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function assertTreesEqual(array $a, array $b)
|
|
|
|
{
|
|
|
|
$this->assertSame(count($a), count($b));
|
|
|
|
|
|
|
|
foreach ($a as $i => $a_stmt) {
|
|
|
|
$b_stmt = $b[$i];
|
|
|
|
|
|
|
|
$this->assertNotSame($a_stmt, $b_stmt);
|
|
|
|
|
|
|
|
$this->assertSame(get_class($a_stmt), get_class($b_stmt));
|
|
|
|
|
|
|
|
if ($a_stmt instanceof PhpParser\Node\Stmt\Expression
|
|
|
|
&& $b_stmt instanceof PhpParser\Node\Stmt\Expression
|
|
|
|
) {
|
|
|
|
$this->assertSame(get_class($a_stmt->expr), get_class($b_stmt->expr));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($a_doc = $a_stmt->getDocComment()) {
|
|
|
|
$b_doc = $b_stmt->getDocComment();
|
|
|
|
|
2018-10-26 19:22:41 +02:00
|
|
|
$this->assertNotNull($b_doc, var_export($a_doc, true));
|
2018-10-26 06:59:14 +02:00
|
|
|
|
|
|
|
$this->assertNotSame($a_doc, $b_doc);
|
|
|
|
|
|
|
|
$this->assertSame($a_doc->getLine(), $b_doc->getLine());
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertSame(
|
|
|
|
$a_stmt->getAttribute('startFilePos'),
|
|
|
|
$b_stmt->getAttribute('startFilePos')
|
|
|
|
);
|
|
|
|
$this->assertSame(
|
|
|
|
$a_stmt->getAttribute('endFilePos'),
|
|
|
|
$b_stmt->getAttribute('endFilePos'),
|
|
|
|
($a_stmt instanceof PhpParser\Node\Stmt\Expression
|
|
|
|
? get_class($a_stmt->expr)
|
|
|
|
: get_class($a_stmt))
|
|
|
|
. ' on line ' . $a_stmt->getLine()
|
|
|
|
);
|
|
|
|
$this->assertSame($a_stmt->getLine(), $b_stmt->getLine());
|
|
|
|
|
|
|
|
if (isset($a_stmt->stmts)) {
|
|
|
|
$this->assertTrue(isset($b_stmt->stmts));
|
|
|
|
|
2019-03-01 14:45:18 +01:00
|
|
|
/**
|
|
|
|
* @psalm-suppress UndefinedPropertyFetch
|
|
|
|
* @psalm-suppress MixedArgument
|
|
|
|
*/
|
2018-10-26 06:59:14 +02:00
|
|
|
$this->assertTreesEqual($a_stmt->stmts, $b_stmt->stmts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-25 23:52:27 +02:00
|
|
|
/**
|
2019-02-23 22:22:39 +01:00
|
|
|
* @return array<string,array{string,string,string[],string[],string[],array<array-key,array{int,int}>}>
|
2018-09-25 23:52:27 +02:00
|
|
|
*/
|
|
|
|
public function getChanges()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'sameFile' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
2018-10-26 22:17:15 +02:00
|
|
|
}',
|
|
|
|
['foo\a::$aB', 'foo\a::F', 'foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0], [0, 0], [0, 0]],
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
|
|
|
'sameFileWithDoubleDocblocks' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* another
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is one line
|
|
|
|
// this is another
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* another
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is one line
|
|
|
|
// this is another
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
2018-09-25 23:52:27 +02:00
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::$aB', 'foo\a::F', 'foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0], [0, 0], [0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-09-26 22:33:59 +02:00
|
|
|
'lineChanges' => [
|
2018-09-25 23:52:27 +02:00
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-09-26 22:33:59 +02:00
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-09-26 22:33:59 +02:00
|
|
|
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-09-26 22:33:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
2018-09-26 22:33:59 +02:00
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::$aB', 'foo\a::F', 'foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[1, 1], [2, 2], [2, 2], [5, 5]],
|
2018-09-26 22:33:59 +02:00
|
|
|
],
|
2018-10-26 06:59:14 +02:00
|
|
|
'simpleBodyChangeWithoutSignatureChange' => [
|
2018-09-26 22:33:59 +02:00
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-07 04:58:21 +02:00
|
|
|
public function foo() : void {
|
2018-09-26 22:33:59 +02:00
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-07 04:58:21 +02:00
|
|
|
public function bar() : void {
|
2018-09-26 22:33:59 +02:00
|
|
|
$b = 1;
|
2018-09-25 23:52:27 +02:00
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-07 04:58:21 +02:00
|
|
|
public function foo() : void {
|
2018-09-26 22:33:59 +02:00
|
|
|
$a = 12;
|
|
|
|
}
|
2018-10-07 04:58:21 +02:00
|
|
|
public function bar() : void {
|
2018-09-26 22:33:59 +02:00
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::bar'],
|
2018-09-25 23:52:27 +02:00
|
|
|
['foo\a::foo'],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[1, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-10-26 06:59:14 +02:00
|
|
|
'simpleBodyChangesWithoutSignatureChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() : void {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
public function bar() : void {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::bar'],
|
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[32, 1]],
|
2018-10-26 06:59:14 +02:00
|
|
|
],
|
2018-09-25 23:52:27 +02:00
|
|
|
'simpleBodyChangeWithSignatureChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar(string $a) {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::foo'],
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bar', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'propertyChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $b;
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::$a', 'foo\a::$b'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'propertyDefaultChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $a = 1;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $a = 2;
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
['foo\a::$a'],
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'propertyDefaultAddition' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $a = 2;
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
['foo\a::$a'],
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'propertySignatureChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?string */
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?int */
|
|
|
|
public $a;
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::$a', 'foo\a::$a'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-09-30 17:33:40 +02:00
|
|
|
'propertyStaticChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?string */
|
|
|
|
public static $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?string */
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::$a', 'foo\a::$a'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-30 17:33:40 +02:00
|
|
|
],
|
|
|
|
'propertyVisibilityChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?string */
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var ?string */
|
|
|
|
private $a;
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::$a', 'foo\a::$a'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-30 17:33:40 +02:00
|
|
|
],
|
2018-09-26 22:33:59 +02:00
|
|
|
'addDocblockToFirst' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::bar'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::foo', 'foo\a::foo'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[84, 3]],
|
2018-09-26 22:33:59 +02:00
|
|
|
],
|
|
|
|
'addDocblockToSecond' => [
|
2018-09-25 23:52:27 +02:00
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bar', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'removeDocblock' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bar', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'changeDocblock' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bar', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-09-30 17:33:40 +02:00
|
|
|
'changeMethodVisibility' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
private function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bar', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0]],
|
2018-09-30 17:33:40 +02:00
|
|
|
],
|
2018-09-25 23:52:27 +02:00
|
|
|
'removeFunctionAtEnd' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
['foo\a::bat'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0]],
|
2018-10-26 06:59:14 +02:00
|
|
|
],
|
|
|
|
'addSpaceInFunction' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$c = 3;
|
|
|
|
$d = 4;
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bat() {
|
|
|
|
$e = 5;
|
|
|
|
$f = 6;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$c = 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$d = 4;
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bat() {
|
|
|
|
$e = 5;
|
|
|
|
$f = 6;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::foo', 'foo\a::bat'],
|
|
|
|
['foo\a::bar'],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [4, 4]],
|
2018-10-26 06:59:14 +02:00
|
|
|
],
|
|
|
|
'removeSpaceInFunction' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$c = 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$d = 4;
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bat() {
|
|
|
|
$e = 5;
|
|
|
|
$f = 6;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$c = 3;
|
|
|
|
$d = 4;
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bat() {
|
|
|
|
$e = 5;
|
|
|
|
$f = 6;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::foo', 'foo\a::bat'],
|
|
|
|
['foo\a::bar'],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [-4, -4]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'removeFunctionAtBeginning' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::bar', 'foo\a::bat'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
['foo\a::foo'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[-98, -3], [-98, -3]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'removeFunctionInMiddle' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bat'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
['foo\a::bar'],
|
2019-01-08 06:54:48 +01:00
|
|
|
[[0, 0], [-98, -3]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'changeNamespace' => [
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'removeNamespace' => [
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
class A {
|
|
|
|
public function bar() {
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
[],
|
2018-09-26 22:33:59 +02:00
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'newFunctionAtEnd' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bat'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'newFunctionAtBeginning' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bat'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[183, 7], [183, 7]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'newFunctionInMiddle' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
2018-10-29 20:28:17 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bat() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
2018-10-29 20:28:17 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2018-09-25 23:52:27 +02:00
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\a::bat'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [183, 7]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-10-29 22:12:20 +01:00
|
|
|
'removeAdditionalComments' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* more Comments
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* more Comments
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use D;
|
|
|
|
use E;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[],
|
2018-11-02 02:52:39 +01:00
|
|
|
['use:D', 'use:E', 'foo\a::foo', 'foo\a::bar', 'foo\a::foo', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-10-29 22:12:20 +01:00
|
|
|
],
|
2018-09-26 22:33:59 +02:00
|
|
|
'SKIPPED-whiteSpaceOnly' => [
|
2018-09-25 23:52:27 +02:00
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
|
|
|
|
$a = 1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::foo', 'foo\a::bar'],
|
|
|
|
[],
|
2018-09-26 23:54:08 +02:00
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
|
|
|
'changeDeclaredMethodId' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function __construct() {}
|
|
|
|
public static function bar() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public static function bat() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C extends B { }',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function __construct() {}
|
|
|
|
public static function bar() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public function __construct() {}
|
|
|
|
public static function bar() : void {}
|
|
|
|
public static function bat() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class C extends B { }',
|
2018-09-26 22:33:59 +02:00
|
|
|
['foo\a::__construct', 'foo\a::bar', 'foo\b::bat'],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\b::__construct', 'foo\b::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0], [120, 2]],
|
2018-09-25 23:52:27 +02:00
|
|
|
],
|
2018-10-03 19:58:32 +02:00
|
|
|
'sameTrait' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
public function bar() {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\t::$aB', 'foo\t::F', 'foo\t::foo', 'foo\t::bar'],
|
|
|
|
[],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [0, 0], [0, 0], [0, 0]],
|
2018-10-03 19:58:32 +02:00
|
|
|
],
|
|
|
|
'traitPropertyChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public $a;
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public $b;
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[],
|
2018-10-04 00:16:33 +02:00
|
|
|
['foo\t::$a', 'foo\t::$b'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-10-03 19:58:32 +02:00
|
|
|
],
|
2018-10-26 06:59:14 +02:00
|
|
|
'traitMethodReturnTypeChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function barBar(): string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bat(): string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function barBar(): int {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bat(): string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\t::bat'],
|
|
|
|
[],
|
|
|
|
['foo\t::barbar', 'foo\t::barbar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[-9, 0]],
|
2018-10-26 06:59:14 +02:00
|
|
|
],
|
|
|
|
'removeManyArguments' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function barBar() {
|
|
|
|
foo(
|
|
|
|
$a,
|
|
|
|
$b
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bat() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function barBar() {
|
|
|
|
foo(
|
|
|
|
$a
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bat() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\c::bat'],
|
|
|
|
['foo\c::barbar'],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[-36, -1]],
|
2018-10-26 06:59:14 +02:00
|
|
|
],
|
2018-10-26 17:48:21 +02:00
|
|
|
'docblockTwiceOver' => [
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class Foo
|
|
|
|
{
|
|
|
|
public function a()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function c()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class Foo
|
|
|
|
{
|
|
|
|
public function a()
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function b()
|
|
|
|
{
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function c()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['bar\foo::a', 'bar\foo::c'],
|
|
|
|
[],
|
|
|
|
['bar\foo::b'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[0, 0], [229, 8]],
|
2018-10-26 17:48:21 +02:00
|
|
|
],
|
2018-10-26 19:22:41 +02:00
|
|
|
'removeStatementsAbove' => [
|
|
|
|
'<?php
|
|
|
|
namespace A;
|
|
|
|
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {
|
|
|
|
echo 4;
|
|
|
|
echo 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar() {
|
|
|
|
echo 4;
|
|
|
|
echo 5;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace A;
|
|
|
|
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {
|
|
|
|
echo 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar() {
|
|
|
|
echo 5;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
'a\b::foo',
|
|
|
|
'a\b::bar',
|
|
|
|
],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-10-26 19:22:41 +02:00
|
|
|
],
|
2018-10-27 05:04:38 +02:00
|
|
|
'removeUse' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
['foo\a::foo'],
|
|
|
|
[],
|
|
|
|
['use:Exception'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[-36, -2]],
|
2018-10-27 05:04:38 +02:00
|
|
|
],
|
2018-10-29 22:12:20 +01:00
|
|
|
'vimeoDiff' => [
|
|
|
|
'<?php
|
|
|
|
namespace C;
|
|
|
|
|
|
|
|
class A extends B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Another thing
|
|
|
|
*
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Other thing
|
|
|
|
*
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Some thing
|
|
|
|
*
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function zap() {
|
|
|
|
$a = 1;
|
|
|
|
$b = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Foo
|
|
|
|
*/
|
|
|
|
private function top(
|
|
|
|
D $c
|
|
|
|
) {
|
|
|
|
return $c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'<?php
|
|
|
|
namespace C;
|
|
|
|
|
|
|
|
class A extends B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function rot() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function bar() {
|
|
|
|
return $c;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
['c\a::foo', 'c\a::bar', 'c\a::zap', 'c\a::top', 'c\a::rot', 'c\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-10-29 22:12:20 +01:00
|
|
|
],
|
2018-10-31 01:51:52 +01:00
|
|
|
'noUseChange' => [
|
|
|
|
'<?php
|
|
|
|
namespace A;
|
|
|
|
|
|
|
|
use PhpParser;
|
|
|
|
use Psalm\Aliases;
|
|
|
|
|
|
|
|
class C
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$c = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'<?php
|
|
|
|
namespace A;
|
|
|
|
|
|
|
|
use PhpParser;
|
|
|
|
use Psalm\Aliases;
|
|
|
|
|
|
|
|
class C
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return D
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$d = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
[],
|
|
|
|
['a\c::foo'],
|
|
|
|
[],
|
2019-03-23 19:27:54 +01:00
|
|
|
[],
|
2018-10-31 01:51:52 +01:00
|
|
|
],
|
2018-11-02 00:11:00 +01:00
|
|
|
'diffMultipleBadDocblocks' => [
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $s
|
|
|
|
* @param string $t
|
|
|
|
* @return Database
|
|
|
|
*/
|
|
|
|
public static function foo()
|
|
|
|
{
|
|
|
|
return D::eep();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $s
|
|
|
|
* @param string $t
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function bar()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return C|null
|
|
|
|
*/
|
|
|
|
public static function bat()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
'<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $s
|
|
|
|
* @param string
|
|
|
|
* @return Database
|
|
|
|
*/
|
|
|
|
public static function foo()
|
|
|
|
{
|
|
|
|
return D::eep();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $s
|
|
|
|
* @param string
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function bar()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return C|null
|
|
|
|
*/
|
|
|
|
public static function bat()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
',
|
|
|
|
['foo\a::bat'],
|
|
|
|
[],
|
|
|
|
['foo\a::foo', 'foo\a::bar', 'foo\a::foo', 'foo\a::bar'],
|
2019-03-23 19:27:54 +01:00
|
|
|
[[-6, 0]],
|
2018-11-02 00:11:00 +01:00
|
|
|
],
|
2018-09-25 23:52:27 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|