Skip to content

Commit 385ba07

Browse files
committed
Merge pull request #163 from FriendsOfSymfony/cs-fixer
Enable PHP CS fixer on Scrutinizer
2 parents 22b1254 + ef11fb8 commit 385ba07

38 files changed

+188
-202
lines changed

.scrutinizer.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,49 @@ imports:
33

44
tools:
55
external_code_coverage: true
6+
php_code_sniffer:
7+
config:
8+
standard: PSR2
9+
10+
checks:
11+
php:
12+
verify_property_names: true
13+
verify_access_scope_valid: true
14+
verify_argument_usable_as_reference: true
15+
uppercase_constants: true
16+
switch_fallthrough_commented: true
17+
spacing_of_function_arguments: true
18+
spacing_around_non_conditional_operators: true
19+
spacing_around_conditional_operators: true
20+
space_after_cast: true
21+
unused_variables: true
22+
unused_properties: true
23+
unused_parameters: true
24+
unused_methods: true
25+
unreachable_code: true
26+
too_many_arguments: true
27+
no_unnecessary_if: true
28+
no_unnecessary_final_modifier: true
29+
no_empty_statements: true
30+
fix_use_statements:
31+
remove_unused: true
32+
preserve_multiple: false
33+
preserve_blanklines: false
34+
order_alphabetically: false
35+
remove_trailing_whitespace: true
36+
remove_php_closing_tag: true
37+
remove_extra_empty_lines: true
38+
fix_php_opening_tag: true
39+
fix_linefeed: true
40+
fix_line_ending: true
41+
fix_identation_4spaces: true
42+
fix_doc_comments: true
43+
avoid_useless_overridden_methods: true
44+
useless_calls: true
45+
single_namespace_per_use: true
46+
scope_indentation:
47+
spaces_per_level: '4'
48+
variable_existence: true
49+
return_doc_comments: true
50+
parameter_doc_comments: true
51+
no_unnecessary_function_call_in_for_loop: true

Command/BaseInvalidateCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
namespace FOS\HttpCacheBundle\Command;
1313

14-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
15-
1614
use FOS\HttpCacheBundle\CacheManager;
15+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1716

1817
/**
1918
* Base class for commands to trigger cache invalidation from the command line.

Command/InvalidatePathCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Input\InputArgument;
17-
1817
use FOS\HttpCacheBundle\CacheManager;
1918

2019
/**

Command/InvalidateRegexCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Input\InputArgument;
17-
1817
use FOS\HttpCacheBundle\CacheManager;
1918

2019
/**

Command/InvalidateTagCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Input\InputArgument;
17-
1817
use FOS\HttpCacheBundle\CacheManager;
1918

2019
/**

Command/RefreshPathCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Input\InputArgument;
17-
1817
use FOS\HttpCacheBundle\CacheManager;
1918

2019
/**

Configuration/InvalidatePath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class InvalidatePath extends ConfigurationAnnotation
3030
*/
3131
public function setValue($data)
3232
{
33-
$this->setPaths((is_array($data) ? $data: array($data)));
33+
$this->setPaths((is_array($data) ? $data : array($data)));
3434
}
3535

3636
/**

Configuration/Tag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Tag extends ConfigurationAnnotation
3030
*/
3131
public function setValue($data)
3232
{
33-
$this->setTags(is_array($data) ? $data: array($data));
33+
$this->setTags(is_array($data) ? $data : array($data));
3434
}
3535

