diff --git a/composer.json b/composer.json index 80755d757..e1f841f07 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ } ], "require": { - "php": ">=5.3.1", - "symfony/process": "~2.1|~3.0" + "php": ">=7.1", + "symfony/process": "~4.0" }, "conflict": { "twig/twig": "<1.27" @@ -29,7 +29,7 @@ "phpunit/phpunit": "~4.8 || ^5.6", "psr/log": "~1.0", "ptachoire/cssembed": "~1.0", - "symfony/phpunit-bridge": "~2.7|~3.0", + "symfony/phpunit-bridge": "~4.0", "twig/twig": "~1.23|~2.0", "yfix/packager": "dev-master" }, diff --git a/src/Assetic/Asset/AssetCache.php b/src/Assetic/Asset/AssetCache.php index 7ce62b5ca..60a3c1287 100644 --- a/src/Assetic/Asset/AssetCache.php +++ b/src/Assetic/Asset/AssetCache.php @@ -157,11 +157,10 @@ private static function getCacheKey(AssetInterface $asset, FilterInterface $addi $cacheKey .= $asset->getLastModified(); foreach ($asset->getFilters() as $filter) { - if ($filter instanceof HashableInterface) { - $cacheKey .= $filter->hash(); - } else { - $cacheKey .= serialize($filter); - } + + $cacheKey .= $filter instanceof HashableInterface + ? $filter->hash() + : serialize($filter); } if ($values = $asset->getValues()) { diff --git a/src/Assetic/Asset/AssetCollection.php b/src/Assetic/Asset/AssetCollection.php index 3141af58b..532e8d3b7 100644 --- a/src/Assetic/Asset/AssetCollection.php +++ b/src/Assetic/Asset/AssetCollection.php @@ -40,9 +40,9 @@ class AssetCollection implements \IteratorAggregate, AssetCollectionInterface * @param string $sourceRoot The root directory * @param array $vars */ - public function __construct($assets = array(), $filters = array(), $sourceRoot = null, array $vars = array()) + public function __construct($assets = [], $filters = [], $sourceRoot = null, array $vars = []) { - $this->assets = array(); + $this->assets = []; foreach ($assets as $asset) { $this->add($asset); } @@ -51,7 +51,7 @@ public function __construct($assets = array(), $filters = array(), $sourceRoot = $this->sourceRoot = $sourceRoot; $this->clones = new \SplObjectStorage(); $this->vars = $vars; - $this->values = array(); + $this->values = []; } public function __clone() @@ -73,8 +73,8 @@ public function add(AssetInterface $asset) public function removeLeaf(AssetInterface $needle, $graceful = false) { foreach ($this->assets as $i => $asset) { - $clone = isset($this->clones[$asset]) ? $this->clones[$asset] : null; - if (in_array($needle, array($asset, $clone), true)) { + $clone = $this->clones[$asset] ?? null; + if (in_array($needle, [$asset, $clone], true)) { unset($this->clones[$asset], $this->assets[$i]); return true; @@ -95,8 +95,8 @@ public function removeLeaf(AssetInterface $needle, $graceful = false) public function replaceLeaf(AssetInterface $needle, AssetInterface $replacement, $graceful = false) { foreach ($this->assets as $i => $asset) { - $clone = isset($this->clones[$asset]) ? $this->clones[$asset] : null; - if (in_array($needle, array($asset, $clone), true)) { + $clone = $this->clones[$asset] ?? null; + if (in_array($needle, [$asset, $clone], true)) { unset($this->clones[$asset]); $this->assets[$i] = $replacement; @@ -134,7 +134,7 @@ public function clearFilters() public function load(FilterInterface $additionalFilter = null) { // loop through leaves and load each asset - $parts = array(); + $parts = []; foreach ($this as $asset) { $asset->load($additionalFilter); $parts[] = $asset->getContent(); @@ -146,7 +146,7 @@ public function load(FilterInterface $additionalFilter = null) public function dump(FilterInterface $additionalFilter = null) { // loop through leaves and dump each asset - $parts = array(); + $parts = []; foreach ($this as $asset) { $parts[] = $asset->dump($additionalFilter); } diff --git a/src/Assetic/Asset/AssetReference.php b/src/Assetic/Asset/AssetReference.php index f66b7695e..961614d04 100644 --- a/src/Assetic/Asset/AssetReference.php +++ b/src/Assetic/Asset/AssetReference.php @@ -23,7 +23,7 @@ class AssetReference implements AssetInterface { private $am; private $name; - private $filters = array(); + private $filters = []; private $clone = false; private $asset; @@ -56,7 +56,7 @@ public function getFilters() public function clearFilters() { - $this->filters = array(); + $this->filters = []; $this->callAsset(__FUNCTION__); } @@ -64,14 +64,14 @@ public function load(FilterInterface $additionalFilter = null) { $this->flushFilters(); - return $this->callAsset(__FUNCTION__, array($additionalFilter)); + return $this->callAsset(__FUNCTION__, [$additionalFilter]); } public function dump(FilterInterface $additionalFilter = null) { $this->flushFilters(); - return $this->callAsset(__FUNCTION__, array($additionalFilter)); + return $this->callAsset(__FUNCTION__, [$additionalFilter]); } public function getContent() @@ -81,7 +81,7 @@ public function getContent() public function setContent($content) { - $this->callAsset(__FUNCTION__, array($content)); + $this->callAsset(__FUNCTION__, [$content]); } public function getSourceRoot() @@ -106,7 +106,7 @@ public function getTargetPath() public function setTargetPath($targetPath) { - $this->callAsset(__FUNCTION__, array($targetPath)); + $this->callAsset(__FUNCTION__, [$targetPath]); } public function getLastModified() @@ -126,16 +126,16 @@ public function getValues() public function setValues(array $values) { - $this->callAsset(__FUNCTION__, array($values)); + $this->callAsset(__FUNCTION__, [$values]); } // private - private function callAsset($method, $arguments = array()) + private function callAsset($method, $arguments = []) { $asset = $this->resolve(); - return call_user_func_array(array($asset, $method), $arguments); + return call_user_func_array([$asset, $method], $arguments); } private function flushFilters() diff --git a/src/Assetic/Asset/BaseAsset.php b/src/Assetic/Asset/BaseAsset.php index 093b92a81..fd545e207 100644 --- a/src/Assetic/Asset/BaseAsset.php +++ b/src/Assetic/Asset/BaseAsset.php @@ -42,7 +42,7 @@ abstract class BaseAsset implements AssetInterface * @param string $sourcePath The asset path * @param array $vars */ - public function __construct($filters = array(), $sourceRoot = null, $sourcePath = null, array $vars = array()) + public function __construct($filters = [], $sourceRoot = null, $sourcePath = null, array $vars = []) { $this->filters = new FilterCollection($filters); $this->sourceRoot = $sourceRoot; @@ -51,7 +51,7 @@ public function __construct($filters = array(), $sourceRoot = null, $sourcePath $this->sourceDir = dirname("$sourceRoot/$sourcePath"); } $this->vars = $vars; - $this->values = array(); + $this->values = []; $this->loaded = false; } diff --git a/src/Assetic/Asset/FileAsset.php b/src/Assetic/Asset/FileAsset.php index 2a33e0803..a24c2ccb9 100644 --- a/src/Assetic/Asset/FileAsset.php +++ b/src/Assetic/Asset/FileAsset.php @@ -34,7 +34,7 @@ class FileAsset extends BaseAsset * * @throws \InvalidArgumentException If the supplied root doesn't match the source when guessing the path */ - public function __construct($source, $filters = array(), $sourceRoot = null, $sourcePath = null, array $vars = array()) + public function __construct($source, $filters = [], $sourceRoot = null, $sourcePath = null, array $vars = []) { if (null === $sourceRoot) { $sourceRoot = dirname($source); diff --git a/src/Assetic/Asset/GlobAsset.php b/src/Assetic/Asset/GlobAsset.php index 6444e612b..42ce8852f 100644 --- a/src/Assetic/Asset/GlobAsset.php +++ b/src/Assetic/Asset/GlobAsset.php @@ -32,12 +32,12 @@ class GlobAsset extends AssetCollection * @param string $root The root directory * @param array $vars */ - public function __construct($globs, $filters = array(), $root = null, array $vars = array()) + public function __construct($globs, $filters = [], $root = null, array $vars = []) { $this->globs = (array) $globs; $this->initialized = false; - parent::__construct(array(), $filters, $root, $vars); + parent::__construct([], $filters, $root, $vars); } public function all() @@ -102,7 +102,7 @@ private function initialize() if (false !== $paths = glob($glob)) { foreach ($paths as $path) { if (is_file($path)) { - $asset = new FileAsset($path, array(), $this->getSourceRoot(), null, $this->getVars()); + $asset = new FileAsset($path, [], $this->getSourceRoot(), null, $this->getVars()); $asset->setValues($this->getValues()); $this->add($asset); } diff --git a/src/Assetic/Asset/HttpAsset.php b/src/Assetic/Asset/HttpAsset.php index cd56761ff..d13739b7e 100644 --- a/src/Assetic/Asset/HttpAsset.php +++ b/src/Assetic/Asset/HttpAsset.php @@ -34,7 +34,7 @@ class HttpAsset extends BaseAsset * * @throws \InvalidArgumentException If the first argument is not an URL */ - public function __construct($sourceUrl, $filters = array(), $ignoreErrors = false, array $vars = array()) + public function __construct($sourceUrl, $filters = [], $ignoreErrors = false, array $vars = []) { if (0 === strpos($sourceUrl, '//')) { $sourceUrl = 'http:'.$sourceUrl; @@ -66,7 +66,7 @@ public function load(FilterInterface $additionalFilter = null) public function getLastModified() { - if (false !== @file_get_contents($this->sourceUrl, false, stream_context_create(array('http' => array('method' => 'HEAD'))))) { + if (false !== @file_get_contents($this->sourceUrl, false, stream_context_create(['http' => ['method' => 'HEAD']]))) { foreach ($http_response_header as $header) { if (0 === stripos($header, 'Last-Modified: ')) { list(, $mtime) = explode(':', $header, 2); diff --git a/src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php b/src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php index fae5d134d..2461705aa 100644 --- a/src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php +++ b/src/Assetic/Asset/Iterator/AssetCollectionFilterIterator.php @@ -31,7 +31,7 @@ class AssetCollectionFilterIterator extends \RecursiveFilterIterator * @param array $visited An array of visited asset objects * @param array $sources An array of visited source strings */ - public function __construct(AssetCollectionIterator $iterator, array $visited = array(), array $sources = array()) + public function __construct(AssetCollectionIterator $iterator, array $visited = [], array $sources = []) { parent::__construct($iterator); diff --git a/src/Assetic/Asset/StringAsset.php b/src/Assetic/Asset/StringAsset.php index d9b9a88f7..6312d8d39 100644 --- a/src/Assetic/Asset/StringAsset.php +++ b/src/Assetic/Asset/StringAsset.php @@ -31,7 +31,7 @@ class StringAsset extends BaseAsset * @param string $sourceRoot The source asset root directory * @param string $sourcePath The source asset path */ - public function __construct($content, $filters = array(), $sourceRoot = null, $sourcePath = null) + public function __construct($content, $filters = [], $sourceRoot = null, $sourcePath = null) { $this->string = $content; diff --git a/src/Assetic/AssetManager.php b/src/Assetic/AssetManager.php index 9b8ee1262..9259459cd 100644 --- a/src/Assetic/AssetManager.php +++ b/src/Assetic/AssetManager.php @@ -20,7 +20,7 @@ */ class AssetManager { - private $assets = array(); + private $assets = []; /** * Gets an asset by name. @@ -84,6 +84,6 @@ public function getNames() */ public function clear() { - $this->assets = array(); + $this->assets = []; } } diff --git a/src/Assetic/AssetWriter.php b/src/Assetic/AssetWriter.php index 4f010a487..f9e0d55c9 100644 --- a/src/Assetic/AssetWriter.php +++ b/src/Assetic/AssetWriter.php @@ -33,7 +33,7 @@ class AssetWriter * * @throws \InvalidArgumentException if a variable value is not a string */ - public function __construct($dir, array $values = array()) + public function __construct($dir, array $values = []) { foreach ($values as $var => $vals) { foreach ($vals as $value) { diff --git a/src/Assetic/Cache/ArrayCache.php b/src/Assetic/Cache/ArrayCache.php index 7f357ac43..dadedbf81 100644 --- a/src/Assetic/Cache/ArrayCache.php +++ b/src/Assetic/Cache/ArrayCache.php @@ -18,7 +18,7 @@ */ class ArrayCache implements CacheInterface { - private $cache = array(); + private $cache = []; /** * @see CacheInterface::has() diff --git a/src/Assetic/Extension/Twig/AsseticExtension.php b/src/Assetic/Extension/Twig/AsseticExtension.php index 951e1c882..d45b1c722 100644 --- a/src/Assetic/Extension/Twig/AsseticExtension.php +++ b/src/Assetic/Extension/Twig/AsseticExtension.php @@ -20,33 +20,32 @@ class AsseticExtension extends \Twig_Extension implements \Twig_Extension_Global protected $functions; protected $valueSupplier; - public function __construct(AssetFactory $factory, $functions = array(), ValueSupplierInterface $valueSupplier = null) + public function __construct(AssetFactory $factory, $functions = [], ValueSupplierInterface $valueSupplier = null) { $this->factory = $factory; - $this->functions = array(); + $this->functions = []; $this->valueSupplier = $valueSupplier; foreach ($functions as $function => $options) { - if (is_integer($function) && is_string($options)) { - $this->functions[$options] = array('filter' => $options); - } else { - $this->functions[$function] = $options + array('filter' => $function); - } + + $this->functions[$options] = is_integer($function) && is_string($options) + ? ['filter' => $options] + : $options + ['filter' => $function]; } } public function getTokenParsers() { - return array( + return [ new AsseticTokenParser($this->factory, 'javascripts', 'js/*.js'), new AsseticTokenParser($this->factory, 'stylesheets', 'css/*.css'), new AsseticTokenParser($this->factory, 'image', 'images/*', true), - ); + ]; } public function getFunctions() { - $functions = array(); + $functions = []; foreach ($this->functions as $function => $filter) { $functions[] = new AsseticFilterFunction($function); } @@ -56,12 +55,12 @@ public function getFunctions() public function getGlobals() { - return array( - 'assetic' => array( + return [ + 'assetic' => [ 'debug' => $this->factory->isDebug(), - 'vars' => null !== $this->valueSupplier ? new ValueContainer($this->valueSupplier) : array(), - ), - ); + 'vars' => null !== $this->valueSupplier ? new ValueContainer($this->valueSupplier) : [], + ], + ]; } public function getFilterInvoker($function) diff --git a/src/Assetic/Extension/Twig/AsseticFilterFunction.php b/src/Assetic/Extension/Twig/AsseticFilterFunction.php index 2c2b13c3d..0eeb079f2 100644 --- a/src/Assetic/Extension/Twig/AsseticFilterFunction.php +++ b/src/Assetic/Extension/Twig/AsseticFilterFunction.php @@ -13,12 +13,12 @@ class AsseticFilterFunction extends \Twig_SimpleFunction { - public function __construct($name, $options = array()) + public function __construct($name, $options = []) { - parent::__construct($name, null, array_merge($options, array( - 'needs_environment' => false, + parent::__construct($name, null, array_merge($options, [ + 'needs_environment' => false, 'needs_context' => false, 'node_class' => '\Assetic\Extension\Twig\AsseticFilterNode', - ))); + ])); } } diff --git a/src/Assetic/Extension/Twig/AsseticFilterInvoker.php b/src/Assetic/Extension/Twig/AsseticFilterInvoker.php index 1b70e4347..045271753 100644 --- a/src/Assetic/Extension/Twig/AsseticFilterInvoker.php +++ b/src/Assetic/Extension/Twig/AsseticFilterInvoker.php @@ -26,12 +26,11 @@ public function __construct($factory, $filter) { $this->factory = $factory; + $this->filters = (array) $filter; + $this->options = []; if (is_array($filter) && isset($filter['filter'])) { $this->filters = (array) $filter['filter']; - $this->options = isset($filter['options']) ? (array) $filter['options'] : array(); - } else { - $this->filters = (array) $filter; - $this->options = array(); + $this->options = (array) $filter['options'] ?? []; } } @@ -50,7 +49,7 @@ public function getOptions() return $this->options; } - public function invoke($input, array $options = array()) + public function invoke($input, array $options = []) { $asset = $this->factory->createAsset($input, $this->filters, $options + $this->options); diff --git a/src/Assetic/Extension/Twig/AsseticNode.php b/src/Assetic/Extension/Twig/AsseticNode.php index 950e46cc6..4e159d3f6 100644 --- a/src/Assetic/Extension/Twig/AsseticNode.php +++ b/src/Assetic/Extension/Twig/AsseticNode.php @@ -33,14 +33,14 @@ class AsseticNode extends \Twig_Node * @param integer $lineno The line number * @param string $tag The tag name */ - public function __construct(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) + public function __construct(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = [], $lineno = 0, $tag = null) { - $nodes = array('body' => $body); + $nodes = ['body' => $body]; $attributes = array_replace( - array('debug' => null, 'combine' => null, 'var_name' => 'asset_url'), + ['debug' => null, 'combine' => null, 'var_name' => 'asset_url'], $attributes, - array('asset' => $asset, 'inputs' => $inputs, 'filters' => $filters, 'name' => $name) + ['asset' => $asset, 'inputs' => $inputs, 'filters' => $filters, 'name' => $name] ); parent::__construct($nodes, $attributes, $lineno, $tag); diff --git a/src/Assetic/Extension/Twig/AsseticTokenParser.php b/src/Assetic/Extension/Twig/AsseticTokenParser.php index 614f5675c..b3f05ceaa 100644 --- a/src/Assetic/Extension/Twig/AsseticTokenParser.php +++ b/src/Assetic/Extension/Twig/AsseticTokenParser.php @@ -34,7 +34,7 @@ class AsseticTokenParser extends \Twig_TokenParser * @param Boolean $single Whether to force a single asset * @param array $extensions Additional attribute names to look for */ - public function __construct(AssetFactory $factory, $tag, $output, $single = false, array $extensions = array()) + public function __construct(AssetFactory $factory, $tag, $output, $single = false, array $extensions = []) { $this->factory = $factory; $this->tag = $tag; @@ -45,14 +45,14 @@ public function __construct(AssetFactory $factory, $tag, $output, $single = fals public function parse(\Twig_Token $token) { - $inputs = array(); - $filters = array(); + $inputs = []; + $filters = []; $name = null; - $attributes = array( + $attributes = [ 'output' => $this->output, 'var_name' => 'asset_url', - 'vars' => array(), - ); + 'vars' => [], + ]; $stream = $this->parser->getStream(); while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { @@ -83,12 +83,12 @@ public function parse(\Twig_Token $token) // debug=true $stream->next(); $stream->expect(\Twig_Token::OPERATOR_TYPE, '='); - $attributes['debug'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, array('true', 'false'))->getValue(); + $attributes['debug'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, ['true', 'false'])->getValue(); } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'combine')) { // combine=true $stream->next(); $stream->expect(\Twig_Token::OPERATOR_TYPE, '='); - $attributes['combine'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, array('true', 'false'))->getValue(); + $attributes['combine'] = 'true' == $stream->expect(\Twig_Token::NAME_TYPE, ['true', 'false'])->getValue(); } elseif ($stream->test(\Twig_Token::NAME_TYPE, 'vars')) { // vars=['locale','browser'] $stream->next(); @@ -119,7 +119,7 @@ public function parse(\Twig_Token $token) $stream->expect(\Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'testEndTag'), true); + $body = $this->parser->subparse([$this, 'testEndTag'], true); $stream->expect(\Twig_Token::BLOCK_END_TYPE); @@ -131,7 +131,7 @@ public function parse(\Twig_Token $token) $name = $this->factory->generateAssetName($inputs, $filters, $attributes); } - $asset = $this->factory->createAsset($inputs, $filters, $attributes + array('name' => $name)); + $asset = $this->factory->createAsset($inputs, $filters, $attributes + ['name' => $name]); return $this->createBodyNode($asset, $body, $inputs, $filters, $name, $attributes, $token->getLine(), $this->getTag()); } @@ -143,7 +143,7 @@ public function getTag() public function testEndTag(\Twig_Token $token) { - return $token->test(array('end'.$this->getTag())); + return $token->test(['end'.$this->getTag()]); } /** @@ -158,7 +158,7 @@ public function testEndTag(\Twig_Token $token) * * @return \Twig_Node */ - protected function createBodyNode(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) + protected function createBodyNode(AssetInterface $asset, \Twig_Node $body, array $inputs, array $filters, $name, array $attributes = [], $lineno = 0, $tag = null) { $reflector = new \ReflectionMethod($this, 'createNode'); @@ -185,7 +185,7 @@ protected function createBodyNode(AssetInterface $asset, \Twig_Node $body, array * * @deprecated since 1.3.0, to be removed in 2.0. Use createBodyNode instead. */ - protected function createNode(AssetInterface $asset, \Twig_NodeInterface $body, array $inputs, array $filters, $name, array $attributes = array(), $lineno = 0, $tag = null) + protected function createNode(AssetInterface $asset, \Twig_NodeInterface $body, array $inputs, array $filters, $name, array $attributes = [], $lineno = 0, $tag = null) { @trigger_error(sprintf('The %s method is deprecated since 1.3 and will be removed in 2.0. Use createBodyNode instead.', __METHOD__), E_USER_DEPRECATED); diff --git a/src/Assetic/Extension/Twig/TwigFormulaLoader.php b/src/Assetic/Extension/Twig/TwigFormulaLoader.php index 2c12d7e84..b0b260a83 100644 --- a/src/Assetic/Extension/Twig/TwigFormulaLoader.php +++ b/src/Assetic/Extension/Twig/TwigFormulaLoader.php @@ -41,7 +41,7 @@ public function load(ResourceInterface $resource) $this->logger->error(sprintf('The template "%s" contains an error: %s', $resource, $e->getMessage())); } - return array(); + return []; } return $this->loadNode($nodes); @@ -56,39 +56,39 @@ public function load(ResourceInterface $resource) */ private function loadNode(\Twig_Node $node) { - $formulae = array(); + $formulae = []; if ($node instanceof AsseticNode) { - $formulae[$node->getAttribute('name')] = array( + $formulae[$node->getAttribute('name')] = [ $node->getAttribute('inputs'), $node->getAttribute('filters'), - array( + [ 'output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars'), - ), - ); + ], + ]; } elseif ($node instanceof AsseticFilterNode) { $name = $node->getAttribute('name'); - $arguments = array(); + $arguments = []; foreach ($node->getNode('arguments') as $argument) { $arguments[] = eval('return '.$this->twig->compile($argument).';'); } $invoker = $this->twig->getExtension('Assetic\Extension\Twig\AsseticExtension')->getFilterInvoker($name); - $inputs = isset($arguments[0]) ? (array) $arguments[0] : array(); + $inputs = (array) $arguments[0] ?? []; $filters = $invoker->getFilters(); - $options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array()); + $options = array_replace($invoker->getOptions(), $arguments[1] ?? []); if (!isset($options['name'])) { $options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options); } - $formulae[$options['name']] = array($inputs, $filters, $options); + $formulae[$options['name']] = [$inputs, $filters, $options]; } foreach ($node as $child) { diff --git a/src/Assetic/Factory/AssetFactory.php b/src/Assetic/Factory/AssetFactory.php index e267196ae..473f207db 100644 --- a/src/Assetic/Factory/AssetFactory.php +++ b/src/Assetic/Factory/AssetFactory.php @@ -48,7 +48,7 @@ public function __construct($root, $debug = false) $this->root = rtrim($root, '/'); $this->debug = $debug; $this->output = 'assetic/*'; - $this->workers = array(); + $this->workers = []; } /** @@ -150,14 +150,14 @@ public function setFilterManager(FilterManager $fm) * * @return AssetCollection An asset collection */ - public function createAsset($inputs = array(), $filters = array(), array $options = array()) + public function createAsset($inputs = [], $filters = [], array $options = []) { if (!is_array($inputs)) { - $inputs = array($inputs); + $inputs = [$inputs]; } if (!is_array($filters)) { - $filters = array($filters); + $filters = [$filters]; } if (!isset($options['output'])) { @@ -165,7 +165,7 @@ public function createAsset($inputs = array(), $filters = array(), array $option } if (!isset($options['vars'])) { - $options['vars'] = array(); + $options['vars'] = []; } if (!isset($options['debug'])) { @@ -173,10 +173,10 @@ public function createAsset($inputs = array(), $filters = array(), array $option } if (!isset($options['root'])) { - $options['root'] = array($this->root); + $options['root'] = [$this->root]; } else { if (!is_array($options['root'])) { - $options['root'] = array($options['root']); + $options['root'] = [$options['root']]; } $options['root'][] = $this->root; @@ -186,14 +186,14 @@ public function createAsset($inputs = array(), $filters = array(), array $option $options['name'] = $this->generateAssetName($inputs, $filters, $options); } - $asset = $this->createAssetCollection(array(), $options); - $extensions = array(); + $asset = $this->createAssetCollection([], $options); + $extensions = []; // inner assets foreach ($inputs as $input) { if (is_array($input)) { // nested formula - $asset->add(call_user_func_array(array($this, 'createAsset'), $input)); + $asset->add(call_user_func_array([$this, 'createAsset'], $input)); } else { $asset->add($this->parseInput($input, $options)); $extensions[pathinfo($input, PATHINFO_EXTENSION)] = true; @@ -211,7 +211,7 @@ public function createAsset($inputs = array(), $filters = array(), array $option // append variables if (!empty($options['vars'])) { - $toAdd = array(); + $toAdd = []; foreach ($options['vars'] as $var) { if (false !== strpos($options['output'], '{'.$var.'}')) { continue; @@ -237,9 +237,9 @@ public function createAsset($inputs = array(), $filters = array(), array $option return $this->applyWorkers($asset); } - public function generateAssetName($inputs, $filters, $options = array()) + public function generateAssetName($inputs, $filters, $options = []) { - foreach (array_diff(array_keys($options), array('output', 'debug', 'root')) as $key) { + foreach (array_diff(array_keys($options), ['output', 'debug', 'root']) as $key) { unset($options[$key]); } @@ -251,14 +251,14 @@ public function generateAssetName($inputs, $filters, $options = array()) public function getLastModified(AssetInterface $asset) { $mtime = 0; - foreach ($asset instanceof AssetCollectionInterface ? $asset : array($asset) as $leaf) { + foreach ($asset instanceof AssetCollectionInterface ? $asset : [$asset] as $leaf) { $mtime = max($mtime, $leaf->getLastModified()); if (!$filters = $leaf->getFilters()) { continue; } - $prevFilters = array(); + $prevFilters = []; foreach ($filters as $filter) { $prevFilters[] = $filter; @@ -300,7 +300,7 @@ public function getLastModified(AssetInterface $asset) * * @return AssetInterface An asset */ - protected function parseInput($input, array $options = array()) + protected function parseInput($input, array $options = []) { if ('@' == $input[0]) { return $this->createAssetReference(substr($input, 1)); @@ -329,9 +329,9 @@ protected function parseInput($input, array $options = array()) return $this->createFileAsset($input, $root, $path, $options['vars']); } - protected function createAssetCollection(array $assets = array(), array $options = array()) + protected function createAssetCollection(array $assets = [], array $options = []) { - return new AssetCollection($assets, array(), null, isset($options['vars']) ? $options['vars'] : array()); + return new AssetCollection($assets, [], null, $options['vars'] ?? []); } protected function createAssetReference($name) @@ -345,17 +345,17 @@ protected function createAssetReference($name) protected function createHttpAsset($sourceUrl, $vars) { - return new HttpAsset($sourceUrl, array(), false, $vars); + return new HttpAsset($sourceUrl, [], false, $vars); } protected function createGlobAsset($glob, $root = null, $vars) { - return new GlobAsset($glob, array(), $root, $vars); + return new GlobAsset($glob, [], $root, $vars); } protected function createFileAsset($source, $root = null, $path = null, $vars) { - return new FileAsset($source, array(), $root, $path, $vars); + return new FileAsset($source, [], $root, $path, $vars); } protected function getFilter($name) @@ -397,7 +397,7 @@ private function applyWorkers(AssetCollectionInterface $asset) } } - return $asset instanceof AssetCollectionInterface ? $asset : $this->createAssetCollection(array($asset)); + return $asset instanceof AssetCollectionInterface ? $asset : $this->createAssetCollection([$asset]); } private static function isAbsolutePath($path) diff --git a/src/Assetic/Factory/LazyAssetManager.php b/src/Assetic/Factory/LazyAssetManager.php index bef72e56a..a403100ff 100644 --- a/src/Assetic/Factory/LazyAssetManager.php +++ b/src/Assetic/Factory/LazyAssetManager.php @@ -36,12 +36,12 @@ class LazyAssetManager extends AssetManager * @param AssetFactory $factory The asset factory * @param array $loaders An array of loaders indexed by alias */ - public function __construct(AssetFactory $factory, $loaders = array()) + public function __construct(AssetFactory $factory, $loaders = []) { $this->factory = $factory; - $this->loaders = array(); - $this->resources = array(); - $this->formulae = array(); + $this->loaders = []; + $this->resources = []; + $this->formulae = []; $this->loaded = false; $this->loading = false; @@ -81,7 +81,7 @@ public function addResource(ResourceInterface $resource, $loader) */ public function getResources() { - $resources = array(); + $resources = []; foreach ($this->resources as $r) { $resources = array_merge($resources, $r); } diff --git a/src/Assetic/Factory/Loader/BasePhpFormulaLoader.php b/src/Assetic/Factory/Loader/BasePhpFormulaLoader.php index 4c747dfd7..bd6ef008e 100644 --- a/src/Assetic/Factory/Loader/BasePhpFormulaLoader.php +++ b/src/Assetic/Factory/Loader/BasePhpFormulaLoader.php @@ -28,19 +28,19 @@ abstract class BasePhpFormulaLoader implements FormulaLoaderInterface public function __construct(AssetFactory $factory) { $this->factory = $factory; - $this->prototypes = array(); + $this->prototypes = []; foreach ($this->registerPrototypes() as $prototype => $options) { $this->addPrototype($prototype, $options); } } - public function addPrototype($prototype, array $options = array()) + public function addPrototype($prototype, array $options = []) { $tokens = token_get_all('prototypes[$prototype] = array($tokens, $options); + $this->prototypes[$prototype] = [$tokens, $options]; } public function load(ResourceInterface $resource) @@ -51,10 +51,10 @@ public function load(ResourceInterface $resource) $buffers = array_fill(0, $nbProtos, ''); $bufferLevels = array_fill(0, $nbProtos, 0); - $buffersInWildcard = array(); + $buffersInWildcard = []; $tokens = token_get_all($resource->getContent()); - $calls = array(); + $calls = []; while ($token = array_shift($tokens)) { $current = self::tokenToString($token); @@ -74,7 +74,7 @@ public function load(ResourceInterface $resource) $buffer .= $current; if (!$level) { - $calls[] = array($buffer.';', $options); + $calls[] = [$buffer.';', $options]; $buffer = ''; unset($buffersInWildcard[$i]); } @@ -92,29 +92,29 @@ public function load(ResourceInterface $resource) } } - $formulae = array(); + $formulae = []; foreach ($calls as $call) { - $formulae += call_user_func_array(array($this, 'processCall'), $call); + $formulae += call_user_func_array([$this, 'processCall'], $call); } return $formulae; } - private function processCall($call, array $protoOptions = array()) + private function processCall($call, array $protoOptions = []) { $tmp = FilesystemUtils::createTemporaryFile('php_formula_loader'); - file_put_contents($tmp, implode("\n", array( + file_put_contents($tmp, implode("\n", [ 'registerSetupCode(), $call, 'echo serialize($_call);', - ))); + ])); $args = unserialize(shell_exec('php '.escapeshellarg($tmp))); unlink($tmp); - $inputs = isset($args[0]) ? self::argumentToArray($args[0]) : array(); - $filters = isset($args[1]) ? self::argumentToArray($args[1]) : array(); - $options = isset($args[2]) ? $args[2] : array(); + $inputs = isset($args[0]) ? self::argumentToArray($args[0]) : []; + $filters = isset($args[1]) ? self::argumentToArray($args[1]) : []; + $options = $args[2] ?? []; if (!isset($options['debug'])) { $options['debug'] = $this->factory->isDebug(); @@ -131,7 +131,7 @@ private function processCall($call, array $protoOptions = array()) $options['name'] = $this->factory->generateAssetName($inputs, $filters, $options); } - return array($options['name'] => array($inputs, $filters, $options)); + return [$options['name'] => [$inputs, $filters, $options]]; } /** diff --git a/src/Assetic/Factory/Loader/CachedFormulaLoader.php b/src/Assetic/Factory/Loader/CachedFormulaLoader.php index 9ab002b00..82a1f522a 100644 --- a/src/Assetic/Factory/Loader/CachedFormulaLoader.php +++ b/src/Assetic/Factory/Loader/CachedFormulaLoader.php @@ -48,10 +48,10 @@ public function __construct(FormulaLoaderInterface $loader, ConfigCache $configC public function load(ResourceInterface $resources) { if (!$resources instanceof IteratorResourceInterface) { - $resources = array($resources); + $resources = [$resources]; } - $formulae = array(); + $formulae = []; foreach ($resources as $resource) { $id = (string) $resource; diff --git a/src/Assetic/Factory/Loader/FunctionCallsFormulaLoader.php b/src/Assetic/Factory/Loader/FunctionCallsFormulaLoader.php index 58b56e106..3b5e93f80 100644 --- a/src/Assetic/Factory/Loader/FunctionCallsFormulaLoader.php +++ b/src/Assetic/Factory/Loader/FunctionCallsFormulaLoader.php @@ -20,11 +20,11 @@ class FunctionCallsFormulaLoader extends BasePhpFormulaLoader { protected function registerPrototypes() { - return array( - 'assetic_javascripts(*)' => array('output' => 'js/*.js'), - 'assetic_stylesheets(*)' => array('output' => 'css/*.css'), - 'assetic_image(*)' => array('output' => 'images/*'), - ); + return [ + 'assetic_javascripts(*)' => ['output' => 'js/*.js'], + 'assetic_stylesheets(*)' => ['output' => 'css/*.css'], + 'assetic_image(*)' => ['output' => 'images/*'], + ]; } protected function registerSetupCode() diff --git a/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php b/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php index 6c089002b..b1d62ecd8 100644 --- a/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php +++ b/src/Assetic/Factory/Resource/CoalescingDirectoryResource.php @@ -22,7 +22,7 @@ class CoalescingDirectoryResource implements IteratorResourceInterface public function __construct($directories) { - $this->directories = array(); + $this->directories = []; foreach ($directories as $directory) { $this->addDirectory($directory); @@ -47,7 +47,7 @@ public function isFresh($timestamp) public function getContent() { - $parts = array(); + $parts = []; foreach ($this->getFileResources() as $file) { $parts[] = $file->getContent(); } @@ -62,7 +62,7 @@ public function getContent() */ public function __toString() { - $parts = array(); + $parts = []; foreach ($this->directories as $directory) { $parts[] = (string) $directory; } @@ -95,7 +95,7 @@ protected function getRelativeName(ResourceInterface $file, ResourceInterface $d */ private function getFileResources() { - $paths = array(); + $paths = []; foreach ($this->directories as $directory) { foreach ($directory as $file) { diff --git a/src/Assetic/Factory/Resource/DirectoryResource.php b/src/Assetic/Factory/Resource/DirectoryResource.php index c823de2d2..492a16556 100644 --- a/src/Assetic/Factory/Resource/DirectoryResource.php +++ b/src/Assetic/Factory/Resource/DirectoryResource.php @@ -57,7 +57,7 @@ public function isFresh($timestamp) */ public function getContent() { - $content = array(); + $content = []; foreach ($this as $resource) { $content[] = $resource->getContent(); } diff --git a/src/Assetic/Filter/AutoprefixerFilter.php b/src/Assetic/Filter/AutoprefixerFilter.php index 51821615d..084b20499 100644 --- a/src/Assetic/Filter/AutoprefixerFilter.php +++ b/src/Assetic/Filter/AutoprefixerFilter.php @@ -31,7 +31,7 @@ class AutoprefixerFilter extends BaseNodeFilter /** * @var array */ - private $browsers = array(); + private $browsers = []; public function __construct($autoprefixerBin) { @@ -57,7 +57,7 @@ public function addBrowser($browser) public function filterLoad(AssetInterface $asset) { $input = $asset->getContent(); - $pb = $this->createProcessBuilder(array($this->autoprefixerBin)); + $pb = $this->createProcessBuilder([$this->autoprefixerBin]); $pb->setInput($input); if ($this->browsers) { diff --git a/src/Assetic/Filter/BaseNodeFilter.php b/src/Assetic/Filter/BaseNodeFilter.php index 64e5a1335..f0ee7c800 100644 --- a/src/Assetic/Filter/BaseNodeFilter.php +++ b/src/Assetic/Filter/BaseNodeFilter.php @@ -13,7 +13,7 @@ abstract class BaseNodeFilter extends BaseProcessFilter { - private $nodePaths = array(); + private $nodePaths = []; public function getNodePaths() { @@ -30,7 +30,7 @@ public function addNodePath($nodePath) $this->nodePaths[] = $nodePath; } - protected function createProcessBuilder(array $arguments = array()) + protected function createProcessBuilder(array $arguments = []) { $pb = parent::createProcessBuilder($arguments); diff --git a/src/Assetic/Filter/BaseProcessFilter.php b/src/Assetic/Filter/BaseProcessFilter.php index 642495ab4..e100b9066 100644 --- a/src/Assetic/Filter/BaseProcessFilter.php +++ b/src/Assetic/Filter/BaseProcessFilter.php @@ -37,7 +37,7 @@ public function setTimeout($timeout) * * @return ProcessBuilder A new process builder */ - protected function createProcessBuilder(array $arguments = array()) + protected function createProcessBuilder(array $arguments = []) { $pb = new ProcessBuilder($arguments); diff --git a/src/Assetic/Filter/CallablesFilter.php b/src/Assetic/Filter/CallablesFilter.php index b81f20147..9757339ff 100644 --- a/src/Assetic/Filter/CallablesFilter.php +++ b/src/Assetic/Filter/CallablesFilter.php @@ -57,6 +57,6 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) return $callable($factory, $content, $loadPath); } - return array(); + return []; } } diff --git a/src/Assetic/Filter/CleanCssFilter.php b/src/Assetic/Filter/CleanCssFilter.php index ada5499bf..0ee3a98a8 100644 --- a/src/Assetic/Filter/CleanCssFilter.php +++ b/src/Assetic/Filter/CleanCssFilter.php @@ -242,8 +242,8 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->cleanCssBin) - : array($this->cleanCssBin)); + ? [$this->nodeBin, $this->cleanCssBin] + : [$this->cleanCssBin]); if ($this->keepLineBreaks) { $pb->add('--keep-line-breaks'); diff --git a/src/Assetic/Filter/CoffeeScriptFilter.php b/src/Assetic/Filter/CoffeeScriptFilter.php index a5cc818b8..f486fb823 100644 --- a/src/Assetic/Filter/CoffeeScriptFilter.php +++ b/src/Assetic/Filter/CoffeeScriptFilter.php @@ -52,8 +52,8 @@ public function filterLoad(AssetInterface $asset) file_put_contents($input, $asset->getContent()); $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->coffeeBin) - : array($this->coffeeBin)); + ? [$this->nodeBin, $this->coffeeBin] + : [$this->coffeeBin]); $pb->add('-cp'); diff --git a/src/Assetic/Filter/CompassFilter.php b/src/Assetic/Filter/CompassFilter.php index d80a1abb9..d26297f3b 100644 --- a/src/Assetic/Filter/CompassFilter.php +++ b/src/Assetic/Filter/CompassFilter.php @@ -46,7 +46,7 @@ class CompassFilter extends BaseSassFilter private $relativeAssets; // compass configuration file options - private $plugins = array(); + private $plugins = []; private $httpPath; private $httpImagesPath; private $httpFontsPath; @@ -193,11 +193,11 @@ public function filterLoad(AssetInterface $asset) $tempDir = $this->cacheLocation ? $this->cacheLocation : FilesystemUtils::getTemporaryDirectory(); - $compassProcessArgs = array( + $compassProcessArgs = [ $this->compassPath, 'compile', $tempDir, - ); + ]; if (null !== $this->rubyPath) { $compassProcessArgs = array_merge(explode(' ', $this->rubyPath), $compassProcessArgs); } @@ -244,7 +244,7 @@ public function filterLoad(AssetInterface $asset) } // options in config file - $optionsConfig = array(); + $optionsConfig = []; if (!empty($loadPaths)) { $optionsConfig['additional_import_paths'] = $loadPaths; @@ -292,7 +292,7 @@ public function filterLoad(AssetInterface $asset) // options in configuration file if (count($optionsConfig)) { - $config = array(); + $config = []; foreach ($this->plugins as $plugin) { $config[] = sprintf("require '%s'", addcslashes($plugin, '\\')); } @@ -371,7 +371,7 @@ public function filterDump(AssetInterface $asset) private function formatArrayToRuby($array) { - $output = array(); + $output = []; // does we have an associative array ? if (count(array_filter(array_keys($array), "is_numeric")) != count($array)) { diff --git a/src/Assetic/Filter/CssEmbedFilter.php b/src/Assetic/Filter/CssEmbedFilter.php index 17970a9f9..1cb721d06 100644 --- a/src/Assetic/Filter/CssEmbedFilter.php +++ b/src/Assetic/Filter/CssEmbedFilter.php @@ -81,11 +81,11 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { - $pb = $this->createProcessBuilder(array( + $pb = $this->createProcessBuilder([ $this->javaPath, '-jar', $this->jarPath, - )); + ]); if (null !== $this->charset) { $pb->add('--charset')->add($this->charset); @@ -138,6 +138,6 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } } diff --git a/src/Assetic/Filter/CssImportFilter.php b/src/Assetic/Filter/CssImportFilter.php index 77ec1c4b6..c2d87f5c1 100644 --- a/src/Assetic/Filter/CssImportFilter.php +++ b/src/Assetic/Filter/CssImportFilter.php @@ -72,12 +72,12 @@ public function filterLoad(AssetInterface $asset) $importSource = $importRoot.'/'.$importPath; if (false !== strpos($importSource, '://') || 0 === strpos($importSource, '//')) { - $import = new HttpAsset($importSource, array($importFilter), true); + $import = new HttpAsset($importSource, [$importFilter], true); } elseif ('css' != pathinfo($importPath, PATHINFO_EXTENSION) || !file_exists($importSource)) { // ignore non-css and non-existant imports return $matches[0]; } else { - $import = new FileAsset($importSource, array($importFilter), $importRoot, $importPath); + $import = new FileAsset($importSource, [$importFilter], $importRoot, $importPath); } $import->setTargetPath($sourcePath); @@ -103,6 +103,6 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } } diff --git a/src/Assetic/Filter/CssMinFilter.php b/src/Assetic/Filter/CssMinFilter.php index 6f0b0d2b0..77393a3ae 100644 --- a/src/Assetic/Filter/CssMinFilter.php +++ b/src/Assetic/Filter/CssMinFilter.php @@ -26,8 +26,8 @@ class CssMinFilter implements FilterInterface public function __construct() { - $this->filters = array(); - $this->plugins = array(); + $this->filters = []; + $this->plugins = []; } public function setFilters(array $filters) @@ -61,7 +61,7 @@ public function filterDump(AssetInterface $asset) if (isset($filters['ImportImports']) && true === $filters['ImportImports']) { if ($dir = $asset->getSourceDirectory()) { - $filters['ImportImports'] = array('BasePath' => $dir); + $filters['ImportImports'] = ['BasePath' => $dir]; } else { unset($filters['ImportImports']); } diff --git a/src/Assetic/Filter/CssRewriteFilter.php b/src/Assetic/Filter/CssRewriteFilter.php index c2250c3a4..0bf16269a 100644 --- a/src/Assetic/Filter/CssRewriteFilter.php +++ b/src/Assetic/Filter/CssRewriteFilter.php @@ -85,7 +85,7 @@ public function filterDump(AssetInterface $asset) $url = substr($url, 3); } - $parts = array(); + $parts = []; foreach (explode('/', $host.$path.$url) as $part) { if ('..' === $part && count($parts) && '..' !== end($parts)) { array_pop($parts); diff --git a/src/Assetic/Filter/EmberPrecompileFilter.php b/src/Assetic/Filter/EmberPrecompileFilter.php index 313d4a045..2ef99e5e6 100644 --- a/src/Assetic/Filter/EmberPrecompileFilter.php +++ b/src/Assetic/Filter/EmberPrecompileFilter.php @@ -37,8 +37,8 @@ public function __construct($handlebarsBin = '/usr/bin/ember-precompile', $nodeB public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->emberBin) - : array($this->emberBin)); + ? [$this->nodeBin, $this->emberBin] + : [$this->emberBin]); if ($sourcePath = $asset->getSourcePath()) { $templateName = basename($sourcePath); diff --git a/src/Assetic/Filter/FilterCollection.php b/src/Assetic/Filter/FilterCollection.php index 0fcd54e81..9bef824ce 100644 --- a/src/Assetic/Filter/FilterCollection.php +++ b/src/Assetic/Filter/FilterCollection.php @@ -20,9 +20,9 @@ */ class FilterCollection implements FilterInterface, \IteratorAggregate, \Countable { - private $filters = array(); + private $filters = []; - public function __construct($filters = array()) + public function __construct($filters = []) { foreach ($filters as $filter) { $this->ensure($filter); @@ -53,7 +53,7 @@ public function all() public function clear() { - $this->filters = array(); + $this->filters = []; } public function filterLoad(AssetInterface $asset) diff --git a/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php b/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php index 347805786..3a0fc149f 100644 --- a/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php +++ b/src/Assetic/Filter/GoogleClosure/CompilerApiFilter.php @@ -36,11 +36,11 @@ public function setProxyFullUri($proxyFullUri) public function filterDump(AssetInterface $asset) { - $query = array( + $query = [ 'js_code' => $asset->getContent(), 'output_format' => 'json', 'output_info' => 'compiled_code', - ); + ]; if (null !== $this->compilationLevel) { $query['compilation_level'] = $this->compilationLevel; @@ -75,11 +75,13 @@ public function filterDump(AssetInterface $asset) } if (preg_match('/1|yes|on|true/i', ini_get('allow_url_fopen'))) { - $contextOptions = array('http' => array( - 'method' => 'POST', - 'header' => 'Content-Type: application/x-www-form-urlencoded', - 'content' => http_build_query($query), - )); + $contextOptions = [ + 'http' => [ + 'method' => 'POST', + 'header' => 'Content-Type: application/x-www-form-urlencoded', + 'content' => http_build_query($query), + ] + ]; if (null !== $this->timeout) { $contextOptions['http']['timeout'] = $this->timeout; } @@ -94,7 +96,7 @@ public function filterDump(AssetInterface $asset) } elseif (defined('CURLOPT_POST') && !in_array('curl_init', explode(',', ini_get('disable_functions')))) { $ch = curl_init('http://closure-compiler.appspot.com/compile'); curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded')); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/x-www-form-urlencoded']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); diff --git a/src/Assetic/Filter/GoogleClosure/CompilerJarFilter.php b/src/Assetic/Filter/GoogleClosure/CompilerJarFilter.php index 7cd340efe..2aac6555d 100644 --- a/src/Assetic/Filter/GoogleClosure/CompilerJarFilter.php +++ b/src/Assetic/Filter/GoogleClosure/CompilerJarFilter.php @@ -42,14 +42,14 @@ public function setFlagFile($flagFile) public function filterDump(AssetInterface $asset) { $is64bit = PHP_INT_SIZE === 8; - $cleanup = array(); + $cleanup = []; $pb = new ProcessBuilder(array_merge( - array($this->javaPath), + [$this->javaPath], $is64bit - ? array('-server', '-XX:+TieredCompilation') - : array('-client', '-d32'), - array('-jar', $this->jarPath) + ? ['-server', '-XX:+TieredCompilation'] + : ['-client', '-d32'], + ['-jar', $this->jarPath] )); if (null !== $this->timeout) { diff --git a/src/Assetic/Filter/GssFilter.php b/src/Assetic/Filter/GssFilter.php index 4b55610b8..1588fc596 100644 --- a/src/Assetic/Filter/GssFilter.php +++ b/src/Assetic/Filter/GssFilter.php @@ -82,13 +82,13 @@ public function setPrettyPrint($prettyPrint) public function filterLoad(AssetInterface $asset) { - $cleanup = array(); + $cleanup = []; - $pb = $this->createProcessBuilder(array( + $pb = $this->createProcessBuilder([ $this->javaPath, '-jar', $this->jarPath, - )); + ]); if (null !== $this->allowUnrecognizedFunctions) { $pb->add('--allow-unrecognized-functions'); diff --git a/src/Assetic/Filter/HandlebarsFilter.php b/src/Assetic/Filter/HandlebarsFilter.php index f34927f98..2f0566b05 100644 --- a/src/Assetic/Filter/HandlebarsFilter.php +++ b/src/Assetic/Filter/HandlebarsFilter.php @@ -48,8 +48,8 @@ public function setSimple($simple) public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->handlebarsBin) - : array($this->handlebarsBin)); + ? [$this->nodeBin, $this->handlebarsBin] + : [$this->handlebarsBin]); if ($sourcePath = $asset->getSourcePath()) { $templateName = basename($sourcePath); diff --git a/src/Assetic/Filter/JpegoptimFilter.php b/src/Assetic/Filter/JpegoptimFilter.php index fcc14892b..a9ecb265a 100644 --- a/src/Assetic/Filter/JpegoptimFilter.php +++ b/src/Assetic/Filter/JpegoptimFilter.php @@ -53,7 +53,7 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { - $pb = $this->createProcessBuilder(array($this->jpegoptimBin)); + $pb = $this->createProcessBuilder([$this->jpegoptimBin]); if ($this->stripAll) { $pb->add('--strip-all'); diff --git a/src/Assetic/Filter/JpegtranFilter.php b/src/Assetic/Filter/JpegtranFilter.php index 78365388e..6abdef8ce 100644 --- a/src/Assetic/Filter/JpegtranFilter.php +++ b/src/Assetic/Filter/JpegtranFilter.php @@ -69,7 +69,7 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { - $pb = $this->createProcessBuilder(array($this->jpegtranBin)); + $pb = $this->createProcessBuilder([$this->jpegtranBin]); if ($this->optimize) { $pb->add('-optimize'); diff --git a/src/Assetic/Filter/LessFilter.php b/src/Assetic/Filter/LessFilter.php index 7ca5cd735..67f0733b3 100644 --- a/src/Assetic/Filter/LessFilter.php +++ b/src/Assetic/Filter/LessFilter.php @@ -44,7 +44,7 @@ class LessFilter extends BaseNodeFilter implements DependencyExtractorInterface * * @var array */ - protected $loadPaths = array(); + protected $loadPaths = []; /** * Constructor. @@ -52,12 +52,12 @@ class LessFilter extends BaseNodeFilter implements DependencyExtractorInterface * @param string $nodeBin The path to the node binary * @param array $nodePaths An array of node paths */ - public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = array()) + public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = []) { $this->nodeBin = $nodeBin; $this->setNodePaths($nodePaths); - $this->treeOptions = array(); - $this->parserOptions = array(); + $this->treeOptions = []; + $this->parserOptions = []; } /** @@ -129,7 +129,7 @@ public function filterLoad(AssetInterface $asset) // parser options $parserOptions = $this->parserOptions; if ($dir = $asset->getSourceDirectory()) { - $parserOptions['paths'] = array($dir); + $parserOptions['paths'] = [$dir]; $parserOptions['filename'] = basename($asset->getSourcePath()); } @@ -172,10 +172,10 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } if (empty($loadPaths)) { - return array(); + return []; } - $children = array(); + $children = []; foreach (LessUtils::extractImports($content) as $reference) { if ('.css' === substr($reference, -4)) { // skip normal css imports @@ -189,7 +189,7 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) foreach ($loadPaths as $loadPath) { if (file_exists($file = $loadPath.'/'.$reference)) { - $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + $coll = $factory->createAsset($file, [], ['root' => $loadPath]); foreach ($coll as $leaf) { $leaf->ensureFilter($this); $children[] = $leaf; diff --git a/src/Assetic/Filter/LessphpFilter.php b/src/Assetic/Filter/LessphpFilter.php index 6116f58bc..516324154 100644 --- a/src/Assetic/Filter/LessphpFilter.php +++ b/src/Assetic/Filter/LessphpFilter.php @@ -27,18 +27,18 @@ */ class LessphpFilter implements DependencyExtractorInterface { - private $presets = array(); + private $presets = []; private $formatter; private $preserveComments; - private $customFunctions = array(); - private $options = array(); + private $customFunctions = []; + private $options = []; /** * Lessphp Load Paths * * @var array */ - protected $loadPaths = array(); + protected $loadPaths = []; /** * Adds a load path to the paths used by lessphp @@ -133,10 +133,10 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } if (empty($loadPaths)) { - return array(); + return []; } - $children = array(); + $children = []; foreach (LessUtils::extractImports($content) as $reference) { if ('.css' === substr($reference, -4)) { // skip normal css imports @@ -150,7 +150,7 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) foreach ($loadPaths as $loadPath) { if (file_exists($file = $loadPath.'/'.$reference)) { - $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + $coll = $factory->createAsset($file, [], ['root' => $loadPath]); foreach ($coll as $leaf) { $leaf->ensureFilter($this); $children[] = $leaf; diff --git a/src/Assetic/Filter/OptiPngFilter.php b/src/Assetic/Filter/OptiPngFilter.php index 5bc1d12ff..f55a6ba41 100644 --- a/src/Assetic/Filter/OptiPngFilter.php +++ b/src/Assetic/Filter/OptiPngFilter.php @@ -47,7 +47,7 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { - $pb = $this->createProcessBuilder(array($this->optipngBin)); + $pb = $this->createProcessBuilder([$this->optipngBin]); if (null !== $this->level) { $pb->add('-o')->add($this->level); diff --git a/src/Assetic/Filter/PackagerFilter.php b/src/Assetic/Filter/PackagerFilter.php index 23ceb4e8f..dd747bc88 100644 --- a/src/Assetic/Filter/PackagerFilter.php +++ b/src/Assetic/Filter/PackagerFilter.php @@ -24,7 +24,7 @@ class PackagerFilter implements FilterInterface { private $packages; - public function __construct(array $packages = array()) + public function __construct(array $packages = []) { $this->packages = $packages; } @@ -49,8 +49,8 @@ public function filterLoad(AssetInterface $asset) file_put_contents($package.'/package.yml', sprintf($manifest, $hash)); file_put_contents($package.'/source.js', $asset->getContent()); - $packager = new \Packager(array_merge(array($package), $this->packages)); - $content = $packager->build(array(), array(), array('Application'.$hash)); + $packager = new \Packager(array_merge([$package], $this->packages)); + $content = $packager->build([], [], ['Application'.$hash]); unlink($package.'/package.yml'); unlink($package.'/source.js'); diff --git a/src/Assetic/Filter/PhpCssEmbedFilter.php b/src/Assetic/Filter/PhpCssEmbedFilter.php index b1ff33f6b..e8160e0d3 100644 --- a/src/Assetic/Filter/PhpCssEmbedFilter.php +++ b/src/Assetic/Filter/PhpCssEmbedFilter.php @@ -23,7 +23,7 @@ */ class PhpCssEmbedFilter implements DependencyExtractorInterface { - private $presets = array(); + private $presets = []; public function setPresets(array $presets) { @@ -47,6 +47,6 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } } diff --git a/src/Assetic/Filter/PngoutFilter.php b/src/Assetic/Filter/PngoutFilter.php index 592ef3ab5..27cfc177e 100644 --- a/src/Assetic/Filter/PngoutFilter.php +++ b/src/Assetic/Filter/PngoutFilter.php @@ -87,7 +87,7 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { - $pb = $this->createProcessBuilder(array($this->pngoutBin)); + $pb = $this->createProcessBuilder([$this->pngoutBin]); if (null !== $this->color) { $pb->add('-c'.$this->color); diff --git a/src/Assetic/Filter/ReactJsxFilter.php b/src/Assetic/Filter/ReactJsxFilter.php index dc4f21801..004db3fd2 100644 --- a/src/Assetic/Filter/ReactJsxFilter.php +++ b/src/Assetic/Filter/ReactJsxFilter.php @@ -26,8 +26,8 @@ public function __construct($jsxBin = '/usr/bin/jsx', $nodeBin = null) public function filterLoad(AssetInterface $asset) { $builder = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->jsxBin) - : array($this->jsxBin)); + ? [$this->nodeBin, $this->jsxBin] + : [$this->jsxBin]); $inputDir = FilesystemUtils::createThrowAwayDirectory('jsx_in'); $inputFile = $inputDir.DIRECTORY_SEPARATOR.'asset.js'; diff --git a/src/Assetic/Filter/RooleFilter.php b/src/Assetic/Filter/RooleFilter.php index cbcaf4cb8..ae03073e1 100644 --- a/src/Assetic/Filter/RooleFilter.php +++ b/src/Assetic/Filter/RooleFilter.php @@ -47,8 +47,8 @@ public function filterLoad(AssetInterface $asset) file_put_contents($input, $asset->getContent()); $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->rooleBin) - : array($this->rooleBin)); + ? [$this->nodeBin, $this->rooleBin] + : [$this->rooleBin]); $pb->add($input); @@ -79,6 +79,6 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } } diff --git a/src/Assetic/Filter/Sass/BaseSassFilter.php b/src/Assetic/Filter/Sass/BaseSassFilter.php index 68903f0ef..6f9df53cb 100644 --- a/src/Assetic/Filter/Sass/BaseSassFilter.php +++ b/src/Assetic/Filter/Sass/BaseSassFilter.php @@ -10,7 +10,7 @@ abstract class BaseSassFilter extends BaseProcessFilter implements DependencyExtractorInterface { - protected $loadPaths = array(); + protected $loadPaths = []; public function setLoadPaths(array $loadPaths) { @@ -30,10 +30,10 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } if (!$loadPaths) { - return array(); + return []; } - $children = array(); + $children = []; foreach (SassUtils::extractImports($content) as $reference) { if ('.css' === substr($reference, -4)) { // skip normal css imports @@ -42,24 +42,22 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } // the reference may or may not have an extension or be a partial - if (pathinfo($reference, PATHINFO_EXTENSION)) { - $needles = array( + $needles = pathinfo($reference, PATHINFO_EXTENSION) + ? [ $reference, self::partialize($reference), - ); - } else { - $needles = array( + ] + : [ $reference.'.scss', $reference.'.sass', self::partialize($reference).'.scss', self::partialize($reference).'.sass', - ); - } + ]; foreach ($loadPaths as $loadPath) { foreach ($needles as $needle) { if (file_exists($file = $loadPath.'/'.$needle)) { - $coll = $factory->createAsset($file, array(), array('root' => $loadPath)); + $coll = $factory->createAsset($file, [], ['root' => $loadPath]); foreach ($coll as $leaf) { /** @var $leaf AssetInterface */ $leaf->ensureFilter($this); @@ -80,11 +78,9 @@ private static function partialize($reference) { $parts = pathinfo($reference); - if ('.' === $parts['dirname']) { - $partial = '_'.$parts['filename']; - } else { - $partial = $parts['dirname'].DIRECTORY_SEPARATOR.'_'.$parts['filename']; - } + $partial = '.' === $parts['dirname'] + ? '_'.$parts['filename'] + : $parts['dirname'].DIRECTORY_SEPARATOR.'_'.$parts['filename']; if (isset($parts['extension'])) { $partial .= '.'.$parts['extension']; diff --git a/src/Assetic/Filter/Sass/SassFilter.php b/src/Assetic/Filter/Sass/SassFilter.php index 68da11625..c58907e2c 100644 --- a/src/Assetic/Filter/Sass/SassFilter.php +++ b/src/Assetic/Filter/Sass/SassFilter.php @@ -106,7 +106,7 @@ public function setCompass($compass) public function filterLoad(AssetInterface $asset) { - $sassProcessArgs = array($this->sassPath); + $sassProcessArgs = [$this->sassPath]; if (null !== $this->rubyPath) { $sassProcessArgs = array_merge(explode(' ', $this->rubyPath), $sassProcessArgs); } diff --git a/src/Assetic/Filter/SassphpFilter.php b/src/Assetic/Filter/SassphpFilter.php index 5d4ed1e16..f1cf4da5d 100644 --- a/src/Assetic/Filter/SassphpFilter.php +++ b/src/Assetic/Filter/SassphpFilter.php @@ -23,7 +23,7 @@ */ class SassphpFilter implements DependencyExtractorInterface { - private $includePaths = array(); + private $includePaths = []; private $outputStyle; public function filterLoad(AssetInterface $asset) @@ -31,7 +31,7 @@ public function filterLoad(AssetInterface $asset) $sass = new \Sass(); $includePaths = array_merge( - array($asset->getSourceDirectory()), + [$asset->getSourceDirectory()], $this->includePaths ); $sass->setIncludePath(implode(':', $includePaths)); @@ -66,7 +66,7 @@ public function addIncludePath($path) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { - $children = array(); + $children = []; $includePaths = $this->includePaths; if (null !== $loadPath && !in_array($loadPath, $includePaths)) { @@ -83,22 +83,20 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } // the reference may or may not have an extension or be a partial - if (pathinfo($reference, PATHINFO_EXTENSION)) { - $needles = array( + $needles = pathinfo($reference, PATHINFO_EXTENSION) + ? [ $reference, $this->partialize($reference), - ); - } else { - $needles = array( + ] + : [ $reference . '.scss', $this->partialize($reference) . '.scss', - ); - } + ]; foreach ($includePaths as $includePath) { foreach ($needles as $needle) { if (file_exists($file = $includePath . '/' . $needle)) { - $child = $factory->createAsset($file, array(), array('root' => $includePath)); + $child = $factory->createAsset($file, [], ['root' => $includePath]); $children[] = $child; $child->load(); $children = array_merge( diff --git a/src/Assetic/Filter/ScssphpFilter.php b/src/Assetic/Filter/ScssphpFilter.php index c2252a146..bbb64ce6a 100644 --- a/src/Assetic/Filter/ScssphpFilter.php +++ b/src/Assetic/Filter/ScssphpFilter.php @@ -28,10 +28,10 @@ class ScssphpFilter implements DependencyExtractorInterface { private $compass = false; - private $importPaths = array(); - private $customFunctions = array(); + private $importPaths = []; + private $customFunctions = []; private $formatter; - private $variables = array(); + private $variables = []; public function enableCompass($enable = true) { @@ -45,12 +45,12 @@ public function isCompassEnabled() public function setFormatter($formatter) { - $legacyFormatters = array( + $legacyFormatters = [ 'scss_formatter' => 'Leafo\ScssPhp\Formatter\Expanded', 'scss_formatter_nested' => 'Leafo\ScssPhp\Formatter\Nested', 'scss_formatter_compressed' => 'Leafo\ScssPhp\Formatter\Compressed', 'scss_formatter_crunched' => 'Leafo\ScssPhp\Formatter\Crunched', - ); + ]; if (isset($legacyFormatters[$formatter])) { @trigger_error(sprintf('The scssphp formatter `%s` is deprecated. Use `%s` instead.', $formatter, $legacyFormatters[$formatter]), E_USER_DEPRECATED); @@ -132,11 +132,11 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) $sc->addImportPath($path); } - $children = array(); + $children = []; foreach (CssUtils::extractImports($content) as $match) { $file = $sc->findImport($match); if ($file) { - $children[] = $child = $factory->createAsset($file, array(), array('root' => $loadPath)); + $children[] = $child = $factory->createAsset($file, [], ['root' => $loadPath]); $child->load(); $children = array_merge($children, $this->getChildren($factory, $child->getContent(), $loadPath)); } diff --git a/src/Assetic/Filter/SprocketsFilter.php b/src/Assetic/Filter/SprocketsFilter.php index ed46b0f99..2836c5c3a 100644 --- a/src/Assetic/Filter/SprocketsFilter.php +++ b/src/Assetic/Filter/SprocketsFilter.php @@ -43,7 +43,7 @@ public function __construct($sprocketsLib = null, $rubyBin = '/usr/bin/ruby') { $this->sprocketsLib = $sprocketsLib; $this->rubyBin = $rubyBin; - $this->includeDirs = array(); + $this->includeDirs = []; } public function addIncludeDir($directory) @@ -103,10 +103,10 @@ public function filterLoad(AssetInterface $asset) $more )); - $pb = $this->createProcessBuilder(array( + $pb = $this->createProcessBuilder([ $this->rubyBin, $input, - )); + ]); $proc = $pb->getProcess(); $code = $proc->run(); @@ -127,7 +127,7 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } private function getHack(AssetInterface $asset) diff --git a/src/Assetic/Filter/StylusFilter.php b/src/Assetic/Filter/StylusFilter.php index aed7861aa..e0e1e046d 100644 --- a/src/Assetic/Filter/StylusFilter.php +++ b/src/Assetic/Filter/StylusFilter.php @@ -34,7 +34,7 @@ class StylusFilter extends BaseNodeFilter implements DependencyExtractorInterfac * @param string $nodeBin The path to the node binary * @param array $nodePaths An array of node paths */ - public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = array()) + public function __construct($nodeBin = '/usr/bin/node', array $nodePaths = []) { $this->nodeBin = $nodeBin; $this->setNodePaths($nodePaths); @@ -81,9 +81,9 @@ public function filterLoad(AssetInterface $asset) EOF; // parser options - $parserOptions = array(); + $parserOptions = []; if ($dir = $asset->getSourceDirectory()) { - $parserOptions['paths'] = array($dir); + $parserOptions['paths'] = [$dir]; $parserOptions['filename'] = basename($asset->getSourcePath()); } @@ -121,6 +121,6 @@ public function filterDump(AssetInterface $asset) public function getChildren(AssetFactory $factory, $content, $loadPath = null) { // todo - return array(); + return []; } } diff --git a/src/Assetic/Filter/TypeScriptFilter.php b/src/Assetic/Filter/TypeScriptFilter.php index 24aee3167..f54202256 100644 --- a/src/Assetic/Filter/TypeScriptFilter.php +++ b/src/Assetic/Filter/TypeScriptFilter.php @@ -35,8 +35,8 @@ public function __construct($tscBin = '/usr/bin/tsc', $nodeBin = null) public function filterLoad(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->tscBin) - : array($this->tscBin)); + ? [$this->nodeBin, $this->tscBin] + : [$this->tscBin)]; if ($sourcePath = $asset->getSourcePath()) { $templateName = basename($sourcePath); diff --git a/src/Assetic/Filter/UglifyCssFilter.php b/src/Assetic/Filter/UglifyCssFilter.php index d534fa35a..3127eaf73 100644 --- a/src/Assetic/Filter/UglifyCssFilter.php +++ b/src/Assetic/Filter/UglifyCssFilter.php @@ -82,8 +82,8 @@ public function filterLoad(AssetInterface $asset) public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder($this->nodeBin - ? array($this->nodeBin, $this->uglifycssBin) - : array($this->uglifycssBin)); + ? [$this->nodeBin, $this->uglifycssBin] + : [$this->uglifycssBin]); if ($this->expandVars) { $pb->add('--expand-vars'); diff --git a/src/Assetic/Filter/UglifyJs2Filter.php b/src/Assetic/Filter/UglifyJs2Filter.php index c0441aee4..1365ef858 100644 --- a/src/Assetic/Filter/UglifyJs2Filter.php +++ b/src/Assetic/Filter/UglifyJs2Filter.php @@ -82,8 +82,8 @@ public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder( $this->nodeBin - ? array($this->nodeBin, $this->uglifyjsBin) - : array($this->uglifyjsBin) + ? [$this->nodeBin, $this->uglifyjsBin] + : [$this->uglifyjsBin] ); if ($this->compress) { diff --git a/src/Assetic/Filter/UglifyJsFilter.php b/src/Assetic/Filter/UglifyJsFilter.php index ff9ad6603..a93b0d565 100644 --- a/src/Assetic/Filter/UglifyJsFilter.php +++ b/src/Assetic/Filter/UglifyJsFilter.php @@ -99,8 +99,8 @@ public function filterDump(AssetInterface $asset) { $pb = $this->createProcessBuilder( $this->nodeBin - ? array($this->nodeBin, $this->uglifyjsBin) - : array($this->uglifyjsBin) + ? [$this->nodeBin, $this->uglifyjsBin] + : [$this->uglifyjsBin] ); if ($this->noCopyright) { diff --git a/src/Assetic/Filter/Yui/BaseCompressorFilter.php b/src/Assetic/Filter/Yui/BaseCompressorFilter.php index b3ec26719..b27da3ba5 100644 --- a/src/Assetic/Filter/Yui/BaseCompressorFilter.php +++ b/src/Assetic/Filter/Yui/BaseCompressorFilter.php @@ -64,9 +64,9 @@ public function filterLoad(AssetInterface $asset) * * @return string The compressed content */ - protected function compress($content, $type, $options = array()) + protected function compress($content, $type, $options = []) { - $pb = $this->createProcessBuilder(array($this->javaPath)); + $pb = $this->createProcessBuilder([$this->javaPath]); if (null !== $this->stackSize) { $pb->add('-Xss'.$this->stackSize); diff --git a/src/Assetic/Filter/Yui/JsCompressorFilter.php b/src/Assetic/Filter/Yui/JsCompressorFilter.php index b2a59fb13..58e3ddd1f 100644 --- a/src/Assetic/Filter/Yui/JsCompressorFilter.php +++ b/src/Assetic/Filter/Yui/JsCompressorFilter.php @@ -42,7 +42,7 @@ public function setDisableOptimizations($disableOptimizations) public function filterDump(AssetInterface $asset) { - $options = array(); + $options = []; if ($this->nomunge) { $options[] = '--nomunge'; diff --git a/src/Assetic/FilterManager.php b/src/Assetic/FilterManager.php index e2820d993..278f5b410 100644 --- a/src/Assetic/FilterManager.php +++ b/src/Assetic/FilterManager.php @@ -20,7 +20,7 @@ */ class FilterManager { - private $filters = array(); + private $filters = []; public function set($alias, FilterInterface $filter) { diff --git a/src/Assetic/Util/CssUtils.php b/src/Assetic/Util/CssUtils.php index ebc44b031..ec295308c 100644 --- a/src/Assetic/Util/CssUtils.php +++ b/src/Assetic/Util/CssUtils.php @@ -124,7 +124,7 @@ public static function filterCommentless($content, $callback) */ public static function extractImports($content) { - $imports = array(); + $imports = []; static::filterImports($content, function ($matches) use (&$imports) { $imports[] = $matches['url']; }); diff --git a/src/Assetic/Util/VarUtils.php b/src/Assetic/Util/VarUtils.php index d9464c0d1..337557847 100644 --- a/src/Assetic/Util/VarUtils.php +++ b/src/Assetic/Util/VarUtils.php @@ -31,7 +31,7 @@ abstract class VarUtils */ public static function resolve($template, array $vars, array $values) { - $map = array(); + $map = []; foreach ($vars as $var) { if (false === strpos($template, '{'.$var.'}')) { continue; @@ -50,11 +50,11 @@ public static function resolve($template, array $vars, array $values) public static function getCombinations(array $vars, array $values) { if (!$vars) { - return array(array()); + return [[]]; } - $combinations = array(); - $nbValues = array(); + $combinations = []; + $nbValues = []; foreach ($values as $var => $vals) { if (!in_array($var, $vars, true)) { continue; @@ -65,7 +65,7 @@ public static function getCombinations(array $vars, array $values) for ($i = array_product($nbValues), $c = $i * 2; $i < $c; $i++) { $k = $i; - $combination = array(); + $combination = []; foreach ($vars as $var) { $combination[$var] = $values[$var][$k % $nbValues[$var]]; diff --git a/src/functions.php b/src/functions.php index 2af5bdec1..92fe610b7 100644 --- a/src/functions.php +++ b/src/functions.php @@ -38,7 +38,7 @@ function assetic_init(AssetFactory $factory) * * @return array An array of javascript URLs */ -function assetic_javascripts($inputs = array(), $filters = array(), array $options = array()) +function assetic_javascripts($inputs = [], $filters = [], array $options = []) { if (!isset($options['output'])) { $options['output'] = 'js/*.js'; @@ -56,7 +56,7 @@ function assetic_javascripts($inputs = array(), $filters = array(), array $optio * * @return array An array of stylesheet URLs */ -function assetic_stylesheets($inputs = array(), $filters = array(), array $options = array()) +function assetic_stylesheets($inputs = [], $filters = [], array $options = []) { if (!isset($options['output'])) { $options['output'] = 'css/*.css'; @@ -74,7 +74,7 @@ function assetic_stylesheets($inputs = array(), $filters = array(), array $optio * * @return string An image URL */ -function assetic_image($input, $filters = array(), array $options = array()) +function assetic_image($input, $filters = [], array $options = []) { if (!isset($options['output'])) { $options['output'] = 'images/*'; @@ -94,7 +94,7 @@ function assetic_image($input, $filters = array(), array $options = array()) * * @return array An array of URLs */ -function _assetic_urls($inputs = array(), $filters = array(), array $options = array()) +function _assetic_urls($inputs = [], $filters = [], array $options = []) { global $_assetic; @@ -113,9 +113,9 @@ function _assetic_urls($inputs = array(), $filters = array(), array $options = a $one = $coll->getTargetPath(); if ($combine) { - $many = array($one); + $many = [$one]; } else { - $many = array(); + $many = []; foreach ($coll as $leaf) { $many[] = $leaf->getTargetPath(); }