From 7a5051bbc4e0944db3551837fa6eac580fbd6f03 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 5 Dec 2021 23:01:15 +0200 Subject: [PATCH] Added reproducer for stub property not set in constructor Refs psalm/psalm-plugin-symfony#225 --- tests/StubTest.php | 56 ++++++++++++++++++++++ tests/fixtures/stubs/SymfonyKernel.phpstub | 11 +++++ 2 files changed, 67 insertions(+) create mode 100644 tests/fixtures/stubs/SymfonyKernel.phpstub diff --git a/tests/StubTest.php b/tests/StubTest.php index 863caad0b9f..5be8f42af85 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -1301,4 +1301,60 @@ function em(EntityManager $em) : void { $this->analyzeFile($file_path, new Context()); } + + public function testOverriddenStubProperty(): void + { + $this->project_analyzer = $this->getProjectAnalyzerWithConfig( + TestConfig::loadFromXML( + dirname(__DIR__), + ' + + + + + + + + ' + ) + ); + + $vendor_file_path = getcwd() . '/vendor/Kernel.php'; + + $this->addFile( + $vendor_file_path, + 'environment = $environment) { + throw new InvalidArgumentException; + } + } + }' + ); + + $file_path = getcwd() . '/src/somefile.php'; + $this->addFile( + $file_path, + 'analyzeFile($file_path, new Context(), false); + } } diff --git a/tests/fixtures/stubs/SymfonyKernel.phpstub b/tests/fixtures/stubs/SymfonyKernel.phpstub new file mode 100644 index 00000000000..445bac7c58f --- /dev/null +++ b/tests/fixtures/stubs/SymfonyKernel.phpstub @@ -0,0 +1,11 @@ +