From 1e7ceae933f07e5a250b61ed94799e6c2ea8daa2 Mon Sep 17 00:00:00 2001 From: Dylan T Date: Sun, 25 Jul 2021 20:33:02 +0100 Subject: [PATCH] proc_open() accepts list for $command in 7.4+ --- resources/functionMap_php74delta.php | 1 + .../Functions/CallToFunctionParametersRuleTest.php | 14 ++++++++++++++ tests/PHPStan/Rules/Functions/data/proc_open.php | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/proc_open.php diff --git a/resources/functionMap_php74delta.php b/resources/functionMap_php74delta.php index 656d998997..73349639fe 100644 --- a/resources/functionMap_php74delta.php +++ b/resources/functionMap_php74delta.php @@ -55,6 +55,7 @@ 'strip_tags' => ['string', 'str'=>'string', 'allowable_tags='=>'string|array'], 'WeakReference::create' => ['WeakReference', 'referent'=>'object'], 'WeakReference::get' => ['?object'], + 'proc_open' => ['resource|false', 'command'=>'string|list', 'descriptorspec'=>'array', '&w_pipes'=>'resource[]', 'cwd='=>'?string', 'env='=>'?array', 'other_options='=>'array'], ], 'old' => [ 'implode\'2' => ['string', 'pieces'=>'array', 'glue'=>'string'], diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 5557501c16..f63cbdbeb2 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -797,4 +797,18 @@ public function testExplode(): void ]); } + public function testProcOpen(): void + { + if (PHP_VERSION_ID < 70400) { + $this->markTestSkipped('Test requires PHP 7.4.'); + } + + $this->analyse([__DIR__ . '/data/proc_open.php'], [ + [ + 'Parameter #1 $command of function proc_open expects array|string, array given.', + 6, + ], + ]); + } + } diff --git a/tests/PHPStan/Rules/Functions/data/proc_open.php b/tests/PHPStan/Rules/Functions/data/proc_open.php new file mode 100644 index 0000000000..045641e382 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/proc_open.php @@ -0,0 +1,6 @@ + 'bogus', 'in' => 'here'], [], $pipes);