Skip to content

Commit

Permalink
proc_get_status() - array shape for PHP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 17, 2021
1 parent 7bc35cd commit f9c5714
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions resources/functionMap_php80delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
'PhpToken::is' => ['bool', 'kind'=>'string|int|string[]|int[]'],
'PhpToken::isIgnorable' => ['bool'],
'PhpToken::getTokenName' => ['string'],
'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}', 'process'=>'resource'],
'socket_addrinfo_lookup' => ['AddressInfo[]', 'node'=>'string', 'service='=>'mixed', 'hints='=>'array'],
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['string|false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
'str_contains' => ['bool', 'haystack'=>'string', 'needle'=>'string'],
Expand Down Expand Up @@ -199,6 +200,7 @@
'parse_str' => ['void', 'encoded_string'=>'string', '&w_result='=>'array'],
'password_hash' => ['string|false|null', 'password'=>'string', 'algo'=>'?string|?int', 'options='=>'array'],
'png2wbmp' => ['bool', 'pngname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'],
'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'],
'read_exif_data' => ['array', 'filename'=>'string', 'sections_needed='=>'string', 'sub_arrays='=>'bool', 'read_thumbnail='=>'bool'],
'sodium_crypto_aead_chacha20poly1305_ietf_decrypt' => ['?string|?false', 'confidential_message'=>'string', 'public_message'=>'string', 'nonce'=>'string', 'key'=>'string'],
'SplFileObject::fgetss' => ['string|false', 'allowable_tags='=>'string'],
Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10807,6 +10807,11 @@ public function dataBug4538(): array
return $this->gatherAssertTypes(__DIR__ . '/data/bug-4538.php');
}

public function dataProcGetStatus(): array
{
return $this->gatherAssertTypes(__DIR__ . '/data/proc_get_status.php');
}

/**
* @param string $file
* @return array<string, mixed[]>
Expand Down Expand Up @@ -11030,6 +11035,7 @@ private function gatherAssertTypes(string $file): array
* @dataProvider dataBug651
* @dataProvider dataBug1283
* @dataProvider dataBug4538
* @dataProvider dataProcGetStatus
* @param string $assertType
* @param string $file
* @param mixed ...$args
Expand Down
15 changes: 15 additions & 0 deletions tests/PHPStan/Analyser/data/proc_get_status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace ProcGetStatusBug;

use function PHPStan\Analyser\assertType;
use function proc_get_status;

function ($r): void {
$status = proc_get_status($r);
if ($status === false) {
return;
}

assertType('array(\'command\' => string, \'pid\' => int, \'running\' => bool, \'signaled\' => bool, \'stopped\' => bool, \'exitcode\' => int, \'termsig\' => int, \'stopsig\' => int)', $status);
};

0 comments on commit f9c5714

Please sign in to comment.