diff --git a/deploy.php b/deploy.php
index 6bbf273..a2ea296 100644
--- a/deploy.php
+++ b/deploy.php
@@ -6,18 +6,18 @@
$version = ltrim(Deployer::get()->getConsole()->getVersion(), 'v');
if (6 !== (int) $version) {
- throw new RuntimeException('YDeploy 1.x requires Deployer 6.x, but Deployer '.$version.' is used');
+ throw new RuntimeException('YDeploy 1.x requires Deployer 6.x, but Deployer ' . $version . ' is used');
}
/** @psalm-suppress MissingFile */
require 'recipe/common.php';
-require __DIR__.'/deployer/config.php';
-require __DIR__.'/deployer/functions.php';
+require __DIR__ . '/deployer/config.php';
+require __DIR__ . '/deployer/functions.php';
-foreach (glob(__DIR__.'/deployer/tasks/**/*.php', GLOB_NOSORT) as $path) {
+foreach (glob(__DIR__ . '/deployer/tasks/**/*.php', GLOB_NOSORT) as $path) {
require $path;
}
-foreach (glob(__DIR__.'/deployer/tasks/*.php', GLOB_NOSORT) as $path) {
+foreach (glob(__DIR__ . '/deployer/tasks/*.php', GLOB_NOSORT) as $path) {
require $path;
}
diff --git a/deployer/config.php b/deployer/config.php
index 010f443..d520601 100644
--- a/deployer/config.php
+++ b/deployer/config.php
@@ -10,7 +10,7 @@
$baseDir = dirname(__DIR__, 5);
if (str_starts_with($baseDir, getcwd())) {
$baseDir = substr($baseDir, strlen(getcwd()));
- $baseDir = ltrim($baseDir.'/', '/');
+ $baseDir = ltrim($baseDir . '/', '/');
}
set('base_dir', $baseDir);
@@ -51,7 +51,7 @@
]);
set('url', static function () {
- return 'https://'.Context::get()->getHost()->getRealHostname();
+ return 'https://' . Context::get()->getHost()->getRealHostname();
});
set('allow_anonymous_stats', false);
diff --git a/deployer/functions.php b/deployer/functions.php
index 40a8c35..38af89c 100644
--- a/deployer/functions.php
+++ b/deployer/functions.php
@@ -17,7 +17,7 @@ function uploadContent(string $destination, string $content): void
$destination = "$workingPath/$destination";
}
- $path = tempnam(getcwd().'/'.get('data_dir').'/addons/ydeploy', 'tmp');
+ $path = tempnam(getcwd() . '/' . get('data_dir') . '/addons/ydeploy', 'tmp');
file_put_contents($path, $content);
try {
@@ -33,7 +33,7 @@ function downloadContent(string $source): string
$source = "$workingPath/$source";
}
- $path = tempnam(getcwd().'/'.get('data_dir').'/addons/ydeploy', 'tmp');
+ $path = tempnam(getcwd() . '/' . get('data_dir') . '/addons/ydeploy', 'tmp');
download($source, $path);
$content = file_get_contents($path);
diff --git a/deployer/tasks/build.php b/deployer/tasks/build.php
index 6d65771..8f299e6 100644
--- a/deployer/tasks/build.php
+++ b/deployer/tasks/build.php
@@ -4,7 +4,7 @@
desc('Prepare the next release in local subdir ".build"');
task('build', static function () {
- set('deploy_path', getcwd().'/.build');
+ set('deploy_path', getcwd() . '/.build');
set('keep_releases', 1);
invoke('build:info');
diff --git a/deployer/tasks/deploy/dump_info.php b/deployer/tasks/deploy/dump_info.php
index dfdd093..08ae6d5 100644
--- a/deployer/tasks/deploy/dump_info.php
+++ b/deployer/tasks/deploy/dump_info.php
@@ -15,5 +15,5 @@
$infos = json_encode($infos, JSON_PRETTY_PRINT);
run('mkdir -p {{release_path}}/{{data_dir}}/addons/ydeploy');
- run('echo '.escapeshellarg($infos).' > {{release_path}}/{{data_dir}}/addons/ydeploy/info.json');
+ run('echo ' . escapeshellarg($infos) . ' > {{release_path}}/{{data_dir}}/addons/ydeploy/info.json');
});
diff --git a/deployer/tasks/local/setup.php b/deployer/tasks/local/setup.php
index 472fee7..575f2f8 100644
--- a/deployer/tasks/local/setup.php
+++ b/deployer/tasks/local/setup.php
@@ -28,7 +28,7 @@ public function __invoke(): void
{
writeln('');
- $this->mysqlOptions = get('data_dir').'/addons/ydeploy/mysql-options';
+ $this->mysqlOptions = get('data_dir') . '/addons/ydeploy/mysql-options';
$this->chooseSource();
@@ -39,7 +39,7 @@ public function __invoke(): void
$this->replaceYrewriteDomains();
$this->copyMedia();
} finally {
- run('rm -f '.escapeshellarg($this->mysqlOptions));
+ run('rm -f ' . escapeshellarg($this->mysqlOptions));
}
}
@@ -64,13 +64,13 @@ private function chooseSource(): void
if (!$fromHost) {
do {
- $file = ask('Dump file', getcwd().'/dump.sql');
+ $file = ask('Dump file', getcwd() . '/dump.sql');
if (file_exists($file)) {
$this->sourceFile = $file;
} else {
writeln('');
- writeln('The file does not exist: '.$file.'');
+ writeln('The file does not exist: ' . $file . '');
writeln('');
}
} while (!$this->sourceFile);
@@ -105,14 +105,14 @@ private function setConfigYml(): void
return downloadContent('{{data_dir}}/core/config.yml');
});
} else {
- $config = file_get_contents(getcwd().'/'.get('src_dir').'/core/default.config.yml');
+ $config = file_get_contents(getcwd() . '/' . get('src_dir') . '/core/default.config.yml');
}
$config = Yaml::parse($config);
$config['setup'] = false;
$config['debug'] = true;
- $config['instname'] = 'rex'.date('YmdHis');
+ $config['instname'] = 'rex' . date('YmdHis');
$config['server'] = ask('Server:', get('url'));
$config['servername'] = ask('Server name:', $config['servername']);
@@ -137,25 +137,25 @@ private function setConfigYml(): void
$db['password'] = askHiddenResponse('Database password:');
file_put_contents($this->mysqlOptions, implode("\n", [
- '--host='.escapeshellarg($db['host']),
- '--user='.escapeshellarg($db['login']),
- '--password='.escapeshellarg($db['password']),
+ '--host=' . escapeshellarg($db['host']),
+ '--user=' . escapeshellarg($db['login']),
+ '--password=' . escapeshellarg($db['password']),
]));
try {
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e "CREATE DATABASE IF NOT EXISTS '.escapeshellcmd($db['name']).' CHARACTER SET utf8 COLLATE utf8_general_ci"');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e "CREATE DATABASE IF NOT EXISTS ' . escapeshellcmd($db['name']) . ' CHARACTER SET utf8 COLLATE utf8_general_ci"');
$dbValid = true;
} catch (ProcessFailedException $e) {
writeln('');
- writeln('Could not create/connect database: '.trim($e->getProcess()->getErrorOutput()).'');
+ writeln('Could not create/connect database: ' . trim($e->getProcess()->getErrorOutput()) . '');
writeln('');
}
} while (!$dbValid);
file_put_contents($this->mysqlOptions, implode("\n", [
- '--host='.escapeshellarg($db['host']),
- '--user='.escapeshellarg($db['login']),
- '--password='.escapeshellarg($db['password']),
+ '--host=' . escapeshellarg($db['host']),
+ '--user=' . escapeshellarg($db['login']),
+ '--password=' . escapeshellarg($db['password']),
escapeshellarg($db['name']),
]));
@@ -175,13 +175,13 @@ private function copyDatabase(): void
if ($this->source) {
$this->headline("Copy database from {$this->source} to local");
- $path = get('data_dir').'/addons/ydeploy/'.date('YmdHis').'.sql';
+ $path = get('data_dir') . '/addons/ydeploy/' . date('YmdHis') . '.sql';
// export source database
onHost($this->source, static function () use ($path) {
- run('{{bin/console}} db:connection-options | xargs {{bin/mysqldump}} > '.escapeshellarg($path));
+ run('{{bin/console}} db:connection-options | xargs {{bin/mysqldump}} > ' . escapeshellarg($path));
download("{{release_path}}/$path", $path);
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
});
} else {
$this->headline('Import database dump');
@@ -190,9 +190,9 @@ private function copyDatabase(): void
}
// import the dump
- run('< '.escapeshellarg($this->mysqlOptions).' xargs sh -c \'{{bin/mysql}} "$0" "$@" < '.escapeshellcmd(escapeshellarg($path)).'\'');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs sh -c \'{{bin/mysql}} "$0" "$@" < ' . escapeshellcmd(escapeshellarg($path)) . '\'');
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
$this->ok();
}
@@ -201,7 +201,7 @@ private function configureDeveloper(): void
{
$this->headline('Configure developer addon for local usage');
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e "UPDATE rex_config SET value = \"true\" WHERE namespace=\"developer\" AND \`key\` IN (\"sync_frontend\", \"sync_backend\", \"rename\", \"dir_suffix\", \"delete\")"');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e "UPDATE rex_config SET value = \"true\" WHERE namespace=\"developer\" AND \`key\` IN (\"sync_frontend\", \"sync_backend\", \"rename\", \"dir_suffix\", \"delete\")"');
$this->ok();
}
@@ -209,7 +209,7 @@ private function configureDeveloper(): void
private function replaceYrewriteDomains(): void
{
try {
- $data = run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} --silent --raw --skip-column-names -e "SELECT id, domain FROM rex_yrewrite_domain"');
+ $data = run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} --silent --raw --skip-column-names -e "SELECT id, domain FROM rex_yrewrite_domain"');
$data = trim($data);
} catch (ProcessFailedException $exception) {
if (str_contains($exception->getProcess()->getErrorOutput(), 'ERROR 1146')) {
@@ -229,8 +229,8 @@ private function replaceYrewriteDomains(): void
foreach (explode("\n", $data) as $line) {
[$id, $domain] = explode("\t", $line, 2);
$id = (int) $id;
- $domain = ask($domain.':', $this->server ?: get('url'));
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e "UPDATE rex_yrewrite_domain SET domain = \"'.addslashes($domain).'\" WHERE id = '.$id.'"');
+ $domain = ask($domain . ':', $this->server ?: get('url'));
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e "UPDATE rex_yrewrite_domain SET domain = \"' . addslashes($domain) . '\" WHERE id = ' . $id . '"');
}
writeln('');
@@ -245,24 +245,24 @@ private function copyMedia(): void
$this->headline("Copy media files from {$this->source} to local");
- $path = get('data_dir').'/addons/ydeploy/media_'.date('YmdHis').'.tar.gz';
+ $path = get('data_dir') . '/addons/ydeploy/media_' . date('YmdHis') . '.tar.gz';
// create source archive
onHost($this->source, static function () use ($path) {
- run('tar -zcvf '.escapeshellarg($path).' -C {{media_dir}} .');
+ run('tar -zcvf ' . escapeshellarg($path) . ' -C {{media_dir}} .');
try {
download("{{release_path}}/$path", $path);
} finally {
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
}
});
try {
run('mkdir -p {{media_dir}}');
- run('tar -zxvf '.escapeshellarg($path).' -C {{media_dir}}/');
+ run('tar -zxvf ' . escapeshellarg($path) . ' -C {{media_dir}}/');
} finally {
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
}
$this->ok();
@@ -270,7 +270,7 @@ private function copyMedia(): void
private function headline(string $headline): void
{
- writeln(''.$headline.'');
+ writeln('' . $headline . '');
writeln('');
}
diff --git a/deployer/tasks/server/clear_cache.php b/deployer/tasks/server/clear_cache.php
index 4795eb9..32d9027 100644
--- a/deployer/tasks/server/clear_cache.php
+++ b/deployer/tasks/server/clear_cache.php
@@ -55,27 +55,27 @@ private function clearWebPhpCache(): void
}
$dir = '_clear_cache';
- $htaccessFile = $dir.'/.htaccess';
- $phpFile = $dir.'/_clear_cache.php';
+ $htaccessFile = $dir . '/.htaccess';
+ $phpFile = $dir . '/_clear_cache.php';
try {
foreach ($paths as $path) {
- run('mkdir -p '.$path.$dir);
- run('echo "Require all granted" > '.$path.$htaccessFile);
- run('echo '.escapeshellarg("getPhpClearCacheCode()).' > '.$path.$phpFile);
+ run('mkdir -p ' . $path . $dir);
+ run('echo "Require all granted" > ' . $path . $htaccessFile);
+ run('echo ' . escapeshellarg("getPhpClearCacheCode()) . ' > ' . $path . $phpFile);
}
run("curl -fsS {{url}}/$phpFile");
} finally {
foreach ($paths as $path) {
- run('rm -rf '.$path.$dir);
+ run('rm -rf ' . $path . $dir);
}
}
}
private function clearCliPhpCache(): void
{
- run('{{bin/php}} -r '.escapeshellarg($this->getPhpClearCacheCode()));
+ run('{{bin/php}} -r ' . escapeshellarg($this->getPhpClearCacheCode()));
}
private function getPhpClearCacheCode(): string
diff --git a/deployer/tasks/setup.php b/deployer/tasks/setup.php
index efad6ca..44e7de7 100644
--- a/deployer/tasks/setup.php
+++ b/deployer/tasks/setup.php
@@ -33,7 +33,7 @@ public function __invoke(): void
writeln('');
- $this->mysqlOptions = get('data_dir').'/addons/ydeploy/mysql-options';
+ $this->mysqlOptions = get('data_dir') . '/addons/ydeploy/mysql-options';
$this->source = $this->chooseSource();
@@ -44,7 +44,7 @@ public function __invoke(): void
$this->replaceYrewriteDomains();
$this->copyMedia();
} finally {
- run('rm -f '.escapeshellarg($this->mysqlOptions));
+ run('rm -f ' . escapeshellarg($this->mysqlOptions));
}
}
@@ -83,7 +83,7 @@ private function setConfigYml(): void
$this->headline('Create config.yml for {{hostname}}');
if ($this->source instanceof Localhost) {
- $config = file_get_contents(getcwd().'/'.get('data_dir').'/core/config.yml');
+ $config = file_get_contents(getcwd() . '/' . get('data_dir') . '/core/config.yml');
} else {
$config = onHost($this->source, static function () {
return downloadContent('{{data_dir}}/core/config.yml');
@@ -94,7 +94,7 @@ private function setConfigYml(): void
$config['setup'] = false;
$config['debug'] = false;
- $config['instname'] = 'rex'.date('YmdHis');
+ $config['instname'] = 'rex' . date('YmdHis');
$config['server'] = ask('Server:', get('url'));
$config['servername'] = ask('Server name:', $config['servername']);
@@ -119,18 +119,18 @@ private function setConfigYml(): void
$db['password'] = askHiddenResponse('Database password:');
uploadContent($this->mysqlOptions, implode("\n", [
- '--host='.escapeshellarg($db['host']),
- '--user='.escapeshellarg($db['login']),
- '--password='.escapeshellarg($db['password']),
+ '--host=' . escapeshellarg($db['host']),
+ '--user=' . escapeshellarg($db['login']),
+ '--password=' . escapeshellarg($db['password']),
escapeshellarg($db['name']),
]));
try {
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e ";"');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e ";"');
$dbValid = true;
} catch (RuntimeException $e) {
writeln('');
- writeln('Could not connect to database: '.trim($e->getErrorOutput()).'');
+ writeln('Could not connect to database: ' . trim($e->getErrorOutput()) . '');
writeln('');
}
} while (!$dbValid);
@@ -150,26 +150,26 @@ private function copyDatabase(): void
{
$this->headline("Copy database from {$this->source} to {{hostname}}");
- $path = get('data_dir').'/addons/ydeploy/'.date('YmdHis').'.sql';
+ $path = get('data_dir') . '/addons/ydeploy/' . date('YmdHis') . '.sql';
// export source database
onHost($this->source, static function () use ($path) {
- run('{{bin/console}} db:connection-options | xargs {{bin/mysqldump}} > '.escapeshellarg($path));
+ run('{{bin/console}} db:connection-options | xargs {{bin/mysqldump}} > ' . escapeshellarg($path));
if (Context::get()->getHost() instanceof Localhost) {
return;
}
download("{{release_path}}/$path", $path);
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
});
// upload and import the dump
upload($path, "{{release_path}}/$path");
- run('< '.escapeshellarg($this->mysqlOptions).' xargs sh -c \'{{bin/mysql}} "$0" "$@" < '.escapeshellcmd(escapeshellarg($path)).'\'');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs sh -c \'{{bin/mysql}} "$0" "$@" < ' . escapeshellcmd(escapeshellarg($path)) . '\'');
- run('rm -f '.escapeshellarg($path));
- unlink(getcwd().'/'.$path);
+ run('rm -f ' . escapeshellarg($path));
+ unlink(getcwd() . '/' . $path);
$this->ok();
}
@@ -178,7 +178,7 @@ private function configureDeveloper(): void
{
$this->headline('Configure developer addon for production usage');
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e "UPDATE rex_config SET value = \"false\" WHERE namespace=\"developer\" AND \`key\` NOT IN (\"templates\", \"modules\", \"actions\", \"items\")"');
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e "UPDATE rex_config SET value = \"false\" WHERE namespace=\"developer\" AND \`key\` NOT IN (\"templates\", \"modules\", \"actions\", \"items\")"');
$this->ok();
}
@@ -186,7 +186,7 @@ private function configureDeveloper(): void
private function replaceYrewriteDomains(): void
{
try {
- $data = run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} --silent --raw --skip-column-names -e "SELECT id, domain FROM rex_yrewrite_domain"');
+ $data = run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} --silent --raw --skip-column-names -e "SELECT id, domain FROM rex_yrewrite_domain"');
$data = trim($data);
} catch (RuntimeException $exception) {
if (str_contains($exception->getMessage(), 'ERROR 1146')) {
@@ -206,8 +206,8 @@ private function replaceYrewriteDomains(): void
foreach (explode("\n", $data) as $line) {
[$id, $domain] = explode("\t", $line, 2);
$id = (int) $id;
- $domain = ask($domain.':', $this->server ?: get('url'));
- run('< '.escapeshellarg($this->mysqlOptions).' xargs {{bin/mysql}} -e "UPDATE rex_yrewrite_domain SET domain = \"'.addslashes($domain).'\" WHERE id = '.$id.'"');
+ $domain = ask($domain . ':', $this->server ?: get('url'));
+ run('< ' . escapeshellarg($this->mysqlOptions) . ' xargs {{bin/mysql}} -e "UPDATE rex_yrewrite_domain SET domain = \"' . addslashes($domain) . '\" WHERE id = ' . $id . '"');
}
writeln('');
@@ -218,11 +218,11 @@ private function copyMedia(): void
{
$this->headline("Copy media files from {$this->source} to {{hostname}}");
- $path = get('data_dir').'/addons/ydeploy/media_'.date('YmdHis').'.tar.gz';
+ $path = get('data_dir') . '/addons/ydeploy/media_' . date('YmdHis') . '.tar.gz';
// create source archive
onHost($this->source, static function () use ($path) {
- run('COPYFILE_DISABLE=1 tar -zcvf '.escapeshellarg($path).' -C {{media_dir}} .');
+ run('COPYFILE_DISABLE=1 tar -zcvf ' . escapeshellarg($path) . ' -C {{media_dir}} .');
if (Context::get()->getHost() instanceof Localhost) {
return;
@@ -231,16 +231,16 @@ private function copyMedia(): void
try {
download("{{release_path}}/$path", $path);
} finally {
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
}
});
try {
upload($path, "{{release_path}}/$path");
- run('tar -zxvf '.escapeshellarg($path).' -C {{media_dir}}/');
+ run('tar -zxvf ' . escapeshellarg($path) . ' -C {{media_dir}}/');
} finally {
unlink($path);
- run('rm -f '.escapeshellarg($path));
+ run('rm -f ' . escapeshellarg($path));
}
$this->ok();
@@ -248,7 +248,7 @@ private function copyMedia(): void
private function headline(string $headline): void
{
- writeln(''.$headline.'');
+ writeln('' . $headline . '');
writeln('');
}
diff --git a/deployer/tasks/upload.php b/deployer/tasks/upload.php
index ccd032a..dc6df1b 100644
--- a/deployer/tasks/upload.php
+++ b/deployer/tasks/upload.php
@@ -4,7 +4,7 @@
desc('Upload locally prepared release to server');
task('upload', static function () {
- upload(getcwd().'/.build/current/', '{{release_path}}', [
+ upload(getcwd() . '/.build/current/', '{{release_path}}', [
'options' => ['--exclude=".git/"', '--delete'],
]);
});
diff --git a/lib/api_protected_page.php b/lib/api_protected_page.php
index aa0f25c..bef3462 100644
--- a/lib/api_protected_page.php
+++ b/lib/api_protected_page.php
@@ -14,7 +14,7 @@ public function execute(): rex_api_result
$action = rex_get('action', 'string');
if (!in_array($action, ['lock', 'unlock'], true)) {
- throw new rex_api_exception('Supported protected page actions are "lock" and "unlock", but "'.$action.'" given.');
+ throw new rex_api_exception('Supported protected page actions are "lock" and "unlock", but "' . $action . '" given.');
}
$protectedPage = rex_get('protected_page', 'string');
@@ -23,7 +23,7 @@ public function execute(): rex_api_result
foreach (rex_ydeploy_handler::getProtectedPages() as $page => $subpages) {
// `yform/manager/table_edit` must not match `yform/man`
// so we add slashes to avoid this
- if (str_starts_with($protectedPage.'/', $page.'/')) {
+ if (str_starts_with($protectedPage . '/', $page . '/')) {
$foundPage = $page;
break;
@@ -31,7 +31,7 @@ public function execute(): rex_api_result
}
if (!$foundPage) {
- throw new rex_api_exception('The page "'.$protectedPage.'" is not protected.');
+ throw new rex_api_exception('The page "' . $protectedPage . '" is not protected.');
}
if ('unlock' === $action) {
diff --git a/lib/command/diff.php b/lib/command/diff.php
index 960e3c5..c86780c 100644
--- a/lib/command/diff.php
+++ b/lib/command/diff.php
@@ -73,13 +73,13 @@ private function handleSchema(array $tables, rex_ydeploy_diff_file $diff): void
FROM INFORMATION_SCHEMA.TABLES T
INNER JOIN INFORMATION_SCHEMA.COLLATION_CHARACTER_SET_APPLICABILITY AS CCSA ON CCSA.COLLATION_NAME = T.TABLE_COLLATION
WHERE T.TABLE_SCHEMA = DATABASE() AND T.TABLE_NAME LIKE :prefix
- ', ['prefix' => rex::getTablePrefix().'%']);
+ ', ['prefix' => rex::getTablePrefix() . '%']);
$charsets = array_column($charsets, null, 'table_name');
$views = [];
foreach ($sql->getViews(rex::getTablePrefix()) as $view) {
- $sql->setQuery('SHOW CREATE VIEW '.$sql->escapeIdentifier($view));
+ $sql->setQuery('SHOW CREATE VIEW ' . $sql->escapeIdentifier($view));
$query = (string) $sql->getValue('Create View');
$query = substr($query, strpos($query, ' AS ') + 4);
$views[$view] = $query;
@@ -163,7 +163,7 @@ private function addSchemaDiff(rex_ydeploy_diff_file $diff, array $tables, array
$diff->createTable($table);
$defaultCharset = rex::getConfig('utf8mb4') ? 'utf8mb4' : 'utf8';
- $defaultCollation = $defaultCharset.'_unicode_ci';
+ $defaultCollation = $defaultCharset . '_unicode_ci';
if ($defaultCharset !== $charsets[$tableName]['charset'] || $defaultCollation !== $charsets[$tableName]['collation']) {
$diff->setCharset($tableName, $charsets[$tableName]['charset'], $charsets[$tableName]['collation']);
}
@@ -407,7 +407,7 @@ private function hash(array $data): string
return sha1(json_encode($data));
}
- private function getData(rex_sql_table $table, array $conditions = null): array
+ private function getData(rex_sql_table $table, ?array $conditions = null): array
{
$sql = rex_sql::factory();
@@ -420,16 +420,16 @@ private function getData(rex_sql_table $table, array $conditions = null): array
foreach ($conditions as $condition) {
$parts = [];
foreach ($condition as $name => $value) {
- $parts[] = $sql->escapeIdentifier($name).' = ?';
+ $parts[] = $sql->escapeIdentifier($name) . ' = ?';
$params[] = $value;
}
$where[] = implode(' AND ', $parts);
}
- $where = ' WHERE '.implode(' OR ', $where);
+ $where = ' WHERE ' . implode(' OR ', $where);
}
- $data = $sql->getArray('SELECT * FROM '.$sql->escapeIdentifier($table->getName()).$where, $params);
+ $data = $sql->getArray('SELECT * FROM ' . $sql->escapeIdentifier($table->getName()) . $where, $params);
foreach ($data as &$row) {
foreach ($row as &$value) {
@@ -472,8 +472,8 @@ private function saveDiff(rex_ydeploy_diff_file $diff): DateTime
{
$timestamp = new DateTime();
$timestamp->setTimezone(new DateTimeZone('UTC'));
- $filename = $timestamp->format('Y-m-d H-i-s.u').'.php';
- $path = $this->addon->getDataPath('migrations/'.$filename);
+ $filename = $timestamp->format('Y-m-d H-i-s.u') . '.php';
+ $path = $this->addon->getDataPath('migrations/' . $filename);
if (file_exists($path)) {
throw new Exception(sprintf('File "%s" already exists.', $path));
diff --git a/lib/command/migrate.php b/lib/command/migrate.php
index 8893ca3..2499f2d 100644
--- a/lib/command/migrate.php
+++ b/lib/command/migrate.php
@@ -26,7 +26,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->title('YDeploy migration');
$sql = rex_sql::factory();
- $migrated = $sql->getArray('SELECT `timestamp` FROM '.$this->migrationTable);
+ $migrated = $sql->getArray('SELECT `timestamp` FROM ' . $this->migrationTable);
$migrated = array_column($migrated, 'timestamp', 'timestamp');
$fake = $input->getOption('fake');
@@ -41,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
continue;
}
- $timestamp = $match[1].' '.$match[2].':'.$match[3].':'.$match[4];
+ $timestamp = $match[1] . ' ' . $match[2] . ':' . $match[3] . ':' . $match[4];
if (!isset($migrated[$timestamp])) {
$paths[$path] = $timestamp;
@@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}
- $io->text(count($paths).' migrations to execute');
+ $io->text(count($paths) . ' migrations to execute');
$countMigrated = 0;
diff --git a/lib/diff_file.php b/lib/diff_file.php
index cf5c37f..eb24359 100644
--- a/lib/diff_file.php
+++ b/lib/diff_file.php
@@ -138,7 +138,7 @@ public function getContent(): string
EOL;
if ($changes) {
- $content .= "\n ".$changes;
+ $content .= "\n " . $changes;
} else {
$content .= "\n // Add migration stuff here";
}
@@ -303,7 +303,7 @@ private function addEnsureIndex(rex_sql_index $index): string
$add = '';
if (rex_sql_index::INDEX !== $index->getType()) {
- $add .= ', '.$types[$index->getType()];
+ $add .= ', ' . $types[$index->getType()];
}
return $this->sprintf(
@@ -324,7 +324,7 @@ private function addEnsureForeignKey(rex_sql_foreign_key $foreignKey): string
rex_sql_foreign_key::SET_NULL => 'rex_sql_foreign_key::SET_NULL',
];
- $add = $modes[$foreignKey->getOnUpdate()].', '.$modes[$foreignKey->getOnDelete()];
+ $add = $modes[$foreignKey->getOnUpdate()] . ', ' . $modes[$foreignKey->getOnDelete()];
return $this->sprintf(
"\n ->ensureForeignKey(new rex_sql_foreign_key(%s, %s, %s, $add))",
@@ -351,8 +351,8 @@ private function addEnsureViews(): string
$sql = rex_sql::factory();
foreach ($this->views as $viewName => $query) {
- $statement = 'CREATE OR REPLACE VIEW '.$sql->escapeIdentifier($viewName)." AS\n".$query;
- $content .= "\n\n \$sql->setQuery(".$this->nowdoc($statement).');';
+ $statement = 'CREATE OR REPLACE VIEW ' . $sql->escapeIdentifier($viewName) . " AS\n" . $query;
+ $content .= "\n\n \$sql->setQuery(" . $this->nowdoc($statement) . ');';
}
return $content;
@@ -364,8 +364,8 @@ private function addDropViews(): string
$sql = rex_sql::factory();
foreach ($this->dropViews as $viewName) {
- $statement = 'DROP VIEW IF EXISTS '.$sql->escapeIdentifier($viewName);
- $content .= "\n\n \$sql->setQuery(".$this->nowdoc($statement).');';
+ $statement = 'DROP VIEW IF EXISTS ' . $sql->escapeIdentifier($viewName);
+ $content .= "\n\n \$sql->setQuery(" . $this->nowdoc($statement) . ');';
}
return $content;
@@ -391,7 +391,7 @@ private function addFixtures(): string
return $sql->escape((string) $value);
}, $data);
- $rows[] = '('.implode(', ', $data).')';
+ $rows[] = '(' . implode(', ', $data) . ')';
}
$columns = array_keys($changes['ensure'][0]);
@@ -401,19 +401,19 @@ private function addFixtures(): string
foreach ($columns as $column) {
if (!in_array($column, $primaryKey)) {
$column = $sql->escapeIdentifier($column);
- $updates[] = $column.' = VALUES('.$column.')';
+ $updates[] = $column . ' = VALUES(' . $column . ')';
}
}
- $query = 'INSERT INTO '.$sql->escapeIdentifier($tableName);
- $query .= ' ('.implode(', ', array_map([$sql, 'escapeIdentifier'], $columns)).')';
+ $query = 'INSERT INTO ' . $sql->escapeIdentifier($tableName);
+ $query .= ' (' . implode(', ', array_map([$sql, 'escapeIdentifier'], $columns)) . ')';
$query .= "\nVALUES\n ";
$query .= implode(",\n ", $rows);
if ($updates) {
- $query .= "\nON DUPLICATE KEY UPDATE ".implode(', ', $updates);
+ $query .= "\nON DUPLICATE KEY UPDATE " . implode(', ', $updates);
}
- $content .= "\n\n \$sql->setQuery(".$this->nowdoc($query).');';
+ $content .= "\n\n \$sql->setQuery(" . $this->nowdoc($query) . ');';
}
if (isset($changes['remove'])) {
@@ -421,16 +421,16 @@ private function addFixtures(): string
foreach ($changes['remove'] as $key) {
$parts = [];
foreach ($key as $name => $value) {
- $parts[] = $sql->escapeIdentifier($name).' = '.(is_int($value) ? $value : $sql->escape((string) $value));
+ $parts[] = $sql->escapeIdentifier($name) . ' = ' . (is_int($value) ? $value : $sql->escape((string) $value));
}
$where[] = implode(' AND ', $parts);
}
- $query = 'DELETE FROM '.$sql->escapeIdentifier($tableName);
+ $query = 'DELETE FROM ' . $sql->escapeIdentifier($tableName);
$query .= "\nWHERE\n ";
$query .= implode(" OR\n ", $where);
- $content .= "\n\n \$sql->setQuery(".$this->nowdoc($query).');';
+ $content .= "\n\n \$sql->setQuery(" . $this->nowdoc($query) . ');';
}
}
@@ -468,15 +468,15 @@ private function quote($var): string
$i = $key + 1;
}
- $elements[] = $this->quote($key).' => '.$value;
+ $elements[] = $this->quote($key) . ' => ' . $value;
}
- return '['.implode(', ', $elements).']';
+ return '[' . implode(', ', $elements) . ']';
}
private function nowdoc(string $var): string
{
- $var = ' '.preg_replace('/(?<=\\n)(?=.)/', ' ', $var);
+ $var = ' ' . preg_replace('/(?<=\\n)(?=.)/', ' ', $var);
return "<<<'SQL'\n$var\n SQL";
}
diff --git a/lib/handler.php b/lib/handler.php
index 8934366..dd9266a 100644
--- a/lib/handler.php
+++ b/lib/handler.php
@@ -16,7 +16,7 @@ public static function addBodyClasses(rex_extension_point $ep): array
$attr['class'][] = 'ydeploy-is-deployed';
if ($ydeploy->getStage()) {
- $attr['class'][] = 'ydeploy-stage-'.rex_string::normalize($ydeploy->getStage(), '-');
+ $attr['class'][] = 'ydeploy-stage-' . rex_string::normalize($ydeploy->getStage(), '-');
}
} else {
$attr['class'][] = 'ydeploy-is-not-deployed';
@@ -34,7 +34,7 @@ public static function addBadge(rex_extension_point $ep): ?string
$badge = $ydeploy->getHost();
if ($ydeploy->getStage()) {
- $badge .= ' – '.ucfirst($ydeploy->getStage());
+ $badge .= ' – ' . ucfirst($ydeploy->getStage());
}
} else {
$badge = 'Development';
@@ -46,9 +46,9 @@ public static function addBadge(rex_extension_point $ep): ?string
return null;
}
- $badge = '
'.$badge.'
';
+ $badge = '' . $badge . '
';
- return str_replace('