2018-10-10 22:24:10 +02:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2023-10-19 14:16:41 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Psalm\Tests\FileUpdates;
|
|
|
|
|
2021-12-03 20:29:06 +01:00
|
|
|
use Psalm\Exception\CodeException;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\Internal\Analyzer\ProjectAnalyzer;
|
2021-07-02 01:10:21 +02:00
|
|
|
use Psalm\Internal\Provider\FakeFileProvider;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\Internal\Provider\Providers;
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Tests\Internal\Provider\FakeFileReferenceCacheProvider;
|
2021-12-03 20:11:20 +01:00
|
|
|
use Psalm\Tests\Internal\Provider\ParserInstanceCacheProvider;
|
|
|
|
use Psalm\Tests\Internal\Provider\ProjectCacheProvider;
|
|
|
|
use Psalm\Tests\TestCase;
|
2019-03-23 19:27:54 +01:00
|
|
|
use Psalm\Tests\TestConfig;
|
2021-12-03 21:40:18 +01:00
|
|
|
use UnexpectedValueException;
|
2018-10-10 22:24:10 +02:00
|
|
|
|
2021-06-08 04:55:21 +02:00
|
|
|
use function array_keys;
|
|
|
|
use function array_pop;
|
|
|
|
use function getcwd;
|
|
|
|
use function preg_quote;
|
|
|
|
|
|
|
|
use const DIRECTORY_SEPARATOR;
|
|
|
|
|
2021-12-03 20:11:20 +01:00
|
|
|
class ErrorAfterUpdateTest extends TestCase
|
2018-10-10 22:24:10 +02:00
|
|
|
{
|
2021-12-05 18:51:26 +01:00
|
|
|
public function setUp(): void
|
2018-10-10 22:24:10 +02:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2021-07-02 01:10:21 +02:00
|
|
|
$this->file_provider = new FakeFileProvider();
|
2018-10-10 22:24:10 +02:00
|
|
|
|
|
|
|
$config = new TestConfig();
|
|
|
|
|
|
|
|
$providers = new Providers(
|
|
|
|
$this->file_provider,
|
2021-12-03 20:11:20 +01:00
|
|
|
new ParserInstanceCacheProvider(),
|
2018-10-10 22:24:10 +02:00
|
|
|
null,
|
|
|
|
null,
|
2021-12-04 21:55:53 +01:00
|
|
|
new FakeFileReferenceCacheProvider(),
|
2022-12-18 17:15:15 +01:00
|
|
|
new ProjectCacheProvider(),
|
2018-10-10 22:24:10 +02:00
|
|
|
);
|
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$this->project_analyzer = new ProjectAnalyzer(
|
2018-10-10 22:24:10 +02:00
|
|
|
$config,
|
2022-12-18 17:15:15 +01:00
|
|
|
$providers,
|
2018-10-10 22:24:10 +02:00
|
|
|
);
|
2021-11-27 01:06:33 +01:00
|
|
|
$this->project_analyzer->setPhpVersion('7.3', 'tests');
|
2018-10-10 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerTestInvalidUpdates
|
|
|
|
* @param array<int, array<string, string>> $file_stages
|
2022-11-05 22:34:42 +01:00
|
|
|
* @param array<string, string> $ignored_issues
|
2018-10-10 22:24:10 +02:00
|
|
|
*/
|
|
|
|
public function testErrorAfterUpdate(
|
|
|
|
array $file_stages,
|
|
|
|
string $error_message,
|
2023-10-19 14:16:41 +02:00
|
|
|
array $ignored_issues = [],
|
2020-09-12 17:24:05 +02:00
|
|
|
): void {
|
2018-11-11 18:01:14 +01:00
|
|
|
$this->project_analyzer->getCodebase()->diff_methods = true;
|
2019-04-17 19:15:06 +02:00
|
|
|
$this->project_analyzer->getCodebase()->reportUnusedCode();
|
2018-10-10 22:24:10 +02:00
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase = $this->project_analyzer->getCodebase();
|
2018-10-10 22:24:10 +02:00
|
|
|
|
|
|
|
$config = $codebase->config;
|
|
|
|
|
2022-11-05 22:34:42 +01:00
|
|
|
foreach ($ignored_issues as $error_type => $error_level) {
|
2018-10-10 22:24:10 +02:00
|
|
|
$config->setCustomErrorLevel($error_type, $error_level);
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:15:19 +01:00
|
|
|
if (!$file_stages) {
|
2021-12-03 21:40:18 +01:00
|
|
|
throw new UnexpectedValueException('$file_stages should not be empty');
|
2018-12-19 22:15:19 +01:00
|
|
|
}
|
|
|
|
|
2018-10-10 22:24:10 +02:00
|
|
|
$end_files = array_pop($file_stages);
|
|
|
|
|
|
|
|
foreach ($file_stages as $files) {
|
|
|
|
foreach ($files as $file_path => $contents) {
|
|
|
|
$this->file_provider->registerFile($file_path, $contents);
|
|
|
|
}
|
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase->reloadFiles($this->project_analyzer, array_keys($files));
|
2018-10-10 22:24:10 +02:00
|
|
|
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false, true);
|
2018-10-10 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($end_files as $file_path => $contents) {
|
|
|
|
$this->file_provider->registerFile($file_path, $contents);
|
|
|
|
}
|
|
|
|
|
2021-12-03 20:29:06 +01:00
|
|
|
$this->expectException(CodeException::class);
|
2022-01-19 19:29:16 +01:00
|
|
|
$this->expectExceptionMessageMatches('/\b' . preg_quote($error_message, '/') . '\b/');
|
2019-01-02 17:18:22 +01:00
|
|
|
|
2018-11-11 18:01:14 +01:00
|
|
|
$codebase->reloadFiles($this->project_analyzer, array_keys($end_files));
|
2018-10-10 22:24:10 +02:00
|
|
|
|
|
|
|
foreach ($end_files as $file_path => $_) {
|
|
|
|
$codebase->addFilesToAnalyze([$file_path => $file_path]);
|
|
|
|
}
|
|
|
|
|
2020-04-01 18:56:32 +02:00
|
|
|
$codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false, true);
|
2018-10-10 22:24:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @return array<string,array{file_stages:array<int,array<string,string>>,error_message:string}>
|
2018-10-10 22:24:10 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function providerTestInvalidUpdates(): array
|
2018-10-10 22:24:10 +02:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
'invalidateParentCaller' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B extends A { }',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'C.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function bar() : void {
|
|
|
|
(new B)->foo();
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(new C())->bar();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A { }',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B extends A { }',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'C.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
|
|
|
public function bar() : void {
|
|
|
|
(new B)->foo();
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(new C())->bar();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'UndefinedMethod',
|
|
|
|
],
|
|
|
|
'invalidateAfterPropertyTypeChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : string {
|
|
|
|
return (new A)->foo;
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new B)->foo();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var int */
|
|
|
|
public $foo = 5;
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : string {
|
|
|
|
return (new A)->foo;
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new B)->foo();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'InvalidReturnStatement',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateAfterConstantChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public const FOO = "bar";
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : string {
|
|
|
|
return A::FOO;
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new B)->foo();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public const FOO = 5;
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function foo() : string {
|
|
|
|
return A::FOO;
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new B)->foo();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'InvalidReturnStatement',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateAfterSkippedAnalysis' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function getB() : B {
|
|
|
|
return new B;
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function getString() : string {
|
|
|
|
return "foo";
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'C.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
2020-03-26 17:35:27 +01:00
|
|
|
public function existingMethod() : string {
|
2018-10-10 22:24:10 +02:00
|
|
|
return (new A)->getB()->getString();
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new C)->existingMethod();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function getB() : B {
|
|
|
|
return new B;
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function getString() : string {
|
|
|
|
return "foo";
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'C.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
2020-03-26 17:35:27 +01:00
|
|
|
public function existingMethod() : string {
|
2018-10-10 22:24:10 +02:00
|
|
|
return (new A)->getB()->getString();
|
|
|
|
}
|
|
|
|
|
2020-03-26 17:35:27 +01:00
|
|
|
public function newMethod() : void {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new C)->existingMethod();
|
2020-03-26 17:35:27 +01:00
|
|
|
// newly-added call, removed in the next code block
|
|
|
|
(new C)->newMethod();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function getB() : B {
|
|
|
|
return new B;
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function getString() : ?string {
|
|
|
|
return "foo";
|
|
|
|
}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'C.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class C {
|
2020-03-26 17:35:27 +01:00
|
|
|
public function existingMethod() : string {
|
2018-10-10 22:24:10 +02:00
|
|
|
return (new A)->getB()->getString();
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-10 18:57:13 +02:00
|
|
|
echo (new C)->existingMethod();',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'NullableReturnStatement',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateMissingConstructorAfterPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'MissingConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateEmptyConstructorAfterPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
|
|
|
|
|
|
|
public function __construct() {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateEmptyTraitConstructorAfterPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateEmptyTraitConstructorAfterTraitPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
use T;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'T.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateSetInPrivateMethodConstructorCheck' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->setFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setFoo() : void {
|
|
|
|
$this->foo = "bar";
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->setFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setFoo() : void {
|
|
|
|
}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateMissingConstructorAfterParentPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
2019-04-16 22:07:48 +02:00
|
|
|
class B extends A {}
|
|
|
|
|
|
|
|
echo (new B)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
2019-04-16 22:07:48 +02:00
|
|
|
class B extends A {}
|
|
|
|
|
|
|
|
echo (new B)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'MissingConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
'invalidateNotSetInConstructorAfterParentPropertyChange' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "bar";
|
|
|
|
|
|
|
|
public function __construct() {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class C extends A {}
|
|
|
|
|
|
|
|
new C();',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public function __construct() {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new B)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
public function __construct() {}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2018-10-10 22:24:10 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public function __construct() {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo (new B)->foo;',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
2018-10-10 22:24:10 +02:00
|
|
|
],
|
2019-01-02 17:18:22 +01:00
|
|
|
'duplicateClass' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-01-02 17:18:22 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
2019-04-16 22:07:48 +02:00
|
|
|
class A {}
|
|
|
|
|
|
|
|
new A();',
|
2019-01-02 17:18:22 +01:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-01-02 17:18:22 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}
|
|
|
|
class A {}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'DuplicateClass',
|
2019-01-02 17:18:22 +01:00
|
|
|
],
|
|
|
|
'duplicateMethod' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-01-02 17:18:22 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
(new A)->foo();',
|
2019-01-02 17:18:22 +01:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-01-02 17:18:22 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
public function foo() : void {}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
2019-03-23 19:27:54 +01:00
|
|
|
'error_message' => 'DuplicateMethod',
|
2019-01-02 17:18:22 +01:00
|
|
|
],
|
2019-04-28 18:59:36 +02:00
|
|
|
'unusedClassReferencedInFile' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-28 18:59:36 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}
|
|
|
|
|
2020-09-21 02:58:34 +02:00
|
|
|
$a = new A();
|
|
|
|
print_r($a);',
|
2019-04-28 18:59:36 +02:00
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-28 18:59:36 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'UnusedClass',
|
|
|
|
],
|
2019-04-16 22:07:48 +02:00
|
|
|
'unusedMethodReferencedInFile' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new A)->foo();',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
2019-04-28 18:59:36 +02:00
|
|
|
}
|
|
|
|
|
2020-09-21 02:58:34 +02:00
|
|
|
$a = new A();
|
|
|
|
print_r($a);',
|
2019-04-16 22:07:48 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedMethod',
|
|
|
|
],
|
2019-04-29 23:29:38 +02:00
|
|
|
'unusedStaticMethodReferencedInFile' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {}
|
|
|
|
public static function bar() : void {}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
\Foo\A::foo();
|
|
|
|
\Foo\A::bar();',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public static function foo() : void {}
|
|
|
|
public static function bar() : void {}
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'B.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
\Foo\A::bar();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedMethod',
|
|
|
|
],
|
|
|
|
'unusedParamReferencedInFile' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(string $s) : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
public function foo(string $s) : void {
|
|
|
|
echo $s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->foo("hello");',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-29 23:29:38 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(string $s) : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->foo("hello");',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedParam',
|
|
|
|
],
|
2019-04-16 22:07:48 +02:00
|
|
|
'unusedMethodReferencedInMethod' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function bar() : void {
|
|
|
|
(new A)->foo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->bar();',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo() : void {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function bar() : void {
|
2019-04-28 18:59:36 +02:00
|
|
|
new A();
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->bar();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedMethod',
|
|
|
|
],
|
|
|
|
'unusedPropertyReferencedInFile' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo (new A)->foo;',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "hello";
|
2019-04-28 18:59:36 +02:00
|
|
|
}
|
|
|
|
|
2020-09-21 02:58:34 +02:00
|
|
|
print_r(new A());',
|
2019-04-16 22:07:48 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedProperty',
|
|
|
|
],
|
|
|
|
'unusedPropertyReferencedInMethod' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function bar() : void {
|
|
|
|
echo (new A)->foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->bar();',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2019-04-16 22:07:48 +02:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo = "hello";
|
|
|
|
}
|
|
|
|
|
|
|
|
class B {
|
|
|
|
public function bar() : void {
|
2019-04-28 18:59:36 +02:00
|
|
|
new A();
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(new B)->bar();',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PossiblyUnusedProperty',
|
|
|
|
],
|
2020-03-02 17:30:41 +01:00
|
|
|
'uninitialisedChildProperty' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-03-02 17:30:41 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
public function __construct() {
|
|
|
|
$this->setFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract protected function setFoo() : void;
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
2020-03-02 17:30:41 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class AChild extends A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
protected function setFoo() : void {
|
|
|
|
$this->reallySetFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function reallySetFoo() : void {
|
|
|
|
$this->foo = "bar";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-03-02 17:30:41 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
abstract class A {
|
|
|
|
public function __construct() {
|
|
|
|
$this->setFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract protected function setFoo() : void;
|
|
|
|
}',
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => '<?php
|
2020-03-02 17:30:41 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class AChild extends A {
|
|
|
|
/** @var string */
|
|
|
|
public $foo;
|
|
|
|
|
|
|
|
protected function setFoo() : void {
|
|
|
|
$this->reallySetFoo();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function reallySetFoo() : void {
|
|
|
|
//$this->foo = "bar";
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'PropertyNotSetInConstructor',
|
|
|
|
],
|
2020-11-01 15:46:21 +01:00
|
|
|
'invalidateChildMethodWhenSignatureChanges' => [
|
|
|
|
'file_stages' => [
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-11-01 15:46:21 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(string $s) : void {
|
|
|
|
echo $s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AChild extends A {
|
|
|
|
public function foo(string $s) : void {
|
|
|
|
echo $s;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
[
|
2023-10-09 22:40:21 +02:00
|
|
|
(string) getcwd() . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
2020-11-01 15:46:21 +01:00
|
|
|
namespace Foo;
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public function foo(string $s = "") : void {
|
|
|
|
echo $s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AChild extends A {
|
|
|
|
public function foo(string $s) : void {
|
|
|
|
echo $s;
|
|
|
|
}
|
|
|
|
}',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'error_message' => 'MethodSignatureMismatch',
|
|
|
|
],
|
2018-10-10 22:24:10 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|