Updated Rector to commit 5a4111e518e866379e5cdce1d9b3b282dfccaa3d

5a4111e518 Bump composer dependencies (#3208)
This commit is contained in:
Tomas Votruba 2022-12-16 14:30:13 +00:00
parent 4fefacce80
commit 2b660785e9
37 changed files with 1264 additions and 155 deletions

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ee4050a5250045ad14cee2982d49daca1367250b';
public const PACKAGE_VERSION = '5a4111e518e866379e5cdce1d9b3b282dfccaa3d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-12-16 12:39:59';
public const RELEASE_DATE = '2022-12-16 15:25:29';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4::getLoader();
return ComposerAutoloaderInit04c2ebb1fb4a68b730cfdc19fa6a61df::getLoader();

View File

@ -415,6 +415,25 @@ return array(
'RectorPrefix202212\\Evenement\\EventEmitter' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitter.php',
'RectorPrefix202212\\Evenement\\EventEmitterInterface' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitterInterface.php',
'RectorPrefix202212\\Evenement\\EventEmitterTrait' => $vendorDir . '/evenement/evenement/src/Evenement/EventEmitterTrait.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\CpuCoreCounter' => $vendorDir . '/fidry/cpu-core-counter/src/CpuCoreCounter.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Diagnoser' => $vendorDir . '/fidry/cpu-core-counter/src/Diagnoser.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Exec\\ProcOpen' => $vendorDir . '/fidry/cpu-core-counter/src/Exec/ProcOpen.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\CpuCoreFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/CpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\CpuInfoFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/CpuInfoFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\DummyCpuCoreFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/DummyCpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\FinderRegistry' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/FinderRegistry.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\HwLogicalFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/HwLogicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\HwPhysicalFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/HwPhysicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NProcFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/NProcFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NProcessorFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/NProcessorFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NullCpuCoreFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/NullCpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\OnlyOnWindowsFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/OnlyOnWindowsFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\ProcOpenBasedFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/ProcOpenBasedFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\SkipOnWindowsFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/SkipOnWindowsFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\WmicLogicalFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/WmicLogicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\WmicPhysicalFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/WmicPhysicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\_NProcessorFinder' => $vendorDir . '/fidry/cpu-core-counter/src/Finder/_NProcessorFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\NumberOfCpuCoreNotFound' => $vendorDir . '/fidry/cpu-core-counter/src/NumberOfCpuCoreNotFound.php',
'RectorPrefix202212\\Nette\\ArgumentOutOfRangeException' => $vendorDir . '/nette/utils/src/exceptions.php',
'RectorPrefix202212\\Nette\\DeprecatedException' => $vendorDir . '/nette/utils/src/exceptions.php',
'RectorPrefix202212\\Nette\\DirectoryNotFoundException' => $vendorDir . '/nette/utils/src/exceptions.php',

View File

@ -39,6 +39,7 @@ return array(
'RectorPrefix202212\\Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'RectorPrefix202212\\Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'RectorPrefix202212\\OndraM\\CiDetector\\' => array($vendorDir . '/ondram/ci-detector/src'),
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\' => array($vendorDir . '/fidry/cpu-core-counter/src'),
'RectorPrefix202212\\Evenement\\' => array($vendorDir . '/evenement/evenement/src/Evenement'),
'RectorPrefix202212\\Doctrine\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib/Doctrine/Inflector'),
'RectorPrefix202212\\Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4
class ComposerAutoloaderInit04c2ebb1fb4a68b730cfdc19fa6a61df
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit04c2ebb1fb4a68b730cfdc19fa6a61df', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit04c2ebb1fb4a68b730cfdc19fa6a61df', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit74737f53e41693f5d63b624a9927fda4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit74737f53e41693f5d63b624a9927fda4::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire74737f53e41693f5d63b624a9927fda4($fileIdentifier, $file);
composerRequire04c2ebb1fb4a68b730cfdc19fa6a61df($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit74737f53e41693f5d63b624a9927fda4
* @param string $file
* @return void
*/
function composerRequire74737f53e41693f5d63b624a9927fda4($fileIdentifier, $file)
function composerRequire04c2ebb1fb4a68b730cfdc19fa6a61df($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit74737f53e41693f5d63b624a9927fda4
class ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -56,6 +56,7 @@ class ComposerStaticInit74737f53e41693f5d63b624a9927fda4
'RectorPrefix202212\\Psr\\Container\\' => 33,
'RectorPrefix202212\\Psr\\Cache\\' => 29,
'RectorPrefix202212\\OndraM\\CiDetector\\' => 37,
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\' => 40,
'RectorPrefix202212\\Evenement\\' => 29,
'RectorPrefix202212\\Doctrine\\Inflector\\' => 38,
'RectorPrefix202212\\Composer\\XdebugHandler\\' => 42,
@ -207,6 +208,10 @@ class ComposerStaticInit74737f53e41693f5d63b624a9927fda4
array (
0 => __DIR__ . '/..' . '/ondram/ci-detector/src',
),
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\' =>
array (
0 => __DIR__ . '/..' . '/fidry/cpu-core-counter/src',
),
'RectorPrefix202212\\Evenement\\' =>
array (
0 => __DIR__ . '/..' . '/evenement/evenement/src/Evenement',
@ -655,6 +660,25 @@ class ComposerStaticInit74737f53e41693f5d63b624a9927fda4
'RectorPrefix202212\\Evenement\\EventEmitter' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitter.php',
'RectorPrefix202212\\Evenement\\EventEmitterInterface' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitterInterface.php',
'RectorPrefix202212\\Evenement\\EventEmitterTrait' => __DIR__ . '/..' . '/evenement/evenement/src/Evenement/EventEmitterTrait.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\CpuCoreCounter' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/CpuCoreCounter.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Diagnoser' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Diagnoser.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Exec\\ProcOpen' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Exec/ProcOpen.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\CpuCoreFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/CpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\CpuInfoFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/CpuInfoFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\DummyCpuCoreFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/DummyCpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\FinderRegistry' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/FinderRegistry.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\HwLogicalFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/HwLogicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\HwPhysicalFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/HwPhysicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NProcFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/NProcFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NProcessorFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/NProcessorFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\NullCpuCoreFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/NullCpuCoreFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\OnlyOnWindowsFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/OnlyOnWindowsFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\ProcOpenBasedFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/ProcOpenBasedFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\SkipOnWindowsFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/SkipOnWindowsFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\WmicLogicalFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/WmicLogicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\WmicPhysicalFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/WmicPhysicalFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\Finder\\_NProcessorFinder' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/Finder/_NProcessorFinder.php',
'RectorPrefix202212\\Fidry\\CpuCoreCounter\\NumberOfCpuCoreNotFound' => __DIR__ . '/..' . '/fidry/cpu-core-counter/src/NumberOfCpuCoreNotFound.php',
'RectorPrefix202212\\Nette\\ArgumentOutOfRangeException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
'RectorPrefix202212\\Nette\\DeprecatedException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
'RectorPrefix202212\\Nette\\DirectoryNotFoundException' => __DIR__ . '/..' . '/nette/utils/src/exceptions.php',
@ -3030,9 +3054,9 @@ class ComposerStaticInit74737f53e41693f5d63b624a9927fda4
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit74737f53e41693f5d63b624a9927fda4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit74737f53e41693f5d63b624a9927fda4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit74737f53e41693f5d63b624a9927fda4::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit04c2ebb1fb4a68b730cfdc19fa6a61df::$classMap;
}, null, ClassLoader::class);
}

View File

@ -438,6 +438,70 @@
},
"install-path": "..\/evenement\/evenement"
},
{
"name": "fidry\/cpu-core-counter",
"version": "0.4.0",
"version_normalized": "0.4.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/theofidry\/cpu-core-counter.git",
"reference": "666cb04a02f2801f3b19955fc23c824f9018bf64"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/theofidry\/cpu-core-counter\/zipball\/666cb04a02f2801f3b19955fc23c824f9018bf64",
"reference": "666cb04a02f2801f3b19955fc23c824f9018bf64",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"fidry\/makefile": "^0.2.0",
"phpstan\/extension-installer": "^1.2.0",
"phpstan\/phpstan": "^1.9.2",
"phpstan\/phpstan-deprecation-rules": "^1.0.0",
"phpstan\/phpstan-phpunit": "^1.2.2",
"phpstan\/phpstan-strict-rules": "^1.4.4",
"phpunit\/phpunit": "^9.5.26 || ^8.5.31",
"theofidry\/php-cs-fixer-config": "^1.0",
"webmozarts\/strict-phpunit": "^7.5"
},
"time": "2022-12-10T21:26:31+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"RectorPrefix202212\\Fidry\\CpuCoreCounter\\": "src\/"
}
},
"notification-url": "https:\/\/packagist.org\/downloads\/",
"license": [
"MIT"
],
"authors": [
{
"name": "Th\u00e9o FIDRY",
"email": "theo.fidry@gmail.com"
}
],
"description": "Tiny utility to get the number of CPU cores.",
"keywords": [
"CPU",
"core"
],
"support": {
"issues": "https:\/\/github.com\/theofidry\/cpu-core-counter\/issues",
"source": "https:\/\/github.com\/theofidry\/cpu-core-counter\/tree\/0.4.0"
},
"funding": [
{
"url": "https:\/\/github.com\/theofidry",
"type": "github"
}
],
"install-path": "..\/fidry\/cpu-core-counter"
},
{
"name": "nette\/utils",
"version": "v3.2.8",
@ -2969,52 +3033,53 @@
},
{
"name": "symplify\/easy-parallel",
"version": "11.1.17",
"version_normalized": "11.1.17.0",
"version": "11.1.18",
"version_normalized": "11.1.18.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/easy-parallel.git",
"reference": "451d792f838028cd83dcf157abdb3ed2d9192286"
"reference": "6376d67294222689f51cd4f791024178520c8856"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-parallel\/zipball\/451d792f838028cd83dcf157abdb3ed2d9192286",
"reference": "451d792f838028cd83dcf157abdb3ed2d9192286",
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-parallel\/zipball\/6376d67294222689f51cd4f791024178520c8856",
"reference": "6376d67294222689f51cd4f791024178520c8856",
"shasum": ""
},
"require": {
"clue\/ndjson-react": "^1.2",
"fidry\/cpu-core-counter": "^0.4.0",
"php": ">=8.1",
"react\/child-process": "^0.6.5",
"react\/event-loop": "^1.3",
"react\/socket": "^1.12",
"symfony\/console": "^6.1"
"symfony\/console": "^6.2"
},
"conflict": {
"symplify\/autowire-array-parameter": "<11.1.17",
"symplify\/coding-standard": "<11.1.17",
"symplify\/composer-json-manipulator": "<11.1.17",
"symplify\/config-transformer": "<11.1.17",
"symplify\/easy-ci": "<11.1.17",
"symplify\/easy-coding-standard": "<11.1.17",
"symplify\/easy-testing": "<11.1.17",
"symplify\/monorepo-builder": "<11.1.17",
"symplify\/package-builder": "<11.1.17",
"symplify\/php-config-printer": "<11.1.17",
"symplify\/phpstan-extensions": "<11.1.17",
"symplify\/phpstan-rules": "<11.1.17",
"symplify\/rule-doc-generator": "<11.1.17",
"symplify\/rule-doc-generator-contracts": "<11.1.17",
"symplify\/smart-file-system": "<11.1.17",
"symplify\/symfony-static-dumper": "<11.1.17",
"symplify\/symplify-kernel": "<11.1.17",
"symplify\/vendor-patches": "<11.1.17"
"symplify\/autowire-array-parameter": "<11.1.18",
"symplify\/coding-standard": "<11.1.18",
"symplify\/composer-json-manipulator": "<11.1.18",
"symplify\/config-transformer": "<11.1.18",
"symplify\/easy-ci": "<11.1.18",
"symplify\/easy-coding-standard": "<11.1.18",
"symplify\/easy-testing": "<11.1.18",
"symplify\/monorepo-builder": "<11.1.18",
"symplify\/package-builder": "<11.1.18",
"symplify\/php-config-printer": "<11.1.18",
"symplify\/phpstan-extensions": "<11.1.18",
"symplify\/phpstan-rules": "<11.1.18",
"symplify\/rule-doc-generator": "<11.1.18",
"symplify\/rule-doc-generator-contracts": "<11.1.18",
"symplify\/smart-file-system": "<11.1.18",
"symplify\/symfony-static-dumper": "<11.1.18",
"symplify\/symplify-kernel": "<11.1.18",
"symplify\/vendor-patches": "<11.1.18"
},
"require-dev": {
"phpunit\/phpunit": "^9.5.25",
"symplify\/package-builder": "^11.1.17"
"phpunit\/phpunit": "^9.5.26",
"symplify\/package-builder": "^11.1.18"
},
"time": "2022-11-10T15:22:58+00:00",
"time": "2022-12-16T14:05:42+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -3034,23 +3099,23 @@
"description": "Helper package for easier CLI project parallelization",
"support": {
"issues": "https:\/\/github.com\/symplify\/easy-parallel\/issues",
"source": "https:\/\/github.com\/symplify\/easy-parallel\/tree\/11.1.17"
"source": "https:\/\/github.com\/symplify\/easy-parallel\/tree\/11.1.18"
},
"install-path": "..\/symplify\/easy-parallel"
},
{
"name": "symplify\/rule-doc-generator-contracts",
"version": "11.1.17",
"version_normalized": "11.1.17.0",
"version": "11.1.18",
"version_normalized": "11.1.18.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts.git",
"reference": "db548865295b95fcd5f868f0782fedef1e96fcb1"
"reference": "1d72ded986974ff6b1f621c94a7e4a23524efb91"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/db548865295b95fcd5f868f0782fedef1e96fcb1",
"reference": "db548865295b95fcd5f868f0782fedef1e96fcb1",
"url": "https:\/\/api.github.com\/repos\/symplify\/rule-doc-generator-contracts\/zipball\/1d72ded986974ff6b1f621c94a7e4a23524efb91",
"reference": "1d72ded986974ff6b1f621c94a7e4a23524efb91",
"shasum": ""
},
"require": {
@ -3058,26 +3123,26 @@
"php": ">=8.1"
},
"conflict": {
"symplify\/autowire-array-parameter": "<11.1.17",
"symplify\/coding-standard": "<11.1.17",
"symplify\/composer-json-manipulator": "<11.1.17",
"symplify\/config-transformer": "<11.1.17",
"symplify\/easy-ci": "<11.1.17",
"symplify\/easy-coding-standard": "<11.1.17",
"symplify\/easy-parallel": "<11.1.17",
"symplify\/easy-testing": "<11.1.17",
"symplify\/monorepo-builder": "<11.1.17",
"symplify\/package-builder": "<11.1.17",
"symplify\/php-config-printer": "<11.1.17",
"symplify\/phpstan-extensions": "<11.1.17",
"symplify\/phpstan-rules": "<11.1.17",
"symplify\/rule-doc-generator": "<11.1.17",
"symplify\/smart-file-system": "<11.1.17",
"symplify\/symfony-static-dumper": "<11.1.17",
"symplify\/symplify-kernel": "<11.1.17",
"symplify\/vendor-patches": "<11.1.17"
"symplify\/autowire-array-parameter": "<11.1.18",
"symplify\/coding-standard": "<11.1.18",
"symplify\/composer-json-manipulator": "<11.1.18",
"symplify\/config-transformer": "<11.1.18",
"symplify\/easy-ci": "<11.1.18",
"symplify\/easy-coding-standard": "<11.1.18",
"symplify\/easy-parallel": "<11.1.18",
"symplify\/easy-testing": "<11.1.18",
"symplify\/monorepo-builder": "<11.1.18",
"symplify\/package-builder": "<11.1.18",
"symplify\/php-config-printer": "<11.1.18",
"symplify\/phpstan-extensions": "<11.1.18",
"symplify\/phpstan-rules": "<11.1.18",
"symplify\/rule-doc-generator": "<11.1.18",
"symplify\/smart-file-system": "<11.1.18",
"symplify\/symfony-static-dumper": "<11.1.18",
"symplify\/symplify-kernel": "<11.1.18",
"symplify\/vendor-patches": "<11.1.18"
},
"time": "2022-11-10T15:23:14+00:00",
"time": "2022-12-16T14:04:58+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -3096,7 +3161,7 @@
],
"description": "Contracts for production code of RuleDocGenerator",
"support": {
"source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/11.1.17"
"source": "https:\/\/github.com\/symplify\/rule-doc-generator-contracts\/tree\/11.1.18"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,16 @@
# The MIT License (MIT)
Copyright (c) 2022 Théo FIDRY <theo.fidry@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the _Software_), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED **AS IS**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

