Skip to content

Commit

Permalink
proc_open() accepts list<string> for $command in 7.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jul 25, 2021
1 parent 51e4c1d commit 1e7ceae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/functionMap_php74delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'strip_tags' => ['string', 'str'=>'string', 'allowable_tags='=>'string|array<int, string>'],
'WeakReference::create' => ['WeakReference', 'referent'=>'object'],
'WeakReference::get' => ['?object'],
'proc_open' => ['resource|false', 'command'=>'string|list<string>', 'descriptorspec'=>'array', '&w_pipes'=>'resource[]', 'cwd='=>'?string', 'env='=>'?array', 'other_options='=>'array'],
],
'old' => [
'implode\'2' => ['string', 'pieces'=>'array', 'glue'=>'string'],
Expand Down
14 changes: 14 additions & 0 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, string>|string, array<string, string> given.',
6,
],
]);
}

}
6 changes: 6 additions & 0 deletions tests/PHPStan/Rules/Functions/data/proc_open.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php declare(strict_types=1);

proc_open('echo "hello world"', [], $pipes);
proc_open(['echo', 'hello world'], [], $pipes);

proc_open(['something' => 'bogus', 'in' => 'here'], [], $pipes);

0 comments on commit 1e7ceae

Please sign in to comment.