Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EventListener/PreAssetsCompileListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __invoke(PreAssetsCompileEvent $event): void
$this->typeScriptBuilder
->setOutput($output);
foreach ($this->typeScriptBuilder->createAllBuildProcess() as $process) {
$process->wait(function ($type, $buffer) use ($output) {
$process->wait(static function ($type, $buffer) use ($output) {
$output->write($buffer);
});

Expand Down
29 changes: 14 additions & 15 deletions src/Tools/WatcherBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,25 @@ public function startWatch(string $watchPath, callable $callback, array $extensi
}
$process = new Process([$this->executablePath, $watchPath]);

$process->start(function ($type, $buffer) use ($callback, $extensions) {
$process->start(static function ($type, $buffer) use ($callback, $extensions) {
if (Process::ERR === $type) {
throw new \Exception($buffer);
} else {
$lines = explode("\n", $buffer);
$changedFiles = [];
foreach ($lines as $line) {
try {
$entry = json_decode($line, true, 512, \JSON_THROW_ON_ERROR);
if ($extensions && !\in_array(pathinfo($entry['name'], \PATHINFO_EXTENSION), $extensions)) {
continue;
}
$changedFiles[$entry['name']] = $entry['operation'];
} catch (\JsonException) {
}
$lines = explode("\n", $buffer);
$changedFiles = [];
foreach ($lines as $line) {
try {
$entry = json_decode($line, true, 512, \JSON_THROW_ON_ERROR);
if ($extensions && !\in_array(pathinfo($entry['name'], \PATHINFO_EXTENSION), $extensions)) {
continue;
}
$changedFiles[$entry['name']] = $entry['operation'];
} catch (\JsonException) {
continue;
}
foreach ($changedFiles as $file => $operation) {
$callback($file, $operation);
}
}
foreach ($changedFiles as $file => $operation) {
$callback($file, $operation);
}
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Tools/WatcherBinaryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testGetBinaryFromServerSpecs(): void
{
// Test that the binary exists and the process is created with the correct arguments
$binary = (new WatcherBinaryFactory())->getBinaryFromServerSpecs('Linux');
$process = $binary->startWatch($this->watchPath, fn ($path, $operation) => '');
$process = $binary->startWatch($this->watchPath, static fn ($path, $operation) => '');
$this->assertEquals('\''.realpath($this->binaryDir).'/watcher-linux\' \''.$this->watchPath.'/...\'', $process->getCommandLine());

// Test that an exception is thrown when the platform is not supported
Expand Down