3636
/**

DependencyInjection/Compiler/TagSubscriberPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function process(ContainerBuilder $container)
2929
) {
3030
throw new \RuntimeException(
3131
'Tag support requires SensioFrameworkExtraBundle’s ControllerListener for the annotations. '
32-
. 'Please install sensio/framework-extra-bundle and add it to your AppKernel.'
32+
.'Please install sensio/framework-extra-bundle and add it to your AppKernel.'
3333
);
3434
}
3535
}

DependencyInjection/Configuration.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ private function addCacheControlSection(ArrayNodeDefinition $rootNode)
204204
->end()
205205
->scalarNode('last_modified')
206206
->validate()
207-
->ifTrue(function ($v) {if (is_string($v)) {new \DateTime($v);} return false;})
207+
->ifTrue(function ($v) {
208+
if (is_string($v)) {
209+
new \DateTime($v);
210+
}
211+
212+
return false;
213+
})
208214
->thenInvalid('') // this will never happen as new DateTime will throw an exception if $v is no date
209215
->end()
210216
->info('Set a default last modified timestamp if none is set yet. Value must be parseable by DateTime')

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function load(array $configs, ContainerBuilder $container)
6565
$loader->load('cache_manager.xml');
6666
}
6767

68-
$container->setParameter($this->getAlias() . '.compiler_pass.tag_annotations', $config['tags']['enabled']);
68+
$container->setParameter($this->getAlias().'.compiler_pass.tag_annotations', $config['tags']['enabled']);
6969
if ($config['tags']['enabled']) {
7070
// true or auto
7171
$loader->load('tag_listener.xml');
@@ -105,7 +105,7 @@ public function load(array $configs, ContainerBuilder $container)
105105
*/
106106
private function loadCacheControl(ContainerBuilder $container, array $config)
107107
{
108-
$controlDefinition = $container->getDefinition($this->getAlias() . '.event_listener.cache_control');
108+
$controlDefinition = $container->getDefinition($this->getAlias().'.event_listener.cache_control');
109109

110110
foreach ($config['rules'] as $rule) {
111111
$ruleMatcher = $this->parseRuleMatcher($container, $rule['match']);
@@ -149,7 +149,7 @@ private function createRuleMatcher(ContainerBuilder $container, Reference $reque
149149
{
150150
$arguments = array((string) $requestMatcher, $extraCriteria);
151151
$serialized = serialize($arguments);
152-
$id = $this->getAlias() . '.rule_matcher.' . md5($serialized) . sha1($serialized);
152+
$id = $this->getAlias().'.rule_matcher.'.md5($serialized).sha1($serialized);
153153

154154
if (!$container->hasDefinition($id)) {
155155
$container
@@ -217,8 +217,8 @@ private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loa
217217
}
218218

219219
$container->setAlias(
220-
$this->getAlias() . '.default_proxy_client',
221-
$this->getAlias() . '.proxy_client.' . $this->getDefault($config)
220+
$this->getAlias().'.default_proxy_client',
221+
$this->getAlias().'.proxy_client.'.$this->getDefault($config)
222222
);
223223
}
224224

@@ -234,10 +234,10 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
234234
} else {
235235
$baseUrl = null;
236236
}
237-
$container->setParameter($this->getAlias() . '.proxy_client.varnish.servers', $config['servers']);
238-
$container->setParameter($this->getAlias() . '.proxy_client.varnish.base_url', $baseUrl);
237+
$container->setParameter($this->getAlias().'.proxy_client.varnish.servers', $config['servers']);
238+
$container->setParameter($this->getAlias().'.proxy_client.varnish.base_url', $baseUrl);
239239
if ($config['guzzle_client']) {
240-
$container->getDefinition($this->getAlias() . '.proxy_client.varnish')
240+
$container->getDefinition($this->getAlias().'.proxy_client.varnish')
241241
->addArgument(
242242
new Reference($config['guzzle_client'])
243243
)
@@ -256,14 +256,14 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
256256
} else {
257257
$baseUrl = null;
258258
}
259-
$container->setParameter($this->getAlias() . '.proxy_client.nginx.servers', $config['servers']);
260-
$container->setParameter($this->getAlias() . '.proxy_client.nginx.base_url', $baseUrl);
261-
$container->setParameter($this->getAlias() . '.proxy_client.nginx.purge_location', $config['purge_location']);
259+
$container->setParameter($this->getAlias().'.proxy_client.nginx.servers', $config['servers']);
260+
$container->setParameter($this->getAlias().'.proxy_client.nginx.base_url', $baseUrl);
261+
$container->setParameter($this->getAlias().'.proxy_client.nginx.purge_location', $config['purge_location']);
262262
}
263263

264264
private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, array $config)
265265
{
266-
$container->setParameter($this->getAlias() . '.test.cache_header', $config['cache_header']);
266+
$container->setParameter($this->getAlias().'.test.cache_header', $config['cache_header']);
267267

268268
if ($config['proxy_server']) {
269269
$this->loadProxyServer($container, $loader, $config['proxy_server']);
@@ -274,18 +274,18 @@ private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, ar
274274
$loader->load('test_client.xml');
275275

276276
if ($config['client']['varnish']['enabled']) {
277-
$container->getDefinition($this->getAlias() . '.test.client.varnish')
277+
$container->getDefinition($this->getAlias().'.test.client.varnish')
278278
->setAbstract(false);
279279
}
280280

281281
if ($config['client']['nginx']['enabled']) {
282-
$container->getDefinition($this->getAlias() . '.test.client.nginx')
282+
$container->getDefinition($this->getAlias().'.test.client.nginx')
283283
->setAbstract(false);
284284
}
285285

286286
$container->setAlias(
287-
$this->getAlias() . '.test.default_client',
288-
$this->getAlias() . '.test.client.' . $this->getDefault($config['client'])
287+
$this->getAlias().'.test.default_client',
288+
$this->getAlias().'.test.client.'.$this->getDefault($config['client'])
289289
);
290290
}
291291
}
@@ -301,8 +301,8 @@ private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loa
301301
}
302302

