Skip to content

Commit

Permalink
Merge pull request #896 from doctrine/dependencies/doctrine-coding-st…
Browse files Browse the repository at this point in the history
…andard-v7

Update to doctrine/coding-standard v7
  • Loading branch information
goetas authored Jan 14, 2020
2 parents cb74ad7 + 6d1bf4c commit f8fa939
Show file tree
Hide file tree
Showing 40 changed files with 95 additions and 62 deletions.
4 changes: 2 additions & 2 deletions bin/doctrine-migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use Doctrine\Migrations\Tools\Console\ConsoleRunner;
use Phar;
use const PHP_EOL;
use const STDERR;
use function extension_loaded;
use function file_exists;
use function fwrite;
use const PHP_EOL;
use const STDERR;

(static function () : void {
$autoloadFiles = [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"ext-pdo_sqlite": "*",
"doctrine/coding-standard": "^6.0",
"doctrine/coding-standard": "^7.0",
"doctrine/orm": "^2.6",
"jdorn/sql-formatter": "^1.1",
"phpstan/phpstan": "^0.11",
Expand Down
55 changes: 28 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/Doctrine/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function freeze() : void
if (! $this->frozen) {
$this->validate();
}

$this->frozen = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Doctrine\Migrations\Configuration\Configuration;

use Doctrine\Migrations\Configuration\Configuration;
use const PATHINFO_EXTENSION;
use function count;
use function pathinfo;
use const PATHINFO_EXTENSION;

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Configuration\Configuration\Exception\JsonNotValid;
use Doctrine\Migrations\Configuration\Exception\FileNotFound;
use const JSON_ERROR_NONE;
use function assert;
use function file_exists;
use function file_get_contents;
use function json_decode;
use function json_last_error;
use const JSON_ERROR_NONE;

final class JsonFile extends ConfigurationFile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getConfiguration() : Configuration
if (! file_exists($this->file)) {
throw FileNotFound::new($this->file);
}

$config = require $this->file;
if ($config instanceof Configuration) {
return $config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
use Doctrine\Migrations\Tools\BooleanStringFormatter;
use DOMDocument;
use SimpleXMLElement;
use const DIRECTORY_SEPARATOR;
use const LIBXML_NOCDATA;
use function assert;
use function file_exists;
use function file_get_contents;
use function libxml_clear_errors;
use function libxml_use_internal_errors;
use function simplexml_load_string;
use function strtr;
use const DIRECTORY_SEPARATOR;
use const LIBXML_NOCDATA;

final class XmlFile extends ConfigurationFile
{
Expand All @@ -44,6 +44,7 @@ public function getConfiguration() : Configuration
false
);
}

if (isset($config['migrations_paths'])) {
$config['migrations_paths'] = $this->getDirectoriesRelativeToFile(
$config['migrations_paths'],
Expand All @@ -66,6 +67,7 @@ private function extractParameters(SimpleXMLElement $root, bool $loopOverNodes)
if (! ($itemsToCheck instanceof SimpleXMLElement)) {
return $config;
}

foreach ($itemsToCheck as $node) {
$nodeName = strtr($node->getName(), '-', '_');
if ($nodeName === 'migrations_paths') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getConnection() : Connection
if (is_array($params)) {
return DriverManager::getConnection($params);
}

throw InvalidConfiguration::invalidArrayConfiguration();
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/Migrations/DbalMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\Stopwatch\StopwatchEvent;
use Throwable;
use const COUNT_RECURSIVE;
use function count;
use const COUNT_RECURSIVE;

/**
* The DbalMigrator class is responsible for generating and executing the SQL for a migration.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/Migrations/DependencyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public function getEntityManager() : EntityManagerInterface
if ($this->emLoader === null) {
throw MissingDependency::noEntityManager();
}

$this->em = $this->emLoader->getEntityManager();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Doctrine\Migrations\Finder\Exception;

use InvalidArgumentException;
use const PHP_EOL;
use function sprintf;
use const PHP_EOL;

final class NameIsReserved extends InvalidArgumentException implements FinderException
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Migrations/Finder/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Doctrine\Migrations\Finder\Exception\InvalidDirectory;
use Doctrine\Migrations\Finder\Exception\NameIsReserved;
use ReflectionClass;
use const SORT_STRING;
use function assert;
use function get_declared_classes;
use function in_array;
Expand All @@ -16,6 +15,7 @@
use function realpath;
use function strlen;
use function strncmp;
use const SORT_STRING;

/**
* The Finder class is responsible for for finding migrations on disk at a given path.
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/Migrations/Finder/RecursiveRegexFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
use const DIRECTORY_SEPARATOR;
use function sprintf;
use const DIRECTORY_SEPARATOR;

/**
* The RecursiveRegexFinder class recursively searches the given directory for migrations.
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/Migrations/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function generateMigration(
if (preg_match('~(.*)\\\\([^\\\\]+)~', $fqcn, $mch) === 0) {
throw new InvalidArgumentException(sprintf('Invalid FQCN'));
}

[$fqcn, $namespace, $className] = $mch;

$dirs = $this->configuration->getMigrationDirectories();
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Migrations/Metadata/AvailableMigrationsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getItems() : array
public function getFirst(int $offset = 0) : AvailableMigration
{
if (! isset($this->items[$offset])) {
throw NoMigrationsFoundWithCriteria::new('first' . ($offset > 0 ? ('+' . $offset) : ''));
throw NoMigrationsFoundWithCriteria::new('first' . ($offset > 0 ? '+' . $offset : ''));
}

return $this->items[$offset];
Expand All @@ -45,7 +45,7 @@ public function getLast(int $offset = 0) : AvailableMigration
{
$offset = count($this->items) - 1 - (-1 * $offset);
if (! isset($this->items[$offset])) {
throw NoMigrationsFoundWithCriteria::new('last' . ($offset > 0 ? ('+' . $offset) : ''));
throw NoMigrationsFoundWithCriteria::new('last' . ($offset > 0 ? '+' . $offset : ''));
}

return $this->items[$offset];
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/Migrations/Metadata/ExecutedMigrationsSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getItems() : array
public function getFirst(int $offset = 0) : ExecutedMigration
{
if (! isset($this->items[$offset])) {
throw NoMigrationsFoundWithCriteria::new('first' . ($offset > 0 ? ('+' . $offset) : ''));
throw NoMigrationsFoundWithCriteria::new('first' . ($offset > 0 ? '+' . $offset : ''));
}

return $this->items[$offset];
Expand All @@ -45,7 +45,7 @@ public function getLast(int $offset = 0) : ExecutedMigration
{
$offset = count($this->items) - 1 - (-1 * $offset);
if (! isset($this->items[$offset])) {
throw NoMigrationsFoundWithCriteria::new('last' . ($offset > 0 ? ('+' . $offset) : ''));
throw NoMigrationsFoundWithCriteria::new('last' . ($offset > 0 ? '+' . $offset : ''));
}

return $this->items[$offset];
Expand Down Expand Up @@ -74,6 +74,7 @@ public function getMigration(Version $version) : ExecutedMigration
return $migration;
}
}

throw MigrationNotExecuted::new((string) $version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
use Doctrine\Migrations\Version\ExecutionResult;
use Doctrine\Migrations\Version\Version;
use InvalidArgumentException;
use const CASE_LOWER;
use function array_change_key_case;
use function floatval;
use function round;
use function sprintf;
use function strlen;
use function strpos;
use function strtolower;
use const CASE_LOWER;

final class TableMetadataStorage implements MetadataStorage
{
Expand Down Expand Up @@ -61,6 +61,7 @@ public function __construct(
if ($configuration !== null && ! ($configuration instanceof TableMetadataStorageConfiguration)) {
throw new InvalidArgumentException(sprintf('%s accepts only %s as configuration', self::class, TableMetadataStorageConfiguration::class));
}

$this->configuration = $configuration ?: new TableMetadataStorageConfiguration();
}

Expand Down Expand Up @@ -230,9 +231,7 @@ private function isAlreadyV3Format(AvailableMigration $availableMigration, Execu
return strpos(
(string) $availableMigration->getVersion(),
(string) $executedMigration->getVersion()
) !== (
strlen((string) $availableMigration->getVersion()) -
strlen((string) $executedMigration->getVersion())
);
) !== strlen((string) $availableMigration->getVersion()) -
strlen((string) $executedMigration->getVersion());
}
}
Loading

0 comments on commit f8fa939

Please sign in to comment.