From 4e24e07a074f4e0750ba27d008d0b5cadef94e36 Mon Sep 17 00:00:00 2001 From: Javakky Date: Tue, 20 Aug 2024 02:14:03 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=E7=84=A1=E5=90=8D=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=A7=20Alias=20=E3=81=8C=E4=BD=BF=E3=81=88=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=83=90=E3=82=B0=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=B1=E3=83=BC=E3=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Analyser/AnalyserIntegrationTest.php | 6 ++ .../Analyser/NodeScopeResolverTest.php | 2 + tests/PHPStan/Analyser/data/bug-9346.php | 64 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/PHPStan/Analyser/data/bug-9346.php diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index 442e5863fe..6f9b3116c0 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -1184,6 +1184,12 @@ public function testBug5091(): void $this->assertNoErrors($errors); } + public function testBug9346(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-9346.php'); + $this->assertNoErrors($errors); + } + public function testBug9459(): void { $errors = $this->runAnalyse(__DIR__ . '/data/bug-9459.php'); diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index 6a8c6b517d..0fad39c8a5 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -181,6 +181,8 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Methods/data/bug-9542.php'); yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Functions/data/bug-9803.php'); yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/PhpDoc/data/bug-10594.php'); + + yield from $this->gatherAssertTypes(__DIR__ . '/../Rules/Methods/data/bug-9346.php'); } /** diff --git a/tests/PHPStan/Analyser/data/bug-9346.php b/tests/PHPStan/Analyser/data/bug-9346.php new file mode 100644 index 0000000000..5331126b4d --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-9346.php @@ -0,0 +1,64 @@ + 'baz']; + + /** + * @phpstan-return FooJson + */ + public function sayHello(DateTime $date): array + { + return $this->var; + } + }; + return $foo; + } +}