114
vendor/fidry/cpu-core-counter/README.md vendored Normal file
View File

@ -0,0 +1,114 @@
# CPU Core Counter
This package is a tiny utility to get the number of CPU cores.
```sh
composer require fidry/cpu-core-counter
```
## Usage
```php
use Fidry\CpuCoreCounter\CpuCoreCounter;
use Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
use Fidry\CpuCoreCounter\Finder\DummyCpuCoreFinder;
$counter = new CpuCoreCounter();
try {
$counter->getCount(); // e.g. 8
} catch (NumberOfCpuCoreNotFound) {
return 1; // Fallback value
}
// An alternative form where we not want to catch the exception:
$counter = new CpuCoreCounter([
...CpuCoreCounter::getDefaultFinders(),
new DummyCpuCoreFinder(1), // Fallback value
]);
$counter->getCount(); // e.g. 8
```
## Advanced usage
### Changing the finders
When creating `CpuCoreCounter`, you may want to change the order of the finders
used or disable a specific finder. You can easily do so by passing the finders
you want
```php
// Remove WindowsWmicFinder
$finders = array_filter(
CpuCoreCounter::getDefaultFinders(),
static fn (CpuCoreFinder $finder) => !($finder instanceof WindowsWmicFinder)
);
$cores = (new CpuCoreCounter($finders))->getCount();
```
```php
// Use CPUInfo first & don't use Nproc
$finders = [
new CpuInfoFinder(),
new WindowsWmicFinder(),
new HwLogicalFinder(),
];
$cores = (new CpuCoreCounter($finders))->getCount();
```
### Choosing only logical or physical finders
`FinderRegistry` provides two helpful entries:
- `::getDefaultLogicalFinders()`: gives an ordered list of finders that will
look for the _logical_ CPU cores count
- `::getDefaultPhysicalFinders()`: gives an ordered list of finders that will
look for the _physical_ CPU cores count
By default when using `CpuCoreCounter`, it will use the logical finders since
it is more likely what you are looking for and is what is used by PHP source to
build the PHP binary.
### Checks what finders find what on your system
You have two commands available that provides insight about what the finders
can find:
```
$ make diagnosis # From this repository
$ ./vendor/fidry/cpu-core-counter/bin/diagnose.php # From the library
```
And:
```
$ make execute # From this repository
$ ./vendor/fidry/cpu-core-counter/bin/execute.php # From the library
```
## Backward Compatibility Promise (BCP)
The policy is for the major part following the same as [Symfony's one][symfony-bc-policy].
Note that the code marked as `@private` or `@internal` are excluded from the BCP.
The following elements are also excluded:
- The `diagnose` and `execute` commands: those are for debugging/inspection purposes only
- `FinderRegistry::get*Finders()`: new finders may be added or the order of finders changed at any time
## License
This package is licensed using the MIT License.
Please have a look at [`LICENSE.md`](LICENSE.md).
[symfony-bc-policy]: https://symfony.com/doc/current/contributing/code/bc.html

View File

@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212;
use RectorPrefix202212\Fidry\CpuCoreCounter\Diagnoser;
use RectorPrefix202212\Fidry\CpuCoreCounter\Finder\FinderRegistry;
require_once __DIR__ . '/../vendor/autoload.php';
echo 'Running diagnosis...' . \PHP_EOL . \PHP_EOL;
echo Diagnoser::diagnose(FinderRegistry::getAllVariants()) . \PHP_EOL;

View File

@ -0,0 +1,18 @@
#!/usr/bin/env php
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212;
use RectorPrefix202212\Fidry\CpuCoreCounter\Diagnoser;
use RectorPrefix202212\Fidry\CpuCoreCounter\Finder\FinderRegistry;
require_once __DIR__ . '/../vendor/autoload.php';
echo 'Executing finders...' . \PHP_EOL . \PHP_EOL;
echo Diagnoser::execute(FinderRegistry::getAllVariants()) . \PHP_EOL;

View File

@ -0,0 +1,48 @@
{
"name": "fidry\/cpu-core-counter",
"description": "Tiny utility to get the number of CPU cores.",
"license": "MIT",
"type": "library",
"keywords": [
"cpu",
"core"
],
"authors": [
{
"name": "Th\u00e9o FIDRY",
"email": "theo.fidry@gmail.com"
}
],
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"fidry\/makefile": "^0.2.0",
"phpstan\/extension-installer": "^1.2.0",
"phpstan\/phpstan": "^1.9.2",
"phpstan\/phpstan-deprecation-rules": "^1.0.0",
"phpstan\/phpstan-phpunit": "^1.2.2",
"phpstan\/phpstan-strict-rules": "^1.4.4",
"phpunit\/phpunit": "^9.5.26 || ^8.5.31",
"theofidry\/php-cs-fixer-config": "^1.0",
"webmozarts\/strict-phpunit": "^7.5"
},
"autoload": {
"psr-4": {
"RectorPrefix202212\\Fidry\\CpuCoreCounter\\": "src\/"
}
},
"autoload-dev": {
"psr-4": {
"RectorPrefix202212\\Fidry\\CpuCoreCounter\\Test\\": "tests\/"
}
},
"config": {
"allow-plugins": {
"ergebnis\/composer-normalize": true,
"infection\/extension-installer": true,
"phpstan\/extension-installer": true
},
"sort-packages": true
}
}

