Skip to content

Commit 1e7ceae

Browse files
authored
proc_open() accepts list<string> for $command in 7.4+
1 parent 51e4c1d commit 1e7ceae

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

resources/functionMap_php74delta.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'strip_tags' => ['string', 'str'=>'string', 'allowable_tags='=>'string|array<int, string>'],
5656
'WeakReference::create' => ['WeakReference', 'referent'=>'object'],
5757
'WeakReference::get' => ['?object'],
58+
'proc_open' => ['resource|false', 'command'=>'string|list<string>', 'descriptorspec'=>'array', '&w_pipes'=>'resource[]', 'cwd='=>'?string', 'env='=>'?array', 'other_options='=>'array'],
5859
],
5960
'old' => [
6061
'implode\'2' => ['string', 'pieces'=>'array', 'glue'=>'string'],

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,4 +797,18 @@ public function testExplode(): void
797797
]);
798798
}
799799

800+
public function testProcOpen(): void
801+
{
802+
if (PHP_VERSION_ID < 70400) {
803+
$this->markTestSkipped('Test requires PHP 7.4.');
804+
}
805+
806+
$this->analyse([__DIR__ . '/data/proc_open.php'], [
807+
[
808+
'Parameter #1 $command of function proc_open expects array<int, string>|string, array<string, string> given.',
809+
6,
810+
],
811+
]);
812+
}
813+
800814
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php declare(strict_types=1);
2+
3+
proc_open('echo "hello world"', [], $pipes);
4+
proc_open(['echo', 'hello world'], [], $pipes);
5+
6+
proc_open(['something' => 'bogus', 'in' => 'here'], [], $pipes);

0 commit comments

Comments
 (0)