mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
add BuilderBase::getPHPVersionFromArchive
This commit is contained in:
parent
939db75268
commit
2649dcd05c
@ -231,6 +231,30 @@ abstract class BuilderBase
|
|||||||
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
throw new RuntimeException('PHP version file format is malformed, please remove it and download again');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get PHP version from archive file name.
|
||||||
|
*
|
||||||
|
* @param null|string $file php-*.*.*.tar.gz filename, read from lockfile if empty
|
||||||
|
*/
|
||||||
|
public function getPHPVersionFromArchive(?string $file = null): false|string
|
||||||
|
{
|
||||||
|
if ($file === null) {
|
||||||
|
$lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false;
|
||||||
|
if ($lock === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$lock = json_decode($lock, true);
|
||||||
|
$file = $lock['php-src']['filename'] ?? null;
|
||||||
|
if ($file === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) {
|
||||||
|
return $match[1];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get build type name string to display.
|
* Get build type name string to display.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user