From 9fcc8fb839d1f0490513d60cf530c38eb56c863c 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 | 55 ++++++++++++++++++++++ tests/fixtures/stubs/SymfonyKernel.phpstub | 11 +++++ 2 files changed, 66 insertions(+) create mode 100644 tests/fixtures/stubs/SymfonyKernel.phpstub diff --git a/tests/StubTest.php b/tests/StubTest.php index 863caad0b9f..60071294359 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -1301,4 +1301,59 @@ 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 @@ +