View File

@ -0,0 +1,76 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter;
use RectorPrefix202212\Fidry\CpuCoreCounter\Finder\CpuCoreFinder;
use RectorPrefix202212\Fidry\CpuCoreCounter\Finder\FinderRegistry;
final class CpuCoreCounter
{
/**
* @var list<CpuCoreFinder>
*/
private $finders;
/**
* @var positive-int|null
*/
private $count;
/**
* @param list<CpuCoreFinder>|null $finders
*/
public function __construct(?array $finders = null)
{
$this->finders = $finders ?? FinderRegistry::getDefaultLogicalFinders();
}
/**
* @throws NumberOfCpuCoreNotFound
*
* @return positive-int
*/
public function getCount() : int
{
// Memoize result
if (null === $this->count) {
$this->count = $this->findCount();
}
return $this->count;
}
/**
* @throws NumberOfCpuCoreNotFound
*
* @return positive-int
*/
private function findCount() : int
{
foreach ($this->finders as $finder) {
$cores = $finder->find();
if (null !== $cores) {
return $cores;
}
}
throw NumberOfCpuCoreNotFound::create();
}
/**
* @throws NumberOfCpuCoreNotFound
*
* @return array{CpuCoreFinder, positive-int}
*/
public function getFinderAndCores() : array
{
foreach ($this->finders as $finder) {
$cores = $finder->find();
if (null !== $cores) {
return [$finder, $cores];
}
}
throw NumberOfCpuCoreNotFound::create();
}
}

