update crush4 for php8
Update for php8 with small changes
This commit is contained in:
		
							parent
							
								
									040589d296
								
							
						
					
					
						commit
						b35bf2a665
					
				
					 10 changed files with 161 additions and 61 deletions
				
			
		
							
								
								
									
										107
									
								
								include/thirdparty/css-crush/.eslintrc.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								include/thirdparty/css-crush/.eslintrc.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,107 @@
 | 
			
		|||
/*eslint sort-keys: 2*/
 | 
			
		||||
/*eslint object-property-newline: 2*/
 | 
			
		||||
/*eslint quote-props: [2, "consistent"]*/
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    env: {
 | 
			
		||||
        es6: true,
 | 
			
		||||
        node: true,
 | 
			
		||||
    },
 | 
			
		||||
    extends: 'eslint:recommended',
 | 
			
		||||
    parserOptions: {
 | 
			
		||||
        ecmaVersion: 9,
 | 
			
		||||
    },
 | 
			
		||||
    rules: {
 | 
			
		||||
        'array-bracket-spacing': [2, 'never'],
 | 
			
		||||
        'array-element-newline': [2, 'consistent'],
 | 
			
		||||
        'arrow-parens': [2, 'as-needed'],
 | 
			
		||||
        'arrow-spacing': 2,
 | 
			
		||||
        'brace-style': [2, 'stroustrup'],
 | 
			
		||||
        'camelcase': [2, {
 | 
			
		||||
            ignoreDestructuring: true,
 | 
			
		||||
            properties: 'never',
 | 
			
		||||
        }],
 | 
			
		||||
        'comma-dangle': [2, {
 | 
			
		||||
            arrays: 'always-multiline',
 | 
			
		||||
            functions: 'never',
 | 
			
		||||
            objects: 'always-multiline',
 | 
			
		||||
        }],
 | 
			
		||||
        'comma-spacing': [2, {
 | 
			
		||||
            after: true,
 | 
			
		||||
            before: false,
 | 
			
		||||
        }],
 | 
			
		||||
        'curly': 2,
 | 
			
		||||
        'eol-last': [2, 'always'],
 | 
			
		||||
        'eqeqeq': 2,
 | 
			
		||||
        'key-spacing': [2, {
 | 
			
		||||
            afterColon: true,
 | 
			
		||||
            beforeColon: false,
 | 
			
		||||
        }],
 | 
			
		||||
        'keyword-spacing': 2,
 | 
			
		||||
        'linebreak-style': [2, 'unix'],
 | 
			
		||||
        'multiline-comment-style': [2, 'starred-block'],
 | 
			
		||||
        'no-console': 2,
 | 
			
		||||
        'no-dupe-keys': 2,
 | 
			
		||||
        'no-else-return': 2,
 | 
			
		||||
        'no-empty': [2, {
 | 
			
		||||
            allowEmptyCatch: true,
 | 
			
		||||
        }],
 | 
			
		||||
        'no-lonely-if': 2,
 | 
			
		||||
        'no-multi-spaces': 2,
 | 
			
		||||
        'no-multiple-empty-lines': [2, {
 | 
			
		||||
            max: 2,
 | 
			
		||||
            maxBOF: 1,
 | 
			
		||||
            maxEOF: 1,
 | 
			
		||||
        }],
 | 
			
		||||
        'no-new-object': 2,
 | 
			
		||||
        'no-template-curly-in-string': 2,
 | 
			
		||||
        'no-tabs': 2,
 | 
			
		||||
        'no-throw-literal': 2,
 | 
			
		||||
        'no-trailing-spaces': 2,
 | 
			
		||||
        'no-unneeded-ternary': 2,
 | 
			
		||||
        'no-unused-expressions': [2, {allowShortCircuit: true}],
 | 
			
		||||
        'no-unused-vars': [2, {
 | 
			
		||||
            args: 'all',
 | 
			
		||||
            argsIgnorePattern: '^(req|res|next)$|^_',
 | 
			
		||||
            varsIgnorePattern: '^_$',
 | 
			
		||||
        }],
 | 
			
		||||
        'no-useless-call': 2,
 | 
			
		||||
        'no-useless-concat': 2,
 | 
			
		||||
        'no-useless-return': 2,
 | 
			
		||||
        'no-var': 2,
 | 
			
		||||
        'object-curly-newline': [2, {consistent: true}],
 | 
			
		||||
        'object-curly-spacing': [2, 'never'],
 | 
			
		||||
        'object-shorthand': [2, 'properties'],
 | 
			
		||||
        'operator-linebreak': [2, 'before', {
 | 
			
		||||
            overrides: {
 | 
			
		||||
                ':': 'ignore',
 | 
			
		||||
                '?': 'ignore',
 | 
			
		||||
            },
 | 
			
		||||
        }],
 | 
			
		||||
        'prefer-arrow-callback': 2,
 | 
			
		||||
        'prefer-const': [2, {destructuring: 'all'}],
 | 
			
		||||
        'prefer-destructuring': [2, {
 | 
			
		||||
            array: false,
 | 
			
		||||
            object: true,
 | 
			
		||||
        }],
 | 
			
		||||
        'prefer-object-spread': 2,
 | 
			
		||||
        'quote-props': [2, 'as-needed'],
 | 
			
		||||
        'quotes': [2, 'single', {
 | 
			
		||||
            allowTemplateLiterals: true,
 | 
			
		||||
            avoidEscape: true,
 | 
			
		||||
        }],
 | 
			
		||||
        'semi': [2, 'always'],
 | 
			
		||||
        'space-before-blocks': 2,
 | 
			
		||||
        'space-before-function-paren': [2, {
 | 
			
		||||
            anonymous: 'always',
 | 
			
		||||
            asyncArrow: 'always',
 | 
			
		||||
            named: 'never',
 | 
			
		||||
        }],
 | 
			
		||||
        'space-unary-ops': [2, {
 | 
			
		||||
            nonwords: false,
 | 
			
		||||
            overrides: {'!': true},
 | 
			
		||||
            words: true,
 | 
			
		||||
        }],
 | 
			
		||||
        'yoda': 2,
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										2
									
								
								include/thirdparty/css-crush/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								include/thirdparty/css-crush/README.md
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
[](https://travis-ci.org/peteboere/css-crush)
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
<img src="http://the-echoplex.net/csscrush/images/css-crush-external.svg?v=2" alt="Logo"/>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										46
									
								
								include/thirdparty/css-crush/aliases.ini
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								include/thirdparty/css-crush/aliases.ini
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -73,40 +73,23 @@
 | 
			
		|||
    align-items[] = -webkit-align-items
 | 
			
		||||
    align-self[] = -webkit-align-self
 | 
			
		||||
    flex[] = -webkit-flex
 | 
			
		||||
    flex[] = -ms-flex
 | 
			
		||||
    flex-basis[] = -webkit-flex-basis
 | 
			
		||||
    flex-direction[] = -webkit-flex-direction
 | 
			
		||||
    flex-direction[] = -ms-flex-direction
 | 
			
		||||
    flex-flow[] = -webkit-flex-flow
 | 
			
		||||
    flex-flow[] = -ms-flex-flow
 | 
			
		||||
    flex-grow[] = -webkit-flex-grow
 | 
			
		||||
    flex-shrink[] = -webkit-flex-shrink
 | 
			
		||||
    flex-wrap[] = -webkit-flex-wrap
 | 
			
		||||
    flex-wrap[] = -ms-flex-wrap
 | 
			
		||||
    justify-content[] = -webkit-justify-content
 | 
			
		||||
    order[] = -webkit-order
 | 
			
		||||
    order[] = -ms-flex-order
 | 
			
		||||
 | 
			
		||||
    ; Hyphens.
 | 
			
		||||
    hyphens[] = -webkit-hyphens
 | 
			
		||||
    hyphens[] = -ms-hyphens
 | 
			
		||||
 | 
			
		||||
    ; Outline radius.
 | 
			
		||||
    outline-radius[] = -moz-outline-radius
 | 
			
		||||
    outline-top-left-radius[] = -moz-outline-radius-topleft
 | 
			
		||||
    outline-top-right-radius[] = -moz-outline-radius-topright
 | 
			
		||||
    outline-bottom-left-radius[] = -moz-outline-radius-bottomleft
 | 
			
		||||
    outline-bottom-right-radius[] = -moz-outline-radius-bottomright
 | 
			
		||||
 | 
			
		||||
    ; Perspective.
 | 
			
		||||
    perspective[] = -webkit-perspective
 | 
			
		||||
    perspective-origin[] = -webkit-perspective-origin
 | 
			
		||||
 | 
			
		||||
    ; Shapes
 | 
			
		||||
    shape-image-threshold[] = -webkit-shape-image-threshold
 | 
			
		||||
    shape-outside[] = -webkit-shape-outside
 | 
			
		||||
    shape-margin[] = -webkit-shape-margin
 | 
			
		||||
 | 
			
		||||
    ; Tab size.
 | 
			
		||||
    tab-size[] = -moz-tab-size
 | 
			
		||||
    tab-size[] = -o-tab-size
 | 
			
		||||
| 
						 | 
				
			
			@ -143,38 +126,9 @@
 | 
			
		|||
[declarations]
 | 
			
		||||
 | 
			
		||||
    ; Flexbox (2012).
 | 
			
		||||
    display:flex[] = display:-ms-flexbox
 | 
			
		||||
    display:flex[] = display:-webkit-flex
 | 
			
		||||
    display:inline-flex[] = display:-ms-inline-flexbox
 | 
			
		||||
    display:inline-flex[] = display:-webkit-inline-flex
 | 
			
		||||
 | 
			
		||||
    ; Flexbox (early 2012).
 | 
			
		||||
    align-content:flex-start[] = -ms-flex-line-pack:start
 | 
			
		||||
    align-content:flex-end[] = -ms-flex-line-pack:end
 | 
			
		||||
    align-content:center[] = -ms-flex-line-pack:center
 | 
			
		||||
    align-content:space-between[] = -ms-flex-line-pack:justify
 | 
			
		||||
    align-content:space-around[] = -ms-flex-line-pack:distribute
 | 
			
		||||
    align-content:stretch[] = -ms-flex-line-pack:stretch
 | 
			
		||||
 | 
			
		||||
    align-items:flex-start[] = -ms-flex-align:start
 | 
			
		||||
    align-items:flex-end[] = -ms-flex-align:end
 | 
			
		||||
    align-items:center[] = -ms-flex-align:center
 | 
			
		||||
    align-items:baseline[] = -ms-flex-align:baseline
 | 
			
		||||
    align-items:stretch[] = -ms-flex-align:stretch
 | 
			
		||||
 | 
			
		||||
    align-self:auto[] = -ms-flex-item-align:auto
 | 
			
		||||
    align-self:flex-start[] = -ms-flex-item-align:start
 | 
			
		||||
    align-self:flex-end[] = -ms-flex-item-align:end
 | 
			
		||||
    align-self:center[] = -ms-flex-item-align:center
 | 
			
		||||
    align-self:baseline[] = -ms-flex-item-align:baseline
 | 
			
		||||
    align-self:stretch[] = -ms-flex-item-align:stretch
 | 
			
		||||
 | 
			
		||||
    justify-content:flex-start[] = -ms-flex-pack:start
 | 
			
		||||
    justify-content:flex-end[] = -ms-flex-pack:end
 | 
			
		||||
    justify-content:center[] = -ms-flex-pack:center
 | 
			
		||||
    justify-content:space-between[] = -ms-flex-pack:justify
 | 
			
		||||
    justify-content:space-around[] = -ms-flex-pack:distribute
 | 
			
		||||
 | 
			
		||||
    ; Cursor values (non-standard).
 | 
			
		||||
    cursor:zoom-in[] = cursor:-webkit-zoom-in
 | 
			
		||||
    cursor:zoom-out[] = cursor:-webkit-zoom-out
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -285,5 +285,9 @@ function log($message, $context = [], $type = 'debug') {
 | 
			
		|||
    Crush::$config->logger->$type($message, $context);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Compat with PHP < 7.2.
 | 
			
		||||
if (! defined('PREG_UNMATCHED_AS_NULL')) {
 | 
			
		||||
    define('PREG_UNMATCHED_AS_NULL', null);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Crush::init();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -368,7 +368,7 @@ class DeclarationList extends Iterator
 | 
			
		|||
    public static function parse($str, $options = [])
 | 
			
		||||
    {
 | 
			
		||||
        $str = Util::stripCommentTokens($str);
 | 
			
		||||
        $lines = preg_split('~\s*;\s*~', $str, null, PREG_SPLIT_NO_EMPTY);
 | 
			
		||||
        $lines = preg_split('~\s*;\s*~', $str, -1, PREG_SPLIT_NO_EMPTY);
 | 
			
		||||
 | 
			
		||||
        $options += [
 | 
			
		||||
            'keyed' => false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,7 +102,9 @@ class Functions
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $str = substr_replace($str, $returns, $offset, $closingParen - $offset);
 | 
			
		||||
            if (! is_null($returns)) {
 | 
			
		||||
                $str = substr_replace($str, $returns, $offset, $closingParen - $offset);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $str;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,10 @@ class IO
 | 
			
		|||
    {
 | 
			
		||||
        $options = $this->process->options;
 | 
			
		||||
 | 
			
		||||
        $inputBasename = basename($this->process->input->filename, '.css');
 | 
			
		||||
        $inputBasename = $this->process->input->filename
 | 
			
		||||
            ? basename($this->process->input->filename, '.css')
 | 
			
		||||
            : 'styles';
 | 
			
		||||
 | 
			
		||||
        $outputBasename = $inputBasename;
 | 
			
		||||
 | 
			
		||||
        if (! empty($options->output_file)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ class Iterator implements \IteratorAggregate, \ArrayAccess, \Countable
 | 
			
		|||
    /*
 | 
			
		||||
        IteratorAggregate implementation.
 | 
			
		||||
    */
 | 
			
		||||
    public function getIterator()
 | 
			
		||||
    public function getIterator(): \Traversable
 | 
			
		||||
    {
 | 
			
		||||
        return new \ArrayIterator($this->store);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -26,22 +26,22 @@ class Iterator implements \IteratorAggregate, \ArrayAccess, \Countable
 | 
			
		|||
    /*
 | 
			
		||||
        ArrayAccess implementation.
 | 
			
		||||
    */
 | 
			
		||||
    public function offsetExists($index)
 | 
			
		||||
    public function offsetExists($index): bool
 | 
			
		||||
    {
 | 
			
		||||
        return array_key_exists($index, $this->store);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function offsetGet($index)
 | 
			
		||||
    public function offsetGet($index): mixed
 | 
			
		||||
    {
 | 
			
		||||
        return isset($this->store[$index]) ? $this->store[$index] : null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function offsetSet($index, $value)
 | 
			
		||||
    public function offsetSet($index, $value): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->store[$index] = $value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function offsetUnset($index)
 | 
			
		||||
    public function offsetUnset($index): void
 | 
			
		||||
    {
 | 
			
		||||
        unset($this->store[$index]);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ class Iterator implements \IteratorAggregate, \ArrayAccess, \Countable
 | 
			
		|||
    /*
 | 
			
		||||
        Countable implementation.
 | 
			
		||||
    */
 | 
			
		||||
    public function count()
 | 
			
		||||
    public function count(): int
 | 
			
		||||
    {
 | 
			
		||||
        return count($this->store);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ class Process
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        $this->input->dir = $input_dir ?: $this->docRoot;
 | 
			
		||||
        $this->input->dirUrl = substr($input_dir, strlen($this->docRoot));
 | 
			
		||||
        $this->input->dirUrl = substr($this->input->dir, strlen($this->docRoot));
 | 
			
		||||
 | 
			
		||||
        $this->output->dir = $this->io->getOutputDir();
 | 
			
		||||
        $this->output->filename = $this->io->getOutputFileName();
 | 
			
		||||
| 
						 | 
				
			
			@ -268,7 +268,7 @@ class Process
 | 
			
		|||
        foreach ($vendor_names as &$vendor_name) {
 | 
			
		||||
            $vendor_name = trim($vendor_name, '-');
 | 
			
		||||
        }
 | 
			
		||||
        $vendor_patt = '~^\-(' . implode($vendor_names, '|') . ')\-~i';
 | 
			
		||||
        $vendor_patt = '~^\-(' . implode('|', $vendor_names) . ')\-~i';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // Loop the aliases array, filter down to the target vendor.
 | 
			
		||||
| 
						 | 
				
			
			@ -623,7 +623,7 @@ class Process
 | 
			
		|||
 | 
			
		||||
            $traceOffset = $traceMatches[0][$count][1];
 | 
			
		||||
 | 
			
		||||
            preg_match($rulePatt, $this->string->raw, $ruleMatch, null, $traceOffset);
 | 
			
		||||
            preg_match($rulePatt, $this->string->raw, $ruleMatch, PREG_UNMATCHED_AS_NULL, $traceOffset);
 | 
			
		||||
 | 
			
		||||
            $selector = trim($ruleMatch['selector']);
 | 
			
		||||
            $block = trim($ruleMatch['block_content']);
 | 
			
		||||
| 
						 | 
				
			
			@ -913,6 +913,9 @@ class Process
 | 
			
		|||
            'memory_limit' => '128M',
 | 
			
		||||
        ] as $name => $value) {
 | 
			
		||||
            $this->iniOriginal[$name] = ini_get($name);
 | 
			
		||||
            if ($name === 'memory_limit' && $this->returnBytes(ini_get($name)) > $this->returnBytes($value)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            ini_set($name, $value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -924,6 +927,25 @@ class Process
 | 
			
		|||
        $this->stat['compile_start_time'] = microtime(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function returnBytes(string $value)
 | 
			
		||||
    {
 | 
			
		||||
        $value = trim($value);
 | 
			
		||||
        $last = strtolower($value[strlen($value) - 1]);
 | 
			
		||||
        $value = (float) $value;
 | 
			
		||||
 | 
			
		||||
        switch ($last) {
 | 
			
		||||
            // The 'G' modifier is available
 | 
			
		||||
            case 'g':
 | 
			
		||||
                $value *= 1024;
 | 
			
		||||
            case 'm':
 | 
			
		||||
                $value *= 1024;
 | 
			
		||||
            case 'k':
 | 
			
		||||
                $value *= 1024;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function postCompile()
 | 
			
		||||
    {
 | 
			
		||||
        $this->release();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -170,8 +170,16 @@ class Url
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        $mime_type = $allowed_file_extensions[$file_ext];
 | 
			
		||||
        $base64 = base64_encode(file_get_contents($file));
 | 
			
		||||
        $this->value = "data:$mime_type;base64,$base64";
 | 
			
		||||
        $file_contents = file_get_contents($file);
 | 
			
		||||
 | 
			
		||||
        if ($file_ext === 'svg') {
 | 
			
		||||
            $string = preg_replace('/\R/', '%0A', trim($file_contents));
 | 
			
		||||
            $this->value = "data:$mime_type;utf8,$string";
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            $base64 = base64_encode($file_contents);
 | 
			
		||||
            $this->value = "data:$mime_type;base64,$base64";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $this->setType('data')->protocol = 'data';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue