Skip to content

Commit cb338eb

Browse files
committed
enforce Symfony coding standards
1 parent eb79ce9 commit cb338eb

24 files changed

+106
-85
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.*.cache
12
composer.lock
23
vendor/*

.php_cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// see https://github.com/FriendsOfPHP/PHP-CS-Fixer
3+
4+
$finder = PhpCsFixer\Finder::create()
5+
->exclude('vendor')
6+
->in([__DIR__])
7+
;
8+
9+
return PhpCsFixer\Config::create()
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@Symfony' => true,
13+
'@Symfony:risky' => true,
14+
'array_syntax' => ['syntax' => 'short'],
15+
])
16+
->setFinder($finder)
17+
;

src/DependencyInjection/Compiler/AddExtensionsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
2323
}
2424

2525
$taggedServiceIds = $container->findTaggedServiceIds('knp_menu.factory_extension');
26-
if (0 === count($taggedServiceIds)) {
26+
if (0 === \count($taggedServiceIds)) {
2727
return;
2828
}
2929

src/DependencyInjection/Compiler/AddProvidersPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Knp\Bundle\MenuBundle\DependencyInjection\Compiler;
34

45
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
@@ -26,7 +27,7 @@ public function process(ContainerBuilder $container)
2627
$providers[] = new Reference($id);
2728
}
2829

29-
if (1 === count($providers)) {
30+
if (1 === \count($providers)) {
3031
// Use an alias instead of wrapping it in the ChainProvider for performances
3132
// when using only one (the default case as the bundle defines one provider)
3233
$container->setAlias('knp_menu.menu_provider', (string) reset($providers));

src/DependencyInjection/Compiler/AddRenderersPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Knp\Bundle\MenuBundle\DependencyInjection\Compiler;
34

45
use Knp\Menu\Renderer\PsrProvider;

src/DependencyInjection/Compiler/AddVotersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function process(ContainerBuilder $container)
5555
}
5656

5757
krsort($voters);
58-
$sortedVoters = call_user_func_array('array_merge', $voters);
58+
$sortedVoters = \call_user_func_array('array_merge', $voters);
5959

6060
if (class_exists(IteratorArgument::class)) {
6161
$definition->replaceArgument(0, new IteratorArgument($sortedVoters));

src/DependencyInjection/Compiler/MenuPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Knp\Bundle\MenuBundle\DependencyInjection\Compiler;
34

45
use Symfony\Component\DependencyInjection\ContainerBuilder;

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Component\Config\Definition\ConfigurationInterface;
77

88
/**
9-
* This class contains the configuration information for the bundle
9+
* This class contains the configuration information for the bundle.
1010
*
1111
* @author Christophe Coevoet <[email protected]>
1212
*/

src/DependencyInjection/KnpMenuExtension.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function getNamespace()
6262
*/
6363
public function getXsdValidationBasePath()
6464
{
65-
return __DIR__ . '/../Resources/config/schema';
65+
return __DIR__.'/../Resources/config/schema';
6666
}
6767

6868
public function prepend(ContainerBuilder $container)
@@ -71,9 +71,8 @@ public function prepend(ContainerBuilder $container)
7171
return;
7272
}
7373

74-
7574
$refl = new \ReflectionClass(ItemInterface::class);
76-
$path = dirname($refl->getFileName()).'/Resources/views';
75+
$path = \dirname($refl->getFileName()).'/Resources/views';
7776

7877
$container->prependExtensionConfig('twig', ['paths' => [$path]]);
7978
}

src/Provider/BuilderAliasProvider.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Symfony\Component\HttpKernel\KernelInterface;
1111

1212
/**
13-
* A menu provider that allows for an AcmeBundle:Builder:mainMenu shortcut syntax
13+
* A menu provider that allows for an AcmeBundle:Builder:mainMenu shortcut syntax.
1414
*
1515
* @author Ryan Weaver <[email protected]>
1616
*/
@@ -32,7 +32,7 @@ public function __construct(KernelInterface $kernel, ContainerInterface $contain
3232
}
3333

3434
/**
35-
* Looks for a menu with the bundle:class:method format
35+
* Looks for a menu with the bundle:class:method format.
3636
*
3737
* For example, AcmeBundle:Builder:mainMenu would create and instantiate
3838
* an Acme\DemoBundle\Menu\Builder class and call the mainMenu() method
@@ -42,6 +42,7 @@ public function __construct(KernelInterface $kernel, ContainerInterface $contain
4242
* @param array $options
4343
*
4444
* @return \Knp\Menu\ItemInterface
45+
*
4546
* @throws \InvalidArgumentException
4647
*/
4748
public function get($name, array $options = [])
@@ -71,15 +72,15 @@ public function get($name, array $options = [])
7172
* @param string $name The alias name of the menu
7273
* @param array $options
7374
*
74-
* @return Boolean
75+
* @return bool
7576
*/
7677
public function has($name, array $options = [])
7778
{
7879
return 2 == substr_count($name, ':');
7980
}
8081

8182
/**
82-
* Creates and returns the builder that lives in the given bundle
83+
* Creates and returns the builder that lives in the given bundle.
8384
*
8485
* The convention is to look in the Menu namespace of the bundle for
8586
* this class, to instantiate it with no arguments, and to inject the
@@ -104,7 +105,7 @@ protected function getBuilder($bundleName, $className)
104105
$allBundles = $this->kernel->getBundle($bundleName, false);
105106

106107
// In Symfony 4, bundle inheritance is gone, so there is no way to get an array anymore.
107-
if (!is_array($allBundles)) {
108+
if (!\is_array($allBundles)) {
108109
$allBundles = [$allBundles];
109110
}
110111

@@ -120,7 +121,7 @@ protected function getBuilder($bundleName, $className)
120121
}
121122

122123
if (null === $class) {
123-
if (1 === count($logs)) {
124+
if (1 === \count($logs)) {
124125
throw new \InvalidArgumentException($logs[0]);
125126
}
126127

0 commit comments

Comments
 (0)