From 2c61a87a2a29d3584d5bb823ce2b4096766c8a5b Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Thu, 2 Nov 2017 07:41:46 +0000 Subject: [PATCH] Apply fixes from StyleCI --- Block/BlockContextManager.php | 6 +++--- Block/Service/ContainerBlockService.php | 2 +- Block/Service/MenuBlockService.php | 4 ++-- Cache/HttpCacheHandler.php | 4 ++-- DependencyInjection/Compiler/TweakCompilerPass.php | 2 +- DependencyInjection/Configuration.php | 2 +- DependencyInjection/SonataBlockExtension.php | 2 +- Event/TextBlockListener.php | 2 +- Profiler/DataCollector/BlockDataCollector.php | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Block/BlockContextManager.php b/Block/BlockContextManager.php index d39ee3fc..5bc8ca05 100644 --- a/Block/BlockContextManager.php +++ b/Block/BlockContextManager.php @@ -166,7 +166,7 @@ public function get($meta, array $settings = []) */ protected function setDefaultSettings(OptionsResolverInterface $optionsResolver, BlockInterface $block) { - if (get_called_class() !== __CLASS__) { + if (__CLASS__ !== get_called_class()) { @trigger_error( 'The '.__METHOD__.' is deprecated since version 2.3, to be renamed in 4.0.' .' Use '.__CLASS__.'::configureSettings instead.', @@ -279,14 +279,14 @@ private function resolve(BlockInterface $block, $settings) $serviceClass = get_class($service); if (!isset($this->reflectionCache[$serviceClass])) { $reflector = new \ReflectionMethod($service, 'setDefaultSettings'); - $isOldOverwritten = $reflector->getDeclaringClass()->getName() !== 'Sonata\BlockBundle\Block\AbstractBlockService'; + $isOldOverwritten = 'Sonata\BlockBundle\Block\AbstractBlockService' !== $reflector->getDeclaringClass()->getName(); // Prevention for service classes implementing directly the interface and not extends the new base class if (!method_exists($service, 'configureSettings')) { $isNewOverwritten = false; } else { $reflector = new \ReflectionMethod($service, 'configureSettings'); - $isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Sonata\BlockBundle\Block\AbstractBlockService'; + $isNewOverwritten = 'Sonata\BlockBundle\Block\AbstractBlockService' !== $reflector->getDeclaringClass()->getName(); } $this->reflectionCache[$serviceClass] = [ diff --git a/Block/Service/ContainerBlockService.php b/Block/Service/ContainerBlockService.php index 87bc14b0..742f5770 100644 --- a/Block/Service/ContainerBlockService.php +++ b/Block/Service/ContainerBlockService.php @@ -94,7 +94,7 @@ public function getBlockMetadata($code = null) protected function getDecorator($layout) { $key = '{{ CONTENT }}'; - if (strpos($layout, $key) === false) { + if (false === strpos($layout, $key)) { return []; } diff --git a/Block/Service/MenuBlockService.php b/Block/Service/MenuBlockService.php index 0efc64a1..32ce4846 100644 --- a/Block/Service/MenuBlockService.php +++ b/Block/Service/MenuBlockService.php @@ -105,7 +105,7 @@ public function buildEditForm(FormMapper $form, BlockInterface $block) */ public function validateBlock(ErrorElement $errorElement, BlockInterface $block) { - if (($name = $block->getSetting('menu_name')) && $name !== '' && !$this->menuProvider->has($name)) { + if (($name = $block->getSetting('menu_name')) && '' !== $name && !$this->menuProvider->has($name)) { // If we specified a menu_name, check that it exists $errorElement->with('menu_name') ->addViolation('sonata.block.menu.not_existing', ['name' => $name]) @@ -155,7 +155,7 @@ protected function getFormSettingsKeys() $choices = $this->menus; - if (count($choices) == 0) { + if (0 == count($choices)) { $choices = $this->menuRegistry->getAliasNames(); } diff --git a/Cache/HttpCacheHandler.php b/Cache/HttpCacheHandler.php index 1f6f2a60..eb859fd2 100644 --- a/Cache/HttpCacheHandler.php +++ b/Cache/HttpCacheHandler.php @@ -49,11 +49,11 @@ public function alterResponse(Response $response) */ public function updateMetadata(Response $response, BlockContextInterface $blockContext = null) { - if ($this->currentTtl === null) { + if (null === $this->currentTtl) { $this->currentTtl = $response->getTtl(); } - if ($response->isCacheable() !== null && $response->getTtl() < $this->currentTtl) { + if (null !== $response->isCacheable() && $response->getTtl() < $this->currentTtl) { $this->currentTtl = $response->getTtl(); } } diff --git a/DependencyInjection/Compiler/TweakCompilerPass.php b/DependencyInjection/Compiler/TweakCompilerPass.php index a3742f90..620226fd 100644 --- a/DependencyInjection/Compiler/TweakCompilerPass.php +++ b/DependencyInjection/Compiler/TweakCompilerPass.php @@ -38,7 +38,7 @@ public function process(ContainerBuilder $container) $arguments = $definition->getArguments(); // Replace empty block id with service id - if (empty($arguments) || strlen($arguments[0]) == 0) { + if (empty($arguments) || 0 == strlen($arguments[0])) { $definition->setArgument(0, $id); } elseif ($id != $arguments[0] && 0 !== strpos( $container->getParameterBag()->resolveValue($definition->getClass()), diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2b62ff4a..2e3e09b7 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -51,7 +51,7 @@ public function getConfigTreeBuilder() ->validate() ->always(function ($value) { foreach ($value['blocks'] as $name => &$block) { - if (count($block['contexts']) == 0) { + if (0 == count($block['contexts'])) { $block['contexts'] = $value['default_contexts']; } } diff --git a/DependencyInjection/SonataBlockExtension.php b/DependencyInjection/SonataBlockExtension.php index 340ed3bc..bfcc1c12 100644 --- a/DependencyInjection/SonataBlockExtension.php +++ b/DependencyInjection/SonataBlockExtension.php @@ -187,7 +187,7 @@ public function configureForm(ContainerBuilder $container, array $config) $contexts = []; foreach ($config['blocks'] as $service => $settings) { - if (count($settings['contexts']) == 0) { + if (0 == count($settings['contexts'])) { $settings['contexts'] = $defaults; } diff --git a/Event/TextBlockListener.php b/Event/TextBlockListener.php index 78e13e44..665b4c89 100644 --- a/Event/TextBlockListener.php +++ b/Event/TextBlockListener.php @@ -34,7 +34,7 @@ class TextBlockListener public function onBlock(BlockEvent $event) { $content = 'This block is coming from inline event from the template'; - if ($event->getSetting('admin') instanceof AdminInterface && $event->getSetting('action') == 'edit') { + if ($event->getSetting('admin') instanceof AdminInterface && 'edit' == $event->getSetting('action')) { $admin = $event->getSetting('admin'); $content = sprintf("

The admin subject is %s

", $admin->toString($admin->getSubject())); diff --git a/Profiler/DataCollector/BlockDataCollector.php b/Profiler/DataCollector/BlockDataCollector.php index 2e940fc8..6cd3fc9f 100644 --- a/Profiler/DataCollector/BlockDataCollector.php +++ b/Profiler/DataCollector/BlockDataCollector.php @@ -76,7 +76,7 @@ public function collect(Request $request, Response $response, \Exception $except return; // something went wrong while collecting information } - if ($id == '_events') { + if ('_events' == $id) { foreach ($block as $uniqid => $event) { $this->events[$uniqid] = $event; }