Skip to content

Commit 7341d12

Browse files
committed
update codestyle
1 parent 1fe91c6 commit 7341d12

File tree

14 files changed

+76
-66
lines changed

14 files changed

+76
-66
lines changed

.gitattributes

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gitattributes export-ignore
2+
/.github/ export-ignore
3+
.gitignore export-ignore
4+
/.php-cs-fixer.dist.php export-ignore
5+
/phpunit.xml.dist export-ignore
6+
/tests/ export-ignore

.github/workflows/ci.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ 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+
2327
- php-version: '7.4'
2428
symfony-version: '^5.4'
2529
monolog-version: '^2.0'

.github/workflows/static.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Static analysis
2+
3+
on:
4+
push:
5+
branches:
6+
- '[0-9]+.x'
7+
- '[0-9]+.[0-9]+'
8+
- '[0-9]+.[0-9]+.x'
9+
pull_request:
10+
11+
jobs:
12+
php-cs-fixer:
13+
name: PHP-CS-Fixer
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: PHP-CS-Fixer
18+
uses: docker://oskarstark/php-cs-fixer-ga
19+
with:
20+
args: --dry-run

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
tests/Resources/App/var
2-
composer.lock
3-
vendor
4-
.phpunit.result.cache
1+
/.php-cs-fixer.cache
2+
/composer.lock
3+
/tests/Resources/App/var
4+
/vendor
5+
/.phpunit.result.cache

.php-cs-fixer.dist.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('src/')
5+
->in('tests/');
6+
$config = new PhpCsFixer\Config();
7+
8+
return $config->setFinder($finder)
9+
->setRules([
10+
'@Symfony' => true,
11+
'array_syntax' => ['syntax' => 'short'],
12+
]);

.php_cs

-29
This file was deleted.

src/Command/MigrateCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class MigrateCommand extends Command
2323
{
2424
private $factory;
2525
private $container;
26-
private $actions = array(
26+
private $actions = [
2727
'up', 'down', 'top', 'bottom',
28-
);
28+
];
2929

3030
public function __construct(
3131
MigratorFactory $factory,

src/Command/StatusCommand.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ public function execute(InputInterface $input, OutputInterface $output)
5555
$currentVersion = $this->versionStorage->getCurrentVersion();
5656

5757
$table = new Table($output);
58-
$table->setHeaders(array(
58+
$table->setHeaders([
5959
'', 'Version', 'Date', 'Migrated', 'Path',
60-
));
60+
]);
6161

6262
foreach ($versionCollection->getAllVersions() as $versionName => $versionClass) {
6363
$reflection = new \ReflectionClass($versionClass);
64-
$table->addRow(array(
64+
$table->addRow([
6565
$versionName == $currentVersion ? '*' : '',
6666
$versionName,
6767
$this->getDate($versionName),
68-
isset($executedVersions[$versionName]) ? '<info>' . $executedVersions[$versionName]['executed']->format('Y-m-d H:i:s') . '</info>' : 'n/a',
68+
isset($executedVersions[$versionName]) ? '<info>'.$executedVersions[$versionName]['executed']->format('Y-m-d H:i:s').'</info>' : 'n/a',
6969
substr($reflection->getFileName(), strlen(getcwd()) + 1),
70-
));
70+
]);
7171
}
7272

7373
$table->render();

src/DependencyInjection/Configuration.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@ class Configuration implements ConfigurationInterface
2424
public function getConfigTreeBuilder()
2525
{
2626
$treeBuilder = new TreeBuilder('phpcr_migrations');
27-
if (method_exists($treeBuilder, 'getRootNode')) {
28-
$root = $treeBuilder->getRootNode();
29-
} else {
30-
// BC layer for symfony/config 4.1 and older
31-
$root = $treeBuilder->root('phpcr_migrations');
32-
}
3327

34-
$root
28+
$treeBuilder->getRootNode()
3529
->children()
36-
->scalarNode('version_node_name')->defaultValue('jcr:versions')->end()
30+
->scalarNode('version_node_name')
31+
->defaultValue('jcr:versions')
32+
->end()
3733
->arrayNode('paths')
3834
->prototype('scalar')->end()
3935
->end()

src/DependencyInjection/PhpcrMigrationsExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function load(array $configs, ContainerBuilder $container)
2222
{
2323
$configuration = new Configuration();
2424
$config = $this->processConfiguration($configuration, $configs);
25-
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
25+
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2626

2727
$container->setParameter('phpcr_migrations.version_node_name', $config['version_node_name']);
2828

@@ -31,7 +31,7 @@ public function load(array $configs, ContainerBuilder $container)
3131
foreach ($container->getParameter('kernel.bundles') as $bundleFqn) {
3232
$reflection = new \ReflectionClass($bundleFqn);
3333
$path = dirname($reflection->getFileName());
34-
$migrationsPath = $path . '/Resources/phpcr-migrations';
34+
$migrationsPath = $path.'/Resources/phpcr-migrations';
3535

3636
if (file_exists($migrationsPath)) {
3737
$paths[] = $migrationsPath;

tests/Functional/MigrateCommandTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MigrateCommandTest extends BaseTestCase
1818
*/
1919
public function testMigrateToLatest(): void
2020
{
21-
$this->executeCommand('phpcr_migrations.command.migrate', array());
21+
$this->executeCommand('phpcr_migrations.command.migrate', []);
2222

2323
$versionNodes = $this->session->getNode('/jcr:migrations')->getNodes();
2424
$this->assertCount(5, $versionNodes);
@@ -29,7 +29,7 @@ public function testMigrateToLatest(): void
2929
*/
3030
public function testUpgradeTo(): void
3131
{
32-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201401011300'));
32+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', ['to' => '201401011300']);
3333
$display = $tester->getDisplay();
3434

3535
$this->assertStringContainsString('Upgrading 1 version', $display);
@@ -43,8 +43,8 @@ public function testUpgradeTo(): void
4343
*/
4444
public function testUpgradeRevertTo(): void
4545
{
46-
$this->executeCommand('phpcr_migrations.command.migrate', array());
47-
$tester = $this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011200'));
46+
$this->executeCommand('phpcr_migrations.command.migrate', []);
47+
$tester = $this->executeCommand('phpcr_migrations.command.migrate', ['to' => '201501011200']);
4848
$display = $tester->getDisplay();
4949

5050
$this->assertStringContainsString('Reverting 3 version', $display);

tests/Functional/StatusCommandTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class StatusCommandTest extends BaseTestCase
1818
*/
1919
public function testShowAll(): void
2020
{
21-
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
21+
$tester = $this->executeCommand('phpcr_migrations.command.status', []);
2222
$display = $tester->getDisplay();
2323

2424
$this->assertStringContainsString('No migrations have been executed', $display);
@@ -29,8 +29,8 @@ public function testShowAll(): void
2929
*/
3030
public function testShowCurrentVersion(): void
3131
{
32-
$this->executeCommand('phpcr_migrations.command.migrate', array('to' => '201501011500'));
33-
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
32+
$this->executeCommand('phpcr_migrations.command.migrate', ['to' => '201501011500']);
33+
$tester = $this->executeCommand('phpcr_migrations.command.status', []);
3434
$display = $tester->getDisplay();
3535

3636
$this->assertStringContainsString('201501011500', $display);

tests/Resources/App/AppKernel.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ class AppKernel extends TestKernel
2222
{
2323
public function configure()
2424
{
25-
$this->requireBundleSets(array(
25+
$this->requireBundleSets([
2626
'default',
2727
'phpcr_odm',
28-
));
28+
]);
2929

30-
$this->addBundles(array(
30+
$this->addBundles([
3131
new PhpcrMigrationsBundle(),
3232
new OneTestBundle(),
3333
new TwoTestBundle(),
34-
));
34+
]);
3535
}
3636

3737
public function registerContainerConfiguration(LoaderInterface $loader)
3838
{
39-
$loader->import(CMF_TEST_CONFIG_DIR . '/default.php');
40-
$loader->import(CMF_TEST_CONFIG_DIR . '/phpcr_odm.php');
41-
$loader->load(__DIR__ . '/config/config.yml');
39+
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
40+
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
41+
$loader->load(__DIR__.'/config/config.yml');
4242
}
4343

4444
protected function prepareContainer(ContainerBuilder $container)

tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class Version201401011300 implements VersionInterface, ContainerAwareInterface
1818
{
1919
private $container;
2020

21-
public function setContainer(ContainerInterface $container = null)
21+
public function setContainer(?ContainerInterface $container = null)
2222
{
2323
$this->container = $container;
2424
}
2525

2626
public function up(SessionInterface $session)
2727
{
2828
if (!$this->container) {
29-
throw new \Exception('This Version class implements ContainerAwareInterface but no container has been set.');
29+
throw new Exception('This Version class implements ContainerAwareInterface but no container has been set.');
3030
}
3131
$session->getRootNode()->addNode('camel');
3232
}

0 commit comments

Comments
 (0)