Skip to content

Commit

Permalink
[Rector]
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Nov 16, 2021
1 parent 64cf9b4 commit 0c0f8d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/admin-block-editor/src/Installer/Update975.php
Expand Up @@ -43,15 +43,17 @@ private function moveBlockDataAnchorToBlockTunesAnchor(): void
if (! isset($block['data']) || ! isset($block['data']['anchor'])) {
continue;
}

$jsonContent['blocks'][$blockKey]['tunes']['anchor'] = $block['data']['anchor'];
unset($jsonContent['blocks'][$blockKey]['data']['anchor']);
$contentHasChanged = true;
}

if (true === $contentHasChanged) {
if ($contentHasChanged) {
if (($content = json_encode($jsonContent)) === false) {
throw new LogicException((string) $page->getId());
}

$page->setMainContent($content);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/installer/src/PostAutoloadDump.php
Expand Up @@ -51,6 +51,7 @@ public static function getKernel(): Kernel
if (! class_exists(Kernel::class)) {
include 'vendor/autoload.php';
}

(new Dotenv())->loadEnv(file_exists('.env') ? '.env' : 'packages/skeleton/.env');
if (class_exists(Debug::class)) {
Debug::enable();
Expand Down
5 changes: 4 additions & 1 deletion packages/installer/src/PostInstall.php
Expand Up @@ -36,7 +36,7 @@ public static function scanDir(string $dirPath): array
throw new LogicException();
}

return array_filter($dir, function ($path) { return ! \in_array($path, ['.', '..'], true); });
return array_filter($dir, function (string $path): bool { return ! \in_array($path, ['.', '..'], true); });
}

public static function mirror(string $source, string $dest): void
Expand All @@ -63,11 +63,13 @@ public static function replace(string $file, string $search, string $replace): v
if (false === $content) {
throw new Exception('`'.$file.'` not found');
}

$count = 0;
$content = str_replace($search, $replace, $content, $count);
if (1 !== $count) {
throw new Exception('Error on replacing `'.$search.'` by `'.$replace.'`');
}

file_put_contents($file, $content);
}

Expand All @@ -77,6 +79,7 @@ public static function addOnTop(string $file, string $toAdd): void
if (false !== strpos($content, $toAdd)) {
return;
}

$content = $toAdd.$content;
self::dumpFile($file, $content);
}
Expand Down

0 comments on commit 0c0f8d7

Please sign in to comment.