Merge branch 'main' into feat/xdebug-dynamic

This commit is contained in:
crazywhalecc
2025-04-18 09:45:19 +08:00
15 changed files with 55 additions and 25 deletions

View File

@@ -461,6 +461,23 @@ class FileSystem
}
}
/**
* @throws FileSystemException
*/
public static function replaceFileLineContainsString(string $file, string $find, string $line): false|int
{
$lines = file($file);
if ($lines === false) {
throw new FileSystemException('Cannot read file: ' . $file);
}
foreach ($lines as $key => $value) {
if (str_contains($value, $find)) {
$lines[$key] = $line . PHP_EOL;
}
}
return file_put_contents($file, implode('', $lines));
}
/**
* @throws RuntimeException
* @throws FileSystemException

View File

@@ -15,7 +15,7 @@ class SourceManager
* @throws FileSystemException
* @throws RuntimeException
*/
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null): void
public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null, bool $source_only = false): void
{
if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) {
throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?');
@@ -56,7 +56,7 @@ class SourceManager
}
// check source downloaded
$pre_built_name = Downloader::getPreBuiltLockName($source);
if (!isset($lock[$pre_built_name])) {
if ($source_only || !isset($lock[$pre_built_name])) {
if (!isset($lock[$source])) {
throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !");
}