Changeset 2817597
- Timestamp:
- 11/14/2022 10:41:38 AM (3 years ago)
- Location:
- torque/trunk
- Files:
-
- 35 edited
-
app.php (modified) (1 diff)
-
assets.php (modified) (1 diff)
-
packages.php (modified) (1 diff)
-
packages/cssdoc/autoload.php (modified) (2 diffs)
-
packages/cssdoc/cssdoc.php (modified) (13 diffs)
-
packages/cssdoc/tokens/directive.php (modified) (2 diffs)
-
packages/cssdoc/tokens/document.php (modified) (3 diffs)
-
packages/cssdoc/tokens/property.php (modified) (2 diffs)
-
packages/cssdoc/tokens/rule.php (modified) (2 diffs)
-
packages/cssdoc/tokens/selector.php (modified) (2 diffs)
-
packages/cssdoc/tokens/value.php (modified) (2 diffs)
-
packages/htmldoc/autoload.php (modified) (2 diffs)
-
packages/htmldoc/helpers/selector.php (modified) (4 diffs)
-
packages/htmldoc/htmldoc.php (modified) (3 diffs)
-
packages/htmldoc/tokens/comment.php (modified) (1 diff)
-
packages/htmldoc/tokens/custom.php (modified) (2 diffs)
-
packages/htmldoc/tokens/doctype.php (modified) (1 diff)
-
packages/htmldoc/tokens/interfaces/token.php (modified) (1 diff)
-
packages/htmldoc/tokens/tag.php (modified) (5 diffs)
-
packages/htmldoc/tokens/text.php (modified) (1 diff)
-
packages/jslite/autoload.php (modified) (2 diffs)
-
packages/jslite/jslite.php (modified) (4 diffs)
-
packages/jslite/tokens/brackets.php (modified) (3 diffs)
-
packages/jslite/tokens/comment.php (modified) (2 diffs)
-
packages/jslite/tokens/expression.php (modified) (9 diffs)
-
packages/jslite/tokens/keyword.php (modified) (2 diffs)
-
packages/jslite/tokens/number.php (modified) (2 diffs)
-
packages/jslite/tokens/operator.php (modified) (2 diffs)
-
packages/jslite/tokens/regexp.php (modified) (2 diffs)
-
packages/jslite/tokens/string.php (modified) (2 diffs)
-
packages/jslite/tokens/variable.php (modified) (3 diffs)
-
packages/jslite/tokens/whitespace.php (modified) (3 diffs)
-
packages/tokenise/autoload.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
torque.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
torque/trunk/app.php
r2727595 r2817597 311 311 protected function getContentSecurityPolicy(array $config) : ?string { 312 312 $fields = [ 313 'default' => 'default ',313 'default' => 'default-src', 314 314 'style' => 'style-src', 315 315 'script' => 'script-src', -
torque/trunk/assets.php
r2658195 r2817597 256 256 257 257 // create the directory if it doesn't exist 258 $dir = \dirname($target);258 $dir = \dirname($target); 259 259 if (!\is_dir($dir)) { 260 260 \mkdir($dir, 0755); -
torque/trunk/packages.php
r2727595 r2817597 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.6. 3';19 public const VERSION = '0.6.4'; 20 20 21 21 /** -
torque/trunk/packages/cssdoc/autoload.php
r2592945 r2817597 1 1 <?php 2 spl_autoload_register(function (string $class) : bool { 2 declare(strict_types = 1); 3 \spl_autoload_register(function (string $class) : void { 3 4 $classes = [ 4 5 'hexydec\\css\\cssdoc' => __DIR__.'/cssdoc.php', … … 11 12 ]; 12 13 if (isset($classes[$class])) { 13 re turn (bool) require($classes[$class]);14 require($classes[$class]); 14 15 } 15 return false;16 16 }); -
torque/trunk/packages/cssdoc/cssdoc.php
r2727595 r2817597 7 7 8 8 /** 9 * @var array $tokens Regexp components keyed by their corresponding codename for tokenising HTML9 * @var array<string> $tokens Regexp components keyed by their corresponding codename for tokenising HTML 10 10 */ 11 11 protected static array $tokens = [ … … 31 31 32 32 /** 33 * @var array $config Object configuration array33 * @var array<array> $config Object configuration array 34 34 */ 35 35 protected array $config = [ … … 83 83 'mediumvioletred' => '#c71585', 84 84 'palevioletred' => '#db7093', 85 'lightsalmon' => '#ffa07a',86 85 'orangered' => '#ff4500', 87 86 'darkorange' => '#ff8c00', … … 143 142 'dodgerblue' => '#1e90ff', 144 143 'cornflowerblue' => '#6495ed', 145 'mediumslateblue' => '#7b68ee',146 144 'royalblue' => '#4169e1', 147 145 'mediumblue' => '#0000cd', … … 202 200 203 201 /** 204 * @var document $document The root document205 */ 206 p rotected document $document;202 * @var ?document $document The root document 203 */ 204 public ?document $document = null; 207 205 208 206 /** … … 231 229 public function __get(string $var) { 232 230 if ($var === 'length') { 233 return \count($this-> children);231 return \count($this->document->rules ?? []); 234 232 } elseif ($var === 'config') { 235 233 return $this->config; … … 244 242 */ 245 243 public function toArray() : array { 246 return $this->document->rules ;244 return $this->document->rules ?? []; 247 245 } 248 246 … … 250 248 * Array access method allows you to set the object's configuration as properties 251 249 * 252 * @param string|integer$i The key to be updated, can be a string or integer250 * @param mixed $i The key to be updated, can be a string or integer 253 251 * @param mixed $value The value of the array key in the children array to be updated 254 252 */ … … 304 302 * Retrieve the the current pointer position for the object 305 303 * 306 * @return scalar The current pointer position 307 */ 308 public function key() : int { 304 * @return mixed The current pointer position 305 */ 306 #[\ReturnTypeWillChange] 307 public function key() : mixed { 309 308 return $this->pointer; 310 309 } … … 342 341 * @param string $url The address of the HTML file to retrieve 343 342 * @param resource $context A resource object made with stream_context_create() 344 * @param string &$error A reference to any user error that is generated343 * @param ?string &$error A reference to any user error that is generated 345 344 * @return mixed The loaded HTML, or false on error 346 345 */ 347 public function open(string $url, mixed $context = null, string &$error = null) {346 public function open(string $url, mixed $context = null, ?string &$error = null) { 348 347 349 348 // check resource … … 387 386 * @param string $css A string containing valid CSS 388 387 * @param string $charset The charset of the document 389 * @param string &$error A reference to any user error that is generated388 * @param ?string &$error A reference to any user error that is generated 390 389 * @return bool Whether the input HTML was parsed 391 390 */ 392 public function load(string $css, string $charset = null, &$error = null) : bool {391 public function load(string $css, string $charset = null, ?string &$error = null) : bool { 393 392 394 393 // detect the charset … … 398 397 399 398 // reset the document 400 $this-> children = [];399 $this->document = null; 401 400 if (($obj = $this->parse($css)) === false) { 402 401 $error = 'Input is not invalid'; … … 413 412 * Reads the charset defined in the Content-Type meta tag, or detects the charset from the HTML content 414 413 * 415 * @param string $ html A string containing valid HTML416 * @return string The defined or detected charset or null if the charset is not defined414 * @param string $css A string containing valid CSS 415 * @return ?string The defined or detected charset or null if the charset is not defined 417 416 */ 418 417 protected function getCharsetFromCss(string $css) : ?string { -
torque/trunk/packages/cssdoc/tokens/directive.php
r2693063 r2817597 44 44 * 45 45 * @param tokenise &$tokens A tokenise object 46 * @param array $config An array of configuration options47 46 * @return bool Whether anything was parsed 48 47 */ … … 142 141 * 143 142 * @param array $options An array of compilation options 144 * @return void143 * @return string The compiled CSS 145 144 */ 146 145 public function compile(array $options) : string { -
torque/trunk/packages/cssdoc/tokens/document.php
r2727595 r2817597 23 23 public function __construct(cssdoc $root, array $rules = []) { 24 24 $this->root = $root; 25 $this->rules = [];25 $this->rules = $rules; 26 26 } 27 27 … … 30 30 * 31 31 * @param tokenise &$tokens A tokenise object 32 * @param array $config An array of configuration options33 32 * @return bool Whether anything was parsed 34 33 */ … … 99 98 * Find rules in the document that match the specified criteria 100 99 * 101 * @param string $selectorA string specifying the selectors to match, comma separate multiple selectors100 * @param ?array $selectors A string specifying the selectors to match, comma separate multiple selectors 102 101 * @param array|string $hasProp A string or array specifying the properties that any rules must contain 103 102 * @param array $media An array specifying how any media queries should be match, where the key is the property and the key the value. 'max-width' will match any rules where the value is lower that that specified, 'min-width' the value must be higher. Use 'media' to specify the media type -
torque/trunk/packages/cssdoc/tokens/property.php
r2693063 r2817597 49 49 * 50 50 * @param string $var The name of the property to retrieve 51 * @return string The value of the requested property, or null if the porperty doesn't exist51 * @return ?string The value of the requested property, or null if the porperty doesn't exist 52 52 */ 53 53 public function __get(string $var) { … … 127 127 * 128 128 * @param array $options An array of compilation options 129 * @return void129 * @return string The compiled CSS property 130 130 */ 131 131 public function compile(array $options) : string { -
torque/trunk/packages/cssdoc/tokens/rule.php
r2727595 r2817597 39 39 * 40 40 * @param tokenise &$tokens A tokenise object 41 * @param array $config An array of configuration options42 41 * @return bool Whether anything was parsed 43 42 */ … … 112 111 * 113 112 * @param array $options An array of compilation options 114 * @return void113 * @return string The compiled CSS rule 115 114 */ 116 115 public function compile(array $options) : string { -
torque/trunk/packages/cssdoc/tokens/selector.php
r2727595 r2817597 29 29 * 30 30 * @param tokenise &$tokens A tokenise object 31 * @param array $config An array of configuration options32 31 * @return bool Whether anything was parsed 33 32 */ … … 162 161 * 163 162 * @param array $options An array of compilation options 164 * @return void163 * @return string The compiled CSS selector 165 164 */ 166 165 public function compile(array $options) : string { -
torque/trunk/packages/cssdoc/tokens/value.php
r2727595 r2817597 44 44 * 45 45 * @param tokenise &$tokens A tokenise object 46 * @param array $config An array of configuration options47 46 * @return bool Whether anything was parsed 48 47 */ … … 246 245 * 247 246 * @param array $options An array of compilation options 248 * @return void247 * @return string The compiled CSS value 249 248 */ 250 249 public function compile(array $options) : string { -
torque/trunk/packages/htmldoc/autoload.php
r2711273 r2817597 1 1 <?php 2 spl_autoload_register(function (string $class) : bool{2 \spl_autoload_register(function (string $class) : void { 3 3 $classes = [ 4 4 'hexydec\\html\\htmldoc' => __DIR__.'/htmldoc.php', … … 15 15 ]; 16 16 if (isset($classes[$class])) { 17 re turn (bool) require($classes[$class]);17 require($classes[$class]); 18 18 } 19 return false;20 19 }); -
torque/trunk/packages/htmldoc/helpers/selector.php
r2711273 r2817597 7 7 8 8 /** 9 * @var array $selectors Regexp components keyed by their corresponding codename for tokenising CSS selectors9 * @var array<string> $selectors Regexp components keyed by their corresponding codename for tokenising CSS selectors 10 10 */ 11 11 protected static array $tokens = [ 12 12 'quotes' => '(?<!\\\\)"(?:[^"\\\\]++|\\\\.)*+"', 13 'comparison' => '[\\^*$<>|~]?=', // comparison operators for media queries or attribute selectors 13 14 'join' => '\\s*[>+~]\\s*', 14 'comparison' => '[\\^*$<>]?=', // comparison operators for media queries or attribute selectors15 15 'squareopen' => '\\[', 16 16 'squareclose' => '\\]', … … 21 21 'id' => '#[^ +>\.#{\\[,]++', 22 22 'class' => '\.[^ +>\.#{\\[\\(\\),]++', 23 'string' => '\\*|[^\\[\\]{}\\(\\):;,>+=~ \\^$!" #\\.*]++',23 'string' => '\\*|[^\\[\\]{}\\(\\):;,>+=~|\\^$!" #\\.*]++', 24 24 'whitespace' => '\s++', 25 25 ]; 26 26 27 /** 28 * Get a selector string parsed into an array 29 * 30 * @param string $selector The CSS selector string to parse 31 * @return array|false An array of selector components or false if the selector was not parsable 32 */ 27 33 public function get(string $selector) { 28 34 $tokens = new tokenise(self::$tokens, \trim($selector)); … … 33 39 * Parses a CSS selector string 34 40 * 35 * @param string $selector The CSS selector stringto parse41 * @param tokenise $tokens A tokenise object loaded with the selector to parse 36 42 * @return array|bool An array of selector components 37 43 */ … … 115 121 } 116 122 117 protected function parseAttributes(tokenise $tokens, ?string $join = null) { 123 /** 124 * Parses the attributes of a CSS selector 125 * 126 * @param tokenise $tokens A tokenise object loaded with the selector to be parsed 127 * @param ?string $join The joining command from the last CSS selector component 128 * @return array An array representing the attribute 129 */ 130 protected function parseAttributes(tokenise $tokens, ?string $join = null) : array { 118 131 $item = ['join' => $join, 'sensitive' => true]; 119 132 while (($token = $tokens->next()) !== null && $token['type'] !== 'squareclose') { -
torque/trunk/packages/htmldoc/htmldoc.php
r2727595 r2817597 150 150 * Retrieve the the current pointer position for the object 151 151 * 152 * @return scalar The current pointer position 153 */ 154 public function key() : int { 152 * @return mixed The current pointer position 153 */ 154 #[\ReturnTypeWillChange] 155 public function key() { 155 156 return $this->pointer; 156 157 } … … 188 189 * @param string $url The address of the HTML file to retrieve 189 190 * @param resource $context A resource object made with stream_context_create() 190 * @param string &$error A reference to any user error that is generated191 * @param ?string &$error A reference to any user error that is generated 191 192 * @return string|false The loaded HTML, or false on error 192 193 */ 193 public function open(string $url, $context = null, string &$error = null) {194 public function open(string $url, $context = null, ?string &$error = null) { 194 195 195 196 // check resource … … 231 232 * @param string $html A string containing valid HTML 232 233 * @param string $charset The charset of the document 233 * @param string &$error A reference to any user error that is generated234 * @param ?string &$error A reference to any user error that is generated 234 235 * @return bool Whether the input HTML was parsed 235 236 */ 236 public function load(string $html, string $charset = null, &$error = null) : bool {237 public function load(string $html, string $charset = null, ?string &$error = null) : bool { 237 238 238 239 // detect the charset -
torque/trunk/packages/htmldoc/tokens/comment.php
r2711273 r2817597 21 21 22 22 /** 23 * Parses an array of tokens into an HTML documents23 * Parses the next HTML component from a tokenise object 24 24 * 25 * @param array &$tokens An array of tokens generated by tokenise() 26 * @param array $config An array of configuration options 25 * @param tokenise $tokens A tokenise object 27 26 * @return void 28 27 */ -
torque/trunk/packages/htmldoc/tokens/custom.php
r2711273 r2817597 25 25 * 26 26 * @param htmldoc $root The parent htmldoc object 27 * @param string $tag The name of the custom tag, note this cannot be null27 * @param string $tagName A string specifying the parent tag name 28 28 */ 29 public function __construct(htmldoc $root, string $tagName = null) {29 public function __construct(htmldoc $root, ?string $tagName = null) { 30 30 $this->tagName = $tagName = \mb_strtolower($tagName ?? ''); 31 31 $this->config = $root->config['custom'][$tagName]; … … 33 33 34 34 /** 35 * Parses an array of tokens into an HTML documents35 * Parses the next HTML component from a tokenise object 36 36 * 37 * @param array &$tokens An array of tokens generated by tokenise() 38 * @param array $config An array of configuration options 37 * @param tokenise $tokens A tokenise object 39 38 * @return void 40 39 */ -
torque/trunk/packages/htmldoc/tokens/doctype.php
r2693063 r2817597 21 21 22 22 /** 23 * Parses an array of tokens into an HTML documents23 * Parses the next HTML component from a tokenise object 24 24 * 25 * @param array &$tokens An array of tokens generated by tokenise() 26 * @param array $config An array of configuration options 25 * @param tokenise $tokens A tokenise object 27 26 * @return void 28 27 */ -
torque/trunk/packages/htmldoc/tokens/interfaces/token.php
r2592945 r2817597 17 17 18 18 /** 19 * Parses an array of tokens into an HTML documents19 * Parses the next HTML component from a tokenise object 20 20 * 21 * @param array &$tokens An array of tokens generated by tokenise() 22 * @param array $config An array of configuration options 21 * @param tokenise $tokens A tokenise object 23 22 * @return void 24 23 */ -
torque/trunk/packages/htmldoc/tokens/tag.php
r2727628 r2817597 103 103 104 104 /** 105 * Parses an array of tokens into an HTML documents 106 * 107 * @param tokenise &$tokens An array of tokens generated by tokenise() 108 * @param array $config An array of configuration options 105 * Parses the next HTML component from a tokenise object 106 * 107 * @param tokenise $tokens A tokenise object 109 108 * @return void 110 109 */ … … 218 217 * 219 218 * @param tokenise &$tokens A reference to an array of tokens generated by tokenise(), the reference allows the array pointer to pass between objectsS 220 * @return bool Whether the parser was able to capture anyobjects219 * @return array An array of child objects 221 220 */ 222 221 public function parseChildren(tokenise $tokens) : array { … … 384 383 * Remove the selected child from the object 385 384 * 386 * @param tag $ childThe child object to delete385 * @param tag $node The child object to delete 387 386 * @return void 388 387 */ … … 630 629 * 631 630 * @param array $selector An array of CSS selectors 632 * @param array$searchChildren Denotes whether to search child tags as well as this tag631 * @param bool $searchChildren Denotes whether to search child tags as well as this tag 633 632 * @return array An array of tag objects that match $selector 634 633 */ … … 678 677 679 678 // check if attribute exists 680 if ( empty($this->attributes[$item['attribute']])) {679 if (!array_key_exists($item['attribute'], $this->attributes)) { 681 680 $match = false; 682 681 break; 683 682 } elseif (!empty($item['value'])) { 684 $current = $this->attributes[$item['attribute']]; 685 switch ($item['comparison']) { 686 687 // exact match 688 case '=': 689 if ($item['sensitive']) { 690 if ($current !== $item['value']) { 683 684 // if current value is null, it won't match 685 if (($current = $this->attributes[$item['attribute']]) === null) { 686 $match = false; 687 break; 688 689 // compare 690 } else { 691 switch ($item['comparison']) { 692 693 // exact match 694 case '=': 695 if ($item['sensitive']) { 696 if ($current !== $item['value']) { 697 $match = false; 698 break; 699 } 700 } elseif (\mb_strtolower($current) !== \mb_strtolower($item['value'])) { 691 701 $match = false; 692 702 break; 693 703 } 694 } elseif (\mb_strtolower($current) !== \mb_strtolower($item['value'])) {695 $match = false;696 704 break; 697 } 698 break; 699 700 // match start 701 case '^=': 702 if ($item['sensitive']) { 703 if (\mb_strpos($current, $item['value']) !== 0) { 705 706 // match start 707 case '^=': 708 $pos = $item['sensitive'] ? \mb_strpos($current, $item['value']) : \mb_stripos($current, $item['value']); 709 if ($pos !== 0) { 704 710 $match = false; 705 711 break; 706 712 } 707 } elseif (\mb_stripos($current, $item['value']) !== 0) {708 $match = false;709 713 break; 710 } 711 break; 712 713 // match within 714 case '*=': 715 if ($item['sensitive']) { 716 if (\mb_strpos($current, $item['value']) === false) { 714 715 // match word 716 case '~=': 717 $current =' '.$current.' '; 718 $item['value'] = ' '.$item['value'].' '; 719 720 // match within 721 case '*=': 722 $pos = $item['sensitive'] ? \mb_strpos($current, $item['value']) : \mb_stripos($current, $item['value']); 723 if ($pos === false) { 717 724 $match = false; 718 725 break; 719 726 } 720 } elseif (\mb_stripos($current, $item['value']) === false) {721 $match = false;722 727 break; 723 } 724 break; 725 726 // match end 727 case '$=': 728 if ($item['sensitive']) { 729 if (\mb_strpos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) { 728 729 // match end 730 case '$=': 731 $pos = $item['sensitive'] ? \mb_strrpos($current, $item['value']) : \mb_strripos($current, $item['value']); 732 if ($pos !== \mb_strlen($current) - \mb_strlen($item['value'])) { 730 733 $match = false; 731 734 break; 732 735 } 733 } elseif (\mb_stripos($current, $item['value']) !== \mb_strlen($current) - \mb_strlen($item['value'])) {734 $match = false;735 736 break; 736 } 737 break; 737 738 // match subcode 739 case '|=': 740 if ($item['sensitive']) { 741 if ($current !== $item['value'] && \mb_strpos($current, $item['value'].'-') !== 0) { 742 $match = false; 743 break; 744 } 745 } elseif (\mb_strtolower($current) !== \mb_strtolower($item['value']) && \mb_stripos($current, $item['value'].'-') !== 0) { 746 $match = false; 747 break; 748 } 749 break; 750 } 738 751 } 739 752 } -
torque/trunk/packages/htmldoc/tokens/text.php
r2711273 r2817597 33 33 34 34 /** 35 * Parses an array of tokens into an HTML documents35 * Magic method to set protected variables 36 36 * 37 * @param array &$tokens An array of tokens generated by tokenise() 38 * @param array $config An array of configuration options 37 * @param string $name The name of the property to set 38 * @param mixed $value The value of the property to set 39 * @return void 40 */ 41 public function __set(string $name, $value) : void { 42 if ($name === 'parent' && \get_class($value) === 'hexydec\\html\\tag') { 43 $this->parent = $value; 44 } 45 } 46 47 /** 48 * Parses the next HTML component from a tokenise object 49 * 50 * @param tokenise $tokens A tokenise object 39 51 * @return void 40 52 */ -
torque/trunk/packages/jslite/autoload.php
r2592945 r2817597 1 1 <?php 2 spl_autoload_register(function (string $class) : bool{2 \spl_autoload_register(function (string $class) : void { 3 3 $classes = [ 4 4 'hexydec\\jslite\\jslite' => __DIR__.'/jslite.php', … … 16 16 ]; 17 17 if (isset($classes[$class])) { 18 re turn (bool) require($classes[$class]);18 require($classes[$class]); 19 19 } 20 return false;21 20 }); -
torque/trunk/packages/jslite/jslite.php
r2727595 r2817597 23 23 24 24 // keywords number and variables 25 'keyword' => '\\b(?:let|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in| instanceof|new|return|super|switch|this|throw|try|typeof|var|void|while|with|yield|null|async|await|true|false|undefined)\\b',25 'keyword' => '\\b(?:let|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|of|instanceof|new|return|super|switch|this|throw|try|typeof|var|void|while|with|yield|null|async|await|true|false|undefined)\\b', 26 26 'variable' => '[\\p{L}\\p{Nl}$_][\\p{L}\\p{Nl}\\p{Mn}\\p{Mc}\\p{Nd}\\p{Pc}$_]*+', 27 27 'number' => '(?:0[bB][01_]++n?|0[oO][0-7_]++n?|0[xX][a-f0-9_]|[0-9][0-9_]*+(?:\\.[0-9_]++)?+(?:e[+-]?[1-9][0-9]*+)?+)', 28 28 29 29 // consume strings in quotes, check for escaped quotes 30 'doublequotes' => '"(?:\\\\ [^\\n\\r]|[^\\\\"\\n\\r])*+"',31 'singlequotes' => "'(?:\\\\ [^\\n\\r]|[^\\\\'\\n\\r])*+'",30 'doublequotes' => '"(?:\\\\.|[^\\\\"])*+"', 31 'singlequotes' => "'(?:\\\\.|[^\\\\'])*+'", 32 32 'templateliterals' => '`(?:\\\\.|[^\\\\`])*+`', 33 33 … … 88 88 * @param string $url The address of the Javascript file to retrieve 89 89 * @param resource $context A resource object made with stream_context_create() 90 * @param string &$error A reference to any user error that is generated90 * @param ?string &$error A reference to any user error that is generated 91 91 * @return string|false The loaded Javascript, or false on error 92 92 */ 93 public function open(string $url, $context = null, string &$error = null) {93 public function open(string $url, $context = null, ?string &$error = null) { 94 94 95 95 // check resource … … 112 112 * 113 113 * @param string $js A string containing valid Javascript 114 * @param string &$error A reference to any user error that is generated114 * @param ?string &$error A reference to any user error that is generated 115 115 * @return bool Whether the input HTML was parsed 116 116 */ 117 public function load(string $js, string &$error = null) : bool {117 public function load(string $js, ?string &$error = null) : bool { 118 118 119 119 // reset the document … … 189 189 * 190 190 * @param array $options An array indicating output options 191 * @return void191 * @return string The compiled Javascript 192 192 */ 193 193 public function compile(array $options = []) : string { -
torque/trunk/packages/jslite/tokens/brackets.php
r2693063 r2817597 6 6 class brackets { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var expression The parent expression object 15 */ 9 16 protected expression $root; 17 18 /** 19 * @var array An array of child expression objects 20 */ 10 21 protected array $expressions = []; 22 23 /** 24 * @var string The type of bracket this object represents, bracket|square|curly 25 */ 11 26 public string $bracket = 'bracket'; // square or bracket or curly 12 27 … … 14 29 * Constructs the comment object 15 30 * 16 * @param jslite $root The parent jslite object 17 * @param array $scopes An array of variables that are available in this scope, where the key is the variable name and the value is the scope object 31 * @param expression $root The parent expression object 18 32 */ 19 33 public function __construct(expression $root) { … … 24 38 * Parses an array of tokens 25 39 * 26 * @param array &$tokens A tokenise object27 * @return void40 * @param tokenise $tokens A tokenise object 41 * @return bool Whether any tokens were parsed 28 42 */ 29 43 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/comment.php
r2693063 r2817597 6 6 class comment { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = false; 12 9 13 /** 10 14 * @var string The text content of this object 11 15 */ 12 16 protected ?string $content = null; 17 18 /** 19 * @var bool Denotes whether the comment object represents a single or multi-line comment 20 */ 13 21 protected bool $multi = false; 14 22 … … 16 24 * Parses an array of tokens 17 25 * 18 * @param array &$tokens A tokenise object19 * @return void26 * @param tokenise $tokens A tokenise object 27 * @return bool Whether there were any tokens to parse 20 28 */ 21 29 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/expression.php
r2727595 r2817597 6 6 class expression { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var array An array of command objects stored within this expression 15 */ 9 16 public array $commands = []; 17 18 /** 19 * @var ?string The end of line marker 20 */ 10 21 public ?string $eol = null; 22 23 /** 24 * @var ?string The type of bracket of the parent 25 */ 11 26 public ?string $bracket = null; 12 27 28 /** 29 * Constructs the expression object 30 * 31 * @param ?string $bracket The type of bracket of the parent 32 */ 13 33 public function __construct(?string $bracket = null) { 14 34 $this->bracket = $bracket; … … 31 51 case 'commentsingle': 32 52 case 'commentmulti': 33 $obj = new comment( $this);53 $obj = new comment(); 34 54 if ($obj->parse($tokens)) { 35 55 $commands[] = $obj; … … 37 57 break; 38 58 case 'operator': 39 $obj = new operator( $this);59 $obj = new operator(); 40 60 if ($obj->parse($tokens)) { 41 61 $commands[] = $obj; … … 46 66 break; 47 67 case 'increment': 48 $obj = new increment( $this);68 $obj = new increment(); 49 69 if ($obj->parse($tokens)) { 50 70 $commands[] = $obj; … … 53 73 case 'keyword': 54 74 if ($this->isKeyword($last, $token, $tokens)) { 55 $obj = new keyword( $this);75 $obj = new keyword(); 56 76 if ($obj->parse($tokens)) { 57 77 $commands[] = $obj; … … 60 80 } 61 81 case 'variable': 62 $obj = new variable( $this);82 $obj = new variable(); 63 83 if ($obj->parse($tokens)) { 64 84 $commands[] = $obj; … … 66 86 break; 67 87 case 'number': 68 $obj = new number( $this);88 $obj = new number(); 69 89 if ($obj->parse($tokens)) { 70 90 $commands[] = $obj; … … 74 94 case 'singlequotes': 75 95 case 'templateliterals': 76 $obj = new jsstring( $this);96 $obj = new jsstring(); 77 97 if ($obj->parse($tokens)) { 78 98 $commands[] = $obj; … … 85 105 86 106 // create regexp object 87 $obj = new regexp( $this);107 $obj = new regexp(); 88 108 if ($obj->parse($tokens)) { 89 109 $commands[] = $obj; -
torque/trunk/packages/jslite/tokens/keyword.php
r2693063 r2817597 6 6 class keyword { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var string The captured keyword 15 */ 9 16 public string $content = ''; 10 17 … … 12 19 * Parses an array of tokens 13 20 * 14 * @param array &$tokens A tokenise object15 * @return void21 * @param tokenise $tokens A tokenise object 22 * @return bool Whether any tokens were parsed 16 23 */ 17 24 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/number.php
r2693063 r2817597 6 6 class number { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var string The captured number 15 */ 9 16 protected string $content = ''; 10 17 … … 12 19 * Parses an array of tokens 13 20 * 14 * @param array &$tokens A tokenise object15 * @return void21 * @param tokenise $tokens A tokenise object 22 * @return bool Whether any tokens were parsed 16 23 */ 17 24 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/operator.php
r2693063 r2817597 6 6 class operator { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 9 13 /** 10 14 * @var string The text content of this object … … 15 19 * Parses an array of tokens 16 20 * 17 * @param array &$tokens A tokenise object18 * @return void21 * @param tokenise $tokens A tokenise object 22 * @return bool Whether any tokens were parsed 19 23 */ 20 24 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/regexp.php
r2693063 r2817597 6 6 class regexp { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var string The captured regexp pattern 15 */ 9 16 protected string $content = ''; 10 17 … … 12 19 * Parses an array of tokens 13 20 * 14 * @param array &$tokens A tokenise object15 * @return void21 * @param tokenise $tokens A tokenise object 22 * @return bool Whether any tokens were parsed 16 23 */ 17 24 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/string.php
r2693063 r2817597 6 6 class jsstring { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var string The captured string 15 */ 9 16 public string $content = ''; 17 18 /** 19 * @var string The quote character used to encapsulate the string 20 */ 10 21 protected string $quote = '"'; 22 23 /** 24 * @var bool Whether the string has been de-encapsulated and processed 25 */ 11 26 protected bool $process = false; 12 27 … … 14 29 * Parses an array of tokens 15 30 * 16 * @param array &$tokens A tokenise object17 * @return void31 * @param tokenise $tokens A tokenise object 32 * @return bool Whether any tokens were parsed 18 33 */ 19 34 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/jslite/tokens/variable.php
r2693063 r2817597 6 6 class variable { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = true; 12 13 /** 14 * @var string The captured variable name 15 */ 9 16 public string $content = ''; 10 17 … … 12 19 * Parses an array of tokens 13 20 * 14 * @param array &$tokens A tokenise object15 * @return void21 * @param tokenise $tokens A tokenise object 22 * @return bool Whether any tokens were parsed 16 23 */ 17 24 public function parse(tokenise $tokens) : bool { … … 35 42 * Compile as Javascript 36 43 * 37 * @return string The compiled HTML44 * @return string The compiled variable name 38 45 */ 39 46 public function compile() : string { -
torque/trunk/packages/jslite/tokens/whitespace.php
r2693063 r2817597 6 6 class whitespace { 7 7 8 /** 9 * @var bool Denotes whether the class represents significant javascript 10 */ 8 11 public const significant = false; 12 13 /** 14 * @var expression The parent expression object 15 */ 9 16 protected expression $parent; 17 18 /** 19 * @var string The captured whitespace 20 */ 10 21 protected string $content; 11 22 … … 14 25 * 15 26 * @param expression $parent The parent expression object 16 * @param array $scopes An array of variables that are available in this scope, where the key is the variable name and the value is the scope object17 27 */ 18 28 public function __construct(expression $parent) { … … 23 33 * Parses an array of tokens 24 34 * 25 * @param array &$tokens A tokenise object26 * @return void35 * @param tokenise $tokens A tokenise object 36 * @return bool Whether any tokens were parsed 27 37 */ 28 38 public function parse(tokenise $tokens) : bool { -
torque/trunk/packages/tokenise/autoload.php
r2592945 r2817597 1 1 <?php 2 2 declare(strict_types = 1); 3 spl_autoload_register(function (string $class) : bool{3 \spl_autoload_register(function (string $class) : void { 4 4 if ($class === 'hexydec\\tokens\\tokenise') { 5 re turn (bool) require(__DIR__.'/tokenise.php');5 require(__DIR__.'/tokenise.php'); 6 6 } 7 return false;8 7 }); -
torque/trunk/readme.txt
r2744378 r2817597 3 3 Tags: minify,minification,performance,security,optimization 4 4 Requires at least: 5.9 5 Tested up to: 6. 05 Tested up to: 6.1 6 6 Requires PHP: 7.4 7 Stable tag: 0.6. 47 Stable tag: 0.6.5 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 99 99 Some advanced minification optimisations can cause issues with your website's layout, or break your Javascript depending on how your CSS/Javascript selectors are setup. 100 100 101 For example, you can strip default attributes from your HTML such as `type="text"` on the `<input>` object. If you have a CSS or Javascript selector that relies on this attribute being there, such as `input[type=input]`, the selec ctor will no longer match. See [https://github.com/hexydec/htmldoc/blob/master/docs/mitigating-side-effects.md](HTMLdoc: Mitigating Side Effects of Minification) for solutions.101 For example, you can strip default attributes from your HTML such as `type="text"` on the `<input>` object. If you have a CSS or Javascript selector that relies on this attribute being there, such as `input[type=input]`, the selector will no longer match. See [HTMLdoc: Mitigating Side Effects of Minification](https://github.com/hexydec/htmldoc/blob/master/docs/mitigating-side-effects.md) for solutions. 102 102 103 103 = Why is HTMLdoc best in class? = … … 136 136 137 137 == Changelog == 138 139 = Version 0.6.5 = 140 141 * Tested with Wordpress v6.1 142 * Fixed bug in Content-Security-Policy generator where a directive was not spelt correctly 143 * Updated dependencies 144 * Minor syntax improvements 145 146 = Version 0.6.4 = 147 148 * Tested with Wordpress v6.0 138 149 139 150 = Version 0.6.3 = -
torque/trunk/torque.php
r2744378 r2817597 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.6. 412 Version: 0.6.5 13 13 Requires PHP: 7.4 14 14 Author: Hexydec … … 25 25 // from GitHub, download packages 26 26 if (\class_exists('\\hexydec\\torque\\installExternal')) { 27 $obj = new \hexydec\torque\installExternal();27 $obj = new installExternal(); 28 28 29 29 // for Wordpress, packages are included 30 30 } else { 31 $obj = new \hexydec\torque\install();31 $obj = new install(); 32 32 } 33 33 $obj->install(); … … 36 36 // install the admin menu 37 37 \add_action('admin_menu', function () { 38 $obj = new \hexydec\torque\admin();38 $obj = new admin(); 39 39 $obj->update(); 40 40 $obj->draw(); … … 43 43 // load the app 44 44 \add_action('wp_loaded', function () { 45 $obj = new \hexydec\torque\app();45 $obj = new app(); 46 46 $obj->optimise(); 47 47 }); … … 52 52 // rebuild files when a plugin is updated 53 53 \add_action('upgrader_process_complete', function () { 54 \hexydec\torque\assets::rebuildAssets();54 assets::rebuildAssets(); 55 55 }); 56 56
Note: See TracChangeset
for help on using the changeset viewer.