From a57127c77e27a7980fd8e0d1bbf36f3cb229a486 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Mon, 3 Oct 2022 15:01:54 +0200 Subject: [PATCH] Regression test --- .../CallToNonExistentFunctionRuleTest.php | 24 +++++++++++++++ .../Rules/Methods/CallMethodsRuleTest.php | 29 +++++++++++++++++++ tests/PHPStan/Rules/Methods/data/bug-8058.php | 15 ++++++++++ 3 files changed, 68 insertions(+) create mode 100644 tests/PHPStan/Rules/Methods/data/bug-8058.php diff --git a/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php b/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php index 29b5d1662b..0f5876e7bc 100644 --- a/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php @@ -162,4 +162,28 @@ public function testBug7952(): void $this->analyse([__DIR__ . '/data/bug-7952.php'], []); } + public function testBug8058(): void + { + if (PHP_VERSION_ID < 80200) { + $this->markTestSkipped('Test requires PHP 8.2'); + } + + $this->analyse([__DIR__ . '/../Methods/data/bug-8058.php'], []); + } + + public function testBug8058b(): void + { + if (PHP_VERSION_ID >= 80200) { + $this->markTestSkipped('Test requires PHP before 8.2'); + } + + $this->analyse([__DIR__ . '/../Methods/data/bug-8058.php'], [ + [ + 'Function mysqli_execute_query not found.', + 13, + 'Learn more at https://phpstan.org/user-guide/discovering-symbols', + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 28f4d52aaf..c40b61e2a4 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -2628,4 +2628,33 @@ public function testBug7600(): void $this->analyse([__DIR__ . '/data/bug-7600.php'], []); } + public function testBug8058(): void + { + if (PHP_VERSION_ID < 80200) { + $this->markTestSkipped('Test requires PHP 8.2'); + } + $this->checkThisOnly = false; + $this->checkNullables = false; + $this->checkUnionTypes = false; + $this->checkExplicitMixed = false; + $this->analyse([__DIR__ . '/data/bug-8058.php'], []); + } + + public function testBug8058b(): void + { + if (PHP_VERSION_ID >= 80200) { + $this->markTestSkipped('Test requires PHP before 8.2'); + } + $this->checkThisOnly = false; + $this->checkNullables = false; + $this->checkUnionTypes = false; + $this->checkExplicitMixed = false; + $this->analyse([__DIR__ . '/data/bug-8058.php'], [ + [ + 'Call to an undefined method mysqli::execute_query().', + 11, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Methods/data/bug-8058.php b/tests/PHPStan/Rules/Methods/data/bug-8058.php new file mode 100644 index 0000000000..b2334de680 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-8058.php @@ -0,0 +1,15 @@ +execute_query($s); + + \mysqli_execute_query($mysqli, $s); + } +}