Skip to content

Enable PHP CS fixer on Scrutinizer #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,49 @@ imports:

tools:
external_code_coverage: true
php_code_sniffer:
config:
standard: PSR2

checks:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to whitelist explicitly? seems a bit cumbersome, especially when new options are added we would need to add them here too...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems adding checks is required if you want to add certain extra, but not all, checks. Scrutinizer now recommends this over configuring the separate tools.

php:
verify_property_names: true
verify_access_scope_valid: true
verify_argument_usable_as_reference: true
uppercase_constants: true
switch_fallthrough_commented: true
spacing_of_function_arguments: true
spacing_around_non_conditional_operators: true
spacing_around_conditional_operators: true
space_after_cast: true
unused_variables: true
unused_properties: true
unused_parameters: true
unused_methods: true
unreachable_code: true
too_many_arguments: true
no_unnecessary_if: true
no_unnecessary_final_modifier: true
no_empty_statements: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: false
order_alphabetically: false
remove_trailing_whitespace: true
remove_php_closing_tag: true
remove_extra_empty_lines: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true
avoid_useless_overridden_methods: true
useless_calls: true
single_namespace_per_use: true
scope_indentation:
spaces_per_level: '4'
variable_existence: true
return_doc_comments: true
parameter_doc_comments: true
no_unnecessary_function_call_in_for_loop: true
3 changes: 1 addition & 2 deletions Command/BaseInvalidateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

namespace FOS\HttpCacheBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

use FOS\HttpCacheBundle\CacheManager;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;

/**
* Base class for commands to trigger cache invalidation from the command line.
Expand Down
1 change: 0 additions & 1 deletion Command/InvalidatePathCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

use FOS\HttpCacheBundle\CacheManager;

/**
Expand Down
1 change: 0 additions & 1 deletion Command/InvalidateRegexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

use FOS\HttpCacheBundle\CacheManager;

/**
Expand Down
1 change: 0 additions & 1 deletion Command/InvalidateTagCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

use FOS\HttpCacheBundle\CacheManager;

/**
Expand Down
1 change: 0 additions & 1 deletion Command/RefreshPathCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

use FOS\HttpCacheBundle\CacheManager;

/**
Expand Down
2 changes: 1 addition & 1 deletion Configuration/InvalidatePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InvalidatePath extends ConfigurationAnnotation
*/
public function setValue($data)
{
$this->setPaths((is_array($data) ? $data: array($data)));
$this->setPaths((is_array($data) ? $data : array($data)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Tag extends ConfigurationAnnotation
*/
public function setValue($data)
{
$this->setTags(is_array($data) ? $data: array($data));
$this->setTags(is_array($data) ? $data : array($data));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/TagSubscriberPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function process(ContainerBuilder $container)
) {
throw new \RuntimeException(
'Tag support requires SensioFrameworkExtraBundle’s ControllerListener for the annotations. '
. 'Please install sensio/framework-extra-bundle and add it to your AppKernel.'
.'Please install sensio/framework-extra-bundle and add it to your AppKernel.'
);
}
}
Expand Down
8 changes: 7 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ private function addCacheControlSection(ArrayNodeDefinition $rootNode)
->end()
->scalarNode('last_modified')
->validate()
->ifTrue(function ($v) {if (is_string($v)) {new \DateTime($v);} return false;})
->ifTrue(function ($v) {
if (is_string($v)) {
new \DateTime($v);
}

return false;
})
->thenInvalid('') // this will never happen as new DateTime will throw an exception if $v is no date
->end()
->info('Set a default last modified timestamp if none is set yet. Value must be parseable by DateTime')
Expand Down
45 changes: 22 additions & 23 deletions DependencyInjection/FOSHttpCacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('cache_manager.xml');
}

$container->setParameter($this->getAlias() . '.compiler_pass.tag_annotations', $config['tags']['enabled']);
$container->setParameter($this->getAlias().'.compiler_pass.tag_annotations', $config['tags']['enabled']);
if ($config['tags']['enabled']) {
// true or auto
$loader->load('tag_listener.xml');
Expand Down Expand Up @@ -105,7 +105,7 @@ public function load(array $configs, ContainerBuilder $container)
*/
private function loadCacheControl(ContainerBuilder $container, array $config)
{
$controlDefinition = $container->getDefinition($this->getAlias() . '.event_listener.cache_control');
$controlDefinition = $container->getDefinition($this->getAlias().'.event_listener.cache_control');

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

if (!$container->hasDefinition($id)) {
$container
Expand Down Expand Up @@ -217,8 +217,8 @@ private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loa
}

$container->setAlias(
$this->getAlias() . '.default_proxy_client',
$this->getAlias() . '.proxy_client.' . $this->getDefault($config)
$this->getAlias().'.default_proxy_client',
$this->getAlias().'.proxy_client.'.$this->getDefault($config)
);
}

Expand All @@ -234,10 +234,10 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
} else {
$baseUrl = null;
}
$container->setParameter($this->getAlias() . '.proxy_client.varnish.servers', $config['servers']);
$container->setParameter($this->getAlias() . '.proxy_client.varnish.base_url', $baseUrl);
$container->setParameter($this->getAlias().'.proxy_client.varnish.servers', $config['servers']);
$container->setParameter($this->getAlias().'.proxy_client.varnish.base_url', $baseUrl);
if ($config['guzzle_client']) {
$container->getDefinition($this->getAlias() . '.proxy_client.varnish')
$container->getDefinition($this->getAlias().'.proxy_client.varnish')
->addArgument(
new Reference($config['guzzle_client'])
)
Expand All @@ -256,14 +256,14 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
} else {
$baseUrl = null;
}
$container->setParameter($this->getAlias() . '.proxy_client.nginx.servers', $config['servers']);
$container->setParameter($this->getAlias() . '.proxy_client.nginx.base_url', $baseUrl);
$container->setParameter($this->getAlias() . '.proxy_client.nginx.purge_location', $config['purge_location']);
$container->setParameter($this->getAlias().'.proxy_client.nginx.servers', $config['servers']);
$container->setParameter($this->getAlias().'.proxy_client.nginx.base_url', $baseUrl);
$container->setParameter($this->getAlias().'.proxy_client.nginx.purge_location', $config['purge_location']);
}

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

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

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

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