View File

@ -0,0 +1,63 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter;
use RectorPrefix202212\Fidry\CpuCoreCounter\Finder\CpuCoreFinder;
use function array_map;
use function explode;
use function implode;
use function max;
use function str_repeat;
use const PHP_EOL;
/**
* Utility to debug.
*
* @private
*/
final class Diagnoser
{
/**
* Provides an aggregated diagnosis based on each finders diagnosis.
*
* @param list<CpuCoreFinder> $finders
*/
public static function diagnose(array $finders) : string
{
$diagnoses = array_map(static function (CpuCoreFinder $finder) : string {
return self::diagnoseFinder($finder);
}, $finders);
return implode(PHP_EOL, $diagnoses);
}
/**
* Executes each finders.
*
* @param list<CpuCoreFinder> $finders
*/
public static function execute(array $finders) : string
{
$diagnoses = array_map(static function (CpuCoreFinder $finder) : string {
$coresCount = $finder->find();
return implode('', [$finder->toString(), ': ', null === $coresCount ? 'NULL' : $coresCount]);
}, $finders);
return implode(PHP_EOL, $diagnoses);
}
private static function diagnoseFinder(CpuCoreFinder $finder) : string
{
$diagnosis = $finder->diagnose();
$maxLineLength = max(array_map('strlen', explode(PHP_EOL, $diagnosis)));
$separator = str_repeat('-', $maxLineLength);
return implode('', [$finder->toString() . ':' . PHP_EOL, $separator . PHP_EOL, $diagnosis . PHP_EOL, $separator . PHP_EOL]);
}
private function __construct()
{
}
}

