Skip to content

Commit

Permalink
apply cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Aug 3, 2019
1 parent 33c290f commit db8c347
Show file tree
Hide file tree
Showing 50 changed files with 381 additions and 384 deletions.
6 changes: 3 additions & 3 deletions Async/ResolveCache.php
Expand Up @@ -22,7 +22,7 @@ class ResolveCache implements \JsonSerializable
private $path;

/**
* @var array|null|\string[]
* @var array|\string[]|null
*/
private $filters;

Expand Down Expand Up @@ -52,7 +52,7 @@ public function getPath(): string
}

/**
* @return null|\string[]
* @return \string[]|null
*/
public function getFilters()
{
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function jsonDeserialize(string $json): self
throw new LogicException('The message does not contain "path" but it is required.');
}

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

Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/ChainLoader.php
Expand Up @@ -68,7 +68,7 @@ private static function getLoaderExceptionMessage(string $path, array $exception
return vsprintf('Source image not resolvable "%s" using "%s" %d loaders (internal exceptions: %s).', [
$path,
implode(', ', $loaders),
count($loaders),
\count($loaders),
implode(', ', $exceptions),
]);
}
Expand Down
2 changes: 1 addition & 1 deletion Binary/Loader/StreamLoader.php
Expand Up @@ -39,7 +39,7 @@ public function __construct($wrapperPrefix, $context = null)
{
$this->wrapperPrefix = $wrapperPrefix;

if ($context && !is_resource($context)) {
if ($context && !\is_resource($context)) {
throw new \InvalidArgumentException('The given context is no valid resource.');
}

Expand Down
2 changes: 1 addition & 1 deletion Binary/Locator/FileSystemLocator.php
Expand Up @@ -131,7 +131,7 @@ private function sanitizeAbsolutePath(string $path): string
return 0 === mb_strpos($path, $root);
});

if (0 === count($roots)) {
if (0 === \count($roots)) {
throw new NotLoadableException(
sprintf('Source image invalid "%s" as it is outside of the defined root path(s) "%s"', $path, implode(':', $this->roots))
);
Expand Down
2 changes: 1 addition & 1 deletion Controller/ImagineController.php
Expand Up @@ -110,7 +110,7 @@ public function filterRuntimeAction(Request $request, $hash, $path, $filter)
$resolver = $request->get('resolver');
$runtimeConfig = $request->query->get('filters', []);

if (!is_array($runtimeConfig)) {
if (!\is_array($runtimeConfig)) {
throw new NotFoundHttpException(sprintf('Filters must be an array. Value was "%s"', $runtimeConfig));
}

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/FiltersCompilerPass.php
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.filter.loader');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
$manager = $container->getDefinition('liip_imagine.filter.manager');

foreach ($tags as $id => $tag) {
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/LoadersCompilerPass.php
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.binary.loader');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.data.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.data.manager')) {
$manager = $container->getDefinition('liip_imagine.data.manager');

foreach ($tags as $id => $tag) {
Expand Down
Expand Up @@ -53,7 +53,7 @@ public function process(ContainerBuilder $container): void
*/
protected function isExifExtensionLoaded(): bool
{
return extension_loaded('exif');
return \extension_loaded('exif');
}

/**
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.filter.post_processor');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.filter.manager')) {
$manager = $container->getDefinition('liip_imagine.filter.manager');

foreach ($tags as $id => $tag) {
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Compiler/ResolversCompilerPass.php
Expand Up @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container)
{
$tags = $container->findTaggedServiceIds('liip_imagine.cache.resolver');

if (count($tags) > 0 && $container->hasDefinition('liip_imagine.cache.manager')) {
if (\count($tags) > 0 && $container->hasDefinition('liip_imagine.cache.manager')) {
$manager = $container->getDefinition('liip_imagine.cache.manager');

foreach ($tags as $id => $tag) {
Expand Down
10 changes: 5 additions & 5 deletions DependencyInjection/Configuration.php
Expand Up @@ -77,23 +77,23 @@ public function getConfigTreeBuilder()
$v['loaders'] = [];
}

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'] = ['filesystem' => null];
}

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

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'] = ['web_path' => null];
}

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

foreach ($this->getBundleResourcePaths($container) as $name => $path) {
if (('whitelist' === $config['access_control_type']) === in_array($name, $config['access_control_list'], true) && 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 @@ -159,7 +159,7 @@ private function getBundlePathsUsingNamedObj(array $classes)
throw new InvalidArgumentException(sprintf('Unable to resolve bundle "%s" while auto-registering bundle resource paths.', $c), null, $exception);
}

$paths[$r->getShortName()] = dirname($r->getFileName());
$paths[$r->getShortName()] = \dirname($r->getFileName());
}

return $paths;
Expand Down
2 changes: 1 addition & 1 deletion Events/CacheResolveEvent.php
Expand Up @@ -41,7 +41,7 @@ class CacheResolveEvent extends Event
*
* @param string $path
* @param string $filter
* @param null|string $url
* @param string|null $url
*/
public function __construct($path, $filter, $url = null)
{
Expand Down
4 changes: 2 additions & 2 deletions Imagine/Cache/CacheManager.php
Expand Up @@ -226,10 +226,10 @@ public function remove($paths = null, $filters = null)
{
if (null === $filters) {
$filters = array_keys($this->filterConfig->all());
} elseif (!is_array($filters)) {
} elseif (!\is_array($filters)) {
$filters = [$filters];
}
if (!is_array($paths)) {
if (!\is_array($paths)) {
$paths = [$paths];
}

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Cache/Resolver/AbstractFilesystemResolver.php
Expand Up @@ -165,7 +165,7 @@ protected function getRequest()
protected function makeFolder($dir)
{
if (!is_dir($dir)) {
$parent = dirname($dir);
$parent = \dirname($dir);
try {
$this->makeFolder($parent);
$this->filesystem->mkdir($dir);
Expand Down
4 changes: 2 additions & 2 deletions Imagine/Cache/Resolver/CacheResolver.php
Expand Up @@ -212,7 +212,7 @@ protected function saveToCache($cacheKey, $content)
if ($this->cache->contains($indexKey)) {
$index = (array) $this->cache->fetch($indexKey);

if (!in_array($cacheKey, $index, true)) {
if (!\in_array($cacheKey, $index, true)) {
$index[] = $cacheKey;
}
} else {
Expand All @@ -236,7 +236,7 @@ protected function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'global_prefix' => 'liip_imagine.resolver_cache',
'prefix' => get_class($this->resolver),
'prefix' => \get_class($this->resolver),
'index_key' => 'index',
]);

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Filter/FilterConfiguration.php
Expand Up @@ -39,7 +39,7 @@ public function __construct(array $filters = [])
*/
public function get($filter)
{
if (false === array_key_exists($filter, $this->filters)) {
if (false === \array_key_exists($filter, $this->filters)) {
throw new NonExistingFilterException(sprintf('Could not find configuration for a filter: %s', $filter));
}

Expand Down
4 changes: 2 additions & 2 deletions Imagine/Filter/FilterManager.php
Expand Up @@ -221,7 +221,7 @@ private function sanitizeFilters(array $filters): array
return isset($this->loaders[$name]);
}, ARRAY_FILTER_USE_KEY);

if (count($filters) !== count($sanitized)) {
if (\count($filters) !== \count($sanitized)) {
throw new \InvalidArgumentException(sprintf('Could not find filter(s): %s', implode(', ', array_map(function (string $name): string {
return sprintf('"%s"', $name);
}, array_diff(array_keys($filters), array_keys($sanitized))))));
Expand All @@ -241,7 +241,7 @@ private function sanitizePostProcessors(array $processors): array
return isset($this->postProcessors[$name]);
}, ARRAY_FILTER_USE_KEY);

if (count($processors) !== count($sanitized)) {
if (\count($processors) !== \count($sanitized)) {
throw new \InvalidArgumentException(sprintf('Could not find post processor(s): %s', implode(', ', array_map(function (string $name): string {
return sprintf('"%s"', $name);
}, array_diff(array_keys($processors), array_keys($sanitized))))));
Expand Down
2 changes: 1 addition & 1 deletion Imagine/Filter/Loader/AutoRotateFilterLoader.php
Expand Up @@ -104,6 +104,6 @@ private function getOrientation(ImageInterface $image)
*/
private function isFlipped($orientation)
{
return in_array((int) $orientation, [2, 4, 5, 7], true);
return \in_array((int) $orientation, [2, 4, 5, 7], true);
}
}
4 changes: 2 additions & 2 deletions Imagine/Filter/Loader/FixedFilterLoader.php
Expand Up @@ -31,10 +31,10 @@ class FixedFilterLoader implements LoaderInterface
*
* @return ImageInterface
*/
public function load(ImageInterface $image, array $options = array())
public function load(ImageInterface $image, array $options = [])
{
$optionsResolver = new OptionsResolver();
$optionsResolver->setRequired(array('width', 'height'));
$optionsResolver->setRequired(['width', 'height']);
$options = $optionsResolver->resolve($options);

// get the original image size and create a crop box
Expand Down
30 changes: 15 additions & 15 deletions Imagine/Filter/Loader/ResampleFilterLoader.php
Expand Up @@ -15,9 +15,9 @@
use Imagine\Image\ImagineInterface;
use Liip\ImagineBundle\Exception\Imagine\Filter\LoadFilterException;
use Liip\ImagineBundle\Exception\InvalidArgumentException;
use Symfony\Component\OptionsResolver\Exception\ExceptionInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\Exception\ExceptionInterface;

class ResampleFilterLoader implements LoaderInterface
{
Expand All @@ -42,7 +42,7 @@ public function __construct(ImagineInterface $imagine)
*
* @return ImageInterface
*/
public function load(ImageInterface $image, array $options = array())
public function load(ImageInterface $image, array $options = [])
{
$options = $this->resolveOptions($options);
$tmpFile = $this->getTemporaryFile($options['temp_dir']);
Expand Down Expand Up @@ -94,11 +94,11 @@ private function delTemporaryFile($file)
*/
private function getImagineSaveOptions(array $options)
{
$saveOptions = array(
$saveOptions = [
'resolution-units' => $options['unit'],
'resolution-x' => $options['x'],
'resolution-y' => $options['y'],
);
];

if (isset($options['filter'])) {
$saveOptions['resampling-filter'] = $options['filter'];
Expand All @@ -116,25 +116,25 @@ private function resolveOptions(array $options)
{
$resolver = new OptionsResolver();

$resolver->setRequired(array('x', 'y', 'unit', 'temp_dir'));
$resolver->setDefined(array('filter'));
$resolver->setRequired(['x', 'y', 'unit', 'temp_dir']);
$resolver->setDefined(['filter']);
$resolver->setDefault('temp_dir', sys_get_temp_dir());
$resolver->setDefault('filter', 'UNDEFINED');

$resolver->setAllowedTypes('x', array('int', 'float'));
$resolver->setAllowedTypes('y', array('int', 'float'));
$resolver->setAllowedTypes('temp_dir', array('string'));
$resolver->setAllowedTypes('filter', array('string'));
$resolver->setAllowedTypes('x', ['int', 'float']);
$resolver->setAllowedTypes('y', ['int', 'float']);
$resolver->setAllowedTypes('temp_dir', ['string']);
$resolver->setAllowedTypes('filter', ['string']);

$resolver->setAllowedValues('unit', array(
$resolver->setAllowedValues('unit', [
ImageInterface::RESOLUTION_PIXELSPERINCH,
ImageInterface::RESOLUTION_PIXELSPERCENTIMETER,
));
]);

$resolver->setNormalizer('filter', function (Options $options, $value) {
foreach (array('\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '%s') as $format) {
if (defined($constant = sprintf($format, strtoupper($value))) || defined($constant = sprintf($format, $value))) {
return constant($constant);
foreach (['\Imagine\Image\ImageInterface::FILTER_%s', '\Imagine\Image\ImageInterface::%s', '%s'] as $format) {
if (\defined($constant = sprintf($format, mb_strtoupper($value))) || \defined($constant = sprintf($format, $value))) {
return \constant($constant);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Imagine/Filter/Loader/ThumbnailFilterLoader.php
Expand Up @@ -28,7 +28,7 @@ public function load(ImageInterface $image, array $options = [])
}

if (!empty($options['filter'])) {
$filter = constant('Imagine\Image\ImageInterface::FILTER_'.mb_strtoupper($options['filter']));
$filter = \constant('Imagine\Image\ImageInterface::FILTER_'.mb_strtoupper($options['filter']));
}
if (empty($filter)) {
$filter = ImageInterface::FILTER_UNDEFINED;
Expand Down
10 changes: 5 additions & 5 deletions Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php
Expand Up @@ -122,28 +122,28 @@ public function setStripAll($stripAll)
public function process(BinaryInterface $binary, array $options = []): BinaryInterface
{
$type = mb_strtolower($binary->getMimeType());
if (!in_array($type, ['image/jpeg', 'image/jpg'], true)) {
if (!\in_array($type, ['image/jpeg', 'image/jpg'], true)) {
return $binary;
}

$tempDir = array_key_exists('temp_dir', $options) ? $options['temp_dir'] : $this->tempDir;
$tempDir = \array_key_exists('temp_dir', $options) ? $options['temp_dir'] : $this->tempDir;
if (false === $input = tempnam($tempDir, 'imagine_jpegoptim')) {
throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', $tempDir));
}

$processArguments = [$this->jpegoptimBin];

$stripAll = array_key_exists('strip_all', $options) ? $options['strip_all'] : $this->stripAll;
$stripAll = \array_key_exists('strip_all', $options) ? $options['strip_all'] : $this->stripAll;
if ($stripAll) {
$processArguments[] = '--strip-all';
}

$max = array_key_exists('max', $options) ? $options['max'] : $this->max;
$max = \array_key_exists('max', $options) ? $options['max'] : $this->max;
if ($max) {
$processArguments[] = '--max='.$max;
}

$progressive = array_key_exists('progressive', $options) ? $options['progressive'] : $this->progressive;
$progressive = \array_key_exists('progressive', $options) ? $options['progressive'] : $this->progressive;
if ($progressive) {
$processArguments[] = '--all-progressive';
} else {
Expand Down

0 comments on commit db8c347

Please sign in to comment.