Skip to content

Commit 9a6bae4

Browse files
committed
Remove ability to toggle sort files. On by default
1 parent c244a93 commit 9a6bae4

File tree

3 files changed

+17
-60
lines changed

3 files changed

+17
-60
lines changed

src/Box.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ private function __construct(
7474
private Phar $phar,
7575
private readonly string $pharFilePath,
7676
private readonly bool $enableParallelization,
77-
private readonly bool $sortCompiledFiles,
7877
) {
7978
$this->compactors = new Compactors();
8079
$this->placeholderCompactor = new Placeholder([]);
@@ -96,7 +95,6 @@ public static function create(
9695
int $pharFlags = 0,
9796
?string $pharAlias = null,
9897
bool $enableParallelization = false,
99-
bool $sortCompiledFiles = false,
10098
): self {
10199
// Ensure the parent directory of the PHAR file exists as `new \Phar()` does not create it and would fail
102100
// otherwise.
@@ -106,7 +104,6 @@ public static function create(
106104
new Phar($pharFilePath, $pharFlags, $pharAlias),
107105
$pharFilePath,
108106
$enableParallelization,
109-
$sortCompiledFiles,
110107
);
111108
}
112109

@@ -145,9 +142,7 @@ public function endBuffering(?callable $dumpAutoload): void
145142
$files = [];
146143

147144
foreach ($this->bufferedFiles as $file) {
148-
if ($this->sortCompiledFiles) {
149-
$files[$file->getPath()] = $tmp.DIRECTORY_SEPARATOR.$file->getPath();
150-
}
145+
$files[$file->getPath()] = $tmp.DIRECTORY_SEPARATOR.$file->getPath();
151146

152147
FS::dumpFile(
153148
$file->getPath(),
@@ -165,26 +160,22 @@ public function endBuffering(?callable $dumpAutoload): void
165160

166161
chdir($cwd);
167162

168-
if ($this->sortCompiledFiles) {
169-
$unknownFiles = Finder::create()
170-
->files()
171-
->in($tmp)
172-
->notPath(array_keys($files))
173-
->sortByName();
163+
$unknownFiles = Finder::create()
164+
->files()
165+
->in($tmp)
166+
->notPath(array_keys($files))
167+
->sortByName();
174168

175-
$files = [...$files, ...$unknownFiles];
169+
$files = [...$files, ...$unknownFiles];
176170

177-
uasort($files, static function (SplFileInfo|string $a, SplFileInfo|string $b) {
178-
$a = is_string($a) ? $a : $a->getPath();
179-
$b = is_string($b) ? $b : $b->getPath();
171+
uasort($files, static function (SplFileInfo|string $a, SplFileInfo|string $b) {
172+
$a = is_string($a) ? $a : $a->getPath();
173+
$b = is_string($b) ? $b : $b->getPath();
180174

181-
return strcmp($a, $b);
182-
});
175+
return strcmp($a, $b);
176+
});
183177

184-
$this->phar->buildFromIterator(new ArrayIterator($files), $tmp);
185-
} else {
186-
$this->phar->buildFromDirectory($tmp);
187-
}
178+
$this->phar->buildFromIterator(new ArrayIterator($files), $tmp);
188179
} finally {
189180
FS::remove($tmp);
190181
}

src/Console/Command/CompileCommand.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ final class CompileCommand implements CommandAware
100100

101101
private const DEBUG_OPTION = 'debug';
102102
private const NO_PARALLEL_PROCESSING_OPTION = 'no-parallel';
103-
private const SORT_COMPILED_FILES = 'sort-compiled-files';
104103
private const NO_RESTART_OPTION = 'no-restart';
105104
private const DEV_OPTION = 'dev';
106105
private const NO_CONFIG_OPTION = 'no-config';
@@ -136,12 +135,6 @@ public function getConfiguration(): CommandConfiguration
136135
InputOption::VALUE_NONE,
137136
'Disable the parallel processing',
138137
),
139-
new InputOption(
140-
self::SORT_COMPILED_FILES,
141-
null,
142-
InputOption::VALUE_NONE,
143-
'Sort compiled files',
144-
),
145138
new InputOption(
146139
self::NO_RESTART_OPTION,
147140
null,
@@ -207,15 +200,6 @@ public function execute(IO $io): int
207200
);
208201
}
209202

210-
$sortCompiledFiles = $io->getTypedOption(self::SORT_COMPILED_FILES)->asBoolean();
211-
212-
if ($sortCompiledFiles) {
213-
$io->writeln(
214-
'<info>[debug] Enabled sorting compiled files</info>',
215-
OutputInterface::VERBOSITY_DEBUG,
216-
);
217-
}
218-
219203
ChangeWorkingDirOption::changeWorkingDirectory($io);
220204

221205
$io->writeln($this->header);
@@ -240,7 +224,7 @@ public function execute(IO $io): int
240224
$restoreLimit = OpenFileDescriptorLimiter::bumpLimit(2048, $io);
241225

242226
try {
243-
$box = $this->createPhar($config, $logger, $io, !$disableParallelization, $sortCompiledFiles, $debug);
227+
$box = $this->createPhar($config, $logger, $io, !$disableParallelization, $debug);
244228
} finally {
245229
$restoreLimit();
246230
}
@@ -261,11 +245,10 @@ private function createPhar(
261245
CompilerLogger $logger,
262246
IO $io,
263247
bool $enableParallelization,
264-
bool $sortCompiledFiles,
265248
bool $debug,
266249
): Box {
267250
$tmpOutputPath = $config->getTmpOutputPath();
268-
$box = Box::create($tmpOutputPath, enableParallelization: $enableParallelization, sortCompiledFiles: $sortCompiledFiles);
251+
$box = Box::create($tmpOutputPath, enableParallelization: $enableParallelization);
269252
$composerOrchestrator = new ComposerOrchestrator(
270253
ComposerProcessFactory::create(
271254
$config->getComposerBin(),

tests/Benchmark/CompileBench.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ public function tearDown(): void
6767
public function bench(array $params): void
6868
{
6969
$enableParallelization = $params[1];
70-
$sortCompiledFiles = $params[2];
7170

7271
$exitCode = $this->runner->run(
73-
self::createIO($enableParallelization, $sortCompiledFiles),
72+
self::createIO($enableParallelization),
7473
);
7574

7675
Assert::assertSame(ExitCode::SUCCESS, $exitCode);
@@ -112,21 +111,9 @@ public static function parameterProvider(): iterable
112111
true,
113112
false,
114113
];
115-
116-
yield 'with compactors; no parallel processing; sort compiled files' => [
117-
self::WITH_COMPACTORS_DIR,
118-
false,
119-
true,
120-
];
121-
122-
yield 'with compactors; parallel processing; sort compiled files' => [
123-
self::WITH_COMPACTORS_DIR,
124-
true,
125-
true,
126-
];
127114
}
128115

129-
private static function createIO(bool $enableParallelization, bool $sortCompiledFiles): IO
116+
private static function createIO(bool $enableParallelization): IO
130117
{
131118
$input = [
132119
'compile',
@@ -137,10 +124,6 @@ private static function createIO(bool $enableParallelization, bool $sortCompiled
137124
$input['--no-parallel'] = null;
138125
}
139126

140-
if ($sortCompiledFiles) {
141-
$input['--sort-compiled-files'] = null;
142-
}
143-
144127
return new IO(
145128
new ArrayInput($input),
146129
new NullOutput(),

0 commit comments

Comments
 (0)