303303
$container->setAlias(
304-
$this->getAlias() . '.test.default_proxy_server',
305-
$this->getAlias() . '.test.proxy_server.' . $this->getDefault($config)
304+
$this->getAlias().'.test.default_proxy_server',
305+
$this->getAlias().'.test.proxy_server.'.$this->getDefault($config)
306306
);
307307
}
308308

@@ -311,7 +311,7 @@ private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoad
311311
$loader->load('varnish_proxy.xml');
312312
foreach ($config as $key => $value) {
313313
$container->setParameter(
314-
$this->getAlias() . '.test.proxy_server.varnish.' . $key,
314+
$this->getAlias().'.test.proxy_server.varnish.'.$key,
315315
$value
316316
);
317317
}
@@ -322,15 +322,15 @@ private function loadNginxProxyServer(ContainerBuilder $container, XmlFileLoader
322322
$loader->load('nginx_proxy.xml');
323323
foreach ($config as $key => $value) {
324324
$container->setParameter(
325-
$this->getAlias() . '.test.proxy_server.nginx.' . $key,
325+
$this->getAlias().'.test.proxy_server.nginx.'.$key,
326326
$value
327327
);
328328
}
329329
}
330330

331331
private function loadTagRules(ContainerBuilder $container, array $config)
332332
{
333-
$tagDefinition = $container->getDefinition($this->getAlias() . '.event_listener.tag');
333+
$tagDefinition = $container->getDefinition($this->getAlias().'.event_listener.tag');
334334

335335
foreach ($config as $rule) {
336336
$ruleMatcher = $this->parseRuleMatcher($container, $rule['match']);
@@ -346,7 +346,7 @@ private function loadTagRules(ContainerBuilder $container, array $config)
346346

347347
private function loadInvalidatorRules(ContainerBuilder $container, array $config)
348348
{
349-
$tagDefinition = $container->getDefinition($this->getAlias() . '.event_listener.invalidation');
349+
$tagDefinition = $container->getDefinition($this->getAlias().'.event_listener.invalidation');
350350

351351
foreach ($config as $rule) {
352352
$ruleMatcher = $this->parseRuleMatcher($container, $rule['match']);
@@ -363,7 +363,6 @@ private function validateUrl($url, $msg)
363363
}
364364
}
365365

366-
367366
private function prefixSchema($url)
368367
{
369368
if (false === strpos($url, '://')) {

EventListener/CacheControlSubscriber.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ private function setExtraCacheDirectives(Response $response, array $controls, $o
202202
&& ($overwrite || !$response->headers->hasCacheControlDirective($option))
203203
) {
204204
$response->headers->addCacheControlDirective($option, $controls[$key]);
205-
206205
}
207206
}
208207
}

EventListener/FlashMessageSubscriber.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ public static function getSubscribedEvents()
5858
);
5959
}
6060

