Skip to content

Commit

Permalink
updated cs rules (php-cs-fixer run)
Browse files Browse the repository at this point in the history
  • Loading branch information
robfrawley committed Sep 20, 2017
1 parent 446ac0e commit e172b74
Show file tree
Hide file tree
Showing 59 changed files with 577 additions and 464 deletions.
47 changes: 34 additions & 13 deletions .php_cs.dist
Expand Up @@ -9,11 +9,7 @@
* file that was distributed with this source code.
*/

use SLLH\StyleCIBridge\ConfigBridge;

require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';

$header = <<<EOF
$header = <<<'EOF'
This file is part of the `liip/LiipImagineBundle` project.
(c) https://github.com/liip/LiipImagineBundle/graphs/contributors
Expand All @@ -22,11 +18,36 @@ For the full copyright and license information, please view the LICENSE.md
file that was distributed with this source code.
EOF;

$config = ConfigBridge::create();
$config
->setRules(array_merge($config->getRules(), array(
'header_comment' => array('header' => $header)
)))
->setUsingCache(false);

return $config;
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'long'),
'combine_consecutive_unsets' => true,
'header_comment' => array('header' => $header),
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => array('syntax' => 'long'),
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'psr4' => true,
'strict_comparison' => true,
'strict_param' => true,
))
->setFinder(
PhpCsFixer\Finder::create()
->name("*.php")
->name("*.twig")
->exclude('vendor/var')
->in(__DIR__)
)
;
9 changes: 9 additions & 0 deletions Async/CacheResolved.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Async;

use Enqueue\Util\JSON;
Expand Down
13 changes: 11 additions & 2 deletions Async/ResolveCache.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Async;