$container->setAlias(
$this->getAlias() . '.test.default_client',
$this->getAlias() . '.test.client.' . $this->getDefault($config['client'])
$this->getAlias().'.test.default_client',
$this->getAlias().'.test.client.'.$this->getDefault($config['client'])
);
}
}
Expand All @@ -301,8 +301,8 @@ private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loa
}

$container->setAlias(
$this->getAlias() . '.test.default_proxy_server',
$this->getAlias() . '.test.proxy_server.' . $this->getDefault($config)
$this->getAlias().'.test.default_proxy_server',
$this->getAlias().'.test.proxy_server.'.$this->getDefault($config)
);
}

Expand All @@ -311,7 +311,7 @@ private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoad
$loader->load('varnish_proxy.xml');
foreach ($config as $key => $value) {
$container->setParameter(
$this->getAlias() . '.test.proxy_server.varnish.' . $key,
$this->getAlias().'.test.proxy_server.varnish.'.$key,
$value
);
}
Expand All @@ -322,15 +322,15 @@ private function loadNginxProxyServer(ContainerBuilder $container, XmlFileLoader
$loader->load('nginx_proxy.xml');
foreach ($config as $key => $value) {
$container->setParameter(
$this->getAlias() . '.test.proxy_server.nginx.' . $key,
$this->getAlias().'.test.proxy_server.nginx.'.$key,
$value
);
}
}

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

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

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

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


private function prefixSchema($url)
{
if (false === strpos($url, '://')) {
Expand Down
1 change: 0 additions & 1 deletion EventListener/CacheControlSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ private function setExtraCacheDirectives(Response $response, array $controls, $o
&& ($overwrite || !$response->headers->hasCacheControlDirective($option))
) {
$response->headers->addCacheControlDirective($option, $controls[$key]);

}
}
}
Expand Down
10 changes: 5 additions & 5 deletions EventListener/FlashMessageSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public static function getSubscribedEvents()
);
}

