2018-10-26 22:17:15 +02:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests\FileUpdates;
|
|
|
|
|
2021-06-08 04:55:21 +02:00
|
|
|
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
2021-07-02 01:10:21 +02:00
|
|
|
use Psalm\Internal\Provider\FakeFileProvider;
|
2021-06-08 04:55:21 +02:00
|
|
|
use Psalm\Internal\Provider\Providers;
|
|
|
|
use Psalm\Tests\Internal\Provider;
|
|
|
|
use Psalm\Tests\TestConfig;
|
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
use function array_keys;
|
|
|
|
use function array_shift;
|
|
|
|
use function count;
|
|
|
|
use function end;
|
|
|
|
use function getcwd;
|
2021-06-08 04:55:21 +02:00
|
|
|
|
|
|
|
use const DIRECTORY_SEPARATOR;
|
2018-10-26 22:17:15 +02:00
|
|
|
|
|
|
|
class TemporaryUpdateTest extends \Psalm\Tests\TestCase
|
|
|
|
{
|
2019-05-17 00:36:36 +02:00
|
|
|
public function setUp() : void
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2021-07-02 01:10:21 +02:00
|
|
|
$this->file_provider = new FakeFileProvider();
|
2018-10-26 22:17:15 +02:00
|
|
|
|
|
|
|
$config = new TestConfig();
|
|
|
|
$config->throw_exception = false;
|
|
|
|
|
|
|
|
$providers = new Providers(
|
|
|
|
$this->file_provider,
|
2018-11-12 16:57:05 +01:00
|
|
|
new \Psalm\Tests\Internal\Provider\ParserInstanceCacheProvider(),
|
2018-10-26 22:17:15 +02:00
|
|
|
null,
|
|
|
|
null,
|
2020-04-12 17:41:01 +02:00
|
|
|
new Provider\FakeFileReferenceCacheProvider(),
|
|
|
|
new \Psalm\Tests\Internal\Provider\ProjectCacheProvider()
|
2018-10-26 22:17:15 +02:00
|
|
|
);
|
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$this->project_analyzer = new ProjectAnalyzer(
|
2018-10-26 22:17:15 +02:00
|
|
|
$config,
|
2019-06-09 18:37:28 +02:00
|
|
|
$providers
|
2018-10-26 22:17:15 +02:00
|
|
|
);
|
2019-02-07 21:27:43 +01:00
|
|
|
$this->project_analyzer->setPhpVersion('7.3');
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTestErrorFix
|
|
|
|
*
|
|
|
|
* @param array<int, array<string, string>> $file_stages
|
2018-11-16 17:15:40 +01:00
|
|
|
* @param array<int, array<int>> $error_positions
|
2018-10-26 22:17:15 +02:00
|
|
|
* @param array<string, string> $error_levels
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function testErrorFix(
|
|
|
|
array $file_stages,
|
|
|
|
array $error_positions,
|
2019-06-13 21:25:55 +02:00
|
|
|
array $error_levels = [],
|
2020-03-31 15:56:27 +02:00
|
|
|
bool $test_save = true,
|
|
|
|
bool $check_unused_code = false
|
2020-09-12 17:24:05 +02:00
|
|
|
): void {
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->diff_methods = true;
|
2018-10-26 22:17:15 +02:00
|
|
|
|
2020-03-31 15:56:27 +02:00
|
|
|
if ($check_unused_code) {
|
|
|
|
$codebase->reportUnusedCode();
|
|
|
|
}
|
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
$config = $codebase->config;
|
|
|
|
|
|
|
|
foreach ($error_levels as $error_type => $error_level) {
|
|
|
|
$config->setCustomErrorLevel($error_type, $error_level);
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:15:19 +01:00
|
|
|
if (!$file_stages) {
|
|
|
|
throw new \UnexpectedValueException('$file_stages should not be empty');
|
|
|
|
}
|
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
$start_files = array_shift($file_stages);
|
|
|
|
|
|
|
|
// first batch
|
|
|
|
foreach ($start_files as $file_path => $contents) {
|
|
|
|
$this->file_provider->registerFile($file_path, $contents);
|
|
|
|
$codebase->addFilesToAnalyze([$file_path => $file_path]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$codebase->scanFiles();
|
|
|
|
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false, true);
|
2020-03-31 15:56:27 +02:00
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
$data = \Psalm\IssueBuffer::clear();
|
|
|
|
|
2020-01-22 03:07:44 +01:00
|
|
|
$found_positions = [];
|
|
|
|
|
|
|
|
foreach ($data as $file_issues) {
|
|
|
|
foreach ($file_issues as $issue_data) {
|
2020-02-17 00:24:40 +01:00
|
|
|
$found_positions[] = $issue_data->from;
|
2020-01-22 03:07:44 +01:00
|
|
|
}
|
|
|
|
}
|
2018-10-26 22:17:15 +02:00
|
|
|
|
|
|
|
$this->assertSame($error_positions[0], $found_positions);
|
|
|
|
|
2020-02-03 22:43:17 +01:00
|
|
|
$i = 0;
|
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
foreach ($file_stages as $i => $file_stage) {
|
|
|
|
foreach ($file_stage as $file_path => $contents) {
|
|
|
|
$codebase->addTemporaryFileChanges(
|
|
|
|
$file_path,
|
2018-11-09 16:41:51 +01:00
|
|
|
$contents
|
2018-10-26 22:17:15 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-20 21:51:47 +01:00
|
|
|
$codebase->reloadFiles($this->project_analyzer, array_keys($file_stage));
|
|
|
|
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false, true);
|
2020-03-31 15:56:27 +02:00
|
|
|
|
2018-10-26 22:17:15 +02:00
|
|
|
$data = \Psalm\IssueBuffer::clear();
|
|
|
|
|
2020-01-22 03:07:44 +01:00
|
|
|
$found_positions = [];
|
|
|
|
|
|
|
|
foreach ($data as $file_issues) {
|
|
|
|
foreach ($file_issues as $issue_data) {
|
2020-02-17 00:24:40 +01:00
|
|
|
$found_positions[] = $issue_data->from;
|
2020-01-22 03:07:44 +01:00
|
|
|
}
|
|
|
|
}
|
2018-10-26 22:17:15 +02:00
|
|
|
|
2020-02-03 22:43:17 +01:00
|
|
|
$this->assertSame($error_positions[$i + 1], $found_positions, 'stage ' . ($i + 2));
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
2019-06-13 21:25:55 +02:00
|
|
|
|
2021-01-11 03:54:49 +01:00
|
|
|
if ($test_save && $file_stages) {
|
2019-06-13 21:25:55 +02:00
|
|
|
$last_file_stage = end($file_stages);
|
|
|
|
|
|
|
|
foreach ($last_file_stage as $file_path => $_) {
|
|
|
|
$codebase->removeTemporaryFileChanges($file_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($last_file_stage as $file_path => $contents) {
|
|
|
|
$this->file_provider->registerFile($file_path, $contents);
|
|
|
|
}
|
|
|
|
|
|
|
|
$codebase->reloadFiles($this->project_analyzer, array_keys($last_file_stage));
|
|
|
|
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false, true);
|
2020-03-31 15:56:27 +02:00
|
|
|
|
2019-06-13 21:25:55 +02:00
|
|
|
$data = \Psalm\IssueBuffer::clear();
|
|
|
|
|
2020-01-22 03:07:44 +01:00
|
|
|
$found_positions = [];
|
|
|
|
|
|
|
|
foreach ($data as $file_issues) {
|
|
|
|
foreach ($file_issues as $issue_data) {
|
2020-02-17 00:24:40 +01:00
|
|
|
$found_positions[] = $issue_data->from;
|
2020-01-22 03:07:44 +01:00
|
|
|
}
|
|
|
|
}
|
2019-06-13 21:25:55 +02:00
|
|
|
|
2020-02-03 22:43:17 +01:00
|
|
|
$this->assertSame($error_positions[count($file_stages)], $found_positions, 'stage ' . ($i + 2));
|
2019-06-13 21:25:55 +02:00
|
|
|
}
|
2018-10-26 22:17:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-06-13 21:25:55 +02:00
|
|
|
* @return array<string,array{array<int, array<string, string>>,error_positions:array<int, array<int>>, error_levels?:array<string, string>, test_save?:bool}>
|
2018-10-26 22:17:15 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerTestErrorFix(): array
|
2018-10-26 22:17:15 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'fixMissingColonSyntaxError' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
$a = 5
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [230], []],
|
|
|
|
],
|
|
|
|
'addReturnTypesToSingleMethod' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[136, 317, 273], [323, 279], [329]],
|
|
|
|
],
|
|
|
|
'addSpaceAffectingOffsets' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
$a = 5;
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
$a = 5;
|
|
|
|
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
$a = 5;
|
|
|
|
|
|
|
|
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
$a = $_GET["foo"];
|
|
|
|
return $this->foo();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[373], [374], [375]],
|
|
|
|
[
|
|
|
|
'MixedAssignment' => \Psalm\Config::REPORT_INFO,
|
2019-03-23 19:27:54 +01:00
|
|
|
],
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
|
|
|
'fixReturnType' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : string {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : int {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-29 20:36:13 +01:00
|
|
|
'error_positions' => [[196, 144, 339, 290], [345, 296], []],
|
2018-10-26 22:17:15 +02:00
|
|
|
[
|
|
|
|
'MissingReturnType' => \Psalm\Config::REPORT_INFO,
|
2019-03-23 19:27:54 +01:00
|
|
|
],
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
2018-11-01 21:04:37 +01:00
|
|
|
'resolveNamesInDifferentFunction' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @param string (A::class | B::class)
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function foo($a) {
|
|
|
|
return A::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @param string $a - one of (A::class | B::class)
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function foo($a) {
|
|
|
|
return A::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[333], []],
|
|
|
|
[
|
|
|
|
'InvalidDocblock' => \Psalm\Config::REPORT_INFO,
|
2019-03-23 19:27:54 +01:00
|
|
|
],
|
2018-11-01 21:04:37 +01:00
|
|
|
],
|
2018-10-26 22:17:15 +02:00
|
|
|
'bridgeStatements' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : int {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-29 20:36:13 +01:00
|
|
|
'error_positions' => [[136, 273], [279], [193, 144]],
|
2018-10-26 22:17:15 +02:00
|
|
|
[
|
|
|
|
'MissingReturnType' => \Psalm\Config::REPORT_INFO,
|
2019-03-23 19:27:54 +01:00
|
|
|
],
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
|
|
|
'colonReturnType' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2018-11-01 22:03:08 +01:00
|
|
|
'error_positions' => [[136, 273], [144, 136, 275]],
|
2018-10-26 22:17:15 +02:00
|
|
|
[
|
|
|
|
'MissingReturnType' => \Psalm\Config::REPORT_INFO,
|
2019-03-23 19:27:54 +01:00
|
|
|
],
|
2019-06-13 21:25:55 +02:00
|
|
|
false,
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
|
|
|
'noChangeJustWeirdDocblocks' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function bat() : void {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* another
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is one line
|
|
|
|
// this is another
|
|
|
|
public function bar() : void {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public $aB = 5;
|
|
|
|
|
|
|
|
const F = 1;
|
|
|
|
|
|
|
|
public function bat() : void {
|
|
|
|
$a = 1;
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* another
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function foo() {
|
|
|
|
$a = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is one line
|
|
|
|
// this is another
|
|
|
|
public function bar() : void {
|
|
|
|
$b = 1;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2018-11-09 06:59:13 +01:00
|
|
|
'error_positions' => [[127], [127]],
|
2018-10-26 22:17:15 +02:00
|
|
|
],
|
2018-10-27 05:04:38 +02:00
|
|
|
'removeUseShouldInvalidate' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
|
|
|
'removeGroupUseShouldInvalidate' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use PhpParser\{Error};
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Error("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Error("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
|
|
|
'removeUseWithAliasShouldInvalidate' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use Exception as E;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
|
|
|
'removeGroupUseWithAliasShouldInvalidate' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use PhpParser\{Error as E};
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
|
|
|
'removeUseShouldInvalidateNoNamespace' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
use PhpParser\Node\Name;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
new Name("Martin");
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
new Name("Martin");
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [147]],
|
|
|
|
],
|
|
|
|
'removeGroupUseShouldInvalidateNoNamespace' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use PhpParser\{Error};
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Error("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new Error("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
|
|
|
'removeUseWithAliasShouldInvalidateNoNamespace' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
use Exception as E;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [153]],
|
|
|
|
],
|
|
|
|
'removeGroupUseWithAliasShouldInvalidateNoNamespace' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
use PhpParser\{Error as E};
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
throw new E("bad", 5);
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [197]],
|
|
|
|
],
|
2018-10-30 23:58:22 +01:00
|
|
|
'addUseShouldValidate' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
2018-11-01 21:04:37 +01:00
|
|
|
throw new E();
|
2018-10-30 23:58:22 +01:00
|
|
|
}
|
|
|
|
}',
|
2018-11-01 21:04:37 +01:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'E.php' => '<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class E extends \Exception {}',
|
2018-10-30 23:58:22 +01:00
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
2018-11-01 21:04:37 +01:00
|
|
|
use Bar\E;
|
2018-10-30 23:58:22 +01:00
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
2018-11-01 21:04:37 +01:00
|
|
|
throw new E();
|
2018-10-30 23:58:22 +01:00
|
|
|
}
|
|
|
|
}',
|
2018-11-01 21:04:37 +01:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'E.php' => '<?php
|
|
|
|
namespace Bar;
|
|
|
|
|
|
|
|
class E extends \Exception {}',
|
2018-10-30 23:58:22 +01:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[197], []],
|
|
|
|
],
|
2020-10-23 00:07:27 +02:00
|
|
|
'changeUseShouldInvalidateBadNew' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
new B();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
new B();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[247], []],
|
|
|
|
],
|
|
|
|
'changeUseShouldInvalidateBadReturn' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : ?B {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : ?B {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[196], []],
|
|
|
|
],
|
2021-02-15 02:23:40 +01:00
|
|
|
'changeUseShouldInvalidateBadDocblockReturn' => [
|
2021-02-14 18:07:09 +01:00
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @return ?B */
|
|
|
|
public function foo() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @return ?B */
|
|
|
|
public function foo() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[184], []],
|
|
|
|
],
|
|
|
|
'changeUseShouldInvalidateBadParam' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(B $b) : void {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(B $b) : void {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[192], []],
|
|
|
|
],
|
|
|
|
'changeUseShouldInvalidateBadDocblockParam' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @param B $b */
|
|
|
|
public function foo($b) : void {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @param B $b */
|
|
|
|
public function foo($b) : void {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[183], []],
|
|
|
|
],
|
2021-02-15 02:23:40 +01:00
|
|
|
'changeUseShouldInvalidateBadExtends' => [
|
2021-02-14 18:07:09 +01:00
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Baz\B;
|
|
|
|
|
|
|
|
class A extends B {}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo {
|
|
|
|
use Bar\B;
|
|
|
|
|
|
|
|
class A extends B {}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Bar {
|
|
|
|
class B {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[142], []],
|
|
|
|
],
|
2018-11-16 00:09:57 +01:00
|
|
|
'fixMissingProperty' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
private $bar = "hello";
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[192, 192], []],
|
|
|
|
],
|
2018-11-20 21:51:47 +01:00
|
|
|
'traitMethodRenameDifferentFiles' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bat() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bat();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bat() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bat();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2020-11-08 17:04:39 +01:00
|
|
|
'error_positions' => [[], [238, 231], [], [238, 231], []],
|
2018-11-20 21:51:47 +01:00
|
|
|
],
|
|
|
|
'traitMethodRenameSameFile' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bat() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bat() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
public function foo() : void {
|
|
|
|
echo $this->bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function bar() : string {
|
|
|
|
return "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2020-11-08 17:04:39 +01:00
|
|
|
'error_positions' => [[], [238, 231], [], [238, 231], []],
|
2018-11-20 21:51:47 +01:00
|
|
|
],
|
2019-01-08 06:54:48 +01:00
|
|
|
'duplicateMethodThenRemove' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [381], []],
|
|
|
|
],
|
2019-01-20 17:10:12 +01:00
|
|
|
'classCopiesUse' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
use B\A;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
],
|
|
|
|
],
|
2019-06-01 06:56:54 +02:00
|
|
|
'error_positions' => [[], [122], []],
|
2019-01-20 17:10:12 +01:00
|
|
|
],
|
2019-01-21 23:29:12 +01:00
|
|
|
'addMissingArgs' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
function variadic_arguments(string $_foo, ...$bars ) : void {}
|
|
|
|
|
|
|
|
function foo() : void {
|
|
|
|
variadic_arguments(
|
|
|
|
$baz,
|
|
|
|
$qux
|
|
|
|
);
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-09 19:58:49 +02:00
|
|
|
function variadic_arguments(string $_foo, string ...$bars ) : void {}
|
2019-01-21 23:29:12 +01:00
|
|
|
|
|
|
|
function foo(string $baz, string $qux) : void {
|
|
|
|
variadic_arguments(
|
|
|
|
$baz,
|
|
|
|
$qux
|
|
|
|
);
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2020-05-15 05:56:04 +02:00
|
|
|
'error_positions' => [[79, 238, 280, 238], []],
|
2019-01-21 23:29:12 +01:00
|
|
|
],
|
2019-02-07 19:56:00 +01:00
|
|
|
'fixClassRef' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class SomeClass {}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
/** @var ?string */
|
|
|
|
private static $s = null;
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
new SomeClas();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : void {
|
|
|
|
self::$s = "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class SomeClass {}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
/** @var ?string */
|
|
|
|
private static $s = null;
|
|
|
|
|
|
|
|
public function foo() : void {
|
|
|
|
new SomeClas();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : void {
|
|
|
|
self::$si = "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-06 00:27:25 +01:00
|
|
|
'error_positions' => [[306], [306, 452, 452]],
|
2019-02-07 19:56:00 +01:00
|
|
|
],
|
2019-02-08 00:47:50 +01:00
|
|
|
'addPropertyDocblock' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {}
|
|
|
|
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
private $bar = [];
|
|
|
|
private $baz = [];
|
|
|
|
|
|
|
|
public static function get() : A
|
|
|
|
{
|
|
|
|
return new A();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {}
|
|
|
|
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array<string, string>
|
|
|
|
*/
|
|
|
|
private $bar = [];
|
|
|
|
private $baz = [];
|
|
|
|
|
|
|
|
public static function get() : A
|
|
|
|
{
|
|
|
|
return new A();
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[152, 203], [337]],
|
|
|
|
],
|
2019-06-13 21:25:55 +02:00
|
|
|
'fixNotNullProperty' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[230], []],
|
|
|
|
],
|
|
|
|
'dontFixNotNullProperty' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[230], [230]],
|
|
|
|
],
|
2020-02-03 22:43:17 +01:00
|
|
|
'requiredFileWithConstructorInitialisation' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
require_once("B.php");',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
//$this->foo = "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
require_once("B.php");',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
class B
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->foo = "hello";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[230], []],
|
|
|
|
],
|
2019-07-28 16:05:45 +02:00
|
|
|
'updatePropertyInitialization' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B {
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $bar;
|
|
|
|
|
|
|
|
public function __construct(string $foo, int $bar) {
|
|
|
|
$this->foo = $foo;
|
|
|
|
$this->bar = $bar;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B {
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $bar;
|
|
|
|
|
|
|
|
public function __construct(string $foo, int $bar) {
|
|
|
|
// $this->foo = $foo;
|
|
|
|
$this->bar = $bar;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class B {
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $bar;
|
|
|
|
|
|
|
|
public function __construct(string $foo, int $bar) {
|
|
|
|
$this->foo = $foo;
|
|
|
|
$this->bar = $bar;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [202], []],
|
|
|
|
],
|
2019-06-29 06:22:41 +02:00
|
|
|
'addPartialMethodWithSyntaxError' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
public function baz() : void {
|
|
|
|
if (rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
public function baz() : void {
|
|
|
|
if (rand(0, 1)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function foo() {}
|
|
|
|
|
|
|
|
public function baz() : void {
|
|
|
|
if (rand(0, 1)) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function bar(
|
|
|
|
string $function_id
|
|
|
|
) {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], [381], []],
|
|
|
|
],
|
2020-03-13 02:39:27 +01:00
|
|
|
'reformat' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public function b(): void {
|
|
|
|
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public function b(): void
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], []],
|
|
|
|
],
|
2020-03-27 05:37:33 +01:00
|
|
|
'dontForgetErrorInTraitMethod' => [
|
|
|
|
[
|
|
|
|
[
|
2020-04-01 18:56:32 +02:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-03-27 05:37:33 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
}
|
|
|
|
|
|
|
|
(new A)->foo();',
|
2020-04-01 18:56:32 +02:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2020-03-27 05:37:33 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function foo() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
2020-04-01 18:56:32 +02:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-03-27 05:37:33 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
}
|
|
|
|
|
|
|
|
(new A)->foo();',
|
2020-04-01 18:56:32 +02:00
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2020-03-27 05:37:33 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function foo() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[192, 192], [192, 192]],
|
|
|
|
],
|
2020-04-01 18:56:32 +02:00
|
|
|
'stillUnusedClass' => [
|
2020-03-31 15:56:27 +02:00
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
new B();',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
new B();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[84], [84]],
|
|
|
|
[],
|
2020-04-01 18:56:32 +02:00
|
|
|
false,
|
|
|
|
true
|
|
|
|
],
|
|
|
|
'stillUnusedMethod' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
|
|
|
|
public function bar() : void {}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
(new A())->foo();',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bar() : void {}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
(new A())->foo();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[201], [234]],
|
|
|
|
[],
|
|
|
|
false,
|
2020-03-31 15:56:27 +02:00
|
|
|
true
|
|
|
|
],
|
2020-04-02 23:17:55 +02:00
|
|
|
'usedMethodWithNoAffectedConstantChanges' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class Z {
|
|
|
|
const ONE = "1";
|
|
|
|
const TWO = "2";
|
|
|
|
|
|
|
|
public static function foo() : void {}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function doFoo() : void {
|
|
|
|
echo Z::ONE;
|
|
|
|
Z::foo();
|
|
|
|
echo Z::TWO;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
(new B())->doFoo();',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class Z {
|
|
|
|
const ONE = "1";
|
|
|
|
const TWO = "2";
|
|
|
|
const THREE = "3";
|
|
|
|
|
|
|
|
public static function foo() : void {}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function doFoo() : void {
|
|
|
|
echo Z::ONE;
|
|
|
|
Z::foo();
|
|
|
|
echo Z::TWO;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'user.php' => '<?php
|
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
(new B())->doFoo();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[], []],
|
|
|
|
[],
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
],
|
2021-02-15 03:16:12 +01:00
|
|
|
'syntaxErrorFixed' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
//foreach ([1, 2, 3] as $b) {
|
|
|
|
echo $b;
|
|
|
|
}
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
foreach ([1, 2, 3] as $b) {
|
|
|
|
echo $b;
|
|
|
|
}
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[347, 452, 538], [500, 500]],
|
|
|
|
],
|
|
|
|
'updateExampleWithSyntaxErrorThen' => [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
foreach ([1, 2, 3] as $b) {
|
|
|
|
echo $b;
|
|
|
|
}
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
//foreach ([1, 2, 3] as $b) {
|
|
|
|
echo $b;
|
|
|
|
}
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {
|
|
|
|
$a = 5;
|
|
|
|
foreach ([1, 2, 3] as $b) {
|
|
|
|
echo $b;
|
|
|
|
}
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bar() : void {
|
|
|
|
echo $a;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_positions' => [[500, 500], [347, 452, 538], [500, 500]],
|
|
|
|
],
|
2018-10-26 22:17:15 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|