use Enqueue\Util\JSON;
Expand Down Expand Up @@ -74,11 +83,11 @@ public static function jsonDeserialize($json)
{
$data = array_replace(array('path' => null, 'filters' => null, 'force' => false), JSON::decode($json));

if (false == $data['path']) {
if (!$data['path']) {
throw new \LogicException('The message does not contain "path" but it is required.');
}

if (false == (is_null($data['filters']) || is_array($data['filters']))) {
if (false === (null === $data['filters'] || is_array($data['filters']))) {
throw new \LogicException('The message filters could be either null or array.');
}

Expand Down
11 changes: 10 additions & 1 deletion Async/ResolveCacheProcessor.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Async;

use Enqueue\Client\ProducerInterface;
Expand Down Expand Up @@ -72,7 +81,7 @@ public function process(PsrMessage $psrMessage, PsrContext $psrContext)
$this->cacheManager->remove($path, $filter);
}

if (false == $this->cacheManager->isStored($path, $filter)) {
if (false === $this->cacheManager->isStored($path, $filter)) {
$binary = $this->dataManager->find($filter, $path);
$this->cacheManager->store(
$this->filterManager->applyFilter($binary, $filter),
Expand Down
9 changes: 9 additions & 0 deletions Async/Topics.php
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace Liip\ImagineBundle\Async;

class Topics
Expand Down
36 changes: 18 additions & 18 deletions Binary/Loader/AbstractDoctrineLoader.php
Expand Up @@ -36,24 +36,6 @@ public function __construct(ObjectManager $manager, $class = null)
$this->class = $class;
}

/**
* Map the requested path (ie. subpath in the URL) to an id that can be used to lookup the image in the Doctrine store.
*
* @param string $path
*
* @return string
*/
abstract protected function mapPathToId($path);

/**
* Return a stream resource from the Doctrine entity/document with the image content.
*
* @param object $image
*
* @return resource
*/
abstract protected function getStreamFromImage($image);

/**
* {@inheritdoc}
*/
Expand All @@ -75,4 +57,22 @@ public function find($path)

return stream_get_contents($this->getStreamFromImage($image));
}

/**
* Map the requested path (ie. subpath in the URL) to an id that can be used to lookup the image in the Doctrine store.
*
* @param string $path
*
* @return string
*/
abstract protected function mapPathToId($path);

/**
* Return a stream resource from the Doctrine entity/document with the image content.
*
* @param object $image
*
* @return resource
*/
abstract protected function getStreamFromImage($image);
}
2 changes: 1 addition & 1 deletion Binary/Loader/FileSystemLoader.php
Expand Up @@ -52,7 +52,7 @@ public function __construct(MimeTypeGuesserInterface $mimeGuesser, ExtensionGues
if ($locator instanceof LocatorInterface) { // post-1.9.0 behavior
$this->locator = $locator;
} elseif (is_array($locator) || is_string($locator)) { // pre-1.9.0 behaviour
if (count((array) $locator) === 0) {
if (0 === count((array) $locator)) {
throw new InvalidArgumentException('One or more data root paths must be specified.');
}

Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/FlysystemLoader.php
Expand Up @@ -41,7 +41,7 @@ public function __construct(
*/
public function find($path)
{
if ($this->filesystem->has($path) === false) {
if (false === $this->filesystem->has($path)) {
throw new NotLoadableException(sprintf('Source image "%s" not found.', $path));
}

Expand Down
22 changes: 11 additions & 11 deletions Binary/Locator/FileSystemLocator.php
Expand Up @@ -76,6 +76,17 @@ public function locate($path)
$path, implode(':', $this->roots)));
}

/**
* @param string $root
* @param string $path
*
* @return string|false
*/
protected function generateAbsolutePath($root, $path)
{
return realpath($root.DIRECTORY_SEPARATOR.$path);
}

/**
* @param string $path
*
Expand Down Expand Up @@ -111,17 +122,6 @@ private function locateUsingRootPlaceholder($path)
$matches['name'], $matches['path']));
}

/**
* @param string $root
* @param string $path
*
* @return string|false
*/
protected function generateAbsolutePath($root, $path)
{
return realpath($root.DIRECTORY_SEPARATOR.$path);
}

/**
* @param string $root
*
Expand Down
12 changes: 6 additions & 6 deletions DependencyInjection/Compiler/MetadataReaderCompilerPass.php
Expand Up @@ -53,20 +53,20 @@ public function process(ContainerBuilder $container)
}

/**
* @param ContainerBuilder $container
*
* @return bool
*/
private function isExifMetadataReaderSet(ContainerBuilder $container)
protected function isExifExtensionLoaded()
{
return $container->getParameter(self::$metadataReaderParameter) === self::$metadataReaderExifClass;
return extension_loaded('exif');
}

/**
* @param ContainerBuilder $container
*
* @return bool
*/
protected function isExifExtensionLoaded()
private function isExifMetadataReaderSet(ContainerBuilder $container)
{
return extension_loaded('exif');
return $container->getParameter(self::$metadataReaderParameter) === self::$metadataReaderExifClass;
}
}
10 changes: 5 additions & 5 deletions DependencyInjection/Configuration.php
Expand Up @@ -79,23 +79,23 @@ public function getConfigTreeBuilder()
$v['loaders'] = array();
}

if (false == is_array($v['loaders'])) {
if (false === is_array($v['loaders'])) {
throw new \LogicException('Loaders has to be array');
}

if (false == array_key_exists('default', $v['loaders'])) {
if (false === array_key_exists('default', $v['loaders'])) {
$v['loaders']['default'] = array('filesystem' => null);
}

if (empty($v['resolvers'])) {
$v['resolvers'] = array();
}

if (false == is_array($v['resolvers'])) {
if (false === is_array($v['resolvers'])) {
throw new \LogicException('Resolvers has to be array');
}

if (false == array_key_exists('default', $v['resolvers'])) {
if (false === array_key_exists('default', $v['resolvers'])) {
$v['resolvers']['default'] = array('web_path' => null);
}

Expand All @@ -110,7 +110,7 @@ public function getConfigTreeBuilder()
->scalarNode('driver')->defaultValue('gd')
->validate()
->ifTrue(function ($v) {
return !in_array($v, array('gd', 'imagick', 'gmagick'));
return !in_array($v, array('gd', 'imagick', 'gmagick'), true);
})
->thenInvalid('Invalid imagine driver specified: %s')
->end()
Expand Down
Expand Up @@ -104,7 +104,7 @@ private function resolveDataRoots(array $staticPaths, array $config, ContainerBu
$resourcePaths = array();

foreach ($this->getBundleResourcePaths($container) as $name => $path) {
if (('whitelist' === $config['access_control_type']) === in_array($name, $config['access_control_list']) && is_dir($path)) {
if (('whitelist' === $config['access_control_type']) === in_array($name, $config['access_control_list'], true) && is_dir($path)) {
$resourcePaths[$name] = $path;
}
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ public function __construct($message, array $options = array())
*/
private function stringifyOptions(array $options = array())
{
if (count($options) === 0) {
if (0 === count($options)) {
return '[]';
}

Expand Down

0 comments on commit e172b74

Please sign in to comment.