Skip to content

Commit 62f44b2

Browse files
authored
Merge pull request #454 from symfony-cmf/fix-cs
codestyle: adjust to symfony default ruleset
2 parents e7f55a6 + c288a64 commit 62f44b2

23 files changed

+44
-76
lines changed

.styleci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
############################################################################
88
# This file is part of the Symfony CMF package. #
99
# #
10-
# (c) 2011-2017 Symfony CMF #
10+
# (c) Symfony CMF i #
1111
# #
1212
# For the full copyright and license information, please view the LICENSE #
1313
# file that was distributed with this source code. #
@@ -16,10 +16,10 @@
1616

1717
preset: symfony
1818

19+
risky: true
20+
1921
enabled:
2022
- combine_consecutive_unsets
21-
- short_array_syntax
22-
- newline_after_open_tag
2323
- no_php4_constructor
2424
- no_useless_else
2525
- ordered_use

src/CmfRoutingBundle.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
*/
3434
class CmfRoutingBundle extends Bundle
3535
{
36-
/**
37-
* @param ContainerBuilder $container
38-
*/
3936
public function build(ContainerBuilder $container)
4037
{
4138
parent::build($container);
@@ -52,8 +49,6 @@ public function build(ContainerBuilder $container)
5249
/**
5350
* Creates and registers compiler passes for PHPCR-ODM mapping if both the
5451
* phpcr-odm and the phpcr-bundle are present.
55-
*
56-
* @param ContainerBuilder $container
5752
*/
5853
private function buildPhpcrCompilerPass(ContainerBuilder $container)
5954
{
@@ -80,8 +75,6 @@ private function buildPhpcrCompilerPass(ContainerBuilder $container)
8075
/**
8176
* Creates and registers compiler passes for ORM mappings if both doctrine
8277
* ORM and a suitable compiler pass implementation are available.
83-
*
84-
* @param ContainerBuilder $container
8578
*/
8679
private function buildOrmCompilerPass(ContainerBuilder $container)
8780
{

src/Controller/RedirectController.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public function __construct(RouterInterface $router)
4343
/**
4444
* Action to redirect based on a RedirectRouteInterface route.
4545
*
46-
* @param RedirectRouteInterface $contentDocument
47-
*
4846
* @return \Symfony\Component\HttpFoundation\RedirectResponse the response
4947
*/
5048
public function redirectAction(RedirectRouteInterface $contentDocument)

src/DependencyInjection/CmfRoutingExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function setupFormTypes(array $config, ContainerBuilder $container, Load
6262
{
6363
$loader->load('form-type.xml');
6464

65-
if (array_key_exists('dynamic', $config)) {
65+
if (\array_key_exists('dynamic', $config)) {
6666
$routeTypeTypeDefinition = $container->getDefinition('cmf_routing.route_type_form_type');
6767

6868
foreach (array_keys($config['dynamic']['controllers_by_type']) as $routeType) {
@@ -94,7 +94,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
9494
$container->setParameter('cmf_routing.default_controller', $defaultController);
9595

9696
$locales = $config['locales'];
97-
if (0 === count($locales) && $config['auto_locale_pattern']) {
97+
if (0 === \count($locales) && $config['auto_locale_pattern']) {
9898
throw new InvalidConfigurationException('It makes no sense to activate auto_locale_pattern when no locales are configured.');
9999
}
100100

@@ -148,17 +148,17 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
148148
$dynamic = $container->getDefinition('cmf_routing.dynamic_router');
149149

150150
// if any mappings are defined, set the respective route enhancer
151-
if (count($config['controllers_by_type']) > 0) {
151+
if (\count($config['controllers_by_type']) > 0) {
152152
$container->getDefinition('cmf_routing.enhancer.controllers_by_type')
153153
->addTag('dynamic_router_route_enhancer', ['priority' => 60]);
154154
}
155155

156-
if (count($config['controllers_by_class']) > 0) {
156+
if (\count($config['controllers_by_class']) > 0) {
157157
$container->getDefinition('cmf_routing.enhancer.controllers_by_class')
158158
->addTag('dynamic_router_route_enhancer', ['priority' => 50]);
159159
}
160160

161-
if (count($config['templates_by_class']) > 0) {
161+
if (\count($config['templates_by_class']) > 0) {
162162
$container->getDefinition('cmf_routing.enhancer.templates_by_class')
163163
->addTag('dynamic_router_route_enhancer', ['priority' => 40]);
164164

@@ -197,7 +197,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
197197
->addTag('dynamic_router_route_enhancer', ['priority' => -100]);
198198
}
199199

200-
if (count($config['route_filters_by_id']) > 0) {
200+
if (\count($config['route_filters_by_id']) > 0) {
201201
$matcher = $container->getDefinition('cmf_routing.nested_matcher');
202202

203203
foreach ($config['route_filters_by_id'] as $id => $priority) {
@@ -217,7 +217,7 @@ private function loadPhpcrProvider(array $config, LoaderInterface $loader, Conta
217217

218218
$container->setParameter('cmf_routing.dynamic.persistence.phpcr.manager_name', $config['manager_name']);
219219

220-
if (0 === count($locales)) {
220+
if (0 === \count($locales)) {
221221
$container->removeDefinition('cmf_routing.phpcrodm_route_locale_listener');
222222
} elseif (!$matchImplicitLocale) {
223223
// remove all but the prefixes configuration from the service definition.

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private function addDynamicSection(ArrayNodeDefinition $root)
9999
->addDefaultsIfNotSet()
100100
->validate()
101101
->ifTrue(function ($v) {
102-
return count(array_filter($v, function ($persistence) {
102+
return \count(array_filter($v, function ($persistence) {
103103
return $persistence['enabled'];
104104
})) > 1;
105105
})

src/Doctrine/DoctrineProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ abstract class DoctrineProvider
5151
protected $routeCollectionLimit;
5252

5353
/**
54-
* @param ManagerRegistry $managerRegistry
55-
* @param string $className
54+
* @param string $className
5655
*/
5756
public function __construct(ManagerRegistry $managerRegistry, $className = null)
5857
{

src/Doctrine/Orm/ContentRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public function findById($id)
5555
*/
5656
public function getContentId($content)
5757
{
58-
if (!is_object($content)) {
58+
if (!\is_object($content)) {
5959
return;
6060
}
6161

6262
try {
63-
$class = get_class($content);
63+
$class = \get_class($content);
6464
$meta = $this->getObjectManager()->getClassMetadata($class);
6565
$ids = $meta->getIdentifierValues($content);
66-
if (1 !== count($ids)) {
66+
if (1 !== \count($ids)) {
6767
throw new \Exception(sprintf('Class "%s" must use only one identifier', $class));
6868
}
6969

src/Doctrine/Orm/RedirectRoute.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class RedirectRoute extends RedirectRouteModel
3838
* Additional options:
3939
*
4040
* * add_trailing_slash: When set, a trailing slash is appended to the route
41-
*
42-
* @param array $options
4341
*/
4442
public function __construct(array $options = [])
4543
{
@@ -74,7 +72,7 @@ public function getParameters()
7472
{
7573
$params = json_decode($this->serialisedParameters);
7674

77-
return is_array($params) ? $params : [];
75+
return \is_array($params) ? $params : [];
7876
}
7977

8078
/**
@@ -83,7 +81,7 @@ public function getParameters()
8381
public function getPath()
8482
{
8583
$pattern = parent::getPath();
86-
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[strlen($pattern) - 1]) {
84+
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[\strlen($pattern) - 1]) {
8785
$pattern .= '/';
8886
}
8987

src/Doctrine/Orm/RouteProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getRouteCollectionForRequest(Request $request)
5151
$collection = new RouteCollection();
5252

5353
$candidates = $this->candidatesStrategy->getCandidates($request);
54-
if (0 === count($candidates)) {
54+
if (0 === \count($candidates)) {
5555
return $collection;
5656
}
5757
$routes = $this->getRouteRepository()->findByStaticPrefix($candidates, ['position' => 'ASC']);

src/Doctrine/Phpcr/ContentRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function findById($id)
3838
*/
3939
public function getContentId($content)
4040
{
41-
if (!is_object($content)) {
41+
if (!\is_object($content)) {
4242
return;
4343
}
4444

src/Doctrine/Phpcr/IdPrefixListener.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class IdPrefixListener
3535
/**
3636
* This listener only makes sense together with the PrefixCandidates
3737
* strategy.
38-
*
39-
* @param PrefixCandidates $candidates
4038
*/
4139
public function __construct(PrefixCandidates $candidates)
4240
{

src/Doctrine/Phpcr/LocaleListener.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public function __construct(
8787

8888
/**
8989
* Specify the list of allowed locales.
90-
*
91-
* @param array $locales
9290
*/
9391
public function setLocales(array $locales)
9492
{
@@ -113,8 +111,6 @@ public function setUpdateAvailableTranslations($update)
113111

114112
/**
115113
* Update locale after loading a route.
116-
*
117-
* @param LifecycleEventArgs $args
118114
*/
119115
public function postLoad(LifecycleEventArgs $args)
120116
{
@@ -127,8 +123,6 @@ public function postLoad(LifecycleEventArgs $args)
127123

128124
/**
129125
* Update locale after persisting a route.
130-
*
131-
* @param LifecycleEventArgs $args
132126
*/
133127
public function postPersist(LifecycleEventArgs $args)
134128
{
@@ -141,8 +135,6 @@ public function postPersist(LifecycleEventArgs $args)
141135

142136
/**
143137
* Update a locale after the route has been moved.
144-
*
145-
* @param MoveEventArgs $args
146138
*/
147139
public function postMove(MoveEventArgs $args)
148140
{
@@ -184,7 +176,7 @@ protected function updateLocale(ModelRoute $doc, $id, DocumentManager $dm, $forc
184176
return;
185177
}
186178

187-
if (in_array($locale = $matches[2], $this->locales)) {
179+
if (\in_array($locale = $matches[2], $this->locales)) {
188180
if ($force || !$doc->getDefault('_locale')) {
189181
$doc->setDefault('_locale', $locale);
190182
}

src/Doctrine/Phpcr/PrefixCandidates.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function isCandidate($name)
8787
public function restrictQuery($queryBuilder)
8888
{
8989
$prefixes = $this->getPrefixes();
90-
if (in_array('', $prefixes) || !count($prefixes)) {
90+
if (\in_array('', $prefixes) || !\count($prefixes)) {
9191
return;
9292
}
9393

@@ -110,7 +110,7 @@ public function getCandidates(Request $request)
110110

111111
$locale = $this->determineLocale($url);
112112
if ($locale) {
113-
$url = substr($url, strlen($locale) + 1);
113+
$url = substr($url, \strlen($locale) + 1);
114114
foreach ($this->getPrefixes() as $prefix) {
115115
$candidates = array_unique(array_merge($candidates, $this->getCandidatesFor($url, $prefix)));
116116
}
@@ -174,12 +174,12 @@ public function setManagerName($manager)
174174
protected function isCandidateValid($candidate)
175175
{
176176
// Candidates cannot start or end with a space in Jackrabbit.
177-
if (' ' === \substr($candidate, 0, 1) || ' ' === \substr($candidate, -1)) {
177+
if (' ' === substr($candidate, 0, 1) || ' ' === substr($candidate, -1)) {
178178
return false;
179179
}
180180

181181
// Jackrabbit does not allow spaces before or after the path separator.
182-
if (false !== \strpos($candidate, ' /') || false !== \strpos($candidate, '/ ')) {
182+
if (false !== strpos($candidate, ' /') || false !== strpos($candidate, '/ ')) {
183183
return false;
184184
}
185185

src/Doctrine/Phpcr/RedirectRoute.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ class RedirectRoute extends RedirectRouteModel implements PrefixInterface, Hiera
6060
* Additional options:
6161
*
6262
* * add_trailing_slash: When set, a trailing slash is appended to the route
63-
*
64-
* @param array $options
6563
*/
6664
public function __construct(array $options = [])
6765
{
@@ -222,7 +220,7 @@ public function generateStaticPrefix($id, $idPrefix)
222220
throw new \LogicException("The id prefix '$idPrefix' does not match the route document path '$id'");
223221
}
224222

225-
$url = substr($id, strlen($idPrefix));
223+
$url = substr($id, \strlen($idPrefix));
226224
if ('' === $url) {
227225
$url = '/';
228226
}
@@ -236,7 +234,7 @@ public function generateStaticPrefix($id, $idPrefix)
236234
public function getPath()
237235
{
238236
$pattern = parent::getPath();
239-
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[strlen($pattern) - 1]) {
237+
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[\strlen($pattern) - 1]) {
240238
$pattern .= '/';
241239
}
242240

src/Doctrine/Phpcr/Route.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public function __construct(array $options = [])
8484
*/
8585
public function setParentDocument($parent)
8686
{
87-
if (!is_object($parent)) {
88-
throw new InvalidArgumentException('Parent must be an object '.gettype($parent).' given.');
87+
if (!\is_object($parent)) {
88+
throw new InvalidArgumentException('Parent must be an object '.\gettype($parent).' given.');
8989
}
9090

9191
$this->parent = $parent;
@@ -159,8 +159,8 @@ public function getName()
159159
*/
160160
public function setPosition($parent, $name)
161161
{
162-
if (!is_object($parent)) {
163-
throw new InvalidArgumentException('Parent must be an object '.gettype($parent).' given.');
162+
if (!\is_object($parent)) {
163+
throw new InvalidArgumentException('Parent must be an object '.\gettype($parent).' given.');
164164
}
165165

166166
$this->parent = $parent;
@@ -239,7 +239,7 @@ public function generateStaticPrefix($id, $idPrefix)
239239
throw new \LogicException("The id prefix '$idPrefix' does not match the route document path '$id'");
240240
}
241241

242-
$url = substr($id, strlen($idPrefix));
242+
$url = substr($id, \strlen($idPrefix));
243243
if (!$url) {
244244
$url = '/';
245245
}
@@ -255,7 +255,7 @@ public function generateStaticPrefix($id, $idPrefix)
255255
public function getPath()
256256
{
257257
$pattern = parent::getPath();
258-
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[strlen($pattern) - 1]) {
258+
if ($this->getOption('add_trailing_slash') && '/' !== $pattern[\strlen($pattern) - 1]) {
259259
$pattern .= '/';
260260
}
261261

src/Doctrine/Phpcr/RouteProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public function __construct(
5858
}
5959

6060
/**
61-
* @param Request $request
62-
*
6361
* @return array a list of PHPCR-ODM ids
6462
*/
6563
public function getCandidates(Request $request)
@@ -88,7 +86,7 @@ public function getRouteCollectionForRequest(Request $request)
8886

8987
$collection = new RouteCollection();
9088

91-
if (0 === count($candidates)) {
89+
if (0 === \count($candidates)) {
9290
return $collection;
9391
}
9492

src/Doctrine/RouteConditionMetadataListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public function getSubscribedEvents()
4040
/**
4141
* Handle the load class metadata event: remove translated attribute from
4242
* fields and remove the locale mapping if present.
43-
*
44-
* @param LoadClassMetadataEventArgs $eventArgs
4543
*/
4644
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
4745
{
@@ -71,7 +69,7 @@ public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
7169
'nullable' => true,
7270
]);
7371
} else {
74-
throw new \LogicException(sprintf('Class metadata was neither PHPCR nor ORM but %s', get_class($meta)));
72+
throw new \LogicException(sprintf('Class metadata was neither PHPCR nor ORM but %s', \get_class($meta)));
7573
}
7674
}
7775
}

0 commit comments

Comments
 (0)