Skip to content

Commit

Permalink
Update and fix CS (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed May 20, 2024
1 parent 7e04a5f commit 52e4ef6
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
->in(__DIR__)
;

return (new Redaxo\PhpCsFixerConfig\Config())
return Redaxo\PhpCsFixerConfig\Config::redaxo5()
->setFinder($finder)
;
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

"require-dev": {
"deployer/deployer": "^7.3.1",
"friendsofphp/php-cs-fixer": "^3.34.0",
"redaxo/php-cs-fixer-config": "^2.2.0"
"redaxo/php-cs-fixer-config": "^2.10.0"
},

"autoload": {
Expand Down
414 changes: 201 additions & 213 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use RuntimeException;

use const GLOB_NOSORT;

$version = ltrim(Deployer::get()->getConsole()->getVersion(), 'v');
if (7 !== (int) $version) {
throw new RuntimeException('YDeploy 2.x requires Deployer 7.x, but Deployer ' . $version . ' is used');
Expand Down
1 change: 0 additions & 1 deletion deployer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Deployer;

use Deployer\Task\Context;

use Symfony\Component\Console\Input\ArgvInput;

use function dirname;
Expand Down
2 changes: 2 additions & 0 deletions deployer/tasks/deploy/dump_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use function in_array;
use function YDeploy\onHost;

use const JSON_PRETTY_PRINT;

desc('Dump info about current deployment');
task('deploy:dump_info', static function () {
$host = get('alias');
Expand Down
4 changes: 2 additions & 2 deletions deployer/tasks/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function chooseSourceFile(): string
{
writeln('');

do {
while (true) {
$file = ask('Dump file', getcwd() . '/dump.sql');
writeln('');

Expand All @@ -112,7 +112,7 @@ private function chooseSourceFile(): string

writeln('<error>The file does not exist: ' . $file . '</error>');
writeln('');
} while (true);
}
}

private function setConfigYml(): void
Expand Down
38 changes: 19 additions & 19 deletions lib/command/diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$tables = rex_sql::factory()->getTables(rex::getTablePrefix());

/** @var rex_sql_table[] $tables */
/** @var list<rex_sql_table> $tables */
$tables = array_map('rex_sql_table::get', $tables);

$schemaExists = file_exists($this->addon->getDataPath('schema.yml'));
Expand Down Expand Up @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

/**
* @param rex_sql_table[] $tables
* @param list<rex_sql_table> $tables
*/
private function handleSchema(array $tables, rex_ydeploy_diff_file $diff): void
{
Expand Down Expand Up @@ -90,7 +90,7 @@ private function handleSchema(array $tables, rex_ydeploy_diff_file $diff): void
}

/**
* @param rex_sql_table[] $tables
* @param list<rex_sql_table> $tables
*/
private function createSchema(array $tables, array $charsets, array $views): void
{
Expand Down Expand Up @@ -140,7 +140,7 @@ private function createSchema(array $tables, array $charsets, array $views): voi
}

/**
* @param rex_sql_table[] $tables
* @param list<rex_sql_table> $tables
*/
private function addSchemaDiff(rex_ydeploy_diff_file $diff, array $tables, array $charsets, array $views): void
{
Expand Down Expand Up @@ -174,8 +174,8 @@ private function addSchemaDiff(rex_ydeploy_diff_file $diff, array $tables, array
$tableSchema = &$schema[$tableName];

if (
!isset($tableSchema['charset']) || $tableSchema['charset'] !== $charsets[$tableName]['charset'] ||
!isset($tableSchema['collation']) || $tableSchema['collation'] !== $charsets[$tableName]['collation']
!isset($tableSchema['charset']) || $tableSchema['charset'] !== $charsets[$tableName]['charset']
|| !isset($tableSchema['collation']) || $tableSchema['collation'] !== $charsets[$tableName]['collation']
) {
$diff->setCharset($tableName, $charsets[$tableName]['charset'], $charsets[$tableName]['collation']);
}
Expand Down Expand Up @@ -216,8 +216,8 @@ private function addSchemaDiff(rex_ydeploy_diff_file $diff, array $tables, array
$after = rex_sql_table::FIRST;
foreach ($columns as $columnName => $column) {
if (
!isset($tableSchema['columns'][$columnName]) && !isset($renamed[$columnName]) ||
!isset($currentOrder[$after]) || $columnName !== $currentOrder[$after]
!isset($tableSchema['columns'][$columnName]) && !isset($renamed[$columnName])
|| !isset($currentOrder[$after]) || $columnName !== $currentOrder[$after]
) {
$diff->ensureColumn($tableName, $column, $after);

Expand Down Expand Up @@ -303,30 +303,30 @@ private function addSchemaDiff(rex_ydeploy_diff_file $diff, array $tables, array
private function columnEqualsSchema(rex_sql_column $column, array $schema): bool
{
return
$column->getType() === $schema['type'] &&
$column->isNullable() === $schema['nullable'] &&
$column->getDefault() === $schema['default'] &&
$column->getExtra() === $schema['extra'];
$column->getType() === $schema['type']
&& $column->isNullable() === $schema['nullable']
&& $column->getDefault() === $schema['default']
&& $column->getExtra() === $schema['extra'];
}

private function indexEqualsSchema(rex_sql_index $index, array $schema): bool
{
return
$index->getType() === $schema['type'] &&
$index->getColumns() === $schema['columns'];
$index->getType() === $schema['type']
&& $index->getColumns() === $schema['columns'];
}

private function foreignKeyEqualsSchema(rex_sql_foreign_key $foreignKey, array $schema): bool
{
return
$foreignKey->getTable() === $schema['table'] &&
$foreignKey->getColumns() === $schema['columns'] &&
$foreignKey->getOnUpdate() === $schema['onUpdate'] &&
$foreignKey->getOnDelete() === $schema['onDelete'];
$foreignKey->getTable() === $schema['table']
&& $foreignKey->getColumns() === $schema['columns']
&& $foreignKey->getOnUpdate() === $schema['onUpdate']
&& $foreignKey->getOnDelete() === $schema['onDelete'];
}

/**
* @param rex_sql_table[] $tables
* @param list<rex_sql_table> $tables
*/
private function handleFixtures(array $tables, rex_ydeploy_diff_file $diff): void
{
Expand Down

0 comments on commit 52e4ef6

Please sign in to comment.