Skip to content

Commit

Permalink
update codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Mar 18, 2024
1 parent 1fe91c6 commit 325a5ae
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 67 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.4'
symfony-version: '^4.4'
monolog-version: '^1.0'

- php-version: '7.4'
symfony-version: '^5.4'
monolog-version: '^2.0'
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Static analysis

on:
push:
branches:
- '[0-9]+.x'
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.x'
pull_request:

jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --dry-run
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tests/Resources/App/var
composer.lock
vendor
.phpunit.result.cache
/.php-cs-fixer.cache
/composer.lock
/tests/Resources/App/var
/vendor
/.phpunit.result.cache
12 changes: 12 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('src/')
->in('tests/');
$config = new PhpCsFixer\Config();

return $config->setFinder($finder)
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
]);
29 changes: 0 additions & 29 deletions .php_cs

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"symfony/symfony": "^4.4 || ^5.4 || ^6.0",
"symfony/monolog-bundle": "^2.0 || ^3.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0",
"symfony-cmf/testing": "^2.1 || ^3.0 || ^4.0"
"symfony-cmf/testing": "^2.1 || ^3.0 || ^4.0",
"phpstan/phpstan-symfony": "^1.3"
},
"conflict": {
"symfony/symfony": "3.4.15"
Expand Down
4 changes: 2 additions & 2 deletions src/Command/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class MigrateCommand extends Command
{
private $factory;
private $container;
private $actions = array(
private $actions = [
'up', 'down', 'top', 'bottom',
);
];

public function __construct(
MigratorFactory $factory,
Expand Down
10 changes: 5 additions & 5 deletions src/Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ public function execute(InputInterface $input, OutputInterface $output)
$currentVersion = $this->versionStorage->getCurrentVersion();

$table = new Table($output);
$table->setHeaders(array(
$table->setHeaders([
'', 'Version', 'Date', 'Migrated', 'Path',
));
]);

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

$table->render();
Expand Down
12 changes: 4 additions & 8 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('phpcr_migrations');
if (method_exists($treeBuilder, 'getRootNode')) {
$root = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$root = $treeBuilder->root('phpcr_migrations');
}

$root
$treeBuilder->getRootNode()
->children()
->scalarNode('version_node_name')->defaultValue('jcr:versions')->end()
->scalarNode('version_node_name')
->defaultValue('jcr:versions')
->end()
->arrayNode('paths')
->prototype('scalar')->end()
->end()
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/PhpcrMigrationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

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

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

if (file_exists($migrationsPath)) {
$paths[] = $migrationsPath;
Expand Down
8 changes: 4 additions & 4 deletions tests/Functional/MigrateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MigrateCommandTest extends BaseTestCase
*/
public function testMigrateToLatest(): void
{
$this->executeCommand('phpcr_migrations.command.migrate', array());
$this->executeCommand('phpcr_migrations.command.migrate', []);

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

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

$this->assertStringContainsString('Reverting 3 version', $display);
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/StatusCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StatusCommandTest extends BaseTestCase
*/
public function testShowAll(): void
{
$tester = $this->executeCommand('phpcr_migrations.command.status', array());
$tester = $this->executeCommand('phpcr_migrations.command.status', []);
$display = $tester->getDisplay();

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

$this->assertStringContainsString('201501011500', $display);
Expand Down
14 changes: 7 additions & 7 deletions tests/Resources/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ class AppKernel extends TestKernel
{
public function configure()
{
$this->requireBundleSets(array(
$this->requireBundleSets([
'default',
'phpcr_odm',
));
]);

$this->addBundles(array(
$this->addBundles([
new PhpcrMigrationsBundle(),
new OneTestBundle(),
new TwoTestBundle(),
));
]);
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->import(CMF_TEST_CONFIG_DIR . '/default.php');
$loader->import(CMF_TEST_CONFIG_DIR . '/phpcr_odm.php');
$loader->load(__DIR__ . '/config/config.yml');
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
$loader->load(__DIR__.'/config/config.yml');
}

protected function prepareContainer(ContainerBuilder $container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Version201401011300 implements VersionInterface, ContainerAwareInterface
{
private $container;

public function setContainer(ContainerInterface $container = null)
public function setContainer(?ContainerInterface $container = null)
{
$this->container = $container;
}

public function up(SessionInterface $session)
{
if (!$this->container) {
throw new \Exception('This Version class implements ContainerAwareInterface but no container has been set.');
throw new Exception('This Version class implements ContainerAwareInterface but no container has been set.');
}
$session->getRootNode()->addNode('camel');
}
Expand Down

0 comments on commit 325a5ae

Please sign in to comment.