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); + } +}