Skip to content

Commit

Permalink
Update coding standard to v12
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Jul 16, 2023
1 parent 478fd2f commit 03c6182
Show file tree
Hide file tree
Showing 112 changed files with 414 additions and 602 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"require-dev": {
"ext-pdo_sqlite": "*",
"doctrine/coding-standard": "^9",
"doctrine/coding-standard": "^12",
"doctrine/orm": "^2.13",
"doctrine/persistence": "^2 || ^3",
"doctrine/sql-formatter": "^1.0",
Expand Down
40 changes: 10 additions & 30 deletions lib/Doctrine/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,62 +74,46 @@ public function warnIf(bool $condition, string $message = 'Unknown Reason'): voi
$this->logger->warning($message, ['migration' => $this]);
}

/**
* @throws AbortMigration
*/
/** @throws AbortMigration */
public function abortIf(bool $condition, string $message = 'Unknown Reason'): void
{
if ($condition) {
throw new AbortMigration($message);
}
}

/**
* @throws SkipMigration
*/
/** @throws SkipMigration */
public function skipIf(bool $condition, string $message = 'Unknown Reason'): void
{
if ($condition) {
throw new SkipMigration($message);
}
}

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
public function preUp(Schema $schema): void
{
}

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
public function postUp(Schema $schema): void
{
}

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
public function preDown(Schema $schema): void
{
}

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
public function postDown(Schema $schema): void
{
}

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
abstract public function up(Schema $schema): void;