61-
/**
62-
* Moves flash messages from the session to a cookie inside a Response Kernel listener
63-
*
64-
* @param FilterResponseEvent $event
65-
*/
61+
/**
62+
* Moves flash messages from the session to a cookie inside a Response Kernel listener
63+
*
64+
* @param FilterResponseEvent $event
65+
*/
6666
public function onKernelResponse(FilterResponseEvent $event)
6767
{
6868
if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {

EventListener/InvalidationSubscriber.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class InvalidationSubscriber extends AbstractRuleSubscriber implements EventSubs
5858
/**
5959
* Constructor
6060
*
61-
* @param CacheManager $cacheManager
62-
* @param UrlGeneratorInterface $urlGenerator
63-
* @param ExpressionLanguage $expressionLanguage
61+
* @param CacheManager $cacheManager
62+
* @param UrlGeneratorInterface $urlGenerator
63+
* @param ExpressionLanguage|null $expressionLanguage
6464
*/
6565
public function __construct(
6666
CacheManager $cacheManager,
@@ -82,8 +82,6 @@ public function __construct(
8282
* HTTP cache.
8383
*
8484
* @param PostResponseEvent $event
85-
*
86-
* @return array Paths that were flushed from the invalidation queue
8785
*/
8886
public function onKernelTerminate(PostResponseEvent $event)
8987
{
@@ -139,7 +137,7 @@ public static function getSubscribedEvents()
139137
KernelEvents::TERMINATE => 'onKernelTerminate',
140138
KernelEvents::EXCEPTION => 'onKernelException',
141139
ConsoleEvents::TERMINATE => 'onConsoleTerminate',
142-
ConsoleEvents::EXCEPTION => 'onConsoleTerminate'
140+
ConsoleEvents::EXCEPTION => 'onConsoleTerminate',
143141
);
144142
}
145143

EventListener/TagSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class TagSubscriber extends AbstractRuleSubscriber implements EventSubscriberInt
3939
/**
4040
* Constructor
4141
*
42-
* @param CacheManager $cacheManager
43-
* @param ExpressionLanguage $expressionLanguage
42+
* @param CacheManager $cacheManager
43+
* @param ExpressionLanguage|null $expressionLanguage
4444
*/
4545
public function __construct(
4646
CacheManager $cacheManager,
@@ -100,7 +100,7 @@ public function onKernelResponse(FilterResponseEvent $event)
100100
public static function getSubscribedEvents()
101101
{
102102
return array(
103-
KernelEvents::RESPONSE => 'onKernelResponse'
103+
KernelEvents::RESPONSE => 'onKernelResponse',
104104
);
105105
}
106106

EventListener/UserContextSubscriber.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function __construct(
6262
array $userIdentifierHeaders = array('Cookie', 'Authorization'),
6363
$hashHeader = "X-User-Context-Hash",
6464
$ttl = 0
65-
)
66-
{
65+
) {
6766
if (!count($userIdentifierHeaders)) {
6867
throw new \InvalidArgumentException('The user context must vary on some request headers');
6968
}
@@ -97,7 +96,7 @@ public function onKernelRequest(GetResponseEvent $event)
9796
// status needs to be 200 as otherwise varnish will not cache the response.
9897
$response = new Response('', 200, array(
9998
$this->hashHeader => $hash,
100-
'Content-Type' => 'application/vnd.fos.user-context-hash'
99+
'Content-Type' => 'application/vnd.fos.user-context-hash',
101100
));
102101

103102
if ($this->ttl > 0) {

HttpCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function cleanupForwardRequest(Request $forwardReq, Request $originalR
178178
{
179179
$sessionIds = array();
180180
foreach ($originalRequest->cookies as $name => $value) {
181-
if ( $this->isSessionName($name)) {
181+
if ($this->isSessionName($name)) {
182182
$sessionIds[$name] = $value;
183183
$forwardReq->cookies->set($name, $value);
184184
}

Security/Http/Logout/ContextInvalidationLogoutHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function logout(Request $request, Response $response, TokenInterface $tok
6161
foreach ($this->userIdentifierHeaders as $header) {
6262
$this->banner->ban(array(
6363
'accept' => $this->acceptHeader,
64-
$header => sprintf('.*%s.*', $sessionId)
64+
$header => sprintf('.*%s.*', $sessionId),
6565
));
6666
}
6767
}

0 commit comments

Comments
 (0)