diff --git a/src/CakeManager.php b/src/CakeManager.php
index 4216a660..6d046996 100644
--- a/src/CakeManager.php
+++ b/src/CakeManager.php
@@ -164,7 +164,7 @@ public function rollbackToDateTime(string $environment, DateTime $dateTime, bool
sort($versions);
$versions = array_reverse($versions);
- if (empty($versions) || $dateString > $versions[0]) {
+ if (!$versions || $dateString > $versions[0]) {
$this->getOutput()->writeln('No migrations to rollback');
return;
@@ -218,7 +218,7 @@ public function markMigrated(int $version, string $path): bool
$migrationFile = glob($path . DS . $version . '*');
- if (empty($migrationFile)) {
+ if (!$migrationFile) {
throw new RuntimeException(
sprintf('A migration file matching version number `%s` could not be found', $version)
);
@@ -254,13 +254,13 @@ public function getVersionsToMark(InputInterface $input): array
$versionArg = $input->getArgument('version');
$targetArg = $input->getOption('target');
$hasAllVersion = in_array($versionArg, ['all', '*'], true);
- if ((empty($versionArg) && empty($targetArg)) || $hasAllVersion) {
+ if ((!$versionArg && !$targetArg) || $hasAllVersion) {
return $versions;
}
$version = (int)$targetArg ?: (int)$versionArg;
- if ($input->getOption('only') || !empty($versionArg)) {
+ if ($input->getOption('only') || $versionArg) {
if (!in_array($version, $versions)) {
throw new InvalidArgumentException("Migration `$version` was not found !");
}
@@ -375,7 +375,7 @@ public function setInput(InputInterface $input)
public function getSeeds(string $environment): array
{
parent::getSeeds($environment);
- if (empty($this->seeds)) {
+ if (!$this->seeds) {
return [];
}
diff --git a/src/Command/BakeMigrationCommand.php b/src/Command/BakeMigrationCommand.php
index c669bfd4..b4776f4e 100644
--- a/src/Command/BakeMigrationCommand.php
+++ b/src/Command/BakeMigrationCommand.php
@@ -91,7 +91,7 @@ public function templateData(Arguments $arguments): array
$this->io->abort('When applying fields the migration name should start with one of the following prefixes: `Create`, `Drop`, `Add`, `Remove`, `Alter`. See: https://book.cakephp.org/migrations/4/en/index.html#migrations-file-name');
}
- if (empty($action)) {
+ if (!$action) {
return [
'plugin' => $this->plugin,
'pluginPath' => $pluginPath,
@@ -103,7 +103,7 @@ public function templateData(Arguments $arguments): array
];
}
- if (in_array($action[0], ['alter_table', 'add_field'], true) && !empty($primaryKey)) {
+ if (in_array($action[0], ['alter_table', 'add_field'], true) && $primaryKey) {
/** @psalm-suppress PossiblyNullReference */
$this->io->abort('Adding a primary key to an already existing table is not supported.');
}
diff --git a/src/Command/BakeMigrationDiffCommand.php b/src/Command/BakeMigrationDiffCommand.php
index 66c119cc..b7de8ab7 100644
--- a/src/Command/BakeMigrationDiffCommand.php
+++ b/src/Command/BakeMigrationDiffCommand.php
@@ -119,7 +119,7 @@ public function bake(string $name, Arguments $args, ConsoleIo $io): void
'Make sure all your migrations have been migrated before baking a diff.');
}
- if (empty($this->migrationsFiles) && empty($this->migratedItems)) {
+ if (!$this->migrationsFiles && !$this->migratedItems) {
$this->bakeSnapshot($name, $args, $io);
}
@@ -322,7 +322,7 @@ protected function getColumns(): void
$this->templateData[$table]['columns']['remove'] = [];
}
$removedColumns = array_diff($oldColumns, $currentColumns);
- if (!empty($removedColumns)) {
+ if ($removedColumns) {
foreach ($removedColumns as $columnName) {
$column = $this->dumpSchema[$table]->getColumn($columnName);
/** @var int $key */
@@ -440,7 +440,7 @@ protected function getIndexes(): void
$removedIndexes = array_diff($oldIndexes, $currentIndexes);
$parts = [];
- if (!empty($removedIndexes)) {
+ if ($removedIndexes) {
foreach ($removedIndexes as $index) {
$parts[$index] = $this->dumpSchema[$table]->getIndex($index);
}
@@ -459,11 +459,11 @@ protected function getIndexes(): void
*/
protected function checkSync(): bool
{
- if (empty($this->migrationsFiles) && empty($this->migratedItems)) {
+ if (!$this->migrationsFiles && !$this->migratedItems) {
return true;
}
- if (!empty($this->migratedItems)) {
+ if ($this->migratedItems) {
$lastVersion = $this->migratedItems[0]['version'];
$lastFile = end($this->migrationsFiles);
@@ -513,7 +513,7 @@ protected function getDumpSchema(Arguments $args): array
$inputArgs = [];
$connectionName = 'default';
- if (!empty($args->getOption('connection'))) {
+ if ($args->getOption('connection')) {
$connectionName = $inputArgs['--connection'] = $args->getOption('connection');
}
@@ -521,7 +521,7 @@ protected function getDumpSchema(Arguments $args): array
$inputArgs['--source'] = $args->getOption('source');
}
- if (!empty($args->getOption('plugin'))) {
+ if ($args->getOption('plugin')) {
$inputArgs['--plugin'] = $args->getOption('plugin');
}
@@ -551,7 +551,7 @@ protected function getCurrentSchema(): array
{
$schema = [];
- if (empty($this->tables)) {
+ if (!$this->tables) {
return $schema;
}
diff --git a/src/Command/BakeSimpleMigrationCommand.php b/src/Command/BakeSimpleMigrationCommand.php
index 7ec97400..38135e73 100644
--- a/src/Command/BakeSimpleMigrationCommand.php
+++ b/src/Command/BakeSimpleMigrationCommand.php
@@ -112,7 +112,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
}
$this->extractCommonProperties($args);
$name = $args->getArgumentAt(0);
- if (empty($name)) {
+ if (!$name) {
$io->err('You must provide a name to bake a ' . $this->name());
$this->abort();
}
@@ -193,7 +193,7 @@ protected function createFile(string $path, string $contents, Arguments $args, C
*/
protected function getMigrationName(?string $name = null): string
{
- if (empty($name)) {
+ if (!$name) {
/** @psalm-suppress PossiblyNullReference */
$this->io->abort('Choose a migration name to bake in CamelCase format');
}
@@ -203,7 +203,7 @@ protected function getMigrationName(?string $name = null): string
if (!preg_match('/^[A-Z]{1}[a-zA-Z0-9]+$/', $name)) {
/** @psalm-suppress PossiblyNullReference */
- $this->io->abort('The className is not correct. The className can only contain "A-Z" and "0-9".');
+ $this->io->abort('The className is not correct. The className can only contain "A-Z" and "0-9" and has to start with a letter.');
}
return $name;
diff --git a/src/Command/MigrationsCommand.php b/src/Command/MigrationsCommand.php
index f5d777d1..bf4ad50f 100644
--- a/src/Command/MigrationsCommand.php
+++ b/src/Command/MigrationsCommand.php
@@ -85,7 +85,7 @@ public function getOptionParser(): ConsoleOptionParser
$parser->setDescription($command->getDescription());
$definition = $command->getDefinition();
foreach ($definition->getOptions() as $option) {
- if (!empty($option->getShortcut())) {
+ if ($option->getShortcut()) {
$parser->addOption($option->getName(), [
'short' => $option->getShortcut(),
'help' => $option->getDescription(),
@@ -140,12 +140,12 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
$exitCode === 0
) {
$newArgs = [];
- if (!empty($args->getOption('connection'))) {
+ if ($args->getOption('connection')) {
$newArgs[] = '-c';
$newArgs[] = $args->getOption('connection');
}
- if (!empty($args->getOption('plugin'))) {
+ if ($args->getOption('plugin')) {
$newArgs[] = '-p';
$newArgs[] = $args->getOption('plugin');
}
diff --git a/src/Command/Phinx/CacheBuild.php b/src/Command/Phinx/CacheBuild.php
index feec9a86..7bde4bbf 100644
--- a/src/Command/Phinx/CacheBuild.php
+++ b/src/Command/Phinx/CacheBuild.php
@@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return static::CODE_ERROR;
}
$tables = [$name];
- if (empty($name)) {
+ if (!$name) {
$tables = $schema->listTables();
}
foreach ($tables as $table) {
diff --git a/src/Command/Phinx/CacheClear.php b/src/Command/Phinx/CacheClear.php
index e8e8e314..69748cab 100644
--- a/src/Command/Phinx/CacheClear.php
+++ b/src/Command/Phinx/CacheClear.php
@@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return static::CODE_ERROR;
}
$tables = [$name];
- if (empty($name)) {
+ if (!$name) {
$tables = $schema->listTables();
}
$cacher = $schema->getCacher();
diff --git a/src/Command/Phinx/Create.php b/src/Command/Phinx/Create.php
index c434fb73..49b69722 100644
--- a/src/Command/Phinx/Create.php
+++ b/src/Command/Phinx/Create.php
@@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
[$phinxTimestamp, $phinxName] = explode('_', Util::mapClassNameToFileName($name), 2);
$migrationFilename = glob($migrationPath . '*' . $phinxName);
- if (empty($migrationFilename)) {
+ if (!$migrationFilename) {
$output->writeln('An error occurred while renaming file');
} else {
$migrationFilename = $migrationFilename[0];
diff --git a/src/Command/Phinx/Seed.php b/src/Command/Phinx/Seed.php
index 37d886df..c7eec38b 100644
--- a/src/Command/Phinx/Seed.php
+++ b/src/Command/Phinx/Seed.php
@@ -71,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$seed = $input->getOption('seed');
- if (!empty($seed) && !is_array($seed)) {
+ if ($seed && !is_array($seed)) {
$input->setOption('seed', [$seed]);
}
diff --git a/src/Command/Phinx/Status.php b/src/Command/Phinx/Status.php
index 9375a216..0207805c 100644
--- a/src/Command/Phinx/Status.php
+++ b/src/Command/Phinx/Status.php
@@ -105,7 +105,7 @@ protected function display(array $migrations): void
{
$output = $this->getManager()->getOutput();
- if (!empty($migrations)) {
+ if ($migrations) {
$output->writeln('');
$output->writeln(' Status Migration ID Migration Name ');
$output->writeln('-----------------------------------------');
diff --git a/src/Command/SeedCommand.php b/src/Command/SeedCommand.php
index b9dbacac..f6340078 100644
--- a/src/Command/SeedCommand.php
+++ b/src/Command/SeedCommand.php
@@ -119,7 +119,7 @@ protected function executeSeeds(Arguments $args, ConsoleIo $io): ?int
$io->out('ordering by ' . $versionOrder . ' time');
$start = microtime(true);
- if (empty($seeds)) {
+ if (!$seeds) {
// run all the seed(ers)
$manager->seed();
} else {
diff --git a/src/Command/StatusCommand.php b/src/Command/StatusCommand.php
index d2c9d370..442a0e2f 100644
--- a/src/Command/StatusCommand.php
+++ b/src/Command/StatusCommand.php
@@ -131,7 +131,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
*/
protected function display(array $migrations, ConsoleIo $io): void
{
- if (!empty($migrations)) {
+ if ($migrations) {
$rows = [];
$rows[] = ['Status', 'Migration ID', 'Migration Name'];
diff --git a/src/Db/Adapter/AbstractAdapter.php b/src/Db/Adapter/AbstractAdapter.php
index 48f8f91a..e37f4b40 100644
--- a/src/Db/Adapter/AbstractAdapter.php
+++ b/src/Db/Adapter/AbstractAdapter.php
@@ -513,7 +513,7 @@ public function execute(string $sql, array $params = []): int
}
$connection = $this->getConnection();
- if (empty($params)) {
+ if (!$params) {
$result = $connection->execute($sql);
return $result->rowCount();
diff --git a/src/Db/Adapter/MysqlAdapter.php b/src/Db/Adapter/MysqlAdapter.php
index 603c9af2..9dfd73d7 100644
--- a/src/Db/Adapter/MysqlAdapter.php
+++ b/src/Db/Adapter/MysqlAdapter.php
@@ -277,7 +277,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A
}
// Add the primary key(s)
- if (!empty($newColumns)) {
+ if ($newColumns) {
$sql = 'ADD PRIMARY KEY (';
if (is_string($newColumns)) { // handle primary_key => 'id'
$sql .= $this->quoteColumnName($newColumns);
@@ -449,7 +449,7 @@ protected function getAddColumnInstructions(Table $table, Column $column): Alter
protected function afterClause(Column $column): string
{
$after = $column->getAfter();
- if (empty($after)) {
+ if (!$after) {
return '';
}
@@ -815,7 +815,7 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr
}
}
- if (empty($matches)) {
+ if (!$matches) {
throw new InvalidArgumentException(sprintf(
'No foreign key on column(s) `%s` exists',
implode(', ', $columns)
@@ -1219,7 +1219,7 @@ public function hasDatabase(string $name): bool
)->fetchAll('assoc');
foreach ($rows as $row) {
- if (!empty($row)) {
+ if ($row) {
return true;
}
}
diff --git a/src/Db/Adapter/PostgresAdapter.php b/src/Db/Adapter/PostgresAdapter.php
index 22502081..13752579 100644
--- a/src/Db/Adapter/PostgresAdapter.php
+++ b/src/Db/Adapter/PostgresAdapter.php
@@ -176,14 +176,14 @@ public function createTable(Table $table, array $columns = [], array $indexes =
$queries[] = $sql;
// process column comments
- if (!empty($this->columnsWithComments)) {
+ if ($this->columnsWithComments) {
foreach ($this->columnsWithComments as $column) {
$queries[] = $this->getColumnCommentSqlDefinition($column, $table->getName());
}
}
// set the indexes
- if (!empty($indexes)) {
+ if ($indexes) {
foreach ($indexes as $index) {
$queries[] = $this->getIndexSqlDefinition($index, $table->getName());
}
@@ -227,7 +227,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, array|string|nu
}
// Add the new primary key
- if (!empty($newColumns)) {
+ if ($newColumns) {
$sql = sprintf(
'ADD CONSTRAINT %s PRIMARY KEY (',
$this->quoteColumnName($parts['table'] . '_pkey')
@@ -698,7 +698,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns
$indexes = $this->getIndexes($tableName);
foreach ($indexes as $indexName => $index) {
$a = array_diff($columns, $index['columns']);
- if (empty($a)) {
+ if (!$a) {
return new AlterInstructions([], [sprintf(
'DROP INDEX IF EXISTS %s',
'"' . ($parts['schema'] . '".' . $this->quoteColumnName($indexName))
@@ -733,8 +733,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind
public function hasPrimaryKey(string $tableName, $columns, ?string $constraint = null): bool
{
$primaryKey = $this->getPrimaryKey($tableName);
-
- if (empty($primaryKey)) {
+ if (!$primaryKey) {
return false;
}
@@ -871,7 +870,7 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr
}
}
- if (empty($matches)) {
+ if (!$matches) {
throw new InvalidArgumentException(sprintf(
'No foreign key on column(s) `%s` exists',
implode(', ', $columns)
diff --git a/src/Db/Adapter/SqliteAdapter.php b/src/Db/Adapter/SqliteAdapter.php
index ca745ee8..d008cd07 100644
--- a/src/Db/Adapter/SqliteAdapter.php
+++ b/src/Db/Adapter/SqliteAdapter.php
@@ -369,7 +369,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A
// Drop the existing primary key
$primaryKey = $this->getPrimaryKey($table->getName());
- if (!empty($primaryKey)) {
+ if ($primaryKey) {
$instructions->merge(
// FIXME: array access is a hack to make this incomplete implementation work with a correct getPrimaryKey implementation
$this->getDropPrimaryKeyInstructions($table, $primaryKey[0])
@@ -377,7 +377,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A
}
// Add the primary key(s)
- if (!empty($newColumns)) {
+ if ($newColumns) {
if (!is_string($newColumns)) {
throw new InvalidArgumentException(sprintf(
'Invalid value for primary key: %s',
diff --git a/src/Db/Adapter/SqlserverAdapter.php b/src/Db/Adapter/SqlserverAdapter.php
index 1b1c7c07..7f46697e 100644
--- a/src/Db/Adapter/SqlserverAdapter.php
+++ b/src/Db/Adapter/SqlserverAdapter.php
@@ -181,7 +181,7 @@ protected function getChangePrimaryKeyInstructions(Table $table, $newColumns): A
}
// Add the primary key(s)
- if (!empty($newColumns)) {
+ if ($newColumns) {
$sql = sprintf(
'ALTER TABLE %s ADD CONSTRAINT %s PRIMARY KEY (',
$this->quoteTableName($table->getName()),
@@ -463,7 +463,7 @@ protected function getChangeDefault(string $tableName, Column $newColumn): Alter
$default = ltrim($this->getDefaultValueDefinition($default));
}
- if (empty($default)) {
+ if (!$default) {
return $instructions;
}
@@ -635,8 +635,7 @@ public function hasIndex(string $tableName, string|array $columns): bool
foreach ($indexes as $index) {
$a = array_diff($columns, $index['columns']);
-
- if (empty($a)) {
+ if (!$a) {
return true;
}
}
@@ -687,7 +686,7 @@ protected function getDropIndexByColumnsInstructions(string $tableName, $columns
foreach ($indexes as $indexName => $index) {
$a = array_diff($columns, $index['columns']);
- if (empty($a)) {
+ if (!$a) {
$instructions->addPostStep(sprintf(
'DROP INDEX %s ON %s',
$this->quoteColumnName($indexName),
@@ -738,8 +737,7 @@ protected function getDropIndexByNameInstructions(string $tableName, string $ind
public function hasPrimaryKey(string $tableName, $columns, ?string $constraint = null): bool
{
$primaryKey = $this->getPrimaryKey($tableName);
-
- if (empty($primaryKey)) {
+ if (!$primaryKey) {
return false;
}
@@ -882,7 +880,7 @@ protected function getDropForeignKeyByColumnsInstructions(string $tableName, arr
}
}
- if (empty($matches)) {
+ if (!$matches) {
throw new InvalidArgumentException(sprintf(
'No foreign key on column(s) `%s` exists',
implode(', ', $columns)
diff --git a/src/Db/Table.php b/src/Db/Table.php
index ce036f6b..90684d09 100644
--- a/src/Db/Table.php
+++ b/src/Db/Table.php
@@ -743,7 +743,7 @@ protected function filterPrimaryKey(array $options): void
return isset($primaryKey[$columnDef->getName()]);
})->toArray();
- if (empty($primaryKeyColumns)) {
+ if (!$primaryKeyColumns) {
return;
}
@@ -755,7 +755,7 @@ protected function filterPrimaryKey(array $options): void
$primaryKey = array_flip($primaryKey);
- if (!empty($primaryKey)) {
+ if ($primaryKey) {
$options['primary_key'] = $primaryKey;
} else {
unset($options['primary_key']);
@@ -784,7 +784,7 @@ public function update(): void
public function saveData(): void
{
$rows = $this->getData();
- if (empty($rows)) {
+ if (!$rows) {
return;
}
diff --git a/src/Db/Table/Table.php b/src/Db/Table/Table.php
index cf2c16e7..847528f7 100644
--- a/src/Db/Table/Table.php
+++ b/src/Db/Table/Table.php
@@ -33,7 +33,7 @@ class Table
*/
public function __construct(string $name, array $options = [])
{
- if (empty($name)) {
+ if (!$name) {
throw new InvalidArgumentException('Cannot use an empty table name');
}
diff --git a/src/Migration/Environment.php b/src/Migration/Environment.php
index 7c78bea2..ecde844c 100644
--- a/src/Migration/Environment.php
+++ b/src/Migration/Environment.php
@@ -279,7 +279,7 @@ public function getCurrentVersion(): int
$versions = $this->getVersions();
$version = 0;
- if (!empty($versions)) {
+ if ($versions) {
$version = end($versions);
}
diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php
index dbdb159c..84c53632 100644
--- a/src/Migration/Manager.php
+++ b/src/Migration/Manager.php
@@ -193,7 +193,7 @@ public function rollbackToDateTime(DateTime $dateTime, bool $force = false): voi
sort($versions);
$versions = array_reverse($versions);
- if (empty($versions) || $dateString > $versions[0]) {
+ if (!$versions || $dateString > $versions[0]) {
$this->getIo()->out('No migrations to rollback');
return;
@@ -247,7 +247,7 @@ public function markMigrated(int $version, string $path): bool
$migrationFile = glob($path . DS . $version . '*');
- if (empty($migrationFile)) {
+ if (!$migrationFile) {
throw new RuntimeException(
sprintf('A migration file matching version number `%s` could not be found', $version)
);
@@ -314,13 +314,13 @@ public function getVersionsToMark(Arguments $args): array
}
$targetArg = $args->getOption('target');
$hasAllVersion = in_array($versionArg, ['all', '*'], true);
- if ((empty($versionArg) && empty($targetArg)) || $hasAllVersion) {
+ if ((!$versionArg && !$targetArg) || $hasAllVersion) {
return $versions;
}
$version = (int)$targetArg ?: (int)$versionArg;
- if ($args->getOption('only') || !empty($versionArg)) {
+ if ($args->getOption('only') || $versionArg) {
if (!in_array($version, $versions)) {
throw new InvalidArgumentException("Migration `$version` was not found !");
}
@@ -399,7 +399,7 @@ public function migrate(?int $version = null, bool $fake = false): void
$versions = $env->getVersions();
$current = $env->getCurrentVersion();
- if (empty($versions) && empty($migrations)) {
+ if (!$versions && !$migrations) {
return;
}
@@ -620,7 +620,7 @@ public function rollback(int|string|null $target = null, bool $force = false, bo
// Check we have at least 1 migration to revert
$executedVersionCreationTimes = array_keys($executedVersions);
- if (empty($executedVersionCreationTimes) || $target == end($executedVersionCreationTimes)) {
+ if (!$executedVersionCreationTimes || $target == end($executedVersionCreationTimes)) {
$io->out('No migrations to rollback');
return;
@@ -913,7 +913,7 @@ protected function getSeedDependenciesInstances(SeedInterface $seed): array
{
$dependenciesInstances = [];
$dependencies = $seed->getDependencies();
- if (!empty($dependencies) && !empty($this->seeds)) {
+ if ($dependencies && $this->seeds) {
foreach ($dependencies as $dependency) {
foreach ($this->seeds as $seed) {
$name = $seed->getName();
@@ -940,7 +940,7 @@ protected function orderSeedsByDependencies(array $seeds): array
$name = $seed->getName();
$orderedSeeds[$name] = $seed;
$dependencies = $this->getSeedDependenciesInstances($seed);
- if (!empty($dependencies)) {
+ if ($dependencies) {
$orderedSeeds = array_merge($this->orderSeedsByDependencies($dependencies), $orderedSeeds);
}
}
@@ -1008,7 +1008,7 @@ public function getSeeds(): array
$this->setSeeds($seeds);
}
$this->seeds = $this->orderSeedsByDependencies((array)$this->seeds);
- if (empty($this->seeds)) {
+ if (!$this->seeds) {
return [];
}
@@ -1072,7 +1072,7 @@ protected function markBreakpoint(?int $version, int $mark): void
$env = $this->getEnvironment();
$versions = $env->getVersionLog();
- if (empty($versions) || empty($migrations)) {
+ if (!$versions || !$migrations) {
return;
}
diff --git a/src/Table.php b/src/Table.php
index 87be2d08..41834e57 100644
--- a/src/Table.php
+++ b/src/Table.php
@@ -215,7 +215,7 @@ protected function filterPrimaryKey(): void
return isset($primaryKey[$columnDef->getName()]);
})->toArray();
- if (empty($primaryKeyColumns)) {
+ if (!$primaryKeyColumns) {
return;
}
@@ -227,7 +227,7 @@ protected function filterPrimaryKey(): void
$primaryKey = array_flip($primaryKey);
- if (!empty($primaryKey)) {
+ if ($primaryKey) {
$options['primary_key'] = $primaryKey;
} else {
unset($options['primary_key']);
diff --git a/src/Util/ColumnParser.php b/src/Util/ColumnParser.php
index 707ebd4e..21fe4bc9 100644
--- a/src/Util/ColumnParser.php
+++ b/src/Util/ColumnParser.php
@@ -278,7 +278,7 @@ public function getLength(string $type): int|array|null
*/
public function getIndexName(string $field, ?string $indexType, ?string $indexName, bool $indexUnique): string
{
- if (empty($indexName)) {
+ if (!$indexName) {
$indexName = strtoupper('BY_' . $field);
if ($indexType === 'primary') {
$indexName = 'PRIMARY';
diff --git a/src/Util/TableFinder.php b/src/Util/TableFinder.php
index eda13aeb..681b0719 100644
--- a/src/Util/TableFinder.php
+++ b/src/Util/TableFinder.php
@@ -65,14 +65,14 @@ public function getTablesToBake(CollectionInterface $collection, array $options
];
$tables = $collection->listTables();
- if (empty($tables)) {
+ if (!$tables) {
return $tables;
}
if ($options['require-table'] === true || $options['plugin']) {
$tableNamesInPlugin = $this->getTableNames($options['plugin']);
- if (empty($tableNamesInPlugin)) {
+ if (!$tableNamesInPlugin) {
return [];
}
@@ -115,13 +115,13 @@ public function getTableNames(?string $pluginName = null): array
if ($pluginName !== null && !CorePlugin::getCollection()->has($pluginName)) {
return [];
}
- $list = [];
- $tables = $this->findTables($pluginName);
- if (empty($tables)) {
+ $tables = $this->findTables($pluginName);
+ if (!$tables) {
return [];
}
+ $list = [];
foreach ($tables as $table) {
$list = array_merge($list, $this->fetchTableName($table, $pluginName));
}
diff --git a/src/Util/UtilTrait.php b/src/Util/UtilTrait.php
index 21906e33..bc464cf4 100644
--- a/src/Util/UtilTrait.php
+++ b/src/Util/UtilTrait.php
@@ -45,7 +45,7 @@ protected function getPhinxTable(?string $plugin = null): string
{
$table = 'phinxlog';
- if (empty($plugin)) {
+ if (!$plugin) {
return $table;
}
diff --git a/src/View/Helper/MigrationHelper.php b/src/View/Helper/MigrationHelper.php
index cb244ca0..1f2043d3 100644
--- a/src/View/Helper/MigrationHelper.php
+++ b/src/View/Helper/MigrationHelper.php
@@ -204,7 +204,7 @@ public function indexes(TableSchemaInterface|string $table): array
$tableIndexes = $tableSchema->indexes();
$indexes = [];
- if (!empty($tableIndexes)) {
+ if ($tableIndexes) {
foreach ($tableIndexes as $name) {
$indexes[$name] = $tableSchema->getIndex($name);
}
@@ -229,7 +229,7 @@ public function constraints(TableSchemaInterface|string $table): array
$constraints = [];
$tableConstraints = $tableSchema->constraints();
- if (empty($tableConstraints)) {
+ if (!$tableConstraints) {
return $constraints;
}
@@ -550,7 +550,7 @@ public function attributes(TableSchemaInterface|string $table, string $column):
*/
public function stringifyList(array $list, array $options = [], array $wantedOptions = []): string
{
- if (!empty($wantedOptions)) {
+ if ($wantedOptions) {
$list = array_intersect_key($list, $wantedOptions);
if (empty($list['comment'])) {
unset($list['comment']);