Skip to content

Commit 2e16aff

Browse files
mad-brillerondrejmirtes
authored andcommitted
Refined fpm_get_status function signature.
1 parent 32b3c67 commit 2e16aff

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

resources/functionMap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@
29982998
'forward_static_call' => ['mixed', 'function'=>'callable', '...parameters='=>'mixed'],
29992999
'forward_static_call_array' => ['mixed', 'function'=>'callable', 'parameters'=>'array<int,mixed>'],
30003000
'fpassthru' => ['0|positive-int|false', 'fp'=>'resource'],
3001-
'fpm_get_status' => ['array|false'],
3001+
'fpm_get_status' => ['array{pool: string, process-manager: \'dynamic\'|\'ondemand\'|\'static\', start-time: int<0, max>, start-since: int<0, max>, accepted-conn: int<0, max>, listen-queue: int<0, max>, max-listen-queue: int<0, max>, listen-queue-len: int<0, max>, idle-processes: int<0, max>, active-processes: int<1, max>, total-processes: int<1, max>, max-active-processes: int<1, max>, max-children-reached: 0|1, slow-requests: int<0, max>, procs: array<int, array{pid: int<2, max>, state: \'Idle\'|\'Running\', start-time: int<0, max>, start-since: int<0, max>, requests: int<0, max>, request-duration: int<0, max>, request-method: string, request-uri: string, query-string: string, request-length: int<0, max>, user: string, script: string, last-request-cpu: float, last-request-memory: int<0, max>}>}|false'],
30023002
'fprintf' => ['int', 'stream'=>'resource', 'format'=>'string', '...values='=>'string|int|float'],
30033003
'fputcsv' => ['0|positive-int|false', 'fp'=>'resource', 'fields'=>'array', 'delimiter='=>'string', 'enclosure='=>'string', 'escape_char='=>'string'],
30043004
'fputs' => ['0|positive-int|false', 'fp'=>'resource', 'str'=>'string', 'length='=>'0|positive-int'],

tests/PHPStan/Analyser/NodeScopeResolverTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,10 @@ public function dataFileAsserts(): iterable
10511051
yield from $this->gatherAssertTypes(__DIR__ . '/data/dnf.php');
10521052
}
10531053

1054+
if (PHP_VERSION_ID >= 70300) {
1055+
yield from $this->gatherAssertTypes(__DIR__ . '/data/fpm-get-status.php');
1056+
}
1057+
10541058
yield from $this->gatherAssertTypes(__DIR__ . '/data/array-offset-unset.php');
10551059
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8008.php');
10561060
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-5552.php');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace FpmGetStatus;
4+
5+
use function fpm_get_status;
6+
use function PHPStan\Testing\assertType;
7+
8+
$status = fpm_get_status();
9+
10+
assertType('array{pool: string, process-manager: \'dynamic\'|\'ondemand\'|\'static\', start-time: int<0, max>, start-since: int<0, max>, accepted-conn: int<0, max>, listen-queue: int<0, max>, max-listen-queue: int<0, max>, listen-queue-len: int<0, max>, idle-processes: int<0, max>, active-processes: int<1, max>, total-processes: int<1, max>, max-active-processes: int<1, max>, max-children-reached: 0|1, slow-requests: int<0, max>, procs: array<int, array{pid: int<2, max>, state: \'Idle\'|\'Running\', start-time: int<0, max>, start-since: int<0, max>, requests: int<0, max>, request-duration: int<0, max>, request-method: string, request-uri: string, query-string: string, request-length: int<0, max>, user: string, script: string, last-request-cpu: float, last-request-memory: int<0, max>}>}|false', $status);
11+
12+
if ($status !== false && isset($status['procs'][0])) {
13+
assertType('array{pid: int<2, max>, state: \'Idle\'|\'Running\', start-time: int<0, max>, start-since: int<0, max>, requests: int<0, max>, request-duration: int<0, max>, request-method: string, request-uri: string, query-string: string, request-length: int<0, max>, user: string, script: string, last-request-cpu: float, last-request-memory: int<0, max>}', $status['procs'][0]);
14+
15+
assertType('int<2, max>', $status['procs'][0]['pid']);
16+
}

0 commit comments

Comments
 (0)