Changeset 2693063
- Timestamp:
- 03/12/2022 10:25:31 PM (4 years ago)
- Location:
- torque/trunk
- Files:
-
- 28 edited
-
packages.php (modified) (1 diff)
-
packages/cssdoc/cssdoc.php (modified) (6 diffs)
-
packages/cssdoc/tokens/directive.php (modified) (1 diff)
-
packages/cssdoc/tokens/document.php (modified) (1 diff)
-
packages/cssdoc/tokens/property.php (modified) (1 diff)
-
packages/cssdoc/tokens/rule.php (modified) (2 diffs)
-
packages/cssdoc/tokens/selector.php (modified) (1 diff)
-
packages/cssdoc/tokens/value.php (modified) (1 diff)
-
packages/htmldoc/htmldoc.php (modified) (8 diffs)
-
packages/htmldoc/tokens/comment.php (modified) (1 diff)
-
packages/htmldoc/tokens/custom.php (modified) (1 diff)
-
packages/htmldoc/tokens/doctype.php (modified) (1 diff)
-
packages/htmldoc/tokens/tag.php (modified) (7 diffs)
-
packages/htmldoc/tokens/text.php (modified) (1 diff)
-
packages/jslite/jslite.php (modified) (3 diffs)
-
packages/jslite/tokens/brackets.php (modified) (1 diff)
-
packages/jslite/tokens/comment.php (modified) (1 diff)
-
packages/jslite/tokens/expression.php (modified) (1 diff)
-
packages/jslite/tokens/keyword.php (modified) (1 diff)
-
packages/jslite/tokens/number.php (modified) (1 diff)
-
packages/jslite/tokens/operator.php (modified) (1 diff)
-
packages/jslite/tokens/regexp.php (modified) (1 diff)
-
packages/jslite/tokens/string.php (modified) (1 diff)
-
packages/jslite/tokens/variable.php (modified) (1 diff)
-
packages/jslite/tokens/whitespace.php (modified) (1 diff)
-
packages/tokenise/tokenise.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
torque.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
torque/trunk/packages.php
r2658197 r2693063 17 17 * @var string VERSION The version number of the application, this is used in the cache key for CSS/Javascript that is minified 18 18 */ 19 public const VERSION = '0. 5.8';19 public const VERSION = '0.6.0'; 20 20 21 21 /** -
torque/trunk/packages/cssdoc/cssdoc.php
r2639345 r2693063 9 9 * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML 10 10 */ 11 protected static $tokens = [11 protected static array $tokens = [ 12 12 'whitespace' => '\s++', 13 13 'comment' => '\\/\\*[\d\D]*?\\*\\/', … … 33 33 * @var array $config Object configuration array 34 34 */ 35 protected $config = [35 protected array $config = [ 36 36 'nested' => ['@media', '@supports', '@keyframes', '@-webkit-keyframes', '@-moz-keyframes', '@-o-keyframes', '@document', '@-moz-document', '@container'], // directive that can have nested rules 37 37 'spaced' => ['calc'], // values where spaces between operators must be retained … … 204 204 * @var document $document The root document 205 205 */ 206 protected $document;206 protected document $document; 207 207 208 208 /** 209 209 * @var int $pointer The current pointer position for the array iterator 210 210 */ 211 protected $pointer = 0;211 protected int $pointer = 0; 212 212 213 213 /** … … 253 253 */ 254 254 public function offsetSet($i, $value) : void { 255 if (\is_null($i)) $this->document->rules[] = $value; 256 else $this->document->rules[$i] = $value; 255 if (\is_null($i)) { 256 $this->document->rules[] = $value; 257 } else { 258 $this->document->rules[$i] = $value; 259 } 257 260 } 258 261 … … 282 285 * @return mixed The requested value or null if the key doesn't exist 283 286 */ 284 public function offsetGet( $i){ // return reference so you can set it like an array287 public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array 285 288 return $this->document->rules[$i] ?? null; 286 289 } … … 291 294 * @return document|rule The child node at the current pointer position 292 295 */ 293 public function current() {296 public function current() : mixed { 294 297 return $this->document->rules[$this->pointer] ?? null; 295 298 } -
torque/trunk/packages/cssdoc/tokens/directive.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var string The name of the directive 15 15 */ 16 protected $directive;16 protected string $directive; 17 17 18 18 /** 19 * @var string The value of the directive19 * @var array The contents of the directive, split into parts 20 20 */ 21 public $content = [];21 public array $content = []; 22 22 23 23 /** 24 24 * @var array An array of properties 25 25 */ 26 public $properties = [];26 public array $properties = []; 27 27 28 28 /** 29 29 * @var document A document object 30 30 */ 31 public $document = null;31 public ?document $document = null; 32 32 33 33 /** -
torque/trunk/packages/cssdoc/tokens/document.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var array An array of child token objects 15 15 */ 16 public $rules = [];16 public array $rules = []; 17 17 18 18 /** -
torque/trunk/packages/cssdoc/tokens/property.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var string The name of the property 15 15 */ 16 protected $name;16 protected string $name; 17 17 18 18 /** 19 19 * @var array The values of the property 20 20 */ 21 protected $value = [];21 protected array $value = []; 22 22 23 23 /** 24 24 * @var bool Whether the property is important 25 25 */ 26 protected $important = false;26 protected bool $important = false; 27 27 28 28 /** 29 29 * @var bool Whether the property has a semi-colon to close it 30 30 */ 31 public $semicolon = false;31 public bool $semicolon = false; 32 32 33 33 /** 34 34 * @var string Any comment specified with the property 35 35 */ 36 protected $comment = null;36 protected ?string $comment = null; 37 37 38 38 /** -
torque/trunk/packages/cssdoc/tokens/rule.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var array An array of selectors 15 15 */ 16 protected $selectors = [];16 protected array $selectors = []; 17 17 18 18 /** 19 19 * @var array An array of properties 20 20 */ 21 public $properties = [];21 public array $properties = []; 22 22 23 23 /** 24 24 * @var string A comment 25 25 */ 26 protected $comment = null;26 protected ?string $comment = null; 27 27 28 28 /** … … 97 97 $item->minify($minify); 98 98 } 99 100 // remove last semi-colon 99 101 if ($this->properties && $minify['semicolons']) { 100 102 \end($this->properties)->semicolon = false; -
torque/trunk/packages/cssdoc/tokens/selector.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var array An array of selectors 15 15 */ 16 protected $selectors = [];16 protected array $selectors = []; 17 17 18 18 /** -
torque/trunk/packages/cssdoc/tokens/value.php
r2592945 r2693063 9 9 * @var cssdoc The parent CSSdoc object 10 10 */ 11 protected $root;11 protected cssdoc $root; 12 12 13 13 /** 14 14 * @var string The name of the parent property 15 15 */ 16 protected $name = null;16 protected ?string $name = null; 17 17 18 18 /** 19 19 * @var bool Whether the value is within brackets 20 20 */ 21 protected $brackets = false;22 23 /** 24 * @var valueProperties21 protected bool $brackets = false; 22 23 /** 24 * @var array Properties 25 25 */ 26 26 protected $properties = []; -
torque/trunk/packages/htmldoc/htmldoc.php
r2615373 r2693063 9 9 * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML 10 10 */ 11 protected static $tokens = [11 protected static array $tokens = [ 12 12 'textnode' => '(?<=>|^)[^<]++(?=<|$)', 13 13 'attributevalue' => '\\s*+=\\s*+(?:"[^"]*+"++|\'[^\']*+\'++|[^\\s>]*+)', … … 27 27 * @var array $selectors Regexp components keyed by their corresponding codename for tokenising CSS selectors 28 28 */ 29 protected static $selectors = [29 protected static array $selectors = [ 30 30 'quotes' => '(?<!\\\\)"(?:[^"\\\\]++|\\\\.)*+"', 31 31 'join' => '\\s*[>+~]\\s*', … … 46 46 * @var array $children Stores the regexp components keyed by their corresponding codename for tokenising CSS selectors 47 47 */ 48 protected $children = [];48 protected array $children = []; 49 49 50 50 /** 51 51 * @var int $pointer The current pointer position for the array iterator 52 52 */ 53 protected $pointer = 0;53 protected int $pointer = 0; 54 54 55 55 /** 56 56 * @var array A cache of attribute and class names for sorting 57 57 */ 58 protected $cache = [];58 protected array $cache = []; 59 59 60 60 /** … … 89 89 */ 90 90 public function offsetSet($i, $value) : void { 91 if (\is_null($i)) $this->children[] = $value; 92 else $this->children[$i] = $value; 91 if (\is_null($i)) { 92 $this->children[] = $value; 93 } else { 94 $this->children[$i] = $value; 95 } 93 96 } 94 97 … … 118 121 * @return mixed The requested value or null if the key doesn't exist 119 122 */ 120 public function offsetGet( $i){ // return reference so you can set it like an array123 public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array 121 124 return $this->children[$i] ?? null; 122 125 } … … 127 130 * @return tag|text|comment|doctype The child node at the current pointer position 128 131 */ 129 public function current() {132 public function current() : mixed { 130 133 return $this->children[$this->pointer] ?? null; 131 134 } … … 342 345 343 346 case 'squareopen': 344 $item = ['join' => $join ];347 $item = ['join' => $join, 'sensitive' => true]; 345 348 while (($token = $tokens->next()) !== null) { 346 349 if ($token['type'] === 'squareclose') { … … 350 353 $token['value'] = \stripslashes(\mb_substr($token['value'], 1, -1)); 351 354 } 352 $item[isset($item['attribute']) ? 'value' : 'attribute'] = $token['value']; 355 if (!isset($item['attribute'])) { 356 $item['attribute'] = $token['value']; 357 } elseif (!isset($item['value'])) { 358 $item['value'] = $token['value']; 359 } elseif ($token['value'] === 'i') { 360 $item['sensitive'] = false; 361 } 353 362 } elseif ($token['type'] === 'comparison') { 354 363 $item['comparison'] = $token['value']; -
torque/trunk/packages/htmldoc/tokens/comment.php
r2592945 r2693063 9 9 * @var string The text content of this object 10 10 */ 11 protected $content = null;11 protected ?string $content = null; 12 12 13 13 /** -
torque/trunk/packages/htmldoc/tokens/custom.php
r2592945 r2693063 9 9 * @var array The custom configuration 10 10 */ 11 protected $config = [];11 protected array $config = []; 12 12 13 13 /** 14 * @var arrayThe name of the tag14 * @var string The name of the tag 15 15 */ 16 protected $tagName;16 protected string $tagName; 17 17 18 18 /** 19 19 * @var string A string containing javascript 20 20 */ 21 protected $content = '';21 protected string $content = ''; 22 22 23 23 /** -
torque/trunk/packages/htmldoc/tokens/doctype.php
r2592945 r2693063 9 9 * @var array The text content of this object 10 10 */ 11 protected $content = [];11 protected array $content = []; 12 12 13 13 /** -
torque/trunk/packages/htmldoc/tokens/tag.php
r2639345 r2693063 9 9 * @var htmldoc The parent htmldoc object 10 10 */ 11 protected $root;11 protected htmldoc $root; 12 12 13 13 /** 14 14 * @var array The object configuration 15 15 */ 16 protected $config = [];16 protected array $config = []; 17 17 18 18 /** 19 19 * @var tag The parent tag object 20 20 */ 21 protected $parent = null;21 protected ?tag $parent = null; 22 22 23 23 /** 24 24 * @var array Cache for the list of parent tags 25 25 */ 26 protected $parenttags = null;26 protected ?array $parenttags = null; 27 27 28 28 /** 29 29 * @var string The type of tag 30 30 */ 31 protected $tagName = null;31 protected ?string $tagName = null; 32 32 33 33 /** 34 34 * @var array An array of attributes where the key is the name of the attribute and the value is the value 35 35 */ 36 protected $attributes = [];36 protected array $attributes = []; 37 37 38 38 /** 39 39 * @var string If the tag is a singleton, this defines the closing string 40 40 */ 41 protected $singleton = null;41 protected ?string $singleton = null; 42 42 43 43 /** 44 44 * @var array An array of child token objects 45 45 */ 46 protected $children = [];46 protected array $children = []; 47 47 48 48 /** 49 49 * @var bool Whether to close the tag when rendering as HTML 50 50 */ 51 public $close = true;51 public bool $close = true; 52 52 53 53 /** … … 330 330 } 331 331 332 /** 333 * Retrieve the index position of the current element in the parent 334 * 335 * @return int|null The index of the current element with the parent, or null if there is no parent 336 */ 332 337 protected function getIndex() : ?int { 333 338 foreach ($this->parent->children() AS $key => $item) { … … 429 434 // remove host for own domain 430 435 if ($minify['urls']['host'] && isset($_SERVER['HTTP_HOST'])) { 431 if (!isset($host)) { 432 $host = ['//'.$_SERVER['HTTP_HOST'], $scheme.$_SERVER['HTTP_HOST']]; 433 } 436 $host ??= ['//'.$_SERVER['HTTP_HOST'], $scheme.$_SERVER['HTTP_HOST']]; 434 437 foreach ($host AS $item) { 435 438 … … 665 668 break; 666 669 } elseif (!empty($item['value'])) { 670 $current = $this->attributes[$item['attribute']]; 667 671 switch ($item['comparison']) { 668 672 669 673 // exact match 670 674 case '=': 671 if ($this->attributes[$item['attribute']] !== $item['value']) { 675 if ($item['sensitive']) { 676 if ($current !== $item['value']) { 677 $match = false; 678 break; 679 } 680 } elseif (\mb_strtolower($current) !== \mb_strtolower($item['value'])) { 672 681 $match = false; 673 682 break; … … 677 686 // match start 678 687 case '^=': 679 if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) !== 0) { 688 if ($item['sensitive']) { 689 if (\mb_strpos($current, $item['value']) !== 0) { 690 $match = false; 691 break; 692 } 693 } elseif (\mb_stripos($current, $item['value']) !== 0) { 680 694 $match = false; 681 695 break; … … 685 699 // match within 686 700 case '*=': 687 if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) === false) { 701 if ($item['sensitive']) { 702 if (\mb_strpos($current, $item['value']) === false) { 703 $match = false; 704 break; 705 } 706 } elseif (\mb_stripos($current, $item['value']) === false) { 688 707 $match = false; 689 708 break; … … 693 712 // match end 694 713 case '$=': 695 if (\mb_strpos($this->attributes[$item['attribute']], $item['value']) !== \mb_strlen($this->attributes[$item['attribute']]) - \mb_strlen($item['value'])) { 714 if ($item['sensitive']) { 715 if (\mb_strpos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) { 716 $match = false; 717 break; 718 } 719 } elseif (\mb_stripos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) { 696 720 $match = false; 697 721 break; -
torque/trunk/packages/htmldoc/tokens/text.php
r2592945 r2693063 9 9 * @var htmldoc The parent htmldoc object 10 10 */ 11 protected $root;11 protected htmldoc $root; 12 12 13 13 /** 14 14 * @var tag The parent tag object 15 15 */ 16 protected $parent;16 protected tag $parent; 17 17 18 18 /** 19 19 * @var string The text content of this object 20 20 */ 21 protected $content = '';21 protected string $content = ''; 22 22 23 23 /** -
torque/trunk/packages/jslite/jslite.php
r2639345 r2693063 9 9 * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML 10 10 */ 11 protected static $tokens = [11 protected static array $tokens = [ 12 12 13 13 // capture the easy stuff first … … 48 48 ]; 49 49 50 protected $config = [50 protected array $config = [ 51 51 'minify' => [ 52 52 'whitespace' => true, // strip whitespace around javascript … … 59 59 ] 60 60 ]; 61 protected $expressions = null;61 protected ?array $expressions = null; 62 62 63 63 public function __construct(array $config = []) { -
torque/trunk/packages/jslite/tokens/brackets.php
r2615373 r2693063 7 7 8 8 public const significant = true; 9 protected $root;10 protected $expressions = [];11 public $bracket = 'bracket'; // square or bracket or curly9 protected expression $root; 10 protected array $expressions = []; 11 public string $bracket = 'bracket'; // square or bracket or curly 12 12 13 13 /** -
torque/trunk/packages/jslite/tokens/comment.php
r2592945 r2693063 10 10 * @var string The text content of this object 11 11 */ 12 protected $content = null;13 protected $multi = false;12 protected ?string $content = null; 13 protected bool $multi = false; 14 14 15 15 /** -
torque/trunk/packages/jslite/tokens/expression.php
r2639345 r2693063 7 7 8 8 public const significant = true; 9 public $commands = [];10 public $eol;11 public $bracket = null;9 public array $commands = []; 10 public ?string $eol = null; 11 public ?string $bracket = null; 12 12 13 13 public function __construct(?string $bracket = null) { -
torque/trunk/packages/jslite/tokens/keyword.php
r2639345 r2693063 7 7 8 8 public const significant = true; 9 public $content = '';9 public string $content = ''; 10 10 11 11 /** -
torque/trunk/packages/jslite/tokens/number.php
r2592945 r2693063 7 7 8 8 public const significant = true; 9 protected $content = '';9 protected string $content = ''; 10 10 11 11 /** -
torque/trunk/packages/jslite/tokens/operator.php
r2592945 r2693063 10 10 * @var string The text content of this object 11 11 */ 12 public $content = '';12 public string $content = ''; 13 13 14 14 /** -
torque/trunk/packages/jslite/tokens/regexp.php
r2592945 r2693063 7 7 8 8 public const significant = true; 9 protected $content = '';9 protected string $content = ''; 10 10 11 11 /** -
torque/trunk/packages/jslite/tokens/string.php
r2592945 r2693063 7 7 8 8 public const significant = true; 9 public $content = '';10 protected $quote = '"';11 protected $process = false;9 public string $content = ''; 10 protected string $quote = '"'; 11 protected bool $process = false; 12 12 13 13 /** -
torque/trunk/packages/jslite/tokens/variable.php
r2592945 r2693063 7 7 8 8 public const significant = true; 9 public $content = '';9 public string $content = ''; 10 10 11 11 /** -
torque/trunk/packages/jslite/tokens/whitespace.php
r2615373 r2693063 7 7 8 8 public const significant = false; 9 protected $parent;10 protected $content;9 protected expression $parent; 10 protected string $content; 11 11 12 12 /** -
torque/trunk/packages/tokenise/tokenise.php
r2592945 r2693063 8 8 * @var string $value Stores the subject value to be tokenised 9 9 */ 10 protected $value = '';10 protected string $value = ''; 11 11 12 12 /** 13 13 * @var string $pattern Stores the regexp pattern to tokenise the string with 14 14 */ 15 protected $pattern = '';15 protected string $pattern = ''; 16 16 17 17 /** 18 18 * @var array $keys An array to map the regexp output with the token type 19 19 */ 20 protected $keys = [];20 protected array $keys = []; 21 21 22 22 /** 23 23 * @var int $pos The position within $value to retrieve the next token from 24 24 */ 25 protected $pos = 0;25 protected int $pos = 0; 26 26 27 27 /** 28 28 * @var int $pointer The current token position 29 29 */ 30 protected $pointer = -1;30 protected int $pointer = -1; 31 31 32 32 /** 33 33 * @var array $tokens An array of captured tokens 34 34 */ 35 protected $tokens = [];35 protected array $tokens = []; 36 36 37 37 /** -
torque/trunk/readme.txt
r2658197 r2693063 2 2 Contributors: hexydec 3 3 Tags: minify,minification,performance,security,optimization 4 Requires at least: 5. 75 Tested up to: 5. 86 Requires PHP: 7.37 Stable tag: 0. 5.84 Requires at least: 5.9 5 Tested up to: 5.9 6 Requires PHP: 8.0 7 Stable tag: 0.6.0 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 137 137 == Changelog == 138 138 139 = Version 0.6.0 = 140 141 * Updated dependencies to fix PHP 8.0/8.1 issues 142 139 143 = Version 0.5.8 = 140 144 -
torque/trunk/torque.php
r2658197 r2693063 10 10 Plugin URI: https://github.com/hexydec/torque 11 11 Description: Make your Wordpress website noticably faster by optimising how it is delivered. Analyse your website's performance and security, minify and combine your assets, and configure an array of performance and security settings quickly and easily with this comprehensive plugin. Achieves the best compression of any minification plugin. 12 Version: 0. 5.813 Requires PHP: 7.312 Version: 0.6.0 13 Requires PHP: 8.0 14 14 Author: Hexydec 15 15 Author URI: https://github.com/hexydec/
Note: See TracChangeset
for help on using the changeset viewer.