Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
soullivaneuh committed Nov 2, 2017
1 parent 46147c8 commit 2c61a87
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Block/BlockContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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] = [
Expand Down
2 changes: 1 addition & 1 deletion Block/Service/ContainerBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}

Expand Down
4 changes: 2 additions & 2 deletions Block/Service/MenuBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -155,7 +155,7 @@ protected function getFormSettingsKeys()

$choices = $this->menus;

if (count($choices) == 0) {
if (0 == count($choices)) {
$choices = $this->menuRegistry->getAliasNames();
}

Expand Down
4 changes: 2 additions & 2 deletions Cache/HttpCacheHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/TweakCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/SonataBlockExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion Event/TextBlockListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<p class='well'>The admin subject is <strong>%s</strong></p>", $admin->toString($admin->getSubject()));
Expand Down
2 changes: 1 addition & 1 deletion Profiler/DataCollector/BlockDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2c61a87

Please sign in to comment.