rob-revisited/tools/web-php.php

16 lines
826 B
PHP

<?php
// The PHP version a web site's Composer files need (tools/web.sh, in a throwaway container): JumPHP\Ide\Web\PhpVersions.
// php tools/web-php.php <folder> ["8.5 8.4 8.3 8.2"] [default] -> "<version>\t<source>: <detail>"
require __DIR__ . '/../ide/src/Web/PhpVersions.php';
use JumPHP\Ide\Web\PhpVersions;
$available = isset($argv[2]) ? (preg_split('/[\s,]+/', trim($argv[2])) ?: PhpVersions::AVAILABLE) : PhpVersions::AVAILABLE;
$r = PhpVersions::resolveFolder($argv[1] ?? '.', array_values($available), $argv[3] ?? PhpVersions::DEFAULT);
$why = match ($r['source']) {
'platform' => $r['detail'],
'composer' => ($r['conflict'] ? '' : 'the newest PHP Composer allows: ') . $r['detail'],
default => 'the default (composer.json does not say)',
};
echo $r['version'], "\t", $r['source'], ': ', $why, "\n";