| @@ -7,32 +7,32 @@ discard block | ||
| 7 | 7 |          const TOKEN = '/{([[:alpha:]]+)(\d+)}/i'; | 
| 8 | 8 | const MAP = [ | 
| 9 | 9 | // Empty part of #id and .class | 
| 10 | - [ '(?<=^|\s) # The begining or an empty space. | |
| 10 | + ['(?<=^|\s) # The begining or an empty space. | |
| 11 | 11 | (?=[.#\[]) # . | # | [', | 
| 12 | 12 | '*', | 
| 13 | 13 | 'TAG', | 
| 14 | - false ], | |
| 14 | + false], | |
| 15 | 15 | // #id | 
| 16 | - [ '\# | |
| 16 | + ['\# | |
| 17 | 17 | ([\w\-]+)', | 
| 18 | 18 | '[@id="\1"]', | 
| 19 | 19 | 'ID', | 
| 20 | - false ], | |
| 20 | + false], | |
| 21 | 21 | // .class | 
| 22 | - [ '\. | |
| 22 | + ['\. | |
| 23 | 23 | ([\w\-]+)', | 
| 24 | 24 |                    '[ contains( concat(" ", normalize-space(@class), " "), concat(" ", "\1", " ") ) ]', | 
| 25 | 25 | 'CLASS', | 
| 26 | - false ], | |
| 26 | + false], | |
| 27 | 27 | // [attr] | 
| 28 | - [ '\[ | |
| 28 | + ['\[ | |
| 29 | 29 | ([\w\-]+) | 
| 30 | 30 | \]', | 
| 31 | 31 | '[@\1]', | 
| 32 | 32 | 'ATTR', | 
| 33 | - false ], | |
| 33 | + false], | |
| 34 | 34 | // [attr="val"] | 
| 35 | - [ '\[ | |
| 35 | + ['\[ | |
| 36 | 36 | ([\w\-]+) | 
| 37 | 37 | =["\'] | 
| 38 | 38 | (.*) | 
| @@ -40,74 +40,74 @@ discard block | ||
| 40 | 40 | \]', | 
| 41 | 41 | '[@\1="\2"]', | 
| 42 | 42 | 'ATTR', | 
| 43 | - false ], | |
| 43 | + false], | |
| 44 | 44 | // ns|A | 
| 45 | - [ '([\w\-]+) | |
| 45 | + ['([\w\-]+) | |
| 46 | 46 | \| | 
| 47 | 47 | (?=\w) # A namespace must be followed at least by a character.', | 
| 48 | 48 | '\1:', | 
| 49 | 49 | 'NS', | 
| 50 | - false ], | |
| 50 | + false], | |
| 51 | 51 | // :root | 
| 52 | - [ ':root\b', | |
| 52 | + [':root\b', | |
| 53 | 53 | '/*', | 
| 54 | 54 | 'TAG', | 
| 55 | - false ], | |
| 55 | + false], | |
| 56 | 56 | // A | 
| 57 | - [ '(?<=^|\s|\}) | |
| 57 | + ['(?<=^|\s|\}) | |
| 58 | 58 | ( [\w\-]+ | \* )', | 
| 59 | 59 | '\1', | 
| 60 | 60 | 'TAG', | 
| 61 | - false ], | |
| 61 | + false], | |
| 62 | 62 | // Aggregates the components of a tag in an expression. | 
| 63 | -                [ '({NS\d+})? | |
| 63 | +                ['({NS\d+})? | |
| 64 | 64 |                     ({TAG\d+}) | 
| 65 | 65 |                     ((?:{ATTR\d+})*|) | 
| 66 | 66 |                     ((?:{ID\d+})*|) | 
| 67 | 67 |                     ((?:{CLASS\d+})*|)', | 
| 68 | 68 | '\1\2\3\4\5', | 
| 69 | 69 | 'EXP', | 
| 70 | - false ], | |
| 71 | -                [ '({EXP\d+}) | |
| 70 | + false], | |
| 71 | +                ['({EXP\d+}) | |
| 72 | 72 | :first-child', | 
| 73 | 73 | '*[1]/self::\1', | 
| 74 | 74 | 'EXP', | 
| 75 | - false ], | |
| 75 | + false], | |
| 76 | 76 |                  // {} + {} | 
| 77 | -                [ '({EXP\d+}) | |
| 77 | +                ['({EXP\d+}) | |
| 78 | 78 | \s* \+ \s* | 
| 79 | 79 |                     ({EXP\d+})', | 
| 80 | 80 | '\1/following-sibling::*[1]/self::\2', | 
| 81 | 81 | 'EXP', | 
| 82 | - true ], | |
| 82 | + true], | |
| 83 | 83 |                  // {} ~ {} | 
| 84 | -                [ '({EXP\d+}) | |
| 84 | +                ['({EXP\d+}) | |
| 85 | 85 | \s* \~ \s* | 
| 86 | 86 |                     ({EXP\d+})', | 
| 87 | 87 | '\1/following-sibling::*/self::\2', | 
| 88 | 88 | 'EXP', | 
| 89 | - true ], | |
| 89 | + true], | |
| 90 | 90 |                  // {} > {} | 
| 91 | -                [ '({EXP\d+}) | |
| 91 | +                ['({EXP\d+}) | |
| 92 | 92 | \s* > \s* | 
| 93 | 93 |                     ({EXP\d+})', | 
| 94 | 94 | '\1/\2', | 
| 95 | 95 | 'EXP', | 
| 96 | - true ], | |
| 96 | + true], | |
| 97 | 97 |                  // {} {} | 
| 98 | -                [ '({EXP\d+}) | |
| 98 | +                ['({EXP\d+}) | |
| 99 | 99 | \s+ | 
| 100 | 100 |                     ({EXP\d+})', | 
| 101 | 101 | '\1//\2', | 
| 102 | 102 | 'EXP', | 
| 103 | - true ], | |
| 103 | + true], | |
| 104 | 104 |                  // {}, {} | 
| 105 | -                [ '({EXP\d+}) | |
| 105 | +                ['({EXP\d+}) | |
| 106 | 106 | \s* , \s* | 
| 107 | 107 |                     ({EXP\d+})', | 
| 108 | 108 | '\1|\2', | 
| 109 | 109 | 'EXP', | 
| 110 | - true ] | |
| 110 | + true] | |
| 111 | 111 | ]; | 
| 112 | 112 | |
| 113 | 113 | public static function xpath($css) | 
| @@ -132,7 +132,7 @@ discard block | ||
| 132 | 132 | |
| 133 | 133 | $xpath = \trim($xpath); | 
| 134 | 134 | $xpath = ".//$xpath"; | 
| 135 | -                $xpath = \str_replace('|', '|.//',   $xpath); | |
| 135 | +                $xpath = \str_replace('|', '|.//', $xpath); | |
| 136 | 136 |                  $xpath = \str_replace('.///', '/', $xpath); | 
| 137 | 137 | |
| 138 | 138 | return $xpath; | 
| @@ -98,7 +98,7 @@ | ||
| 98 | 98 | $nodes = (new \DOMXPath($dom))->query($query); | 
| 99 | 99 | |
| 100 | 100 |                  foreach ($nodes as $n) { | 
| 101 | -                        if (! \in_array($n->nodeName, $voids)) { | |
| 101 | +                        if (!\in_array($n->nodeName, $voids)) { | |
| 102 | 102 | // If it is not a void/empty tag, | 
| 103 | 103 | // we need to leave the tag open. | 
| 104 | 104 |                                  $n->appendChild(new \DOMProcessingInstruction('X-NOT-VOID')); | 
| @@ -4,16 +4,16 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | class FluidNamespace | 
| 6 | 6 |  { | 
| 7 | - const ID = 'id' ; | |
| 8 | - const URI = 'uri' ; | |
| 7 | + const ID = 'id'; | |
| 8 | + const URI = 'uri'; | |
| 9 | 9 | const MODE = 'mode'; | 
| 10 | 10 | |
| 11 | 11 | const MODE_IMPLICIT = 0; | 
| 12 | 12 | const MODE_EXPLICIT = 1; | 
| 13 | 13 | |
| 14 | - private $config = [ self::ID => '', | |
| 14 | + private $config = [self::ID => '', | |
| 15 | 15 | self::URI => '', | 
| 16 | - self::MODE => self::MODE_EXPLICIT ]; | |
| 16 | + self::MODE => self::MODE_EXPLICIT]; | |
| 17 | 17 | |
| 18 | 18 | public function __construct($id, $uri, $mode = 1) | 
| 19 | 19 |          { | 
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 |          { | 
| 52 | 52 | $id = $this->id(); | 
| 53 | 53 | |
| 54 | -                if (! empty($id)) { | |
| 54 | +                if (!empty($id)) { | |
| 55 | 55 | $id .= ':'; | 
| 56 | 56 | } | 
| 57 | 57 | |
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |                  $nodes = \explode('/', $xpath); | 
| 63 | 63 | |
| 64 | 64 |                  foreach ($nodes as $node) { | 
| 65 | -                        if (! empty($node)) { | |
| 65 | +                        if (!empty($node)) { | |
| 66 | 66 | // An XPath query can have multiple slashes. | 
| 67 | 67 | // Example: //target | 
| 68 | 68 |                                  $new_xpath .= "{$id}{$node}"; | 
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 |          { | 
| 9 | 9 | $status = \file_put_contents($file, $this->xml($strip)); | 
| 10 | 10 | |
| 11 | -                if (! $status) { | |
| 11 | +                if (!$status) { | |
| 12 | 12 |                          throw new \Exception("The file '$file' is not writable."); | 
| 13 | 13 | } | 
| 14 | 14 | |
| @@ -9,15 +9,15 @@ discard block | ||
| 9 | 9 |  { | 
| 10 | 10 | use NewableTrait, | 
| 11 | 11 | FluidSaveTrait, | 
| 12 | - ReservedCallTrait, // For compatibility with PHP 5.6. | |
| 13 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. | |
| 12 | + ReservedCallTrait, // For compatibility with PHP 5.6. | |
| 13 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. | |
| 14 | 14 | |
| 15 | 15 | const ROOT_NODE = 'doc'; | 
| 16 | 16 | |
| 17 | - private $defaults = [ 'root' => self::ROOT_NODE, | |
| 17 | + private $defaults = ['root' => self::ROOT_NODE, | |
| 18 | 18 | 'version' => '1.0', | 
| 19 | 19 | 'encoding' => 'UTF-8', | 
| 20 | - 'stylesheet' => null ]; | |
| 20 | + 'stylesheet' => null]; | |
| 21 | 21 | |
| 22 | 22 | private $document; | 
| 23 | 23 | private $handler; | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | $document = \file_get_contents($file); | 
| 32 | 32 | |
| 33 | 33 | // file_get_contents() returns false in case of error. | 
| 34 | -                if (! $document) { | |
| 34 | +                if (!$document) { | |
| 35 | 35 |                          throw new \Exception("File '$file' not accessible."); | 
| 36 | 36 | } | 
| 37 | 37 | |
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | |
| 96 | 96 | private function initStylesheet(&$options) | 
| 97 | 97 |          { | 
| 98 | -                if (! empty($options['stylesheet'])) { | |
| 98 | +                if (!empty($options['stylesheet'])) { | |
| 99 | 99 | $attrs = 'type="text/xsl" ' | 
| 100 | 100 |                                 . "encoding=\"{$options['encoding']}\" " | 
| 101 | 101 | . 'indent="yes" ' | 
| @@ -115,7 +115,7 @@ discard block | ||
| 115 | 115 | |
| 116 | 116 | private function initRoot(&$options) | 
| 117 | 117 |          { | 
| 118 | -                if (! empty($options['root'])) { | |
| 118 | +                if (!empty($options['root'])) { | |
| 119 | 119 | $this->appendSibling($options['root']); | 
| 120 | 120 | } | 
| 121 | 121 | |
| @@ -143,7 +143,7 @@ discard block | ||
| 143 | 143 | // it is shadowed by the __call() method. | 
| 144 | 144 | public function array_() | 
| 145 | 145 |          { | 
| 146 | - return [ $this->document->dom ]; | |
| 146 | + return [$this->document->dom]; | |
| 147 | 147 | } | 
| 148 | 148 | |
| 149 | 149 | public function __toString() | 
| @@ -186,7 +186,7 @@ discard block | ||
| 186 | 186 | $namespaces = []; | 
| 187 | 187 | |
| 188 | 188 |                  if (\is_string($arguments[0])) { | 
| 189 | - $args = [ $arguments[0], $arguments[1] ]; | |
| 189 | + $args = [$arguments[0], $arguments[1]]; | |
| 190 | 190 | |
| 191 | 191 |                          if (isset($arguments[2])) { | 
| 192 | 192 | $args[] = $arguments[2]; | 
| @@ -193,7 +193,7 @@ | ||
| 193 | 193 | } | 
| 194 | 194 | |
| 195 | 195 | $namespaces[] = new FluidNamespace(...$args); | 
| 196 | -                }  elseif (\is_array($arguments[0])) { | |
| 196 | +                } elseif (\is_array($arguments[0])) { | |
| 197 | 197 | $namespaces = $arguments[0]; | 
| 198 | 198 |                  } else { | 
| 199 | 199 | $namespaces = $arguments; | 
| @@ -9,8 +9,8 @@ discard block | ||
| 9 | 9 |  { | 
| 10 | 10 | use NewableTrait, | 
| 11 | 11 | FluidSaveTrait, | 
| 12 | - ReservedCallTrait, // For compatibility with PHP 5.6. | |
| 13 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. | |
| 12 | + ReservedCallTrait, // For compatibility with PHP 5.6. | |
| 13 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. | |
| 14 | 14 | |
| 15 | 15 | private $document; | 
| 16 | 16 | private $handler; | 
| @@ -22,14 +22,14 @@ discard block | ||
| 22 | 22 | $this->document = $document; | 
| 23 | 23 | $this->handler = $handler; | 
| 24 | 24 | |
| 25 | -                if (! \is_array($context) && ! $context instanceof \Traversable) { | |
| 25 | +                if (!\is_array($context) && !$context instanceof \Traversable) { | |
| 26 | 26 | // DOMDocument, DOMElement and DOMNode are not iterable. | 
| 27 | 27 | // DOMNodeList and FluidContext are iterable. | 
| 28 | - $context = [ $context ]; | |
| 28 | + $context = [$context]; | |
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 |                  foreach ($context as $n) { | 
| 32 | -                        if (! $n instanceof \DOMNode) { | |
| 32 | +                        if (!$n instanceof \DOMNode) { | |
| 33 | 33 |                                  throw new \Exception('Node type not recognized.'); | 
| 34 | 34 | } | 
| 35 | 35 | |
| @@ -204,7 +204,7 @@ discard block | ||
| 204 | 204 | // addChild($child, $value?, $attributes? = [], $switchContext? = false) | 
| 205 | 205 | public function addChild($child, ...$optionals) | 
| 206 | 206 |          { | 
| 207 | -                return $this->handler->insertElement($this->nodes, $child, $optionals, function ($parent, $element) { | |
| 207 | +                return $this->handler->insertElement($this->nodes, $child, $optionals, function($parent, $element) { | |
| 208 | 208 | return $parent->appendChild($element); | 
| 209 | 209 | }, $this); | 
| 210 | 210 | } | 
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | |
| 218 | 218 | public function prependSibling($sibling, ...$optionals) | 
| 219 | 219 |          { | 
| 220 | -                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) { | |
| 220 | +                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function($sibling, $element) { | |
| 221 | 221 | return $sibling->parentNode->insertBefore($element, $sibling); | 
| 222 | 222 | }, $this); | 
| 223 | 223 | } | 
| @@ -230,7 +230,7 @@ discard block | ||
| 230 | 230 | |
| 231 | 231 | public function appendSibling($sibling, ...$optionals) | 
| 232 | 232 |          { | 
| 233 | -                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) { | |
| 233 | +                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function($sibling, $element) { | |
| 234 | 234 | // If ->nextSibling is null, $element is simply appended as last sibling. | 
| 235 | 235 | return $sibling->parentNode->insertBefore($element, $sibling->nextSibling); | 
| 236 | 236 | }, $this); | 
| @@ -255,8 +255,8 @@ discard block | ||
| 255 | 255 | // the user has passed two arguments: | 
| 256 | 256 | // 1. is the attribute name | 
| 257 | 257 | // 2. is the attribute value | 
| 258 | -                if (! \is_array($arguments[0])) { | |
| 259 | - $val = isset($arguments[1]) ? $arguments[1]: ''; | |
| 258 | +                if (!\is_array($arguments[0])) { | |
| 259 | + $val = isset($arguments[1]) ? $arguments[1] : ''; | |
| 260 | 260 | $attrs = [$arguments[0] => $val]; | 
| 261 | 261 | } | 
| 262 | 262 | |
| @@ -433,10 +433,10 @@ discard block | ||
| 433 | 433 | |
| 434 | 434 | protected function resolveQuery($query) | 
| 435 | 435 |          { | 
| 436 | - if ( $query === '.' | |
| 436 | + if ($query === '.' | |
| 437 | 437 | || $query[0] === '/' | 
| 438 | - || ( $query[0] === '.' && $query[1] === '/' ) | |
| 439 | -                     || ( $query[0] === '.' && $query[1] === '.' ) ) { | |
| 438 | + || ($query[0] === '.' && $query[1] === '/') | |
| 439 | +                     || ($query[0] === '.' && $query[1] === '.')) { | |
| 440 | 440 | return $query; | 
| 441 | 441 | } | 
| 442 | 442 | |
| @@ -454,7 +454,7 @@ discard block | ||
| 454 | 454 | $found = ($r === $u) || $found; | 
| 455 | 455 | } | 
| 456 | 456 | |
| 457 | -                        if (! $found) { | |
| 457 | +                        if (!$found) { | |
| 458 | 458 | $set[] = $r; | 
| 459 | 459 | } | 
| 460 | 460 | } | 
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 |          { | 
| 13 | 13 | $this->document = $document; | 
| 14 | 14 | $this->dom = $document->dom; | 
| 15 | - $this->namespaces =& $document->namespaces; | |
| 15 | + $this->namespaces = & $document->namespaces; | |
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | 18 | public function insertElement(&$nodes, $element, &$optionals, $fn, $orig_context) | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | // offers to the user and is the same of: | 
| 35 | 35 | // 1. appending a child switching the context | 
| 36 | 36 | // 2. setting the attributes over the new context. | 
| 37 | -                if (! empty($attributes)) { | |
| 37 | +                if (!empty($attributes)) { | |
| 38 | 38 | $new_context->setAttribute($attributes); | 
| 39 | 39 | } | 
| 40 | 40 | |
| @@ -48,8 +48,8 @@ discard block | ||
| 48 | 48 | |
| 49 | 49 | protected function handleOptionals($element, &$optionals) | 
| 50 | 50 |          { | 
| 51 | -                if (! \is_array($element)) { | |
| 52 | - $element = [ $element ]; | |
| 51 | +                if (!\is_array($element)) { | |
| 52 | + $element = [$element]; | |
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | 55 | $switch_context = false; | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | } | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | - return [ $element, $attributes, $switch_context ]; | |
| 77 | + return [$element, $attributes, $switch_context]; | |
| 78 | 78 | } | 
| 79 | 79 | |
| 80 | 80 | |
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | |
| 103 | 103 | protected function handleStringMixed($parent, $k, $v, $fn, &$optionals, &$status) | 
| 104 | 104 |          { | 
| 105 | -                if (! \is_string($k)) { | |
| 105 | +                if (!\is_string($k)) { | |
| 106 | 106 | return; | 
| 107 | 107 | } | 
| 108 | 108 | |
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 | } | 
| 117 | 117 |                  } else { | 
| 118 | 118 |                          if (\is_string($v)) { | 
| 119 | -                                if (! FluidHelper::isAnXmlString($v)) { | |
| 119 | +                                if (!FluidHelper::isAnXmlString($v)) { | |
| 120 | 120 | $handler = 'insertStringSimple'; | 
| 121 | 121 | } | 
| 122 | 122 |                          } else { | 
| @@ -224,8 +224,8 @@ discard block | ||
| 224 | 224 | |
| 225 | 225 | protected function attachNodes($parent, $nodes, $fn) | 
| 226 | 226 |          { | 
| 227 | -                if (! \is_array($nodes) && ! $nodes instanceof \Traversable) { | |
| 228 | - $nodes = [ $nodes ]; | |
| 227 | +                if (!\is_array($nodes) && !$nodes instanceof \Traversable) { | |
| 228 | + $nodes = [$nodes]; | |
| 229 | 229 | } | 
| 230 | 230 | |
| 231 | 231 | $context = []; | 
| @@ -274,7 +274,7 @@ discard block | ||
| 274 | 274 | $el = $this->createElement($k, $v); | 
| 275 | 275 | $el = $fn($parent, $el); | 
| 276 | 276 | |
| 277 | - return [ $el ]; | |
| 277 | + return [$el]; | |
| 278 | 278 | } | 
| 279 | 279 | |
| 280 | 280 | protected function insertStringMixed($parent, $k, $v, $fn, &$optionals) | 
| @@ -291,7 +291,7 @@ discard block | ||
| 291 | 291 | // they are supplied, so 'addChild' is the perfect operation. | 
| 292 | 292 | $this->newContext($el)->addChild($v, ...$optionals); | 
| 293 | 293 | |
| 294 | - return [ $el ]; | |
| 294 | + return [$el]; | |
| 295 | 295 | } | 
| 296 | 296 | |
| 297 | 297 | protected function insertIntegerArray($parent, $k, $v, $fn, &$optionals) | 
| @@ -318,7 +318,7 @@ discard block | ||
| 318 | 318 | $el = $this->createElement($v); | 
| 319 | 319 | $el = $fn($parent, $el); | 
| 320 | 320 | |
| 321 | - return [ $el ]; | |
| 321 | + return [$el]; | |
| 322 | 322 | } | 
| 323 | 323 | |
| 324 | 324 | protected function insertIntegerXml($parent, $k, $v, $fn) |