/**
* @throws MigrationException|DBALException
*/
/** @throws MigrationException|DBALException */
public function down(Schema $schema): void
{
$this->abortIf(true, sprintf('No down() migration implemented for "%s"', static::class));
Expand All @@ -147,9 +131,7 @@ protected function addSql(
$this->plannedSql[] = new Query($sql, $params, $types);
}

/**
* @return Query[]
*/
/** @return Query[] */
public function getSql(): array
{
return $this->plannedSql;
Expand All @@ -160,9 +142,7 @@ protected function write(string $message): void
$this->logger->notice($message, ['migration' => $this]);
}

/**
* @throws IrreversibleMigration
*/
/** @throws IrreversibleMigration */
protected function throwIrreversibleMigrationException(?string $message = null): void
{
if ($message === null) {
Expand Down
16 changes: 4 additions & 12 deletions lib/Doctrine/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public function setMetadataStorageConfiguration(MetadataStorageConfiguration $me
$this->metadataStorageConfiguration = $metadataStorageConfiguration;
}

/**
* @return string[]
*/
/** @return string[] */
public function getMigrationClasses(): array
{
return $this->migrationClasses;
Expand All @@ -91,9 +89,7 @@ public function addMigrationsDirectory(string $namespace, string $path): void
$this->migrationsDirectories[$namespace] = $path;
}

/**
* @return array<string,string>
*/
/** @return array<string,string> */
public function getMigrationDirectories(): array
{
return $this->migrationsDirectories;
Expand Down Expand Up @@ -137,19 +133,15 @@ public function areMigrationsOrganizedByYear(): bool
return $this->migrationsAreOrganizedByYear;
}

/**
* @throws MigrationException
*/
/** @throws MigrationException */
public function setMigrationsAreOrganizedByYear(
bool $migrationsAreOrganizedByYear = true
): void {
$this->assertNotFrozen();
$this->migrationsAreOrganizedByYear = $migrationsAreOrganizedByYear;
}

/**
* @throws MigrationException
*/
/** @throws MigrationException */
public function setMigrationsAreOrganizedByYearAndMonth(
bool $migrationsAreOrganizedByYearAndMonth = true
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ConnectionNotSpecified extends InvalidArgumentException implements L
public static function new(): self
{
return new self(
'You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.'
'You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.',

Check warning on line 14 in lib/Doctrine/Migrations/Configuration/Connection/Exception/ConnectionNotSpecified.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Migrations/Configuration/Connection/Exception/ConnectionNotSpecified.php#L14

Added line #L14 was not covered by tests
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@

final class UnknownConfigurationValue extends LogicException implements ConfigurationException
{
/**
* @param mixed $value
*/
/** @param mixed $value */
public static function new(string $key, $value): self
{
return new self(
sprintf(
'Unknown %s for configuration "%s".',
var_export($value, true),
$key
$key,
),
10
10,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ final class ConfigurationArray implements ConfigurationLoader
/** @var array<string,mixed> */
private array $configurations;

/**
* @param array<string,mixed> $configurations
*/
/** @param array<string,mixed> $configurations */
public function __construct(array $configurations)
{
$this->configurations = $configurations;
Expand Down Expand Up @@ -109,7 +107,7 @@ private static function applyConfigs(array $configMap, $object, array $data): vo
$callable,
$configurationValue,
$object,
$data
$data,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ private function configurationFileExists(string $config): bool
return file_exists($config);
}

/**
* @throws FileTypeNotSupported
*/
/** @throws FileTypeNotSupported */
private function loadConfiguration(string $file): Configuration
{
return (new FormattedFile($file))->getConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function new(): self
{
return new self(
'Unable to load yaml configuration files, please run '
. '`composer require symfony/yaml` to load yaml configuration files.'
. '`composer require symfony/yaml` to load yaml configuration files.',

Check warning on line 16 in lib/Doctrine/Migrations/Configuration/Migration/Exception/YamlNotAvailable.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Migrations/Configuration/Migration/Exception/YamlNotAvailable.php#L16

Added line #L16 was not covered by tests
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

use const PATHINFO_EXTENSION;

/**
* @internal
*/
/** @internal */
final class FormattedFile extends ConfigurationFile
{
/** @var callable[] */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getConfiguration(): Configuration
if (isset($config['migrations_paths'])) {
$config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
$config['migrations_paths'],
$this->file
$this->file,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getConfiguration(): Configuration
if (isset($config['migrations_paths'])) {
$config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
$config['migrations_paths'],
$this->file
$this->file,
);
}

Expand Down
14 changes: 6 additions & 8 deletions lib/Doctrine/Migrations/Configuration/Migration/XmlFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,28 @@ public function getConfiguration(): Configuration
if (isset($config['all_or_nothing'])) {
$config['all_or_nothing'] = BooleanStringFormatter::toBoolean(
$config['all_or_nothing'],
false
false,
);
}

if (isset($config['transactional'])) {
$config['transactional'] = BooleanStringFormatter::toBoolean(
$config['transactional'],
true
true,

Check warning on line 53 in lib/Doctrine/Migrations/Configuration/Migration/XmlFile.php

View check run for this annotation

Codecov / codecov/patch

lib/Doctrine/Migrations/Configuration/Migration/XmlFile.php#L53

Added line #L53 was not covered by tests
);
}

if (isset($config['migrations_paths'])) {
$config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
$config['migrations_paths'],
$this->file
$this->file,
);
}

return (new ConfigurationArray($config))->getConfiguration();
}

/**
* @return mixed[]
*/
/** @return mixed[] */
private function extractParameters(SimpleXMLElement $root, bool $loopOverNodes): array
{
$config = [];
Expand All @@ -81,7 +79,7 @@ private function extractParameters(SimpleXMLElement $root, bool $loopOverNodes):
$nodeName = strtr($node->getName(), '-', '_');
if ($nodeName === 'migrations_paths') {
$config['migrations_paths'] = [];
foreach ($node->{'path'} as $pathNode) {
foreach ($node->path as $pathNode) {
$config['migrations_paths'][(string) $pathNode['namespace']] = (string) $pathNode;
}
} elseif ($nodeName === 'storage' && $node->{'table-storage'} instanceof SimpleXMLElement) {
Expand All @@ -100,7 +98,7 @@ private function extractParameters(SimpleXMLElement $root, bool $loopOverNodes):
private function extractMigrations(SimpleXMLElement $node): array
{
$migrations = [];
foreach ($node->{'migration'} as $pathNode) {
foreach ($node->migration as $pathNode) {
$migrations[] = (string) $pathNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getConfiguration(): Configuration
if (isset($config['migrations_paths'])) {
$config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
$config['migrations_paths'],
$this->file
$this->file,
);
}

Expand Down
14 changes: 4 additions & 10 deletions lib/Doctrine/Migrations/DbalMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public function __construct(
$this->dispatcher = $dispatcher;
}

/**
* @return array<string, Query[]>
*/
/** @return array<string, Query[]> */
private function executeMigrations(
MigrationPlanList $migrationsPlan,
MigratorConfiguration $migratorConfiguration
Expand Down Expand Up @@ -95,9 +93,7 @@ private function assertAllMigrationsAreTransactional(MigrationPlanList $migratio
}
}

/**
* @return array<string, Query[]>
*/
/** @return array<string, Query[]> */
private function executePlan(MigrationPlanList $migrationsPlan, MigratorConfiguration $migratorConfiguration): array
{
$sql = [];
Expand All @@ -120,9 +116,7 @@ private function executePlan(MigrationPlanList $migrationsPlan, MigratorConfigur
return $sql;
}

/**
* @param array<string, Query[]> $sql
*/
/** @param array<string, Query[]> $sql */
private function endMigrations(
StopwatchEvent $stopwatchEvent,
MigrationPlanList $migrationsPlan,
Expand All @@ -137,7 +131,7 @@ private function endMigrations(
'memory' => BytesFormatter::formatBytes($stopwatchEvent->getMemory()),
'migrations_count' => count($migrationsPlan),
'queries_count' => count($sql, COUNT_RECURSIVE) - count($sql),
]
],
);
}

Expand Down
Loading

0 comments on commit 03c6182

Please sign in to comment.