Skip to content

Commit 8d0a2cc

Browse files
authored
Merge pull request #3 from phpcr/symfony-7
allow symfony 7
2 parents cb74ac6 + eaa58aa commit 8d0a2cc

File tree

8 files changed

+41
-66
lines changed

8 files changed

+41
-66
lines changed

.github/workflows/ci.yaml

+4-18
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
php:
13-
name: "PHP ${{ matrix.php-version }}"
13+
name: "PHP ${{ matrix.php-version }} Symfony ${{ matrix.symfony-version }}"
1414
runs-on: ubuntu-latest
1515

1616
env:
@@ -20,29 +20,18 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
include:
23-
- php-version: '7.4'
24-
symfony-version: '^4.4'
25-
monolog-version: '^1.0'
26-
27-
- php-version: '7.4'
23+
- php-version: '8.1'
2824
symfony-version: '^5.4'
29-
monolog-version: '^2.0'
3025

31-
- php-version: '8.0'
26+
- php-version: '8.1'
3227
symfony-version: '6.0.*'
33-
monolog-version: '^2.0'
3428

3529
- php-version: '8.1'
3630
symfony-version: '^6.0'
37-
monolog-version: '^2.0'
3831

3932
- php-version: '8.2'
40-
symfony-version: '^6.0'
41-
monolog-version: '^2.0'
4233

4334
- php-version: '8.3'
44-
symfony-version: '^6.0'
45-
monolog-version: '^2.0'
4635

4736
steps:
4837
- name: Checkout project
@@ -53,19 +42,16 @@ jobs:
5342
with:
5443
php-version: ${{ matrix.php-version }}
5544
extensions: ctype, iconv, mysql
56-
tools: composer:v2
5745
ini-values: memory_limit=-1
5846
coverage: none
5947

6048
- name: Add additional packages
6149
run: |
62-
composer require monolog/monolog:${{ matrix.monolog-version }} --no-update
6350
composer require symfony/symfony:${{ matrix.symfony-version }} --no-update
51+
if: ${{ matrix.symfony-version }}
6452

6553
- name: Install composer dependencies
6654
uses: ramsey/composer-install@v3
67-
with:
68-
dependency-versions: ${{matrix.dependency-versions}}
6955

7056
- name: Prepare phpcr odm doctrine dbal
7157
run: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
1.5.0 (unreleased)
5+
------------------
6+
7+
* Allow installation with Symfony 7
8+
* Drop support for PHP < 8.1 and modernize code
9+
410
1.4.0
511
-----
612

composer.json