View File

@ -0,0 +1,45 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Exec;
use function fclose;
use function is_resource;
use function proc_close;
use function proc_open;
use function stream_get_contents;
final class ProcOpen
{
/**
* @return array{string, string} STDOUT & STDERR tuple
*/
public static function execute(string $command) : ?array
{
$pipes = [];
$process = @proc_open($command, [
['pipe', 'rb'],
['pipe', 'wb'],
// stdout
['pipe', 'wb'],
], $pipes);
if (!is_resource($process)) {
return null;
}
fclose($pipes[0]);
$stdout = (string) stream_get_contents($pipes[1]);
$stderr = (string) stream_get_contents($pipes[2]);
proc_close($process);
return [$stdout, $stderr];
}
private function __construct()
{
}
}

View File

@ -0,0 +1,33 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
interface CpuCoreFinder
{
/**
* Provides an explanation which may offer some insight as to what the finder
* will be able to find.
*
* This is practical to have an idea of what each finder will find collect
* information for the unit tests, since integration tests are quite complicated
* as dependent on complex infrastructures.
*/
public function diagnose() : string;
/**
* Find the number of CPU cores. If it could not find it, returns null. The
* means used to find the cores are at the implementation discretion.
*
* @return positive-int|null
*/
public function find() : ?int;
public function toString() : string;
}

View File

