Skip to content

Conversation

mad-briller
Copy link
Contributor

https://www.php.net/manual/en/function.fpm-get-status.php
https://www.php.net/manual/en/fpm.status.php#fpm.status.contents

An example from a local vagrant machine:

^ array:15 [▼
  "pool" => "admin"
  "process-manager" => "dynamic"
  "start-time" => 1664364711
  "start-since" => 3810
  "accepted-conn" => 7
  "listen-queue" => 0
  "max-listen-queue" => 0
  "listen-queue-len" => 0
  "idle-processes" => 1
  "active-processes" => 1
  "total-processes" => 2
  "max-active-processes" => 1
  "max-children-reached" => 0
  "slow-requests" => 0
  "procs" => array:2 [▼
    0 => array:14 [▼
      "pid" => 770
      "state" => "Running"
      "start-time" => 1664364711
      "start-since" => 3810
      "requests" => 4
      "request-duration" => 33595
      "request-method" => "GET"
      "request-uri" => "/admin/index.php"
      "query-string" => ""
      "request-length" => 0
      "user" => "-"
      "script" => "/vagrant/admin/public/index.php"
      "last-request-cpu" => 0.0
      "last-request-memory" => 0
    ]
    1 => array:14 [▼
      "pid" => 771
      "state" => "Idle"
      "start-time" => 1664364711
      "start-since" => 3810
      "requests" => 3
      "request-duration" => 73026
      "request-method" => "GET"
      "request-uri" => "/admin/index.php"
      "query-string" => ""
      "request-length" => 0
      "user" => "-"
      "script" => "/vagrant/admin/public/index.php"
      "last-request-cpu" => 54.775010415373
      "last-request-memory" => 4194304
    ]
  ]
]

@@ -2998,7 +2998,7 @@
'forward_static_call' => ['mixed', 'function'=>'callable', '...parameters='=>'mixed'],
'forward_static_call_array' => ['mixed', 'function'=>'callable', 'parameters'=>'array<int,mixed>'],
'fpassthru' => ['0|positive-int|false', 'fp'=>'resource'],
'fpm_get_status' => ['array|false'],
'fpm_get_status' => ['array{pool: string, process-manager: \'static\'|\'dynamic\'|\'ondemand\', 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>}>}'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active-processes and total-processes must be atleast 1 or this function will not have been called

@mad-briller mad-briller marked this pull request as draft October 5, 2022 16:17
@mad-briller mad-briller marked this pull request as ready for review October 5, 2022 16:18
@mad-briller
Copy link
Contributor Author

i added a test for this because that array shape is way too complex for a human to eyeball, but i'm seeing a failure because phpstan still thinks false can be returned from fpm_get_status

i've checked the jetbrains stubs and they have @return array so i'm not sure where phpstan is getting that information from.

unfortunately the CI doesn't seem to be running on pr's at the moment so it can't really be seen on here

@mad-briller
Copy link
Contributor Author

ah i've found it, it's here:
https://github.com/phpstan/php-8-stubs/blob/8214b152847de42ff4cf77ce6242fa150eb3f503/stubs/sapi/fpm/fpm/fpm_get_status.php

and there PR that added fpm_get_status is here, which clearly shows RETURN_FALSE:
https://github.com/php/php-src/pull/3182/files#diff-0354097cf69667d6a030457e558abb7f479910bf797bc019124738f1fb3edd93R1556

so i'm not sure what to believe 😅

@mad-briller
Copy link
Contributor Author

reading php-src it seems that false can be returned if the fpm scoreboard is absent or already locked, so the php.net docs are optimistic at best

@ondrejmirtes ondrejmirtes merged commit 2e16aff into phpstan:1.8.x Oct 13, 2022
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants