The number of available processors is valuable for tools like php-cs-fixer, enabling parallel execution, or when used with semaphores to manage the concurrent execution of resource-intensive tasks. The new num_available_processors function simplifies getting the number of logical processors across various operating systems.
This RFC proposes the addition of a new function that retrieves the number of available processors:
function num_available_processors(): ?int
None.
Next PHP 8.x
This RFC introduces a new function, which might affect existing userland extensions if developers have already created helper functions with the same name. Since the proposed function has a clear and meaningful name, any custom functions should ideally do the same thing and be easy to replace.
There is no impact on SAPIs or the opcache.
There has already been some discussion on the GitHub pull request. While not currently proposed, a valuable addition could be the introduction of a class such as ReflectionServer or, OS (similar to Node.js, https://nodejs.org/api/os.html) to provide information about the underlying system. Existing functions like sys_getloadavg or php_uname could be integrated into this class.
Include these so readers know where you are heading and can discuss the proposed voting options.
https://github.com/php/php-src/pull/11137 (the current prototype, probably just a rename of the function is necessary)
After the project is implemented, this section should contain
Links to external references, discussions or RFCs
Keep this updated with features that were discussed on the mail lists.