+9-12
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,23 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7.4 || ^8.0",
16+
"php": "^8.1",
1717
"phpcr/phpcr-migrations": "^1.1",
1818
"phpcr/phpcr-implementation": "^2.1",
1919
"doctrine/phpcr-bundle": "^1.3 || ^2.0",
20-
"symfony/config": "^4.4 || ^5.4 || ^6.0",
21-
"symfony/console": "^4.4 || ^5.4 || ^6.0",
22-
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",
23-
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0"
20+
"symfony/config": "^5.4 || ^6.0 || ^7.0",
21+
"symfony/console": "^5.4 || ^6.0 || ^7.0",
22+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
23+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0"
2424
},
2525
"require-dev": {
2626
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
27-
"doctrine/phpcr-odm": "^1.4",
28-
"symfony/symfony": "^4.4 || ^5.4 || ^6.0",
29-
"symfony/monolog-bundle": "^2.0 || ^3.0",
30-
"symfony/phpunit-bridge": "^5.4 || ^6.0",
27+
"doctrine/phpcr-odm": "^1.4 || ^2.0",
28+
"symfony/monolog-bundle": "^3.0",
29+
"symfony/phpunit-bridge": "^7.0",
30+
"symfony/symfony": "^5.4 || ^6.0 || ^7.0",
3131
"symfony-cmf/testing": "^2.1 || ^3.0 || ^4.0"
3232
},
33-
"conflict": {
34-
"symfony/symfony": "3.4.15"
35-
},
3633
"autoload": {
3734
"psr-4": {
3835
"PHPCR\\PhpcrMigrationsBundle\\": "src/"

src/Command/InitializeCommand.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818

1919
class InitializeCommand extends Command
2020
{
21-
private $factory;
22-
2321
public function __construct(
24-
MigratorFactory $factory
22+
private MigratorFactory $factory
2523
) {
2624
parent::__construct();
27-
$this->factory = $factory;
2825
}
2926

30-
public function configure()
27+
public function configure(): void
3128
{
3229
$this->setName('phpcr:migrations:initialize');
3330
$this->setDescription('Initialize the migration versions');
@@ -40,7 +37,7 @@ public function configure()
4037
);
4138
}
4239

43-
public function execute(InputInterface $input, OutputInterface $output)
40+
public function execute(InputInterface $input, OutputInterface $output): int
4441
{
4542
$this->factory->getMigrator()->initialize();
4643

src/Command/MigrateCommand.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@
2121

2222
class MigrateCommand extends Command
2323
{
24-
private $factory;
25-
private $container;
26-
private $actions = [
24+
/**
25+
* @var string[]
26+
*/
27+
private array $actions = [
2728
'up', 'down', 'top', 'bottom',
2829
];
2930

3031
public function __construct(
31-
MigratorFactory $factory,
32-
ContainerInterface $container
32+
private MigratorFactory $factory,
33+
private ContainerInterface $container
3334
) {
3435
parent::__construct();
35-
$this->factory = $factory;
36-
$this->container = $container;
3736
}
3837

39-
public function configure()
38+
public function configure(): void
4039
{
4140
$this->setName('phpcr:migrations:migrate');
4241
$this->addArgument('to', InputArgument::OPTIONAL, sprintf(
@@ -47,7 +46,7 @@ public function configure()
4746
$this->setHelp(<<<EOT
4847
Migrate to a specific version or perform an action.
4948
50-
By default it will migrate to the latest version:
49+
By default, it will migrate to the latest version:
5150
5251
$ %command.full_name%
5352
@@ -70,7 +69,7 @@ public function configure()
7069
);
7170
}
7271

73-
public function execute(InputInterface $input, OutputInterface $output)
72+
public function execute(InputInterface $input, OutputInterface $output): int
7473
{
7574
$to = $input->getArgument('to');
7675
$migrator = $this->factory->getMigrator();

src/Command/StatusCommand.php

+7-12
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@
2020

2121
class StatusCommand extends Command
2222
{
23-
private $versionStorage;
24-
private $finder;
25-
2623
public function __construct(
27-
VersionStorage $versionStorage,
28-
VersionFinder $finder
24+
private VersionStorage $versionStorage,
25+
private VersionFinder $finder,
2926
) {
3027
parent::__construct();
31-
$this->versionStorage = $versionStorage;
32-
$this->finder = $finder;
3328
}
3429

35-
public function configure()
30+
public function configure(): void
3631
{
3732
$this->setName('phpcr:migrations:status');
3833
$this->setDescription('Show the current migration status');
@@ -48,10 +43,10 @@ public function configure()
4843
);
4944
}
5045

51-
public function execute(InputInterface $input, OutputInterface $output)
46+
public function execute(InputInterface $input, OutputInterface $output): int
5247
{
5348
$versionCollection = $this->finder->getCollection();
54-
$executedVersions = (array) $this->versionStorage->getPersistedVersions();
49+
$executedVersions = $this->versionStorage->getPersistedVersions();
5550
$currentVersion = $this->versionStorage->getCurrentVersion();
5651

5752
$table = new Table($output);
@@ -62,7 +57,7 @@ public function execute(InputInterface $input, OutputInterface $output)
6257
foreach ($versionCollection->getAllVersions() as $versionName => $versionClass) {
6358
$reflection = new \ReflectionClass($versionClass);
6459
$table->addRow([
65-
$versionName == $currentVersion ? '*' : '',
60+
$versionName === $currentVersion ? '*' : '',
6661
$versionName,
6762
$this->getDate($versionName),
6863
isset($executedVersions[$versionName]) ? '<info>'.$executedVersions[$versionName]['executed']->format('Y-m-d H:i:s').'</info>' : 'n/a',
@@ -81,7 +76,7 @@ public function execute(InputInterface $input, OutputInterface $output)
8176
return 0;
8277
}
8378

84-
private function getDate($versionName)
79+
private function getDate($versionName): string
8580
{
8681
return date('Y-m-d H:i', strtotime($versionName));
8782
}

src/DependencyInjection/Configuration.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616

1717
class Configuration implements ConfigurationInterface
1818
{
19-
/**
20-
* Returns the config tree builder.
21-
*
22-
* @return TreeBuilder
23-
*/
24-
public function getConfigTreeBuilder()
19+
public function getConfigTreeBuilder(): TreeBuilder
2520
{
2621
$treeBuilder = new TreeBuilder('phpcr_migrations');
2722

src/DependencyInjection/PhpcrMigrationsExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
use Symfony\Component\Config\FileLocator;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Extension\Extension;
1617
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
17-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1818

1919
class PhpcrMigrationsExtension extends Extension
2020
{
21-
public function load(array $configs, ContainerBuilder $container)
21+
public function load(array $configs, ContainerBuilder $container): void
2222
{
2323
$configuration = new Configuration();
2424
$config = $this->processConfiguration($configuration, $configs);

0 commit comments

Comments
 (0)