From 563c8298218d2510acf6e1714f6fae69e6e3998b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tvrd=C3=ADk?= Date: Wed, 25 Feb 2026 20:53:50 +0100 Subject: [PATCH 1/2] Raise minimum PHP version to 8.0 - Update composer.json: PHP >=8.0, dibi ^4.0+, doctrine/dbal ^2.12+, nextras/dbal ^4.0+ - Remove DibiAdapter proxy pattern, inline Dibi3Adapter implementation - Remove DoctrineAdapter method_exists fallbacks for pre-2.12 API - Remove NextrasAdapter v1 code path (nextras/dbal 1.x-3.x) - Remove Symfony Configuration compat for Symfony < 4.2 - Remove dibi3/dibi4 entries from DI extension $dbals arrays - Remove PHP 7.1-7.4 from CI matrix and Docker Compose - Delete 16 test matrix files for libraries incompatible with PHP 8 - Update PHP_VERSION_MIN to 80000 in 27 remaining matrix files --- .github/workflows/qa.yaml | 2 +- composer.json | 8 +- docker-compose.yaml | 16 ---- src/Bridges/Dibi/Dibi3Adapter.php | 73 ------------------- src/Bridges/Dibi/DibiAdapter.php | 34 ++++----- src/Bridges/DoctrineDbal/DoctrineAdapter.php | 8 +- src/Bridges/NetteDI/MigrationsExtension.php | 2 - src/Bridges/NextrasDbal/NextrasAdapter.php | 24 ++---- .../DependencyInjection/Configuration.php | 12 +-- .../NextrasMigrationsExtension.php | 2 - tests/matrix/dbal/dibi-3.0.sh | 5 -- tests/matrix/dbal/dibi-3.1.sh | 5 -- tests/matrix/dbal/dibi-3.2.sh | 5 -- tests/matrix/dbal/dibi-4.0.sh | 2 +- tests/matrix/dbal/dibi-4.1.sh | 2 +- tests/matrix/dbal/dibi-4.2.sh | 2 +- tests/matrix/dbal/doctrine-2.10.sh | 5 -- tests/matrix/dbal/doctrine-2.11.sh | 5 -- tests/matrix/dbal/doctrine-2.12.sh | 2 +- tests/matrix/dbal/doctrine-2.13.sh | 2 +- tests/matrix/dbal/doctrine-2.5.sh | 5 -- tests/matrix/dbal/doctrine-2.6.sh | 5 -- tests/matrix/dbal/doctrine-2.7.sh | 5 -- tests/matrix/dbal/doctrine-2.8.sh | 5 -- tests/matrix/dbal/doctrine-2.9.sh | 5 -- tests/matrix/dbal/doctrine-3.1.sh | 2 +- tests/matrix/dbal/doctrine-3.10.sh | 2 +- tests/matrix/dbal/doctrine-3.2.sh | 2 +- tests/matrix/dbal/doctrine-3.3.sh | 2 +- tests/matrix/dbal/doctrine-3.4.sh | 2 +- tests/matrix/dbal/doctrine-3.5.sh | 2 +- tests/matrix/dbal/doctrine-3.6.sh | 2 +- tests/matrix/dbal/doctrine-3.7.sh | 2 +- tests/matrix/dbal/doctrine-3.8.sh | 2 +- tests/matrix/dbal/doctrine-3.9.sh | 2 +- tests/matrix/dbal/nette-2.4.sh | 2 +- tests/matrix/dbal/nette-3.0.sh | 2 +- tests/matrix/dbal/nette-3.1.sh | 2 +- tests/matrix/dbal/nextras-1.0.sh | 5 -- tests/matrix/dbal/nextras-1.1.sh | 5 -- tests/matrix/dbal/nextras-2.0.sh | 5 -- tests/matrix/dbal/nextras-2.1.sh | 5 -- tests/matrix/dbal/nextras-3.0.sh | 5 -- tests/matrix/dbal/nextras-3.1.sh | 5 -- tests/matrix/dbal/nextras-4.0.sh | 2 +- tests/matrix/nette-di/nette-2.4.sh | 2 +- tests/matrix/nette-di/nette-3.0.sh | 2 +- tests/matrix/symfony-bundle/symfony-4.4.sh | 2 +- tests/matrix/symfony-bundle/symfony-5.0.sh | 2 +- tests/matrix/symfony-bundle/symfony-5.1.sh | 2 +- tests/matrix/symfony-bundle/symfony-5.2.sh | 2 +- tests/matrix/symfony-bundle/symfony-5.3.sh | 2 +- tests/matrix/symfony-bundle/symfony-5.4.sh | 2 +- 53 files changed, 57 insertions(+), 258 deletions(-) delete mode 100644 src/Bridges/Dibi/Dibi3Adapter.php delete mode 100755 tests/matrix/dbal/dibi-3.0.sh delete mode 100755 tests/matrix/dbal/dibi-3.1.sh delete mode 100755 tests/matrix/dbal/dibi-3.2.sh delete mode 100755 tests/matrix/dbal/doctrine-2.10.sh delete mode 100755 tests/matrix/dbal/doctrine-2.11.sh delete mode 100755 tests/matrix/dbal/doctrine-2.5.sh delete mode 100755 tests/matrix/dbal/doctrine-2.6.sh delete mode 100755 tests/matrix/dbal/doctrine-2.7.sh delete mode 100755 tests/matrix/dbal/doctrine-2.8.sh delete mode 100755 tests/matrix/dbal/doctrine-2.9.sh delete mode 100755 tests/matrix/dbal/nextras-1.0.sh delete mode 100755 tests/matrix/dbal/nextras-1.1.sh delete mode 100755 tests/matrix/dbal/nextras-2.0.sh delete mode 100755 tests/matrix/dbal/nextras-2.1.sh delete mode 100755 tests/matrix/dbal/nextras-3.0.sh delete mode 100755 tests/matrix/dbal/nextras-3.1.sh diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 2335db76..1473e84d 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] name: PHP ${{ matrix.php }} diff --git a/composer.json b/composer.json index 36f4c05a..9ad02a97 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,12 @@ "type": "library", "license": "BSD-3-Clause", "require": { - "php": ">=7.1" + "php": ">=8.0" }, "require-dev": { - "dibi/dibi": "^3.0 || ^4.0 || ^5.0", + "dibi/dibi": "^4.0 || ^5.0", "doctrine/cache": "^1.11", - "doctrine/dbal": "^2.5 || ^3.0 || ^4.0", + "doctrine/dbal": "^2.12 || ^3.0 || ^4.0", "doctrine/doctrine-bundle": "^2.0 || ^3.0", "doctrine/orm": "^2.7 || ^3.0", "mockery/mockery": "^1.3", @@ -17,7 +17,7 @@ "nette/di": "^2.4 || ^3.0", "nette/tester": "^2.3", "nette/utils": "^2.3 || ^3.0 || ^4.0", - "nextras/dbal": "^1.0 || ^2.0 || ^3.0 || ^4.0 || ^5.0", + "nextras/dbal": "^4.0 || ^5.0", "symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0", "symfony/console": "^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0", "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0 || ^7.0 || ^8.0", diff --git a/docker-compose.yaml b/docker-compose.yaml index 11d5c1a1..35003825 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,22 +12,6 @@ x-php-service-base: &php-service-base PHP_EXTENSION_PDO_PGSQL: 1 services: - php71: - <<: *php-service-base - image: thecodingmachine/php:7.1-v3-cli - - php72: - <<: *php-service-base - image: thecodingmachine/php:7.2-v4-cli - - php73: - <<: *php-service-base - image: thecodingmachine/php:7.3-v4-cli - - php74: - <<: *php-service-base - image: thecodingmachine/php:7.4-v5-cli - php80: <<: *php-service-base image: thecodingmachine/php:8.0-v5-cli diff --git a/src/Bridges/Dibi/Dibi3Adapter.php b/src/Bridges/Dibi/Dibi3Adapter.php deleted file mode 100644 index 05dd5c3a..00000000 --- a/src/Bridges/Dibi/Dibi3Adapter.php +++ /dev/null @@ -1,73 +0,0 @@ -conn = $dibi; - } - - - public function query(string $sql): array - { - $result = $this->conn->nativeQuery($sql); - $result->setRowClass(null); - return $result->fetchAll(); - } - - - public function exec(string $sql): int - { - $this->conn->nativeQuery($sql); - return $this->conn->getAffectedRows(); - } - - - public function escapeString(string $value): string - { - return $this->conn->getDriver()->escapeText($value); - } - - - public function escapeInt(int $value): string - { - return (string) $value; - } - - - public function escapeBool(bool $value): string - { - return (string) $this->conn->getDriver()->escapeBool($value); - } - - - public function escapeDateTime(DateTimeInterface $value): string - { - return $this->conn->getDriver()->escapeDateTime($value); - } - - - public function escapeIdentifier(string $value): string - { - return $this->conn->getDriver()->escapeIdentifier($value); - } - -} diff --git a/src/Bridges/Dibi/DibiAdapter.php b/src/Bridges/Dibi/DibiAdapter.php index e8807e2e..f45716b6 100644 --- a/src/Bridges/Dibi/DibiAdapter.php +++ b/src/Bridges/Dibi/DibiAdapter.php @@ -10,68 +10,64 @@ namespace Nextras\Migrations\Bridges\Dibi; use DateTimeInterface; -use dibi; -use Dibi\Connection; -use LogicException; +use Dibi; use Nextras\Migrations\IDbal; class DibiAdapter implements IDbal { - /** @var IDbal */ - private $innerAdapter; + /** @var Dibi\Connection */ + private $conn; - public function __construct(Connection $conn) + public function __construct(Dibi\Connection $conn) { - if (version_compare(dibi::VERSION, '3.0.0', '>=')) { - $this->innerAdapter = new Dibi3Adapter($conn); - - } else { - throw new LogicException('Unsupported dibi version'); - } + $this->conn = $conn; } public function query(string $sql): array { - return $this->innerAdapter->query($sql); + $result = $this->conn->nativeQuery($sql); + $result->setRowClass(null); + return $result->fetchAll(); } public function exec(string $sql): int { - return $this->innerAdapter->exec($sql); + $this->conn->nativeQuery($sql); + return $this->conn->getAffectedRows(); } public function escapeString(string $value): string { - return $this->innerAdapter->escapeString($value); + return $this->conn->getDriver()->escapeText($value); } public function escapeInt(int $value): string { - return $this->innerAdapter->escapeInt($value); + return (string) $value; } public function escapeBool(bool $value): string { - return $this->innerAdapter->escapeBool($value); + return (string) $this->conn->getDriver()->escapeBool($value); } public function escapeDateTime(DateTimeInterface $value): string { - return $this->innerAdapter->escapeDateTime($value); + return $this->conn->getDriver()->escapeDateTime($value); } public function escapeIdentifier(string $value): string { - return $this->innerAdapter->escapeIdentifier($value); + return $this->conn->getDriver()->escapeIdentifier($value); } } diff --git a/src/Bridges/DoctrineDbal/DoctrineAdapter.php b/src/Bridges/DoctrineDbal/DoctrineAdapter.php index 72514d03..42aceeb5 100644 --- a/src/Bridges/DoctrineDbal/DoctrineAdapter.php +++ b/src/Bridges/DoctrineDbal/DoctrineAdapter.php @@ -28,17 +28,13 @@ public function __construct(Doctrine\DBAL\Connection $conn) public function query(string $sql): array { - return method_exists($this->conn, 'fetchAllAssociative') - ? $this->conn->fetchAllAssociative($sql) - : $this->conn->fetchAll($sql); + return $this->conn->fetchAllAssociative($sql); } public function exec(string $sql): int { - return method_exists($this->conn, 'executeStatement') - ? $this->conn->executeStatement($sql) - : $this->conn->exec($sql); + return $this->conn->executeStatement($sql); } diff --git a/src/Bridges/NetteDI/MigrationsExtension.php b/src/Bridges/NetteDI/MigrationsExtension.php index 004916c4..1bc3c818 100644 --- a/src/Bridges/NetteDI/MigrationsExtension.php +++ b/src/Bridges/NetteDI/MigrationsExtension.php @@ -45,8 +45,6 @@ class MigrationsExtension extends Nette\DI\CompilerExtension /** @var array */ protected $dbals = [ 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, - 'dibi3' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, - 'dibi4' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, 'nextras' => Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter::class, diff --git a/src/Bridges/NextrasDbal/NextrasAdapter.php b/src/Bridges/NextrasDbal/NextrasAdapter.php index 1cacb0e0..1b7980bc 100644 --- a/src/Bridges/NextrasDbal/NextrasAdapter.php +++ b/src/Bridges/NextrasDbal/NextrasAdapter.php @@ -11,7 +11,6 @@ use DateTimeInterface; use Nextras\Dbal\Connection; -use Nextras\Dbal\Drivers\IDriver; use Nextras\Dbal\Result\Row; use Nextras\Migrations\IDbal; @@ -30,10 +29,7 @@ public function __construct(Connection $connection) $this->conn = $connection; $this->conn->connect(); - if (method_exists($connection->getDriver(), 'convertToSql')) { - $this->version = 1; - - } elseif (method_exists($connection->getDriver(), 'convertBoolToSql')) { + if (method_exists($connection->getDriver(), 'convertBoolToSql')) { $this->version = 2; } else { @@ -60,11 +56,7 @@ public function exec(string $sql): int public function escapeString(string $value): string { - if ($this->version >= 2) { - return $this->conn->getDriver()->convertStringToSql($value); - } else { - return $this->conn->getDriver()->convertToSql($value, IDriver::TYPE_STRING); - } + return $this->conn->getDriver()->convertStringToSql($value); } @@ -78,10 +70,8 @@ public function escapeBool(bool $value): string { if ($this->version >= 5) { return $this->conn->getPlatform()->formatBool($value); - } elseif ($this->version >= 2) { - return $this->conn->getDriver()->convertBoolToSql($value); } else { - return $this->conn->getDriver()->convertToSql($value, IDriver::TYPE_BOOL); + return $this->conn->getDriver()->convertBoolToSql($value); } } @@ -90,10 +80,8 @@ public function escapeDateTime(DateTimeInterface $value): string { if ($this->version >= 5) { return $this->conn->getPlatform()->formatDateTime($value); - } elseif ($this->version >= 2) { - return $this->conn->getDriver()->convertDateTimeToSql($value); } else { - return $this->conn->getDriver()->convertToSql($value, IDriver::TYPE_DATETIME); + return $this->conn->getDriver()->convertDateTimeToSql($value); } } @@ -102,10 +90,8 @@ public function escapeIdentifier(string $value): string { if ($this->version >= 5) { return $this->conn->getPlatform()->formatIdentifier($value); - } elseif ($this->version >= 2) { - return $this->conn->getDriver()->convertIdentifierToSql($value); } else { - return $this->conn->getDriver()->convertToSql($value, IDriver::TYPE_IDENTIFIER); + return $this->conn->getDriver()->convertIdentifierToSql($value); } } } diff --git a/src/Bridges/SymfonyBundle/DependencyInjection/Configuration.php b/src/Bridges/SymfonyBundle/DependencyInjection/Configuration.php index d422257d..a5b5da4a 100644 --- a/src/Bridges/SymfonyBundle/DependencyInjection/Configuration.php +++ b/src/Bridges/SymfonyBundle/DependencyInjection/Configuration.php @@ -17,14 +17,8 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder(): TreeBuilder { - if (!method_exists(TreeBuilder::class, '__construct')) { // Symfony < 4.2.0 - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('nextras_migrations'); - - } else { // Symfony >= 4.2.0 - $treeBuilder = new TreeBuilder('nextras_migrations'); - $rootNode = $treeBuilder->getRootNode(); - } + $treeBuilder = new TreeBuilder('nextras_migrations'); + $rootNode = $treeBuilder->getRootNode(); $rootNode->children() ->scalarNode('dir') @@ -32,7 +26,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->cannotBeEmpty() ->end() ->enumNode('dbal') - ->values(['dibi', 'dibi3', 'dibi4', 'doctrine', 'nette', 'nextras']) + ->values(['dibi', 'doctrine', 'nette', 'nextras']) ->defaultValue('doctrine') ->cannotBeEmpty() ->end() diff --git a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php index 1e29673b..dcf42579 100644 --- a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php +++ b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php @@ -20,8 +20,6 @@ class NextrasMigrationsExtension extends Extension /** @var array */ protected $dbals = [ 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, - 'dibi3' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, - 'dibi4' => Nextras\Migrations\Bridges\Dibi\Dibi3Adapter::class, 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, 'nextras' => Nextras\Migrations\Bridges\NextrasDbal\NextrasAdapter::class, diff --git a/tests/matrix/dbal/dibi-3.0.sh b/tests/matrix/dbal/dibi-3.0.sh deleted file mode 100755 index 5baffa82..00000000 --- a/tests/matrix/dbal/dibi-3.0.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:3.0.*" -DBAL="dibi" diff --git a/tests/matrix/dbal/dibi-3.1.sh b/tests/matrix/dbal/dibi-3.1.sh deleted file mode 100755 index 15156b5c..00000000 --- a/tests/matrix/dbal/dibi-3.1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:3.1.*" -DBAL="dibi" diff --git a/tests/matrix/dbal/dibi-3.2.sh b/tests/matrix/dbal/dibi-3.2.sh deleted file mode 100755 index 12c0851a..00000000 --- a/tests/matrix/dbal/dibi-3.2.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:3.2.*" -DBAL="dibi" diff --git a/tests/matrix/dbal/dibi-4.0.sh b/tests/matrix/dbal/dibi-4.0.sh index 5c16c967..e9924f06 100755 --- a/tests/matrix/dbal/dibi-4.0.sh +++ b/tests/matrix/dbal/dibi-4.0.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:4.0.*" DBAL="dibi" diff --git a/tests/matrix/dbal/dibi-4.1.sh b/tests/matrix/dbal/dibi-4.1.sh index 8b5528c3..bdfef5a4 100755 --- a/tests/matrix/dbal/dibi-4.1.sh +++ b/tests/matrix/dbal/dibi-4.1.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:4.1.*" DBAL="dibi" diff --git a/tests/matrix/dbal/dibi-4.2.sh b/tests/matrix/dbal/dibi-4.2.sh index 7061ac15..cf126692 100755 --- a/tests/matrix/dbal/dibi-4.2.sh +++ b/tests/matrix/dbal/dibi-4.2.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80599" COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:4.2.*" DBAL="dibi" diff --git a/tests/matrix/dbal/doctrine-2.10.sh b/tests/matrix/dbal/doctrine-2.10.sh deleted file mode 100755 index 06254ab1..00000000 --- a/tests/matrix/dbal/doctrine-2.10.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70200" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.10.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.11.sh b/tests/matrix/dbal/doctrine-2.11.sh deleted file mode 100755 index 44836478..00000000 --- a/tests/matrix/dbal/doctrine-2.11.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70300" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.11.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.12.sh b/tests/matrix/dbal/doctrine-2.12.sh index 1c1607bb..5ec98d82 100755 --- a/tests/matrix/dbal/doctrine-2.12.sh +++ b/tests/matrix/dbal/doctrine-2.12.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70300" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.12.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.13.sh b/tests/matrix/dbal/doctrine-2.13.sh index ab90fd89..56790f67 100755 --- a/tests/matrix/dbal/doctrine-2.13.sh +++ b/tests/matrix/dbal/doctrine-2.13.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80199" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.13.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.5.sh b/tests/matrix/dbal/doctrine-2.5.sh deleted file mode 100755 index c6f65154..00000000 --- a/tests/matrix/dbal/doctrine-2.5.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.5.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.6.sh b/tests/matrix/dbal/doctrine-2.6.sh deleted file mode 100755 index 4e94fb37..00000000 --- a/tests/matrix/dbal/doctrine-2.6.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.6.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.7.sh b/tests/matrix/dbal/doctrine-2.7.sh deleted file mode 100755 index 2f3300a4..00000000 --- a/tests/matrix/dbal/doctrine-2.7.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.7.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.8.sh b/tests/matrix/dbal/doctrine-2.8.sh deleted file mode 100755 index 71441362..00000000 --- a/tests/matrix/dbal/doctrine-2.8.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.8.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-2.9.sh b/tests/matrix/dbal/doctrine-2.9.sh deleted file mode 100755 index 03bf8cdb..00000000 --- a/tests/matrix/dbal/doctrine-2.9.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:2.9.*" -DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.1.sh b/tests/matrix/dbal/doctrine-3.1.sh index 7f4ac1a1..2d8c56b9 100755 --- a/tests/matrix/dbal/doctrine-3.1.sh +++ b/tests/matrix/dbal/doctrine-3.1.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70300" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80199" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.1.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.10.sh b/tests/matrix/dbal/doctrine-3.10.sh index 4bda01d9..f2d16e47 100755 --- a/tests/matrix/dbal/doctrine-3.10.sh +++ b/tests/matrix/dbal/doctrine-3.10.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80599" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.10.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.2.sh b/tests/matrix/dbal/doctrine-3.2.sh index 50f421fd..c1f65bc3 100755 --- a/tests/matrix/dbal/doctrine-3.2.sh +++ b/tests/matrix/dbal/doctrine-3.2.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70300" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80199" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.2.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.3.sh b/tests/matrix/dbal/doctrine-3.3.sh index 1691ac45..bffaeab1 100755 --- a/tests/matrix/dbal/doctrine-3.3.sh +++ b/tests/matrix/dbal/doctrine-3.3.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70300" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.3.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.4.sh b/tests/matrix/dbal/doctrine-3.4.sh index 2c74c507..6c79fce7 100755 --- a/tests/matrix/dbal/doctrine-3.4.sh +++ b/tests/matrix/dbal/doctrine-3.4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.4.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.5.sh b/tests/matrix/dbal/doctrine-3.5.sh index 8a90ac54..a242974c 100755 --- a/tests/matrix/dbal/doctrine-3.5.sh +++ b/tests/matrix/dbal/doctrine-3.5.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.5.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.6.sh b/tests/matrix/dbal/doctrine-3.6.sh index 30d74668..674818af 100755 --- a/tests/matrix/dbal/doctrine-3.6.sh +++ b/tests/matrix/dbal/doctrine-3.6.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.6.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.7.sh b/tests/matrix/dbal/doctrine-3.7.sh index 0abece58..c650d04b 100755 --- a/tests/matrix/dbal/doctrine-3.7.sh +++ b/tests/matrix/dbal/doctrine-3.7.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.7.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.8.sh b/tests/matrix/dbal/doctrine-3.8.sh index 56398c7c..0b6d1e2c 100755 --- a/tests/matrix/dbal/doctrine-3.8.sh +++ b/tests/matrix/dbal/doctrine-3.8.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.8.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/doctrine-3.9.sh b/tests/matrix/dbal/doctrine-3.9.sh index 9d8c4ace..d0295a63 100755 --- a/tests/matrix/dbal/doctrine-3.9.sh +++ b/tests/matrix/dbal/doctrine-3.9.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70400" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80499" COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:3.9.*" DBAL="doctrine" diff --git a/tests/matrix/dbal/nette-2.4.sh b/tests/matrix/dbal/nette-2.4.sh index 3a9ab5ce..aa1f6d1d 100755 --- a/tests/matrix/dbal/nette-2.4.sh +++ b/tests/matrix/dbal/nette-2.4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/database:2.4.*" DBAL="nette" diff --git a/tests/matrix/dbal/nette-3.0.sh b/tests/matrix/dbal/nette-3.0.sh index e23b9291..ea7e0ea2 100755 --- a/tests/matrix/dbal/nette-3.0.sh +++ b/tests/matrix/dbal/nette-3.0.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/database:3.0.*" DBAL="nette" diff --git a/tests/matrix/dbal/nette-3.1.sh b/tests/matrix/dbal/nette-3.1.sh index 560d9762..7b0cfb39 100755 --- a/tests/matrix/dbal/nette-3.1.sh +++ b/tests/matrix/dbal/nette-3.1.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/database:3.1.*" DBAL="nette" diff --git a/tests/matrix/dbal/nextras-1.0.sh b/tests/matrix/dbal/nextras-1.0.sh deleted file mode 100755 index 513ff986..00000000 --- a/tests/matrix/dbal/nextras-1.0.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:1.0.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-1.1.sh b/tests/matrix/dbal/nextras-1.1.sh deleted file mode 100755 index 9886bdd0..00000000 --- a/tests/matrix/dbal/nextras-1.1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:1.1.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-2.0.sh b/tests/matrix/dbal/nextras-2.0.sh deleted file mode 100755 index 01832c19..00000000 --- a/tests/matrix/dbal/nextras-2.0.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:2.0.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-2.1.sh b/tests/matrix/dbal/nextras-2.1.sh deleted file mode 100755 index db53f0a9..00000000 --- a/tests/matrix/dbal/nextras-2.1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70399" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:2.1.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-3.0.sh b/tests/matrix/dbal/nextras-3.0.sh deleted file mode 100755 index 24bd79d4..00000000 --- a/tests/matrix/dbal/nextras-3.0.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:3.0.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-3.1.sh b/tests/matrix/dbal/nextras-3.1.sh deleted file mode 100755 index 4c8576a5..00000000 --- a/tests/matrix/dbal/nextras-3.1.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -PHP_VERSION_MIN="70100" -PHP_VERSION_MAX="70499" -COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:3.1.*" -DBAL="nextras" diff --git a/tests/matrix/dbal/nextras-4.0.sh b/tests/matrix/dbal/nextras-4.0.sh index 2789a0a5..f33be0df 100755 --- a/tests/matrix/dbal/nextras-4.0.sh +++ b/tests/matrix/dbal/nextras-4.0.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nextras/dbal:4.0.*" DBAL="nextras" diff --git a/tests/matrix/nette-di/nette-2.4.sh b/tests/matrix/nette-di/nette-2.4.sh index f061c5fc..474da1d8 100644 --- a/tests/matrix/nette-di/nette-2.4.sh +++ b/tests/matrix/nette-di/nette-2.4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80099" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/di:2.4.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:*" diff --git a/tests/matrix/nette-di/nette-3.0.sh b/tests/matrix/nette-di/nette-3.0.sh index ea8719ea..d8c369eb 100644 --- a/tests/matrix/nette-di/nette-3.0.sh +++ b/tests/matrix/nette-di/nette-3.0.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80299" COMPOSER_REQUIRE="$COMPOSER_REQUIRE nette/di:3.0.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE dibi/dibi:*" diff --git a/tests/matrix/symfony-bundle/symfony-4.4.sh b/tests/matrix/symfony-bundle/symfony-4.4.sh index 165be0ba..982addd4 100755 --- a/tests/matrix/symfony-bundle/symfony-4.4.sh +++ b/tests/matrix/symfony-bundle/symfony-4.4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70100" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:4.4.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:4.4.*" diff --git a/tests/matrix/symfony-bundle/symfony-5.0.sh b/tests/matrix/symfony-bundle/symfony-5.0.sh index 12a0e821..040a4d5a 100755 --- a/tests/matrix/symfony-bundle/symfony-5.0.sh +++ b/tests/matrix/symfony-bundle/symfony-5.0.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:5.0.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:5.0.*" diff --git a/tests/matrix/symfony-bundle/symfony-5.1.sh b/tests/matrix/symfony-bundle/symfony-5.1.sh index 08b1b09c..0e502d6b 100755 --- a/tests/matrix/symfony-bundle/symfony-5.1.sh +++ b/tests/matrix/symfony-bundle/symfony-5.1.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:5.1.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:5.1.*" diff --git a/tests/matrix/symfony-bundle/symfony-5.2.sh b/tests/matrix/symfony-bundle/symfony-5.2.sh index 0e079421..65cb231a 100755 --- a/tests/matrix/symfony-bundle/symfony-5.2.sh +++ b/tests/matrix/symfony-bundle/symfony-5.2.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:5.2.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:5.2.*" diff --git a/tests/matrix/symfony-bundle/symfony-5.3.sh b/tests/matrix/symfony-bundle/symfony-5.3.sh index 1eac548f..c5561a81 100755 --- a/tests/matrix/symfony-bundle/symfony-5.3.sh +++ b/tests/matrix/symfony-bundle/symfony-5.3.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80399" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:5.3.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:5.3.*" diff --git a/tests/matrix/symfony-bundle/symfony-5.4.sh b/tests/matrix/symfony-bundle/symfony-5.4.sh index 9683b99b..2e89b986 100755 --- a/tests/matrix/symfony-bundle/symfony-5.4.sh +++ b/tests/matrix/symfony-bundle/symfony-5.4.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -PHP_VERSION_MIN="70200" +PHP_VERSION_MIN="80000" PHP_VERSION_MAX="80599" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/framework-bundle:5.4.*" COMPOSER_REQUIRE="$COMPOSER_REQUIRE symfony/yaml:5.4.*" From f8f8ecf65707fb2d21f8d7dd294e3fc1161475ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tvrd=C3=ADk?= Date: Wed, 25 Feb 2026 21:21:13 +0100 Subject: [PATCH 2/2] Modernize codebase to PHP 8.0 language features - Constructor property promotion across all classes - Typed properties (PHP 7.4) replacing @var phpdoc - Arrow functions replacing single-expression closures - Native union types replacing @param/@return phpdoc - match expressions replacing simple switch/if-elseif chains - Null-safe operator (?->) where applicable - str_starts_with()/str_ends_with() replacing manual checks - mixed type for untyped parameters --- src/Bridges/Dibi/DibiAdapter.php | 9 +- src/Bridges/DoctrineDbal/DoctrineAdapter.php | 9 +- .../DoctrineOrm/StructureDiffGenerator.php | 22 +-- src/Bridges/NetteDI/MigrationsExtension.php | 78 +++------- src/Bridges/NetteDatabase/NetteAdapter.php | 11 +- src/Bridges/NextrasDbal/NextrasAdapter.php | 47 +++--- src/Bridges/PsrLog/PsrLogPrinter.php | 9 +- .../NextrasMigrationsExtension.php | 6 +- src/Bridges/SymfonyConsole/BaseCommand.php | 17 +-- src/Bridges/SymfonyConsole/CreateCommand.php | 9 +- src/Configurations/Configuration.php | 14 +- src/Configurations/DefaultConfiguration.php | 37 ++--- src/Drivers/BaseDriver.php | 16 +- src/Drivers/PgSqlDriver.php | 9 +- src/Engine/Finder.php | 6 +- src/Engine/Runner.php | 23 +-- src/Entities/File.php | 13 +- src/Entities/Group.php | 13 +- src/Entities/Migration.php | 18 +-- src/Extensions/PhpHandler.php | 14 +- src/Extensions/SqlHandler.php | 9 +- src/Printers/Console.php | 3 +- src/Printers/HtmlDump.php | 6 +- .../integration/dbal/Runner.SecondRun.phpt | 4 +- .../symfony-bundle/SymfonyBundleTest.phpt | 3 +- tests/cases/unit/Finder.logicalName.phpt | 5 +- tests/cases/unit/OrderResolverTest.phpt | 143 +++++++----------- tests/fixtures/mysql/cleanup.php | 4 +- tests/inc/IntegrationTestCase.php | 111 ++++++-------- tests/inc/TestPrinter.php | 5 +- tests/inc/TestSymfonyKernel.php | 15 +- 31 files changed, 240 insertions(+), 448 deletions(-) diff --git a/src/Bridges/Dibi/DibiAdapter.php b/src/Bridges/Dibi/DibiAdapter.php index f45716b6..938f2ac5 100644 --- a/src/Bridges/Dibi/DibiAdapter.php +++ b/src/Bridges/Dibi/DibiAdapter.php @@ -16,13 +16,10 @@ class DibiAdapter implements IDbal { - /** @var Dibi\Connection */ - private $conn; - - - public function __construct(Dibi\Connection $conn) + public function __construct( + private Dibi\Connection $conn, + ) { - $this->conn = $conn; } diff --git a/src/Bridges/DoctrineDbal/DoctrineAdapter.php b/src/Bridges/DoctrineDbal/DoctrineAdapter.php index 42aceeb5..ed980601 100644 --- a/src/Bridges/DoctrineDbal/DoctrineAdapter.php +++ b/src/Bridges/DoctrineDbal/DoctrineAdapter.php @@ -16,13 +16,10 @@ class DoctrineAdapter implements IDbal { - /** @var Doctrine\DBAL\Connection */ - private $conn; - - - public function __construct(Doctrine\DBAL\Connection $conn) + public function __construct( + private Doctrine\DBAL\Connection $conn, + ) { - $this->conn = $conn; } diff --git a/src/Bridges/DoctrineOrm/StructureDiffGenerator.php b/src/Bridges/DoctrineOrm/StructureDiffGenerator.php index 12b6e970..11d342c9 100644 --- a/src/Bridges/DoctrineOrm/StructureDiffGenerator.php +++ b/src/Bridges/DoctrineOrm/StructureDiffGenerator.php @@ -18,17 +18,14 @@ class StructureDiffGenerator implements IDiffGenerator { - /** @var EntityManagerInterface */ - private $entityManager; - - /** @var string|null absolute path to a file */ - private $ignoredQueriesFile; - - - public function __construct(EntityManagerInterface $entityManager, ?string $ignoredQueriesFile = null) + /** + * @param string|null $ignoredQueriesFile absolute path to a file + */ + public function __construct( + private EntityManagerInterface $entityManager, + private ?string $ignoredQueriesFile = null, + ) { - $this->entityManager = $entityManager; - $this->ignoredQueriesFile = $ignoredQueriesFile; } @@ -52,10 +49,7 @@ public function generateContent(): string */ protected function getUpdateQueries(): array { - $cache = $this->entityManager->getConfiguration()->getMetadataCache(); - if ($cache !== null) { - $cache->clear(); - } + $this->entityManager->getConfiguration()->getMetadataCache()?->clear(); $schemaTool = new SchemaTool($this->entityManager); $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata(); diff --git a/src/Bridges/NetteDI/MigrationsExtension.php b/src/Bridges/NetteDI/MigrationsExtension.php index 1bc3c818..299795c0 100644 --- a/src/Bridges/NetteDI/MigrationsExtension.php +++ b/src/Bridges/NetteDI/MigrationsExtension.php @@ -15,7 +15,6 @@ use Nette\DI\ContainerBuilder; use Nette\DI\ServiceDefinition; use Nette\DI\Statement; -use Nette\Utils\Strings; use Nette\Utils\Validators; use Nextras; use Symfony; @@ -30,7 +29,7 @@ class MigrationsExtension extends Nette\DI\CompilerExtension const TAG_EXTENSION_HANDLER = 'nextras.migrations.extensionHandler'; /** @var array */ - public $defaults = [ + public array $defaults = [ 'dir' => null, 'phpParams' => [], 'driver' => null, @@ -43,7 +42,7 @@ class MigrationsExtension extends Nette\DI\CompilerExtension ]; /** @var array */ - protected $dbals = [ + protected array $dbals = [ 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, @@ -51,13 +50,13 @@ class MigrationsExtension extends Nette\DI\CompilerExtension ]; /** @var array */ - protected $drivers = [ + protected array $drivers = [ 'mysql' => Nextras\Migrations\Drivers\MySqlDriver::class, 'pgsql' => Nextras\Migrations\Drivers\PgSqlDriver::class, ]; /** @var array */ - protected $printers = [ + protected array $printers = [ 'console' => Nextras\Migrations\Printers\Console::class, 'psrLog' => Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter::class, ]; @@ -160,11 +159,7 @@ public function beforeCompile(): void } - /** - * @param null|string|Statement $dbal - * @return string|ServiceDefinition - */ - private function getDbalDefinition($dbal) + private function getDbalDefinition(null|string|Statement $dbal): string|ServiceDefinition { $factory = $this->getDbalFactory($dbal); @@ -183,11 +178,7 @@ private function getDbalDefinition($dbal) } - /** - * @param null|string|Statement $dbal - * @return string|Statement|null - */ - private function getDbalFactory($dbal) + private function getDbalFactory(null|string|Statement $dbal): string|Statement|null { if ($dbal instanceof Statement) { return $this->filterArguments([$dbal])[0]; @@ -195,7 +186,7 @@ private function getDbalFactory($dbal) } elseif (is_string($dbal) && isset($this->dbals[$dbal])) { return $this->dbals[$dbal]; - } elseif (is_string($dbal) && Strings::startsWith($dbal, '@')) { + } elseif (is_string($dbal) && str_starts_with($dbal, '@')) { return $dbal; } else { @@ -204,12 +195,7 @@ private function getDbalFactory($dbal) } - /** - * @param null|string|Statement $driver - * @param string|ServiceDefinition $dbal - * @return string|ServiceDefinition - */ - private function getDriverDefinition($driver, $dbal) + private function getDriverDefinition(null|string|Statement $driver, string|ServiceDefinition $dbal): string|ServiceDefinition { $factory = $this->getDriverFactory($driver, $dbal); @@ -228,12 +214,7 @@ private function getDriverDefinition($driver, $dbal) } - /** - * @param null|string|Statement $driver - * @param string|ServiceDefinition $dbal - * @return string|Statement|null - */ - private function getDriverFactory($driver, $dbal) + private function getDriverFactory(null|string|Statement $driver, string|ServiceDefinition $dbal): string|Statement|null { if ($driver instanceof Statement) { return $this->filterArguments([$driver])[0]; @@ -247,11 +228,7 @@ private function getDriverFactory($driver, $dbal) } - /** - * @param null|string|Statement $printer - * @return string|ServiceDefinition - */ - private function getPrinterDefinition($printer) + private function getPrinterDefinition(null|string|Statement $printer): string|ServiceDefinition { $factory = $this->getPrinterFactory($printer); @@ -270,11 +247,7 @@ private function getPrinterDefinition($printer) } - /** - * @param null|string|Statement $printer - * @return string|Statement|null - */ - private function getPrinterFactory($printer) + private function getPrinterFactory(null|string|Statement $printer): string|Statement|null { if ($printer instanceof Statement) { return $this->filterArguments([$printer])[0]; @@ -282,7 +255,7 @@ private function getPrinterFactory($printer) } elseif (is_string($printer) && isset($this->printers[$printer])) { return $this->printers[$printer]; - } elseif (is_string($printer) && Strings::startsWith($printer, '@')) { + } elseif (is_string($printer) && str_starts_with($printer, '@')) { return $printer; } else { @@ -292,20 +265,15 @@ private function getPrinterFactory($printer) /** - * @param string|Nette\PhpGenerator\PhpLiteral $dir * @return array, generator?: ServiceDefinition|null}> */ - private function createDefaultGroupConfiguration($dir, bool $withDummyData): array + private function createDefaultGroupConfiguration(string|Nette\PhpGenerator\PhpLiteral $dir, bool $withDummyData): array { if ($dir instanceof Nette\PhpGenerator\PhpLiteral) { - $append = function (string $path) use ($dir): Nette\PhpGenerator\PhpLiteral { - return ContainerBuilder::literal('? . ?', [$dir, $path]); - }; + $append = fn(string $path): Nette\PhpGenerator\PhpLiteral => ContainerBuilder::literal('? . ?', [$dir, $path]); } else { - $append = function (string $path) use ($dir): string { - return $dir . $path; - }; + $append = fn(string $path): string => $dir . $path; } $builder = $this->getContainerBuilder(); @@ -347,10 +315,10 @@ private function createGroupDefinitions(array $groups): array foreach ($groups as $groupName => $groupConfig) { Validators::assertField($groupConfig, 'directory', 'string|Nette\PhpGenerator\PhpLiteral'); - $enabled = isset($groupConfig['enabled']) ? $groupConfig['enabled'] : true; + $enabled = $groupConfig['enabled'] ?? true; $directory = $groupConfig['directory']; - $dependencies = isset($groupConfig['dependencies']) ? $groupConfig['dependencies'] : []; - $generator = isset($groupConfig['generator']) ? $groupConfig['generator'] : null; + $dependencies = $groupConfig['dependencies'] ?? []; + $generator = $groupConfig['generator'] ?? null; $serviceName = lcfirst(str_replace('-', '', ucwords($groupName, '-'))); $groupDefinitions[] = $builder->addDefinition($this->prefix("group.$serviceName")) @@ -369,11 +337,10 @@ private function createGroupDefinitions(array $groups): array /** - * @param string|ServiceDefinition $driver * @param array $phpParams * @return list */ - private function createExtensionHandlerDefinitions($driver, array $phpParams): array + private function createExtensionHandlerDefinitions(string|ServiceDefinition $driver, array $phpParams): array { $builder = $this->getContainerBuilder(); @@ -414,12 +381,7 @@ private function createDoctrineStructureDiffGeneratorDefinition(?string $ignored } - /** - * @param string|ServiceDefinition $driver - * @param string|ServiceDefinition $configuration - * @param string|ServiceDefinition $printer - */ - private function createSymfonyCommandDefinitions($driver, $configuration, $printer): void + private function createSymfonyCommandDefinitions(string|ServiceDefinition $driver, string|ServiceDefinition $configuration, string|ServiceDefinition $printer): void { $builder = $this->getContainerBuilder(); $builder->addExcludedClasses([Nextras\Migrations\Bridges\SymfonyConsole\BaseCommand::class]); diff --git a/src/Bridges/NetteDatabase/NetteAdapter.php b/src/Bridges/NetteDatabase/NetteAdapter.php index 53275284..934dab9b 100644 --- a/src/Bridges/NetteDatabase/NetteAdapter.php +++ b/src/Bridges/NetteDatabase/NetteAdapter.php @@ -17,20 +17,17 @@ class NetteAdapter implements IDbal { - /** @var Nette\Database\Connection */ - private $conn; - - - public function __construct(Nette\Database\Connection $ndb) + public function __construct( + private Nette\Database\Connection $conn, + ) { - $this->conn = $ndb; } public function query(string $sql): array { return array_map( - function ($row) { return (array) $row; }, + fn($row) => (array) $row, $this->conn->fetchAll($sql) ); } diff --git a/src/Bridges/NextrasDbal/NextrasAdapter.php b/src/Bridges/NextrasDbal/NextrasAdapter.php index 1b7980bc..e66ffee6 100644 --- a/src/Bridges/NextrasDbal/NextrasAdapter.php +++ b/src/Bridges/NextrasDbal/NextrasAdapter.php @@ -17,31 +17,23 @@ class NextrasAdapter implements IDbal { - /** @var Connection */ - private $conn; + private int $version; - /** @var int */ - private $version; - - public function __construct(Connection $connection) + public function __construct( + private Connection $conn, + ) { - $this->conn = $connection; $this->conn->connect(); - if (method_exists($connection->getDriver(), 'convertBoolToSql')) { - $this->version = 2; - - } else { - $this->version = 5; - } + $this->version = method_exists($conn->getDriver(), 'convertBoolToSql') ? 2 : 5; } public function query(string $sql): array { return array_map( - function (Row $row) { return $row->toArray(); }, + fn(Row $row) => $row->toArray(), iterator_to_array($this->conn->query('%raw', $sql)) ); } @@ -68,30 +60,27 @@ public function escapeInt(int $value): string public function escapeBool(bool $value): string { - if ($this->version >= 5) { - return $this->conn->getPlatform()->formatBool($value); - } else { - return $this->conn->getDriver()->convertBoolToSql($value); - } + return match (true) { + $this->version >= 5 => $this->conn->getPlatform()->formatBool($value), + default => $this->conn->getDriver()->convertBoolToSql($value), + }; } public function escapeDateTime(DateTimeInterface $value): string { - if ($this->version >= 5) { - return $this->conn->getPlatform()->formatDateTime($value); - } else { - return $this->conn->getDriver()->convertDateTimeToSql($value); - } + return match (true) { + $this->version >= 5 => $this->conn->getPlatform()->formatDateTime($value), + default => $this->conn->getDriver()->convertDateTimeToSql($value), + }; } public function escapeIdentifier(string $value): string { - if ($this->version >= 5) { - return $this->conn->getPlatform()->formatIdentifier($value); - } else { - return $this->conn->getDriver()->convertIdentifierToSql($value); - } + return match (true) { + $this->version >= 5 => $this->conn->getPlatform()->formatIdentifier($value), + default => $this->conn->getDriver()->convertIdentifierToSql($value), + }; } } diff --git a/src/Bridges/PsrLog/PsrLogPrinter.php b/src/Bridges/PsrLog/PsrLogPrinter.php index fc1539df..abe3246b 100644 --- a/src/Bridges/PsrLog/PsrLogPrinter.php +++ b/src/Bridges/PsrLog/PsrLogPrinter.php @@ -17,13 +17,10 @@ class PsrLogPrinter implements IPrinter { - /** @var LoggerInterface */ - private $logger; - - - public function __construct(LoggerInterface $logger) + public function __construct( + private LoggerInterface $logger, + ) { - $this->logger = $logger; } diff --git a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php index dcf42579..0b6ff8c7 100644 --- a/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php +++ b/src/Bridges/SymfonyBundle/DependencyInjection/NextrasMigrationsExtension.php @@ -18,7 +18,7 @@ class NextrasMigrationsExtension extends Extension { /** @var array */ - protected $dbals = [ + protected array $dbals = [ 'dibi' => Nextras\Migrations\Bridges\Dibi\DibiAdapter::class, 'doctrine' => Nextras\Migrations\Bridges\DoctrineDbal\DoctrineAdapter::class, 'nette' => Nextras\Migrations\Bridges\NetteDatabase\NetteAdapter::class, @@ -26,13 +26,13 @@ class NextrasMigrationsExtension extends Extension ]; /** @var array */ - protected $drivers = [ + protected array $drivers = [ 'mysql' => Nextras\Migrations\Drivers\MySqlDriver::class, 'pgsql' => Nextras\Migrations\Drivers\PgSqlDriver::class, ]; /** @var array */ - protected $printers = [ + protected array $printers = [ 'console' => Nextras\Migrations\Printers\Console::class, 'psrLog' => Nextras\Migrations\Bridges\PsrLog\PsrLogPrinter::class, ]; diff --git a/src/Bridges/SymfonyConsole/BaseCommand.php b/src/Bridges/SymfonyConsole/BaseCommand.php index 13a3f161..99cb6966 100644 --- a/src/Bridges/SymfonyConsole/BaseCommand.php +++ b/src/Bridges/SymfonyConsole/BaseCommand.php @@ -19,20 +19,15 @@ abstract class BaseCommand extends Command { - /** @var IDriver */ - protected $driver; + protected IPrinter $printer; - /** @var IConfiguration */ - protected $config; - /** @var IPrinter */ - protected $printer; - - - public function __construct(IDriver $driver, IConfiguration $config, ?IPrinter $printer = null) + public function __construct( + protected IDriver $driver, + protected IConfiguration $config, + ?IPrinter $printer = null, + ) { - $this->driver = $driver; - $this->config = $config; $this->printer = $printer ?? new Console(); parent::__construct(); } diff --git a/src/Bridges/SymfonyConsole/CreateCommand.php b/src/Bridges/SymfonyConsole/CreateCommand.php index f5dacd8e..36bd1ca8 100644 --- a/src/Bridges/SymfonyConsole/CreateCommand.php +++ b/src/Bridges/SymfonyConsole/CreateCommand.php @@ -29,8 +29,7 @@ class CreateCommand extends BaseCommand const CONTENT_SOURCE_STDIN = 'stdin'; const CONTENT_SOURCE_EMPTY = 'empty'; - /** @var string */ - protected $defaultContentSource = self::CONTENT_SOURCE_DIFF; + protected string $defaultContentSource = self::CONTENT_SOURCE_DIFF; public static function getDefaultName(): string @@ -80,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int protected function getPath(Group $group, string $label): string { $dir = $group->directory; - $extension = $group->generator ? $group->generator->getExtension() : 'sql'; + $extension = $group->generator?->getExtension() ?? 'sql'; $name = $this->getFileName($label, $extension); if ($this->hasNumericSubdirectory($dir, $foundYear)) { @@ -172,9 +171,7 @@ protected function getTypeArgDescription(): string { $options = []; $groups = $this->config->getGroups(); - usort($groups, function (Group $a, Group $b) { - return strcmp($a->name, $b->name); - }); + usort($groups, fn(Group $a, Group $b) => strcmp($a->name, $b->name)); foreach ($groups as $i => $group) { for ($j = 1; $j < strlen($group->name); $j++) { diff --git a/src/Configurations/Configuration.php b/src/Configurations/Configuration.php index 567d2f7b..1dcd2299 100644 --- a/src/Configurations/Configuration.php +++ b/src/Configurations/Configuration.php @@ -19,21 +19,15 @@ */ class Configuration implements IConfiguration { - /** @var list */ - private $groups; - - /** @var array (extension => IExtensionHandler) */ - private $extensionHandlers; - - /** * @param list $groups * @param array $extensionHandlers (extension => IExtensionHandler) */ - public function __construct(array $groups, array $extensionHandlers) + public function __construct( + private array $groups, + private array $extensionHandlers, + ) { - $this->groups = $groups; - $this->extensionHandlers = $extensionHandlers; } diff --git a/src/Configurations/DefaultConfiguration.php b/src/Configurations/DefaultConfiguration.php index fc71bbb3..b89ac457 100644 --- a/src/Configurations/DefaultConfiguration.php +++ b/src/Configurations/DefaultConfiguration.php @@ -24,46 +24,33 @@ */ class DefaultConfiguration implements IConfiguration { - /** @var string */ - protected $dir; - - /** @var IDriver */ - protected $driver; - - /** @var bool */ - protected $withDummyData; - - /** @var array */ - protected $phpParams; - /** @var list */ - protected $groups; + protected array $groups; /** @var array */ - protected $handlers; + protected array $handlers; - /** @var ?IDiffGenerator */ - protected $structureDiffGenerator; + protected ?IDiffGenerator $structureDiffGenerator = null; - /** @var ?IDiffGenerator */ - protected $dummyDataDiffGenerator; + protected ?IDiffGenerator $dummyDataDiffGenerator = null; /** * @param array $phpParams */ - public function __construct(string $dir, IDriver $driver, bool $withDummyData = true, array $phpParams = []) + public function __construct( + protected string $dir, + protected IDriver $driver, + protected bool $withDummyData = true, + protected array $phpParams = [], + ) { - $this->dir = $dir; - $this->driver = $driver; - $this->withDummyData = $withDummyData; - $this->phpParams = $phpParams; } public function getGroups(): array { - if ($this->groups === null) { + if (!isset($this->groups)) { $structures = new Group(); $structures->enabled = true; $structures->name = 'structures'; @@ -93,7 +80,7 @@ public function getGroups(): array public function getExtensionHandlers(): array { - if ($this->handlers === null) { + if (!isset($this->handlers)) { $this->handlers = [ 'sql' => new SqlHandler($this->driver), 'php' => new PhpHandler($this->phpParams), diff --git a/src/Drivers/BaseDriver.php b/src/Drivers/BaseDriver.php index 6c942d74..db0a7709 100644 --- a/src/Drivers/BaseDriver.php +++ b/src/Drivers/BaseDriver.php @@ -21,20 +21,14 @@ */ abstract class BaseDriver implements IDriver { - /** @var IDbal */ - protected $dbal; + protected ?string $tableNameQuoted = null; - /** @var string */ - protected $tableName; - /** @var null|string */ - protected $tableNameQuoted; - - - public function __construct(IDbal $dbal, string $tableName = 'migrations') + public function __construct( + protected IDbal $dbal, + protected string $tableName = 'migrations', + ) { - $this->dbal = $dbal; - $this->tableName = $tableName; } diff --git a/src/Drivers/PgSqlDriver.php b/src/Drivers/PgSqlDriver.php index acb49054..40931566 100644 --- a/src/Drivers/PgSqlDriver.php +++ b/src/Drivers/PgSqlDriver.php @@ -23,17 +23,12 @@ */ class PgSqlDriver extends BaseDriver implements IDriver { - /** @var string */ - protected $schema; + protected ?string $schemaQuoted = null; - /** @var null|string */ - protected $schemaQuoted; - - public function __construct(IDbal $dbal, string $tableName = 'migrations', string $schema = 'public') + public function __construct(IDbal $dbal, string $tableName = 'migrations', protected string $schema = 'public') { parent::__construct($dbal, $tableName); - $this->schema = $schema; } diff --git a/src/Engine/Finder.php b/src/Engine/Finder.php index 06878642..c31db681 100644 --- a/src/Engine/Finder.php +++ b/src/Engine/Finder.php @@ -59,7 +59,7 @@ protected function getName(string $path): string $parts = explode('/', $path); $dirName = implode('-', array_slice($parts, 0, -1)); $fileName = implode('-', array_slice($parts, -1)); - $isPrefix = strncmp($fileName, $dirName, strlen($dirName)) === 0; + $isPrefix = str_starts_with($fileName, $dirName); return ($isPrefix ? $fileName : "$dirName-$fileName"); } @@ -75,7 +75,7 @@ protected function getExtension(File $file, array $extensions): string $fileExt = null; foreach ($extensions as $extension) { - if (substr($file->name, -strlen($extension)) === $extension) { + if (str_ends_with($file->name, $extension)) { if ($fileExt !== null) { throw new LogicException(sprintf( 'Finder: Extension of "%s" is ambiguous, both "%s" and "%s" can be used.', @@ -119,7 +119,7 @@ protected function getFilesRecursive(string $dir): array $items = $this->getItems($dir); foreach ($items as $i => $item) { // skip '.', '..' and hidden files - if ($item[0] === '.') { + if (str_starts_with($item, '.')) { unset($items[$i]); // year or month diff --git a/src/Engine/Runner.php b/src/Engine/Runner.php index 5e49e314..81c6961d 100644 --- a/src/Engine/Runner.php +++ b/src/Engine/Runner.php @@ -30,29 +30,22 @@ class Runner const MODE_RESET = 'reset'; const MODE_INIT = 'init'; - /** @var IPrinter */ - private $printer; - /** @var array (extension => IExtensionHandler) */ - private $extensionsHandlers = []; + private array $extensionsHandlers = []; /** @var list */ - private $groups = []; - - /** @var IDriver */ - private $driver; + private array $groups = []; - /** @var Finder */ - private $finder; + private Finder $finder; - /** @var OrderResolver */ - private $orderResolver; + private OrderResolver $orderResolver; - public function __construct(IDriver $driver, IPrinter $printer) + public function __construct( + private IDriver $driver, + private IPrinter $printer, + ) { - $this->driver = $driver; - $this->printer = $printer; $this->finder = new Finder; $this->orderResolver = new OrderResolver; } diff --git a/src/Entities/File.php b/src/Entities/File.php index a9bf3e50..cca6dd1f 100644 --- a/src/Entities/File.php +++ b/src/Entities/File.php @@ -16,18 +16,15 @@ */ class File { - /** @var Group */ - public $group; + public Group $group; - /** @var string */ - public $extension; + public string $extension; /** @var string logical name, may or may not correspond to filename */ - public $name; + public string $name; /** @var string absolute path */ - public $path; + public string $path; - /** @var string */ - public $checksum; + public string $checksum; } diff --git a/src/Entities/Group.php b/src/Entities/Group.php index 146db30a..6b76cae0 100644 --- a/src/Entities/Group.php +++ b/src/Entities/Group.php @@ -17,18 +17,15 @@ */ class Group { - /** @var string */ - public $name; + public string $name; - /** @var bool */ - public $enabled; + public bool $enabled; /** @var string absolute path do directory */ - public $directory; + public string $directory; /** @var list */ - public $dependencies; + public array $dependencies; - /** @var IDiffGenerator|null */ - public $generator; + public ?IDiffGenerator $generator = null; } diff --git a/src/Entities/Migration.php b/src/Entities/Migration.php index d49335db..99871e6d 100644 --- a/src/Entities/Migration.php +++ b/src/Entities/Migration.php @@ -18,21 +18,15 @@ */ class Migration { - /** @var int */ - public $id; + public int $id; - /** @var string */ - public $group; + public string $group; - /** @var string */ - public $filename; + public string $filename; - /** @var string */ - public $checksum; + public string $checksum; - /** @var DateTime */ - public $executedAt; + public DateTime $executedAt; - /** @var bool */ - public $completed; + public bool $completed; } diff --git a/src/Extensions/PhpHandler.php b/src/Extensions/PhpHandler.php index 08ab3a7d..92809d18 100644 --- a/src/Extensions/PhpHandler.php +++ b/src/Extensions/PhpHandler.php @@ -20,23 +20,17 @@ */ class PhpHandler implements IExtensionHandler { - /** @var array name => value */ - private $params; - - /** * @param array $params (name => value) */ - public function __construct(array $params = []) + public function __construct( + private array $params = [], + ) { - $this->params = $params; } - /** - * @param mixed $value - */ - public function addParameter(string $name, $value): self + public function addParameter(string $name, mixed $value): self { $this->params[$name] = $value; return $this; diff --git a/src/Extensions/SqlHandler.php b/src/Extensions/SqlHandler.php index 7eb61ab6..6bf8d12f 100644 --- a/src/Extensions/SqlHandler.php +++ b/src/Extensions/SqlHandler.php @@ -20,13 +20,10 @@ */ class SqlHandler implements IExtensionHandler { - /** @var IDriver */ - private $driver; - - - public function __construct(IDriver $driver) + public function __construct( + private IDriver $driver, + ) { - $this->driver = $driver; } diff --git a/src/Printers/Console.php b/src/Printers/Console.php index 45f9147c..e635e6f4 100644 --- a/src/Printers/Console.php +++ b/src/Printers/Console.php @@ -26,8 +26,7 @@ class Console implements IPrinter const COLOR_INTRO = '1;35'; const COLOR_INFO = '1;36'; - /** @var bool */ - protected $useColors; + protected bool $useColors; public function __construct() diff --git a/src/Printers/HtmlDump.php b/src/Printers/HtmlDump.php index 5d35d7ea..ae8724b0 100644 --- a/src/Printers/HtmlDump.php +++ b/src/Printers/HtmlDump.php @@ -20,11 +20,9 @@ */ class HtmlDump implements IPrinter { - /** @var int number of migrations to be executed */ - private $count; + private int $count; - /** @var int order of last executed migration */ - private $index; + private int $index; public function printIntro(string $mode): void diff --git a/tests/cases/integration/dbal/Runner.SecondRun.phpt b/tests/cases/integration/dbal/Runner.SecondRun.phpt index c0c59473..c63667d3 100644 --- a/tests/cases/integration/dbal/Runner.SecondRun.phpt +++ b/tests/cases/integration/dbal/Runner.SecondRun.phpt @@ -63,9 +63,7 @@ class SecondRunTest extends IntegrationTestCase $this->driver->loadFile($this->fixtureDir . '/2ok, 1ko.sql'); Assert::count(3, $this->driver->getAllMigrations()); - Assert::throws(function () { - $this->runner->run(Runner::MODE_CONTINUE); - }, Nextras\Migrations\LogicException::class); + Assert::throws(fn() => $this->runner->run(Runner::MODE_CONTINUE), Nextras\Migrations\LogicException::class); Assert::same([ 'Nextras Migrations', diff --git a/tests/cases/integration/symfony-bundle/SymfonyBundleTest.phpt b/tests/cases/integration/symfony-bundle/SymfonyBundleTest.phpt index 6bb71e0a..5050631b 100644 --- a/tests/cases/integration/symfony-bundle/SymfonyBundleTest.phpt +++ b/tests/cases/integration/symfony-bundle/SymfonyBundleTest.phpt @@ -20,8 +20,7 @@ require __DIR__ . '/../../../bootstrap.php'; class SymfonyBundleTest extends TestCase { - /** @var KernelInterface */ - private $symfonyKernel; + private KernelInterface $symfonyKernel; protected function setUp(): void diff --git a/tests/cases/unit/Finder.logicalName.phpt b/tests/cases/unit/Finder.logicalName.phpt index 7b125c60..84a05d51 100644 --- a/tests/cases/unit/Finder.logicalName.phpt +++ b/tests/cases/unit/Finder.logicalName.phpt @@ -19,11 +19,10 @@ require __DIR__ . '/../../bootstrap.php'; class FinderLogicalNameTest extends Tester\TestCase { - /** @var Finder|Mockery\MockInterface */ - private $finder; + private Finder|Mockery\MockInterface $finder; /** @var list */ - private $groups; + private array $groups; protected function setUp(): void diff --git a/tests/cases/unit/OrderResolverTest.phpt b/tests/cases/unit/OrderResolverTest.phpt index d1c2860d..9433a48d 100644 --- a/tests/cases/unit/OrderResolverTest.phpt +++ b/tests/cases/unit/OrderResolverTest.phpt @@ -258,14 +258,11 @@ class OrderResolverTest extends Tester\TestCase $fileB = $this->createFile('2s', $groupA); // 1s 2s* - Assert::exception(function () use ($resolver, $groupA, $migrationA, $fileB) { - $resolver->resolve( - [$migrationA], - [$groupA], - [$fileB], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" is missing.'); + Assert::exception( + fn() => $resolver->resolve([$migrationA], [$groupA], [$fileB], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Previously executed migration "structures/1s" is missing.', + ); } @@ -279,14 +276,11 @@ class OrderResolverTest extends Tester\TestCase $fileB = $this->createFile('2s', $groupA); // 1s 2s* - Assert::exception(function () use ($resolver, $groupA, $migrationA, $fileA, $fileB) { - $resolver->resolve( - [$migrationA], - [$groupA], - [$fileB, $fileA], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" has been changed. File checksum is "1s.md5.Y", but executed migration had checksum "1s.md5.X".'); + Assert::exception( + fn() => $resolver->resolve([$migrationA], [$groupA], [$fileB, $fileA], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Previously executed migration "structures/1s" has been changed. File checksum is "1s.md5.Y", but executed migration had checksum "1s.md5.X".', + ); } @@ -300,14 +294,11 @@ class OrderResolverTest extends Tester\TestCase $fileB = $this->createFile('2s', $groupA); // 1s 2s* - Assert::exception(function () use ($resolver, $groupA, $migrationA, $fileA, $fileB) { - $resolver->resolve( - [$migrationA], - [$groupA], - [$fileB, $fileA], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Previously executed migration "structures/1s" did not succeed. Please fix this manually or reset the migrations.'); + Assert::exception( + fn() => $resolver->resolve([$migrationA], [$groupA], [$fileB, $fileA], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Previously executed migration "structures/1s" did not succeed. Please fix this manually or reset the migrations.', + ); } @@ -323,14 +314,11 @@ class OrderResolverTest extends Tester\TestCase $fileC = $this->createFile('3s', $groupA); // 1s 2s* 3s - Assert::exception(function () use ($resolver, $groupA, $migrationA, $migrationC, $fileA, $fileB, $fileC) { - $resolver->resolve( - [$migrationC, $migrationA], - [$groupA], - [$fileA, $fileB, $fileC], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'New migration "structures/2s" must follow after the latest executed migration "structures/3s".'); + Assert::exception( + fn() => $resolver->resolve([$migrationC, $migrationA], [$groupA], [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'New migration "structures/2s" must follow after the latest executed migration "structures/3s".', + ); } @@ -350,14 +338,11 @@ class OrderResolverTest extends Tester\TestCase $fileC = $this->createFile('3c', $groupC); // 1a 2b* 3c - Assert::exception(function () use ($resolver, $groupA, $groupB, $groupC, $migrationA, $migrationC, $fileA, $fileB, $fileC) { - $resolver->resolve( - [$migrationA, $migrationC], - [$groupA, $groupB, $groupC], - [$fileA, $fileB, $fileC], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'New migration "b/2b" must follow after the latest executed migration "c/3c".'); + Assert::exception( + fn() => $resolver->resolve([$migrationA, $migrationC], [$groupA, $groupB, $groupC], [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'New migration "b/2b" must follow after the latest executed migration "c/3c".', + ); } @@ -376,14 +361,11 @@ class OrderResolverTest extends Tester\TestCase $fileC = $this->createFile('3a', $groupA); // 1b 2b* 3a - Assert::exception(function () use ($resolver, $groupA, $groupB, $migrationA, $migrationC, $fileA, $fileB, $fileC) { - $resolver->resolve( - [$migrationA, $migrationC], - [$groupA, $groupB], - [$fileA, $fileB, $fileC], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'New migration "b/2b" must follow after the latest executed migration "a/3a".'); + Assert::exception( + fn() => $resolver->resolve([$migrationA, $migrationC], [$groupA, $groupB], [$fileA, $fileB, $fileC], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'New migration "b/2b" must follow after the latest executed migration "a/3a".', + ); } @@ -393,14 +375,11 @@ class OrderResolverTest extends Tester\TestCase $migrationA = $this->createMigration('foo', '1s'); - Assert::exception(function () use ($resolver, $migrationA) { - $resolver->resolve( - [$migrationA], - [], - [], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Existing migrations depend on unknown group "foo".'); + Assert::exception( + fn() => $resolver->resolve([$migrationA], [], [], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Existing migrations depend on unknown group "foo".', + ); } @@ -410,14 +389,11 @@ class OrderResolverTest extends Tester\TestCase $groupB = $this->createGroup('data', true, ['structures']); - Assert::exception(function () use ($resolver, $groupB) { - $resolver->resolve( - [], - [$groupB], - [], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Group "data" depends on unknown group "structures".'); + Assert::exception( + fn() => $resolver->resolve([], [$groupB], [], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Group "data" depends on unknown group "structures".', + ); } @@ -428,14 +404,11 @@ class OrderResolverTest extends Tester\TestCase $groupA = $this->createGroup('structures', false); $groupB = $this->createGroup('data', true, ['structures']); - Assert::exception(function () use ($resolver, $groupA, $groupB) { - $resolver->resolve( - [], - [$groupA, $groupB], - [], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Group "data" depends on disabled group "structures". Please enable group "structures" to continue.'); + Assert::exception( + fn() => $resolver->resolve([], [$groupA, $groupB], [], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Group "data" depends on disabled group "structures". Please enable group "structures" to continue.', + ); } @@ -449,14 +422,11 @@ class OrderResolverTest extends Tester\TestCase $fileA = $this->createFile('foo', $groupA); $fileB = $this->createFile('foo', $groupB); - Assert::exception(function () use ($resolver, $groupA, $groupB, $fileA, $fileB) { - $resolver->resolve( - [], - [$groupA, $groupB], - [$fileA, $fileB], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Unable to determine order for migrations "data/foo" and "structures/foo".'); + Assert::exception( + fn() => $resolver->resolve([], [$groupA, $groupB], [$fileA, $fileB], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Unable to determine order for migrations "data/foo" and "structures/foo".', + ); } @@ -470,14 +440,11 @@ class OrderResolverTest extends Tester\TestCase $fileA = $this->createFile('foo', $groupA); $fileB = $this->createFile('foo', $groupB); - Assert::exception(function () use ($resolver, $groupA, $groupB, $fileA, $fileB) { - $resolver->resolve( - [], - [$groupA, $groupB], - [$fileA, $fileB], - Runner::MODE_CONTINUE - ); - }, Nextras\Migrations\LogicException::class, 'Unable to determine order for migrations "data/foo" and "structures/foo".'); + Assert::exception( + fn() => $resolver->resolve([], [$groupA, $groupB], [$fileA, $fileB], Runner::MODE_CONTINUE), + Nextras\Migrations\LogicException::class, + 'Unable to determine order for migrations "data/foo" and "structures/foo".', + ); } diff --git a/tests/fixtures/mysql/cleanup.php b/tests/fixtures/mysql/cleanup.php index 39d951c4..6279f906 100644 --- a/tests/fixtures/mysql/cleanup.php +++ b/tests/fixtures/mysql/cleanup.php @@ -1,5 +1,3 @@ dbal->exec('DROP DATABASE IF EXISTS ' . $this->dbal->escapeIdentifier($this->dbName)); -}; +return fn() => $this->dbal->exec('DROP DATABASE IF EXISTS ' . $this->dbal->escapeIdentifier($this->dbName)); diff --git a/tests/inc/IntegrationTestCase.php b/tests/inc/IntegrationTestCase.php index f68e152b..e9e3c615 100644 --- a/tests/inc/IntegrationTestCase.php +++ b/tests/inc/IntegrationTestCase.php @@ -21,23 +21,17 @@ abstract class IntegrationTestCase extends TestCase { - /** @var IDbal */ - protected $dbal; + protected IDbal $dbal; - /** @var IDriver */ - protected $driver; + protected IDriver $driver; - /** @var IPrinter|TestPrinter */ - protected $printer; + protected IPrinter|TestPrinter $printer; - /** @var Runner */ - protected $runner; + protected Runner $runner; - /** @var string */ - protected $dbName; + protected string $dbName; - /** @var string */ - protected $fixtureDir; + protected string $fixtureDir; protected function setUp(): void @@ -124,73 +118,54 @@ protected function getExtensionHandlers(): array */ protected function createDbal(array $options): IDbal { - switch ($options['dbal']) { - case 'dibi': - $drivers = [ + return match ($options['dbal']) { + 'dibi' => new DibiAdapter(new Dibi\Connection([ + 'host' => $options['host'], + 'username' => $options['username'], + 'password' => $options['password'], + 'database' => $options['database'], + 'driver' => match ($options['driver']) { 'mysql' => 'mysqli', 'pgsql' => 'postgre', - ]; - - return new DibiAdapter(new Dibi\Connection([ - 'host' => $options['host'], - 'username' => $options['username'], - 'password' => $options['password'], - 'database' => $options['database'], - 'driver' => $drivers[$options['driver']], - ])); - - - case 'doctrine': - $drivers = [ + }, + ])), + 'doctrine' => new DoctrineAdapter(Doctrine\DBAL\DriverManager::getConnection([ + 'host' => $options['host'], + 'user' => $options['username'], + 'password' => $options['password'], + 'database' => $options['database'], + 'driver' => match ($options['driver']) { 'mysql' => 'mysqli', 'pgsql' => 'pdo_pgsql', - ]; - return new DoctrineAdapter(Doctrine\DBAL\DriverManager::getConnection([ - 'host' => $options['host'], - 'user' => $options['username'], - 'password' => $options['password'], - 'database' => $options['database'], - 'driver' => $drivers[$options['driver']], - ])); - - case 'nette': - return new NetteAdapter(new Nette\Database\Connection( - "$options[driver]:host=$options[host];dbname=$options[database]", - $options['username'], - $options['password'] - )); - - case 'nextras': - $drivers = [ + }, + ])), + 'nette' => new NetteAdapter(new Nette\Database\Connection( + "$options[driver]:host=$options[host];dbname=$options[database]", + $options['username'], + $options['password'] + )), + 'nextras' => new NextrasAdapter(new Nextras\Dbal\Connection([ + 'host' => $options['host'], + 'username' => $options['username'], + 'password' => $options['password'], + 'database' => $options['database'], + 'driver' => match ($options['driver']) { 'mysql' => 'mysqli', 'pgsql' => 'pgsql', - ]; - return new NextrasAdapter(new Nextras\Dbal\Connection([ - 'host' => $options['host'], - 'username' => $options['username'], - 'password' => $options['password'], - 'database' => $options['database'], - 'driver' => $drivers[$options['driver']], - ])); - - default: - throw new \Exception("Unknown DBAL '$options[dbal]'."); - } + }, + ])), + default => throw new \Exception("Unknown DBAL '$options[dbal]'."), + }; } protected function createDriver(string $name, IDbal $dbal): IDriver { - switch ($name) { - case 'mysql': - return new Nextras\Migrations\Drivers\MySqlDriver($dbal, 'm'); - - case 'pgsql': - return new Nextras\Migrations\Drivers\PgSqlDriver($dbal, 'm', $this->dbName); - - default: - throw new \Exception("Unknown driver '$name'."); - } + return match ($name) { + 'mysql' => new Nextras\Migrations\Drivers\MySqlDriver($dbal, 'm'), + 'pgsql' => new Nextras\Migrations\Drivers\PgSqlDriver($dbal, 'm', $this->dbName), + default => throw new \Exception("Unknown driver '$name'."), + }; } diff --git a/tests/inc/TestPrinter.php b/tests/inc/TestPrinter.php index bbb87035..ab46ed5a 100644 --- a/tests/inc/TestPrinter.php +++ b/tests/inc/TestPrinter.php @@ -8,10 +8,9 @@ class TestPrinter extends Console { /** @var list output lines */ - public $lines = []; + public array $lines = []; - /** @var string whole output */ - public $out = ''; + public string $out = ''; public function __construct() diff --git a/tests/inc/TestSymfonyKernel.php b/tests/inc/TestSymfonyKernel.php index 939e2946..7883035e 100644 --- a/tests/inc/TestSymfonyKernel.php +++ b/tests/inc/TestSymfonyKernel.php @@ -13,19 +13,12 @@ class TestSymfonyKernel extends Kernel { - /** @var string */ - private $configPath; - - /** @var array */ - private $parameters; - - - public function __construct(string $configPath, array $parameters) + public function __construct( + private string $configPath, + private array $parameters, + ) { parent::__construct('dev', true); - - $this->configPath = $configPath; - $this->parameters = $parameters; }