@ -0,0 +1,70 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function file_get_contents;
use function is_file;
use function sprintf;
use function substr_count;
use const PHP_EOL;
/**
* Find the number of CPU cores looking up at the cpuinfo file which is available
* on Linux systems and Windows systems with a Linux sub-system.
*
* @see https://github.com/paratestphp/paratest/blob/c163539818fd96308ca8dc60f46088461e366ed4/src/Runners/PHPUnit/Options.php#L903-L909
* @see https://unix.stackexchange.com/questions/146051/number-of-processors-in-proc-cpuinfo
*/
final class CpuInfoFinder implements CpuCoreFinder
{
private const CPU_INFO_PATH = '/proc/cpuinfo';
public function diagnose() : string
{
if (!is_file(self::CPU_INFO_PATH)) {
return sprintf('The file "%s" could not be found.', self::CPU_INFO_PATH);
}
$cpuInfo = file_get_contents(self::CPU_INFO_PATH);
if (\false === $cpuInfo) {
return sprintf('Could not get the content of the file "%s".', self::CPU_INFO_PATH);
}
return sprintf('Found the file "%s" with the content:%s%s', self::CPU_INFO_PATH, PHP_EOL, $cpuInfo);
}
/**
* @return positive-int|null
*/
public function find() : ?int
{
$cpuInfo = self::getCpuInfo();
return null === $cpuInfo ? null : self::countCpuCores($cpuInfo);
}
public function toString() : string
{
return 'CpuInfoFinder';
}
private static function getCpuInfo() : ?string
{
if (!@is_file(self::CPU_INFO_PATH)) {
return null;
}
$cpuInfo = @file_get_contents(self::CPU_INFO_PATH);
return \false === $cpuInfo ? null : $cpuInfo;
}
/**
* @internal
*
* @return positive-int|null
*/
public static function countCpuCores(string $cpuInfo) : ?int
{
$processorCount = substr_count($cpuInfo, 'processor');
return $processorCount > 0 ? $processorCount : null;
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function sprintf;
/**
* This finder returns whatever value you gave to it. This is useful for testing
* or as a fallback to avoid to catch the NumberOfCpuCoreNotFound exception.
*/
final class DummyCpuCoreFinder implements CpuCoreFinder
{
/**
* @var positive-int
*/
private $count;
public function diagnose() : string
{
return sprintf('Will return "%d".', $this->count);
}
/**
* @param positive-int $count
*/
public function __construct(int $count)
{
$this->count = $count;
}
public function find() : ?int
{
return $this->count;
}
public function toString() : string
{
return sprintf('DummyCpuCoreFinder(value=%d)', $this->count);
}
}

View File

@ -0,0 +1,40 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
final class FinderRegistry
{
/**
* @return list<CpuCoreFinder> List of all the known finders with all their variants.
*/
public static function getAllVariants() : array
{
return [new CpuInfoFinder(), new DummyCpuCoreFinder(1), new HwLogicalFinder(), new HwPhysicalFinder(), new _NProcessorFinder(), new NProcessorFinder(), new NProcFinder(\true), new NProcFinder(\false), new NullCpuCoreFinder(), new OnlyOnWindowsFinder(new DummyCpuCoreFinder(1)), new SkipOnWindowsFinder(new DummyCpuCoreFinder(1)), new WmicPhysicalFinder(), new WmicLogicalFinder()];
}
/**
* @return list<CpuCoreFinder>
*/
public static function getDefaultLogicalFinders() : array
{
return [new OnlyOnWindowsFinder(new WmicLogicalFinder()), new NProcFinder(), new HwLogicalFinder(), new _NProcessorFinder(), new NProcessorFinder(), new CpuInfoFinder()];
}
/**
* @return list<CpuCoreFinder>
*/
public static function getDefaultPhysicalFinders() : array
{
return [new OnlyOnWindowsFinder(new WmicPhysicalFinder()), new HwPhysicalFinder()];
}
private function __construct()
{
}
}

View File

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
/**
* Find the number of logical CPU cores for Linux, BSD and OSX.
*
* @see https://github.com/paratestphp/paratest/blob/c163539818fd96308ca8dc60f46088461e366ed4/src/Runners/PHPUnit/Options.php#L903-L909
* @see https://opensource.apple.com/source/xnu/xnu-792.2.4/libkern/libkern/sysctl.h.auto.html
*/
final class HwLogicalFinder extends ProcOpenBasedFinder
{
protected function getCommand() : string
{
return 'sysctl -n hw.logicalcpu';
}
public function toString() : string
{
return 'HwLogicalFinder';
}
}

View File

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
/**
* Find the number of physical CPU cores for Linux, BSD and OSX.
*
* @see https://github.com/paratestphp/paratest/blob/c163539818fd96308ca8dc60f46088461e366ed4/src/Runners/PHPUnit/Options.php#L903-L909
* @see https://opensource.apple.com/source/xnu/xnu-792.2.4/libkern/libkern/sysctl.h.auto.html
*/
final class HwPhysicalFinder extends ProcOpenBasedFinder
{
protected function getCommand() : string
{
return 'sysctl -n hw.physicalcpu';
}
public function toString() : string
{
return 'HwPhysicalFinder';
}
}

View File

@ -0,0 +1,53 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function filter_var;
use function is_int;
use function sprintf;
use const FILTER_VALIDATE_INT;
/**
* The number of (logical) cores.
*
* @see https://github.com/infection/infection/blob/fbd8c44/src/Resource/Processor/CpuCoresCountProvider.php#L69-L82
* @see https://unix.stackexchange.com/questions/146051/number-of-processors-in-proc-cpuinfo
*/
final class NProcFinder extends ProcOpenBasedFinder
{
/**
* @var bool
*/
private $all;
/**
* @param bool $all If disabled will give the number of cores available for the current process only.
*/
public function __construct(bool $all = \true)
{
$this->all = $all;
}
public function toString() : string
{
return sprintf('NProcFinder(all=%s)', $this->all ? 'true' : 'false');
}
protected function getCommand() : string
{
return 'nproc' . ($this->all ? ' --all' : '') . ' 2>&1';
}
/**
* @return positive-int|null
*/
public static function countCpuCores(string $nproc) : ?int
{
$cpuCount = filter_var($nproc, FILTER_VALIDATE_INT);
return is_int($cpuCount) && $cpuCount > 0 ? $cpuCount : null;
}
}

View File

@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
/**
* Find the number of logical CPU cores for FreeSBD, Solaris and the likes.
*
* @see https://twitter.com/freebsdfrau/status/1052016199452700678?s=20&t=M2pHkRqmmna-UF68lfL2hw
*/
final class NProcessorFinder extends ProcOpenBasedFinder
{
protected function getCommand() : string
{
return 'getconf NPROCESSORS_ONLN';
}
public function toString() : string
{
return 'NProcessorFinder';
}
}

View File

@ -0,0 +1,31 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
/**
* This finder returns whatever value you gave to it. This is useful for testing.
*/
final class NullCpuCoreFinder implements CpuCoreFinder
{
public function diagnose() : string
{
return 'Will return "null".';
}
public function find() : ?int
{
return null;
}
public function toString() : string
{
return 'NullCpuCoreFinder';
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function defined;
use function sprintf;
final class OnlyOnWindowsFinder implements CpuCoreFinder
{
/**
* @var CpuCoreFinder
*/
private $decoratedFinder;
public function __construct(CpuCoreFinder $decoratedFinder)
{
$this->decoratedFinder = $decoratedFinder;
}
public function diagnose() : string
{
return self::skip() ? 'Non-windows platform detected (PHP_WINDOWS_VERSION_MAJOR is not set).' : $this->decoratedFinder->diagnose();
}
public function find() : ?int
{
return self::skip() ? null : $this->decoratedFinder->find();
}
public function toString() : string
{
return sprintf('OnlyOnWindowsFinder(%s)', $this->decoratedFinder->toString());
}
private static function skip() : bool
{
// Skip if not on Windows. Rely on PHP to detect the platform
// rather than reading the platform name or others.
return !defined('PHP_WINDOWS_VERSION_MAJOR');
}
}

View File

@ -0,0 +1,65 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use RectorPrefix202212\Fidry\CpuCoreCounter\Exec\ProcOpen;
use function filter_var;
use function function_exists;
use function is_int;
use function sprintf;
use function trim;
use const FILTER_VALIDATE_INT;
use const PHP_EOL;
abstract class ProcOpenBasedFinder implements CpuCoreFinder
{
public function diagnose() : string
{
if (!function_exists('proc_open')) {
return 'The function "proc_open" is not available.';
}
$command = $this->getCommand();
$output = ProcOpen::execute($command);
if (null === $output) {
return sprintf('Failed to execute the command "%s".', $command);
}
[$stdout, $stderr] = $output;
$failed = '' !== trim($stderr);
return $failed ? sprintf('Executed the command "%s" which wrote the following output to the STDERR:%s%s', $command, PHP_EOL, $stderr) : sprintf('Executed the command "%s" and got the following (STDOUT) output:%s%s', $command, PHP_EOL, $stdout);
}
/**
* @return positive-int|null
*/
public function find() : ?int
{
if (!function_exists('proc_open')) {
return null;
}
$output = ProcOpen::execute($this->getCommand());
if (null === $output) {
return null;
}
[$stdout, $stderr] = $output;
$failed = '' !== trim($stderr);
return $failed ? null : self::countCpuCores($stdout);
}
/**
* @internal
*
* @return positive-int|null
*/
public static function countCpuCores(string $process) : ?int
{
$cpuCount = filter_var($process, FILTER_VALIDATE_INT);
return is_int($cpuCount) && $cpuCount > 0 ? $cpuCount : null;
}
protected abstract function getCommand() : string;
}

View File

@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function defined;
use function sprintf;
final class SkipOnWindowsFinder implements CpuCoreFinder
{
/**
* @var CpuCoreFinder
*/
private $decoratedFinder;
public function __construct(CpuCoreFinder $decoratedFinder)
{
$this->decoratedFinder = $decoratedFinder;
}
public function diagnose() : string
{
return self::skip() ? 'Windows platform detected (PHP_WINDOWS_VERSION_MAJOR is set).' : $this->decoratedFinder->diagnose();
}
public function find() : ?int
{
return self::skip() ? null : $this->decoratedFinder->find();
}
public function toString() : string
{
return sprintf('SkipOnWindowsFinder(%s)', $this->decoratedFinder->toString());
}
private static function skip() : bool
{
// Skip if on Windows. Rely on PHP to detect the platform
// rather than reading the platform name or others.
return defined('PHP_WINDOWS_VERSION_MAJOR');
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function preg_match;
/**
* Find the number of logical CPU cores for Windows.
*
* @see https://github.com/paratestphp/paratest/blob/c163539818fd96308ca8dc60f46088461e366ed4/src/Runners/PHPUnit/Options.php#L912-L916
*/
final class WmicLogicalFinder extends ProcOpenBasedFinder
{
private const CPU_CORE_COUNT_REGEX = '/NumberOfLogicalProcessors[\\s\\n]+(?<count>\\d+)/';
protected function getCommand() : string
{
return 'wmic cpu get NumberOfLogicalProcessors';
}
public function toString() : string
{
return 'WmicLogicalFinder';
}
public static function countCpuCores(string $process) : ?int
{
if (0 === preg_match(self::CPU_CORE_COUNT_REGEX, $process, $matches)) {
return parent::countCpuCores($process);
}
$count = $matches['count'];
return parent::countCpuCores($count);
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
use function preg_match;
/**
* Find the number of physical CPU cores for Windows.
*
* @see https://github.com/paratestphp/paratest/blob/c163539818fd96308ca8dc60f46088461e366ed4/src/Runners/PHPUnit/Options.php#L912-L916
*/
final class WmicPhysicalFinder extends ProcOpenBasedFinder
{
private const CPU_CORE_COUNT_REGEX = '/NumberOfCores[\\s\\n]+(?<count>\\d+)/';
protected function getCommand() : string
{
return 'wmic cpu get NumberOfCores';
}
public function toString() : string
{
return 'WmicPhysicalFinder';
}
public static function countCpuCores(string $process) : ?int
{
if (0 === preg_match(self::CPU_CORE_COUNT_REGEX, $process, $matches)) {
return parent::countCpuCores($process);
}
$count = $matches['count'];
return parent::countCpuCores($count);
}
}

View File

@ -0,0 +1,29 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter\Finder;
/**
* Find the number of logical CPU cores for Linux and the likes.
*
* @see https://twitter.com/freebsdfrau/status/1052016199452700678?s=20&t=M2pHkRqmmna-UF68lfL2hw
*/
final class _NProcessorFinder extends ProcOpenBasedFinder
{
protected function getCommand() : string
{
return 'getconf _NPROCESSORS_ONLN';
}
public function toString() : string
{
return '_NProcessorFinder';
}
}

View File

@ -0,0 +1,21 @@
<?php
/*
* This file is part of the Fidry CPUCounter Config package.
*
* (c) Théo FIDRY <theo.fidry@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace RectorPrefix202212\Fidry\CpuCoreCounter;
use RuntimeException;
final class NumberOfCpuCoreNotFound extends RuntimeException
{
public static function create() : self
{
return new self('Could not find the number of CPU cores available.');
}
}

View File

@ -8,11 +8,12 @@
"react\/child-process": "^0.6.5",
"react\/event-loop": "^1.3",
"react\/socket": "^1.12",
"symfony\/console": "^6.1"
"symfony\/console": "^6.2",
"fidry\/cpu-core-counter": "^0.4.0"
},
"require-dev": {
"symplify\/package-builder": "^11.1.17",
"phpunit\/phpunit": "^9.5.25"
"symplify\/package-builder": "^11.1.18",
"phpunit\/phpunit": "^9.5.26"
},
"autoload": {
"psr-4": {
@ -33,24 +34,24 @@
"platform-check": false
},
"conflict": {
"symplify\/easy-coding-standard": "<11.1.17",
"symplify\/phpstan-rules": "<11.1.17",
"symplify\/easy-testing": "<11.1.17",
"symplify\/rule-doc-generator-contracts": "<11.1.17",
"symplify\/php-config-printer": "<11.1.17",
"symplify\/autowire-array-parameter": "<11.1.17",
"symplify\/phpstan-extensions": "<11.1.17",
"symplify\/rule-doc-generator": "<11.1.17",
"symplify\/vendor-patches": "<11.1.17",
"symplify\/symfony-static-dumper": "<11.1.17",
"symplify\/config-transformer": "<11.1.17",
"symplify\/easy-ci": "<11.1.17",
"symplify\/coding-standard": "<11.1.17",
"symplify\/composer-json-manipulator": "<11.1.17",
"symplify\/smart-file-system": "<11.1.17",
"symplify\/monorepo-builder": "<11.1.17",
"symplify\/symplify-kernel": "<11.1.17",
"symplify\/package-builder": "<11.1.17"
"symplify\/phpstan-rules": "<11.1.18",
"symplify\/easy-testing": "<11.1.18",
"symplify\/rule-doc-generator-contracts": "<11.1.18",
"symplify\/php-config-printer": "<11.1.18",
"symplify\/autowire-array-parameter": "<11.1.18",
"symplify\/phpstan-extensions": "<11.1.18",
"symplify\/rule-doc-generator": "<11.1.18",
"symplify\/symfony-static-dumper": "<11.1.18",
"symplify\/config-transformer": "<11.1.18",
"symplify\/coding-standard": "<11.1.18",
"symplify\/composer-json-manipulator": "<11.1.18",
"symplify\/smart-file-system": "<11.1.18",
"symplify\/symplify-kernel": "<11.1.18",
"symplify\/package-builder": "<11.1.18",
"symplify\/easy-ci": "<11.1.18",
"symplify\/monorepo-builder": "<11.1.18",
"symplify\/vendor-patches": "<11.1.18",
"symplify\/easy-coding-standard": "<11.1.18"
},
"minimum-stability": "dev",
"prefer-stable": true

View File

@ -7,5 +7,5 @@ use RectorPrefix202212\Symfony\Component\DependencyInjection\Loader\Configurator
return static function (ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->defaults()->public()->autowire();
$services->load('RectorPrefix202212\Symplify\\EasyParallel\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/ValueObject']);
$services->load('RectorPrefix202212\Symplify\\EasyParallel\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Enum', __DIR__ . '/../src/Exception', __DIR__ . '/../src/Contract']);
};

View File

@ -3,60 +3,20 @@
declare (strict_types=1);
namespace RectorPrefix202212\Symplify\EasyParallel;
use RectorPrefix202212\Nette\Utils\Strings;
/**
* From https://github.com/phpstan/phpstan-src/commit/9124c66dcc55a222e21b1717ba5f60771f7dda92
*/
use RectorPrefix202212\Fidry\CpuCoreCounter\CpuCoreCounter;
use RectorPrefix202212\Fidry\CpuCoreCounter\NumberOfCpuCoreNotFound;
final class CpuCoreCountProvider
{
/**
* @see https://regex101.com/r/XMeAl4/1
* @var string
*/
private const PROCESSOR_REGEX = '#^processor#m';
/**
* @var int
*/
private const DEFAULT_CORE_COUNT = 2;
public function provide() : int
{
// from brianium/paratest
$cpuInfoCount = $this->resolveFromProcCpuinfo();
if ($cpuInfoCount !== null) {
return $cpuInfoCount;
try {
return (new CpuCoreCounter())->getCount();
} catch (NumberOfCpuCoreNotFound $exception) {
return self::DEFAULT_CORE_COUNT;
}
$coreCount = self::DEFAULT_CORE_COUNT;
if (\DIRECTORY_SEPARATOR === '\\') {
// Windows
$process = @\popen('wmic cpu get NumberOfCores', 'rb');
if ($process !== \false) {
\fgets($process);
$coreCount = (int) \fgets($process);
\pclose($process);
}
return $coreCount;
}
$process = @\popen('sysctl -n hw.ncpu', 'rb');
if ($process !== \false) {
$coreCount = (int) \fgets($process);
\pclose($process);
}
return $coreCount;
}
private function resolveFromProcCpuinfo() : ?int
{
if (!\is_file('/proc/cpuinfo')) {
return null;
}
// Linux (and potentially Windows with linux sub systems)
$cpuinfo = \file_get_contents('/proc/cpuinfo');
if ($cpuinfo === \false) {
return null;
}
$matches = Strings::matchAll($cpuinfo, self::PROCESSOR_REGEX);
if ($matches === []) {
return 0;
}
return \count($matches);
}
}

View File

@ -23,7 +23,7 @@ final class ParallelProcess
/**
* @var \React\ChildProcess\Process
*/
public $process;
private $process;
/**
* @var \Clue\React\NDJson\Encoder
*/

View File

@ -17,24 +17,24 @@
}
},
"conflict": {
"symplify\/composer-json-manipulator": "<11.1.17",
"symplify\/easy-coding-standard": "<11.1.17",
"symplify\/phpstan-rules": "<11.1.17",
"symplify\/easy-testing": "<11.1.17",
"symplify\/php-config-printer": "<11.1.17",
"symplify\/autowire-array-parameter": "<11.1.17",
"symplify\/package-builder": "<11.1.17",
"symplify\/phpstan-extensions": "<11.1.17",
"symplify\/rule-doc-generator": "<11.1.17",
"symplify\/vendor-patches": "<11.1.17",
"symplify\/smart-file-system": "<11.1.17",
"symplify\/symfony-static-dumper": "<11.1.17",
"symplify\/symplify-kernel": "<11.1.17",
"symplify\/monorepo-builder": "<11.1.17",
"symplify\/config-transformer": "<11.1.17",
"symplify\/easy-ci": "<11.1.17",
"symplify\/coding-standard": "<11.1.17",
"symplify\/easy-parallel": "<11.1.17"
"symplify\/composer-json-manipulator": "<11.1.18",
"symplify\/phpstan-rules": "<11.1.18",
"symplify\/easy-testing": "<11.1.18",
"symplify\/php-config-printer": "<11.1.18",
"symplify\/autowire-array-parameter": "<11.1.18",
"symplify\/package-builder": "<11.1.18",
"symplify\/phpstan-extensions": "<11.1.18",
"symplify\/rule-doc-generator": "<11.1.18",
"symplify\/smart-file-system": "<11.1.18",
"symplify\/symfony-static-dumper": "<11.1.18",
"symplify\/symplify-kernel": "<11.1.18",
"symplify\/config-transformer": "<11.1.18",
"symplify\/coding-standard": "<11.1.18",
"symplify\/easy-parallel": "<11.1.18",
"symplify\/easy-ci": "<11.1.18",
"symplify\/monorepo-builder": "<11.1.18",
"symplify\/vendor-patches": "<11.1.18",
"symplify\/easy-coding-standard": "<11.1.18"
},
"minimum-stability": "dev",
"prefer-stable": true