Skip to content

Commit f9c5714

Browse files
committed
proc_get_status() - array shape for PHP 8
1 parent 7bc35cd commit f9c5714

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

resources/functionMap_php80delta.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
'PhpToken::is' => ['bool', 'kind'=>'string|int|string[]|int[]'],
7979
'PhpToken::isIgnorable' => ['bool'],
8080
'PhpToken::getTokenName' => ['string'],
81+
'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}', 'process'=>'resource'],
8182
'socket_addrinfo_lookup' => ['AddressInfo[]', 'node'=>'string', 'service='=>'mixed', 'hints='=>'array'],
8283
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['string|false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
8384
'str_contains' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
@@ -199,6 +200,7 @@
199200
'parse_str' => ['void', 'encoded_string'=>'string', '&w_result='=>'array'],
200201
'password_hash' => ['string|false|null', 'password'=>'string', 'algo'=>'?string|?int', 'options='=>'array'],
201202
'png2wbmp' => ['bool', 'pngname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'],
203+
'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'],
202204
'read_exif_data' => ['array', 'filename'=>'string', 'sections_needed='=>'string', 'sub_arrays='=>'bool', 'read_thumbnail='=>'bool'],
203205
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['?string|?false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
204206
'SplFileObject::fgetss' => ['string|false', 'allowable_tags='=>'string'],

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10807,6 +10807,11 @@ public function dataBug4538(): array
1080710807
return $this->gatherAssertTypes(__DIR__ . '/data/bug-4538.php');
1080810808
}
1080910809

10810+
public function dataProcGetStatus(): array
10811+
{
10812+
return $this->gatherAssertTypes(__DIR__ . '/data/proc_get_status.php');
10813+
}
10814+
1081010815
/**
1081110816
* @param string $file
1081210817
* @return array<string, mixed[]>
@@ -11030,6 +11035,7 @@ private function gatherAssertTypes(string $file): array
1103011035
* @dataProvider dataBug651
1103111036
* @dataProvider dataBug1283
1103211037
* @dataProvider dataBug4538
11038+
* @dataProvider dataProcGetStatus
1103311039
* @param string $assertType
1103411040
* @param string $file
1103511041
* @param mixed ...$args
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace ProcGetStatusBug;
4+
5+
use function PHPStan\Analyser\assertType;
6+
use function proc_get_status;
7+
8+
function ($r): void {
9+
$status = proc_get_status($r);
10+
if ($status === false) {
11+
return;
12+
}
13+
14+
assertType('array(\'command\' => string, \'pid\' => int, \'running\' => bool, \'signaled\' => bool, \'stopped\' => bool, \'exitcode\' => int, \'termsig\' => int, \'stopsig\' => int)', $status);
15+
};

0 commit comments

Comments
 (0)