/**
* Moves flash messages from the session to a cookie inside a Response Kernel listener
*
* @param FilterResponseEvent $event
*/
/**
* Moves flash messages from the session to a cookie inside a Response Kernel listener
*
* @param FilterResponseEvent $event
*/
public function onKernelResponse(FilterResponseEvent $event)
{
if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
Expand Down
10 changes: 4 additions & 6 deletions EventListener/InvalidationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class InvalidationSubscriber extends AbstractRuleSubscriber implements EventSubs
/**
* Constructor
*
* @param CacheManager $cacheManager
* @param UrlGeneratorInterface $urlGenerator
* @param ExpressionLanguage $expressionLanguage
* @param CacheManager $cacheManager
* @param UrlGeneratorInterface $urlGenerator
* @param ExpressionLanguage|null $expressionLanguage
*/
public function __construct(
CacheManager $cacheManager,
Expand All @@ -82,8 +82,6 @@ public function __construct(
* HTTP cache.
*
* @param PostResponseEvent $event
*
* @return array Paths that were flushed from the invalidation queue
*/
public function onKernelTerminate(PostResponseEvent $event)
{
Expand Down Expand Up @@ -139,7 +137,7 @@ public static function getSubscribedEvents()
KernelEvents::TERMINATE => 'onKernelTerminate',
KernelEvents::EXCEPTION => 'onKernelException',
ConsoleEvents::TERMINATE => 'onConsoleTerminate',
ConsoleEvents::EXCEPTION => 'onConsoleTerminate'
ConsoleEvents::EXCEPTION => 'onConsoleTerminate',
);
}

Expand Down
6 changes: 3 additions & 3 deletions EventListener/TagSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class TagSubscriber extends AbstractRuleSubscriber implements EventSubscriberInt
/**
* Constructor
*
* @param CacheManager $cacheManager
* @param ExpressionLanguage $expressionLanguage
* @param CacheManager $cacheManager
* @param ExpressionLanguage|null $expressionLanguage
*/
public function __construct(
CacheManager $cacheManager,
Expand Down Expand Up @@ -100,7 +100,7 @@ public function onKernelResponse(FilterResponseEvent $event)
public static function getSubscribedEvents()
{
return array(
KernelEvents::RESPONSE => 'onKernelResponse'
KernelEvents::RESPONSE => 'onKernelResponse',
);
}

Expand Down
5 changes: 2 additions & 3 deletions EventListener/UserContextSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public function __construct(
array $userIdentifierHeaders = array('Cookie', 'Authorization'),
$hashHeader = "X-User-Context-Hash",
$ttl = 0
)
{
) {
if (!count($userIdentifierHeaders)) {
throw new \InvalidArgumentException('The user context must vary on some request headers');
}
Expand Down Expand Up @@ -97,7 +96,7 @@ public function onKernelRequest(GetResponseEvent $event)
// status needs to be 200 as otherwise varnish will not cache the response.
$response = new Response('', 200, array(
$this->hashHeader => $hash,
'Content-Type' => 'application/vnd.fos.user-context-hash'
'Content-Type' => 'application/vnd.fos.user-context-hash',
));

if ($this->ttl > 0) {
Expand Down
2 changes: 1 addition & 1 deletion HttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected function cleanupForwardRequest(Request $forwardReq, Request $originalR
{
$sessionIds = array();
foreach ($originalRequest->cookies as $name => $value) {
if ( $this->isSessionName($name)) {
if ($this->isSessionName($name)) {
$sessionIds[$name] = $value;
$forwardReq->cookies->set($name, $value);
}
Expand Down
2 changes: 1 addition & 1 deletion Security/Http/Logout/ContextInvalidationLogoutHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function logout(Request $request, Response $response, TokenInterface $tok
foreach ($this->userIdentifierHeaders as $header) {
$this->banner->ban(array(
'accept' => $this->acceptHeader,
$header => sprintf('.*%s.*', $sessionId)
$header => sprintf('.*%s.*', $sessionId),
));
}
}
Expand Down
Loading