Skip to content

Detection number of CPU cores 2.0.2 #12076

@matraux

Description

@matraux

Bug report

Version 2.0.2
https://github.com/phpstan/phpstan/releases/tag/1.12.11
phpstan/phpstan-src#3632
#12026

Issue with detection number of CPU cores still persist.
Tested with CPU Intel i9-13900H (14 cores / 20 threads).

Downloaded phpstan 2.0.0 via composer

composer require phpstan/phpstan 2.0.2

Ran analyse

php "vendor/bin/phpstan" analyse --configuration "bin/phpstan.neon" -vvv --ansi

Config neon

includes:
	- %currentWorkingDirectory%/.phpstan.neon

parameters:
	scanDirectories:
		- %currentWorkingDirectory%/App
		- %currentWorkingDirectory%/vendor
		- %currentWorkingDirectory%/libs

	paths:
		- %currentWorkingDirectory%/App

	tmpDir:
		%currentWorkingDirectory%/temp/phpstan

	level: 5

	editorUrlTitle: '%%relFile%%:%%line%%'

Result

Parallel processing scheduler:
# of detected CPU core:  1
....
....

So, i unpacked PHAR and removed try/catch from src\Process\CpuCoreCounter.php.
Then i tried to run standalone CpuCoreCounter in test index.php file:

<?php

use PHPStan\Process\CpuCoreCounter;

require_once 'vendor/autoload.php';

$counter = new CpuCoreCounter();
echo $counter->getNumberOfCpuCores();
exit;

and got this error:

Fatal error: Uncaught _PHPStan_c684505c9\Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound: Could not find the number of CPU cores available. in D:\WebDevelopment\Localhost\phpstan\vendor\fidry\cpu-core-counter\src\NumberOfCpuCoreNotFound.php:19

This issue was fixed in phpstan-src 2.0.x. I checked it again and phpstan-src 2.0.x detect CPU cores correctly. Issue should be with release phpstan 2.0.2.

Code snippet that reproduces the problem

No response

Expected output

Expected correct detection of CPU cores :-)

Did PHPStan help you today? Did it make you happy in any way?

All the time :-). I recomended phpstan all developers who i knows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions