Skip to content

Commit

Permalink
Updated syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
peteboere committed Sep 3, 2017
1 parent d0c13f3 commit a3f64a7
Show file tree
Hide file tree
Showing 33 changed files with 130 additions and 130 deletions.
18 changes: 9 additions & 9 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
$options = CssCrush\Util::readConfigFile($configFile);
}
else {
$options = array();
$options = [];
}

if ($args->pretty) {
Expand Down Expand Up @@ -234,7 +234,7 @@ function get_stdin_contents() {

function parse_list(array $option) {

$out = array();
$out = [];
foreach ($option as $arg) {
if (is_string($arg)) {
foreach (preg_split('~\s*,\s*~', $arg) as $item) {
Expand All @@ -248,7 +248,7 @@ function parse_list(array $option) {
return $out;
}

function message($messages, $options = array()) {
function message($messages, $options = []) {

$defaults = array(
'color' => 'b',
Expand Down Expand Up @@ -285,7 +285,7 @@ function message($messages, $options = array()) {
}
extract($options + $defaults);

$out = array();
$out = [];
foreach ((array) $messages as $_label => $value) {
$_label = $label ?: $_label;
if ($format_label) {
Expand Down Expand Up @@ -372,19 +372,19 @@ function get_trailing_io_args($required_value_opts) {
$other_opt_patt = "~^-{1,2}([a-z0-9\-]+)?(=|$)~ix";

// Step through the args.
$filtered = array();
$filtered = [];
for ($i = 0; $i < count($trailing_args); $i++) {

$current = $trailing_args[$i];

// If tests as a required value option, reset and skip next.
if (preg_match($value_opt_patt, $current)) {
$filtered = array();
$filtered = [];
$i++;
}
// If it looks like any other kind of flag, or optional value option, reset.
elseif (preg_match($other_opt_patt, $current)) {
$filtered = array();
$filtered = [];
}
else {
$filtered[] = $current;
Expand Down Expand Up @@ -438,8 +438,8 @@ function parse_args() {
);

// Create option strings for getopt().
$short_opts = array();
$long_opts = array();
$short_opts = [];
$long_opts = [];
$join_opts = function ($opts_list, $modifier) use (&$short_opts, &$long_opts) {
foreach ($opts_list as $opt) {
foreach (explode('|', $opt) as $arg) {
Expand Down
6 changes: 3 additions & 3 deletions lib/CssCrush/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function test($str)
)~ixS');
}

$color_test = array();
$color_test = [];
$str = strtolower(trim($str));

// First match a hex value or the start of a function.
Expand Down Expand Up @@ -299,7 +299,7 @@ public static function hexToRgb($hex)

// Handle shortened format.
if (strlen($hex) === 3) {
$long_hex = array();
$long_hex = [];
foreach (str_split($hex) as $val) {
$long_hex[] = $val . $val;
}
Expand Down Expand Up @@ -391,7 +391,7 @@ public function __toString()
}

// R, G and B components must be integers.
$components = array();
$components = [];
foreach (($this->hslColorSpace ? $this->getRgb() : $this->value) as $index => $component) {
$components[] = ($index === 3) ? $component : min(round($component), 255);
}
Expand Down
28 changes: 14 additions & 14 deletions lib/CssCrush/Crush.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public static function init()
self::$config->io = 'CssCrush\IO';

// Shared resources.
self::$config->vars = array();
self::$config->vars = [];
self::$config->aliasesFile = self::$dir . '/aliases.ini';
self::$config->aliases = array();
self::$config->aliases = [];
self::$config->bareAliases = array(
'properties' => array(),
'functions' => array(),
'function_groups' => array(),
'declarations' => array(),
'at-rules' => array(),
'properties' => [],
'functions' => [],
'function_groups' => [],
'declarations' => [],
'at-rules' => [],
);
self::$config->options = new Options();

Expand Down Expand Up @@ -138,7 +138,7 @@ public static function parseAliasesFile($file)

if ($section === 'declarations') {

$store = array();
$store = [];
foreach ($items as $prop_val => $aliases) {

list($prop, $value) = array_map('trim', explode(':', $prop_val));
Expand Down Expand Up @@ -167,7 +167,7 @@ public static function parseAliasesFile($file)

$group = substr($section, strlen('functions'));

$vendor_grouped_aliases = array();
$vendor_grouped_aliases = [];
foreach ($items as $func_name => $aliases) {

// Assign group name to the aliasable function.
Expand Down Expand Up @@ -207,7 +207,7 @@ public static function printLog()
if (! empty(self::$process->debugLog)) {

if (PHP_SAPI !== 'cli') {
$out = array();
$out = [];
foreach (self::$process->debugLog as $item) {
$out[] = '<pre>' . htmlspecialchars($item) . '</pre>';
}
Expand Down Expand Up @@ -259,7 +259,7 @@ public static function runStat()
}
}

function warning($message, $context = array()) {
function warning($message, $context = []) {
Crush::$process->errors[] = $message;
$logger = Crush::$config->logger;
if ($logger instanceof Logger) {
Expand All @@ -268,7 +268,7 @@ function warning($message, $context = array()) {
$logger->warning($message, $context);
}

function notice($message, $context = array()) {
function notice($message, $context = []) {
Crush::$process->warnings[] = $message;
$logger = Crush::$config->logger;
if ($logger instanceof Logger) {
Expand All @@ -277,11 +277,11 @@ function notice($message, $context = array()) {
$logger->notice($message, $context);
}

function debug($message, $context = array()) {
function debug($message, $context = []) {
Crush::$config->logger->debug($message, $context);
}

function log($message, $context = array(), $type = 'debug') {
function log($message, $context = [], $type = 'debug') {
Crush::$config->logger->$type($message, $context);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/CssCrush/Declaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function process($parentRule)
public function indexFunctions()
{
// Create an index of all regular functions in the value.
$functions = array();
$functions = [];
if (preg_match_all(Regex::$patt->functionTest, $this->value, $m)) {
foreach ($m['func_name'] as $fn_name) {
$functions[strtolower($fn_name)] = true;
Expand Down
32 changes: 16 additions & 16 deletions lib/CssCrush/DeclarationList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class DeclarationList extends Iterator
public $processed = false;
protected $rule;

public $properties = array();
public $canonicalProperties = array();
public $properties = [];
public $canonicalProperties = [];

// Declarations hash table for inter-rule this() referencing.
public $data = array();
public $data = [];

// Declarations hash table for external query() referencing.
public $queryData = array();
public $queryData = [];

public function __construct($declarationsString, Rule $rule)
{
Expand Down Expand Up @@ -104,8 +104,8 @@ public function index($declaration)

public function updateIndex()
{
$this->properties = array();
$this->canonicalProperties = array();
$this->properties = [];
$this->canonicalProperties = [];

foreach ($this->store as $declaration) {
$this->index($declaration);
Expand Down Expand Up @@ -134,7 +134,7 @@ public function aliasProperties($vendor_context = null)
return;
}

$stack = array();
$stack = [];
$rule_updated = false;
$regex = Regex::$patt;

Expand Down Expand Up @@ -199,7 +199,7 @@ public function aliasFunctions($vendor_context = null)
$function_alias_groups =& Crush::$process->aliases['function_groups'];

// The new modified set of declarations.
$new_set = array();
$new_set = [];
$rule_updated = false;

// Shim in aliased functions.
Expand All @@ -219,12 +219,12 @@ public function aliasFunctions($vendor_context = null)
}

// Keep record of which groups have been applied.
$processed_groups = array();
$processed_groups = [];

foreach (array_keys($intersect) as $fn_name) {

// Store for all the duplicated declarations.
$prefixed_copies = array();
$prefixed_copies = [];

// Grouped function aliases.
if ($function_aliases[$fn_name][0] === '.') {
Expand Down Expand Up @@ -323,7 +323,7 @@ public function aliasDeclarations($vendor_context = null)
}

$intersect = array_flip(array_keys($intersect));
$new_set = array();
$new_set = [];
$rule_updated = false;

foreach ($this->store as $declaration) {
Expand Down Expand Up @@ -365,7 +365,7 @@ public function aliasDeclarations($vendor_context = null)
}
}

public static function parse($str, $options = array())
public static function parse($str, $options = [])
{
$str = Util::stripCommentTokens($str);
$lines = preg_split('~\s*;\s*~', $str, null, PREG_SPLIT_NO_EMPTY);
Expand All @@ -379,7 +379,7 @@ public static function parse($str, $options = array())
'apply_hooks' => false,
);

$pairs = array();
$pairs = [];

foreach ($lines as $line) {

Expand Down Expand Up @@ -443,10 +443,10 @@ public function flatten()
return;
}

$newSet = array();
$newSet = [];
foreach ($this->store as $declaration) {
if (is_array($declaration) && $declaration[0] === 'mixin') {
foreach (Mixin::merge(array(), $declaration[1], array('context' => $this->rule)) as $mixable) {
foreach (Mixin::merge([], $declaration[1], array('context' => $this->rule)) as $mixable) {
if ($mixable instanceof Declaration) {
$clone = clone $mixable;
$clone->index = count($newSet);
Expand Down Expand Up @@ -552,7 +552,7 @@ public function expandData($dataset, $property)
}
if ($trbl_fmt) {
$parts = explode(' ', $value);
$placeholders = array();
$placeholders = [];

// 4 values.
if (isset($parts[3])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/CssCrush/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Fragment extends Template
{
public $name;

public function __construct($str, $options = array())
public function __construct($str, $options = [])
{
parent::__construct($str, $options);
$this->name = $options['name'];
Expand All @@ -32,7 +32,7 @@ public function __invoke(array $args = null, $str = null)

// Skip over same named fragments to avoid infinite recursion.
if ($fragment && $name !== $this->name) {
$args = array();
$args = [];
if (isset($m['parens'][1])) {
$args = Functions::parseArgs($m['parens_content'][0]);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/CssCrush/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Functions
'a-adjust' => 'CssCrush\fn__a_adjust',
);

public $register = array();
public $register = [];

protected $pattern;

protected $patternOptions;

public function __construct($register = array())
public function __construct($register = [])
{
$this->register = $register;
}
Expand Down Expand Up @@ -116,7 +116,7 @@ public function apply($str, \stdClass $context = null)

public static function parseArgs($input, $allowSpaceDelim = false)
{
$options = array();
$options = [];
if ($allowSpaceDelim) {
$options['regex'] = Regex::$patt->argListSplit;
}
Expand All @@ -135,8 +135,8 @@ public static function parseArgsSimple($input)

public static function makePattern($functionNames)
{
$idents = array();
$nonIdents = array();
$idents = [];
$nonIdents = [];

foreach ($functionNames as $functionName) {
if (preg_match(Regex::$patt->ident, $functionName[0])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/CssCrush/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getCacheData()

$cache_data_exists = file_exists($process->cacheFile);
$cache_data_file_is_writable = $cache_data_exists ? is_writable($process->cacheFile) : false;
$cache_data = array();
$cache_data = [];

if (
$cache_data_exists &&
Expand All @@ -178,7 +178,7 @@ public function getCacheData()
else {
debug('Creating cache data file.');
}
Util::filePutContents($process->cacheFile, json_encode(array()), __METHOD__);
Util::filePutContents($process->cacheFile, json_encode([]), __METHOD__);
}

return $cache_data;
Expand Down
4 changes: 2 additions & 2 deletions lib/CssCrush/IO/Watch.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class Watch extends IO
{
public static $cacheData = array();
public static $cacheData = [];

public function getOutputFileName()
{
Expand All @@ -36,7 +36,7 @@ public function getCacheData()
{
// Clear results from earlier processes.
clearstatcache();
$this->process->cacheData = array();
$this->process->cacheData = [];

return self::$cacheData;
}
Expand Down
Loading

0 comments on commit a3f64a7

Please sign in to comment.