Skip to content

Commit 7c02a43

Browse files
committed
Test create_function() reported as nonexistent on PHP 8
1 parent 1501229 commit 7c02a43

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Rules/Functions/CallToNonExistentFunctionRuleTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,28 @@ public function testMatchExprAnalysis(): void
9797
]);
9898
}
9999

100+
public function testCreateFunctionPhp8(): void
101+
{
102+
if (PHP_VERSION_ID < 80000) {
103+
$this->markTestSkipped('Test requires PHP 8.0.');
104+
}
105+
106+
$this->analyse([__DIR__ . '/data/create_function.php'], [
107+
[
108+
'Function create_function not found.',
109+
4,
110+
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
111+
],
112+
]);
113+
}
114+
115+
public function testCreateFunctionPhp7(): void
116+
{
117+
if (PHP_VERSION_ID >= 80000) {
118+
$this->markTestSkipped('Test requires PHP 7.x.');
119+
}
120+
121+
$this->analyse([__DIR__ . '/data/create_function.php'], []);
122+
}
123+
100124
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function (): void {
4+
create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');
5+
};

0 commit comments

Comments
 (0)