@@ -8,10 +8,10 @@ |
||
| 8 | 8 | class FluidContext implements FluidInterface, \ArrayAccess, \Iterator |
| 9 | 9 | { |
| 10 | 10 | use FluidAliasesTrait, |
| 11 | - FluidSaveTrait, |
|
| 12 | - NewableTrait, |
|
| 13 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 14 | - ReservedCallStaticTrait; |
|
| 11 | + FluidSaveTrait, |
|
| 12 | + NewableTrait, |
|
| 13 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 14 | + ReservedCallStaticTrait; |
|
| 15 | 15 | private array $nodes = []; |
| 16 | 16 | private int $seek = 0; |
| 17 | 17 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | use FluidAliasesTrait, |
| 11 | 11 | FluidSaveTrait, |
| 12 | 12 | NewableTrait, |
| 13 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 13 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 14 | 14 | ReservedCallStaticTrait; |
| 15 | 15 | private array $nodes = []; |
| 16 | 16 | private int $seek = 0; |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function __construct(private $document, private $handler, $context) |
| 22 | 22 | { |
| 23 | - if (! \is_array($context) && ! $context instanceof \Traversable) { |
|
| 23 | + if (!\is_array($context) && !$context instanceof \Traversable) { |
|
| 24 | 24 | // DOMDocument, DOMElement and DOMNode are not iterable. |
| 25 | 25 | // DOMNodeList and FluidContext are iterable. |
| 26 | - $context = [ $context ]; |
|
| 26 | + $context = [$context]; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | foreach ($context as $n) { |
| 30 | - if (! $n instanceof \DOMNode) { |
|
| 30 | + if (!$n instanceof \DOMNode) { |
|
| 31 | 31 | throw new \Exception('Node type not recognized.'); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | return $this->query(...$query); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function times($times, callable $fn = null): FluidRepeater|static |
|
| 158 | + public function times($times, callable $fn = null): FluidRepeater | static |
|
| 159 | 159 | { |
| 160 | 160 | if ($fn === null) { |
| 161 | 161 | return new FluidRepeater($this->document, $this->handler, $this, $times); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | public function prependSibling($sibling, ...$optionals) |
| 228 | 228 | { |
| 229 | - return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) { |
|
| 229 | + return $this->handler->insertElement($this->nodes, $sibling, $optionals, function($sibling, $element) { |
|
| 230 | 230 | if ($sibling->parentNode === null) { |
| 231 | 231 | // If the node doesn't have at least one parent node, |
| 232 | 232 | // the sibling creation fails. In this case we replace |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | public function appendSibling($sibling, ...$optionals) |
| 243 | 243 | { |
| 244 | - return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) { |
|
| 244 | + return $this->handler->insertElement($this->nodes, $sibling, $optionals, function($sibling, $element) { |
|
| 245 | 245 | if ($sibling->parentNode === null) { |
| 246 | 246 | // If the node doesn't have at least one parent node, |
| 247 | 247 | // the sibling creation fails. In this case we replace |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | if (\is_array($name)) { |
| 263 | 263 | $attrs = $name; |
| 264 | 264 | } else { |
| 265 | - $attrs = [ $name => $value ]; |
|
| 265 | + $attrs = [$name => $value]; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | foreach ($this->nodes as $n) { |
@@ -415,12 +415,12 @@ discard block |
||
| 415 | 415 | return new FluidContext($this->document, $this->handler, $context); |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - protected function resolveQuery($query): array|string |
|
| 418 | + protected function resolveQuery($query): array | string |
|
| 419 | 419 | { |
| 420 | - if ( $query === '.' |
|
| 420 | + if ($query === '.' |
|
| 421 | 421 | || $query[0] === '/' |
| 422 | - || ( $query[0] === '.' && $query[1] === '/' ) |
|
| 423 | - || ( $query[0] === '.' && $query[1] === '.' ) ) { |
|
| 422 | + || ($query[0] === '.' && $query[1] === '/') |
|
| 423 | + || ($query[0] === '.' && $query[1] === '.')) { |
|
| 424 | 424 | return $query; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $found = ($r === $u) || $found; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - if (! $found) { |
|
| 441 | + if (!$found) { |
|
| 442 | 442 | $set[] = $r; |
| 443 | 443 | } |
| 444 | 444 | } |
@@ -7,32 +7,32 @@ discard block |
||
| 7 | 7 | final public const TOKEN = '/{([[:alpha:]]+)(\d+)}/i'; |
| 8 | 8 | final public 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,81 +40,81 @@ 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 | // *|A |
| 52 | - [ '\* # Namespace wildcard |
|
| 52 | + ['\* # Namespace wildcard |
|
| 53 | 53 | \| |
| 54 | 54 | (\w+)', |
| 55 | 55 | '*[local-name() = \'\1\']', |
| 56 | 56 | 'NS', |
| 57 | - false ], |
|
| 57 | + false], |
|
| 58 | 58 | // :root |
| 59 | - [ ':root\b', |
|
| 59 | + [':root\b', |
|
| 60 | 60 | '/*', |
| 61 | 61 | 'TAG', |
| 62 | - false ], |
|
| 62 | + false], |
|
| 63 | 63 | // A |
| 64 | - [ '(?<=^|\s|\}) |
|
| 64 | + ['(?<=^|\s|\}) |
|
| 65 | 65 | ( [\w\-]+ | \* )', |
| 66 | 66 | '\1', |
| 67 | 67 | 'TAG', |
| 68 | - false ], |
|
| 68 | + false], |
|
| 69 | 69 | // Aggregates the components of a tag in an expression. |
| 70 | - [ '({NS\d+})? |
|
| 70 | + ['({NS\d+})? |
|
| 71 | 71 | ({TAG\d+}) |
| 72 | 72 | ((?:{ATTR\d+})*|) |
| 73 | 73 | ((?:{ID\d+})*|) |
| 74 | 74 | ((?:{CLASS\d+})*|)', |
| 75 | 75 | '\1\2\3\4\5', |
| 76 | 76 | 'EXP', |
| 77 | - false ], |
|
| 78 | - [ '({EXP\d+}) |
|
| 77 | + false], |
|
| 78 | + ['({EXP\d+}) |
|
| 79 | 79 | :first-child', |
| 80 | 80 | '*[1]/self::\1', |
| 81 | 81 | 'EXP', |
| 82 | - false ], |
|
| 82 | + false], |
|
| 83 | 83 | // {} + {} |
| 84 | - [ '({EXP\d+}) |
|
| 84 | + ['({EXP\d+}) |
|
| 85 | 85 | \s* \+ \s* |
| 86 | 86 | ({EXP\d+})', |
| 87 | 87 | '\1/following-sibling::*[1]/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/following-sibling::*/self::\2', |
| 95 | 95 | 'EXP', |
| 96 | - true ], |
|
| 96 | + true], |
|
| 97 | 97 | // {} > {} |
| 98 | - [ '({EXP\d+}) |
|
| 98 | + ['({EXP\d+}) |
|
| 99 | 99 | \s* > \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+ |
| 107 | 107 | ({EXP\d+})', |
| 108 | 108 | '\1//\2', |
| 109 | 109 | 'EXP', |
| 110 | - true ], |
|
| 110 | + true], |
|
| 111 | 111 | // {}, {} |
| 112 | - [ '({EXP\d+}) |
|
| 112 | + ['({EXP\d+}) |
|
| 113 | 113 | \s* , \s* |
| 114 | 114 | ({EXP\d+})', |
| 115 | 115 | '\1|\2', |
| 116 | 116 | 'EXP', |
| 117 | - true ] |
|
| 117 | + true] |
|
| 118 | 118 | ]; |
| 119 | 119 | |
| 120 | 120 | public static function xpath($css) |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $xpath = \trim((string) $xpath); |
| 141 | 141 | $xpath = ".//$xpath"; |
| 142 | - $xpath = \str_replace('|', '|.//', $xpath); |
|
| 142 | + $xpath = \str_replace('|', '|.//', $xpath); |
|
| 143 | 143 | $xpath = \str_replace('.///', '/', $xpath); |
| 144 | 144 | |
| 145 | 145 | return $xpath; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | return $string && $string[0] === '<'; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public static function exportNode(\DOMDocument $dom, \DOMNode $node, $html = false): array|bool|string|null |
|
| 16 | + public static function exportNode(\DOMDocument $dom, \DOMNode $node, $html = false): array | bool | string | null |
|
| 17 | 17 | { |
| 18 | 18 | // $delegate = $html ? 'saveHTML' : 'saveXML'; |
| 19 | 19 | // return $dom->$delegate($node); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return $dom->saveXML($node); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public static function domdocumentToStringWithoutHeaders(\DOMDocument $dom, $html = false): bool|array|string|null |
|
| 28 | + public static function domdocumentToStringWithoutHeaders(\DOMDocument $dom, $html = false): bool | array | string | null |
|
| 29 | 29 | { |
| 30 | 30 | return static::exportNode($dom, $dom->documentElement, $html); |
| 31 | 31 | } |
@@ -53,20 +53,20 @@ discard block |
||
| 53 | 53 | $xml = ''; |
| 54 | 54 | |
| 55 | 55 | foreach ($nodes as $n) { |
| 56 | - $xml .= static::exportNode($dom, $n, $html) . PHP_EOL; |
|
| 56 | + $xml .= static::exportNode($dom, $n, $html).PHP_EOL; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return \rtrim($xml); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public static function simplexmlToStringWithoutHeaders(\SimpleXMLElement $element, $html = false): bool|array|string|null |
|
| 62 | + public static function simplexmlToStringWithoutHeaders(\SimpleXMLElement $element, $html = false): bool | array | string | null |
|
| 63 | 63 | { |
| 64 | 64 | $dom = \dom_import_simplexml($element); |
| 65 | 65 | |
| 66 | 66 | return static::exportNode($dom->ownerDocument, $dom, $html); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public static function domdocumentToHtml($dom, $clone = true): array|string|null |
|
| 69 | + public static function domdocumentToHtml($dom, $clone = true): array | string | null |
|
| 70 | 70 | { |
| 71 | 71 | if ($clone) { |
| 72 | 72 | $dom = $dom->cloneNode(true); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $nodes = (new \DOMXPath($dom))->query($query); |
| 96 | 96 | |
| 97 | 97 | foreach ($nodes as $n) { |
| 98 | - if (! \in_array($n->nodeName, $voids)) { |
|
| 98 | + if (!\in_array($n->nodeName, $voids)) { |
|
| 99 | 99 | // If it is not a void/empty tag, |
| 100 | 100 | // we need to leave the tag open. |
| 101 | 101 | $n->appendChild(new \DOMProcessingInstruction('X-NOT-VOID')); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | return $html; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public static function domnodeToHtml(\DOMNode $node): array|string|null |
|
| 113 | + public static function domnodeToHtml(\DOMNode $node): array | string | null |
|
| 114 | 114 | { |
| 115 | 115 | $dom = new \DOMDocument(); |
| 116 | 116 | $dom->formatOutput = true; |
@@ -9,17 +9,17 @@ discard block |
||
| 9 | 9 | class FluidXml implements FluidInterface |
| 10 | 10 | { |
| 11 | 11 | use FluidAliasesTrait, |
| 12 | - FluidSaveTrait, |
|
| 13 | - NewableTrait, |
|
| 14 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 15 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 12 | + FluidSaveTrait, |
|
| 13 | + NewableTrait, |
|
| 14 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 15 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 16 | 16 | |
| 17 | 17 | final public const ROOT_NODE = 'doc'; |
| 18 | 18 | |
| 19 | 19 | private array $defaults = [ 'root' => self::ROOT_NODE, |
| 20 | - 'version' => '1.0', |
|
| 21 | - 'encoding' => 'UTF-8', |
|
| 22 | - 'stylesheet' => null ]; |
|
| 20 | + 'version' => '1.0', |
|
| 21 | + 'encoding' => 'UTF-8', |
|
| 22 | + 'stylesheet' => null ]; |
|
| 23 | 23 | |
| 24 | 24 | private readonly \FluidXml\FluidDocument $document; |
| 25 | 25 | private readonly \FluidXml\FluidInsertionHandler $handler; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | // Now, we can further populate the DOM with any stylesheet or child. |
| 65 | 65 | $this->initStylesheet($options) |
| 66 | - ->initRoot($options); |
|
| 66 | + ->initRoot($options); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | protected function mergeOptions(&$arguments): array |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | if (! empty($options['stylesheet'])) { |
| 100 | 100 | $attrs = 'type="text/xsl" ' |
| 101 | - . "encoding=\"{$options['encoding']}\" " |
|
| 102 | - . 'indent="yes" ' |
|
| 103 | - . "href=\"{$options['stylesheet']}\""; |
|
| 101 | + . "encoding=\"{$options['encoding']}\" " |
|
| 102 | + . 'indent="yes" ' |
|
| 103 | + . "href=\"{$options['stylesheet']}\""; |
|
| 104 | 104 | |
| 105 | 105 | $stylesheet = new \DOMProcessingInstruction('xml-stylesheet', $attrs); |
| 106 | 106 | |
@@ -11,15 +11,15 @@ discard block |
||
| 11 | 11 | use FluidAliasesTrait, |
| 12 | 12 | FluidSaveTrait, |
| 13 | 13 | NewableTrait, |
| 14 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 15 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 14 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 15 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 16 | 16 | |
| 17 | 17 | final public const ROOT_NODE = 'doc'; |
| 18 | 18 | |
| 19 | - private array $defaults = [ 'root' => self::ROOT_NODE, |
|
| 19 | + private array $defaults = ['root' => self::ROOT_NODE, |
|
| 20 | 20 | 'version' => '1.0', |
| 21 | 21 | 'encoding' => 'UTF-8', |
| 22 | - 'stylesheet' => null ]; |
|
| 22 | + 'stylesheet' => null]; |
|
| 23 | 23 | |
| 24 | 24 | private readonly \FluidXml\FluidDocument $document; |
| 25 | 25 | private readonly \FluidXml\FluidInsertionHandler $handler; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $document = \file_get_contents($file); |
| 33 | 33 | |
| 34 | 34 | // file_get_contents() returns false in case of error. |
| 35 | - if (! $document) { |
|
| 35 | + if (!$document) { |
|
| 36 | 36 | throw new \Exception("File '$file' not accessible."); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | private function initStylesheet(&$options): static |
| 98 | 98 | { |
| 99 | - if (! empty($options['stylesheet'])) { |
|
| 99 | + if (!empty($options['stylesheet'])) { |
|
| 100 | 100 | $attrs = 'type="text/xsl" ' |
| 101 | 101 | . "encoding=\"{$options['encoding']}\" " |
| 102 | 102 | . 'indent="yes" ' |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | private function initRoot(&$options): static |
| 118 | 118 | { |
| 119 | - if (! empty($options['root'])) { |
|
| 119 | + if (!empty($options['root'])) { |
|
| 120 | 120 | $this->appendSibling($options['root']); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $el = $this->document->dom; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return [ $el ]; |
|
| 147 | + return [$el]; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public function __toString(): string |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $namespaces = []; |
| 188 | 188 | |
| 189 | 189 | if (\is_string($arguments[0])) { |
| 190 | - $args = [ $arguments[0], $arguments[1] ]; |
|
| 190 | + $args = [$arguments[0], $arguments[1]]; |
|
| 191 | 191 | |
| 192 | 192 | if (isset($arguments[2])) { |
| 193 | 193 | $args[] = $arguments[2]; |
@@ -206,19 +206,19 @@ discard block |
||
| 206 | 206 | return $this; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - public function query(...$query) { return $this->context()->query(...$query); } |
|
| 209 | + public function query(...$query) { return $this->context()->query(...$query); } |
|
| 210 | 210 | public function times($times, callable $fn = null) { return $this->context()->times($times, $fn); } |
| 211 | - public function each(callable $fn) { return $this->context()->each($fn); } |
|
| 212 | - public function map(callable $fn) { return $this->context()->map($fn); } |
|
| 213 | - public function filter(callable $fn) { return $this->context()->filter($fn); } |
|
| 211 | + public function each(callable $fn) { return $this->context()->each($fn); } |
|
| 212 | + public function map(callable $fn) { return $this->context()->map($fn); } |
|
| 213 | + public function filter(callable $fn) { return $this->context()->filter($fn); } |
|
| 214 | 214 | public function setAttribute($name, $value = null) { $this->context()->setAttribute($name, $value); return $this; } |
| 215 | - public function setText($text) { $this->context()->setText($text); return $this; } |
|
| 216 | - public function addText($text) { $this->context()->addText($text); return $this; } |
|
| 217 | - public function setCdata($text) { $this->context()->setCdata($text); return $this; } |
|
| 218 | - public function addCdata($text) { $this->context()->addCdata($text); return $this; } |
|
| 219 | - public function setComment($text) { $this->context()->setComment($text); return $this; } |
|
| 220 | - public function addComment($text) { $this->context()->addComment($text); return $this; } |
|
| 221 | - public function remove(...$query) { $this->context()->remove(...$query); return $this; } |
|
| 215 | + public function setText($text) { $this->context()->setText($text); return $this; } |
|
| 216 | + public function addText($text) { $this->context()->addText($text); return $this; } |
|
| 217 | + public function setCdata($text) { $this->context()->setCdata($text); return $this; } |
|
| 218 | + public function addCdata($text) { $this->context()->addCdata($text); return $this; } |
|
| 219 | + public function setComment($text) { $this->context()->setComment($text); return $this; } |
|
| 220 | + public function addComment($text) { $this->context()->addComment($text); return $this; } |
|
| 221 | + public function remove(...$query) { $this->context()->remove(...$query); return $this; } |
|
| 222 | 222 | |
| 223 | 223 | public function addChild($child, ...$optionals) |
| 224 | 224 | { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | public function __construct(private $document) |
| 11 | 11 | { |
| 12 | 12 | $this->dom = $document->dom; |
| 13 | - $this->namespaces =& $document->namespaces; |
|
| 13 | + $this->namespaces = & $document->namespaces; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // offers to the user and is the same of: |
| 36 | 36 | // 1. appending a child switching the context |
| 37 | 37 | // 2. setting the attributes over the new context. |
| 38 | - if (! empty($attributes)) { |
|
| 38 | + if (!empty($attributes)) { |
|
| 39 | 39 | $new_context->setAttribute($attributes); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | protected function handleOptionals($element, &$optionals): array |
| 54 | 54 | { |
| 55 | - if (! \is_array($element)) { |
|
| 56 | - $element = [ $element ]; |
|
| 55 | + if (!\is_array($element)) { |
|
| 56 | + $element = [$element]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $switch_context = false; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return [ $element, $attributes, $switch_context ]; |
|
| 78 | + return [$element, $attributes, $switch_context]; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | protected function recognizeStringMixed($k, $v) |
| 107 | 107 | { |
| 108 | - if (! \is_string($k)) { |
|
| 108 | + if (!\is_string($k)) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (\is_string($v) || $v === null) { |
| 120 | - if (! FluidHelper::isAnXmlString($v)) { |
|
| 120 | + if (!FluidHelper::isAnXmlString($v)) { |
|
| 121 | 121 | return 'insertStringSimple'; |
| 122 | 122 | } |
| 123 | 123 | } else { |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | protected function attachNodes($parent, $nodes, $fn): array |
| 221 | 221 | { |
| 222 | - if (! \is_array($nodes) && ! $nodes instanceof \Traversable) { |
|
| 223 | - $nodes = [ $nodes ]; |
|
| 222 | + if (!\is_array($nodes) && !$nodes instanceof \Traversable) { |
|
| 223 | + $nodes = [$nodes]; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $context = []; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $el = $this->createElement($k, $v); |
| 273 | 273 | $el = $fn($parent, $el); |
| 274 | 274 | |
| 275 | - return [ $el ]; |
|
| 275 | + return [$el]; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | // they are supplied, so 'addChild' is the perfect operation. |
| 293 | 293 | $this->newContext($el)->addChild($v, ...$optionals); |
| 294 | 294 | |
| 295 | - return [ $el ]; |
|
| 295 | + return [$el]; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $el = $this->createElement($v); |
| 326 | 326 | $el = $fn($parent, $el); |
| 327 | 327 | |
| 328 | - return [ $el ]; |
|
| 328 | + return [$el]; |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | protected function insertIntegerXml($parent, $k, $v, $fn): array |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | final public const MODE_EXPLICIT = 1; |
| 13 | 13 | |
| 14 | 14 | private array $config = [ self::ID => '', |
| 15 | - self::URI => '', |
|
| 16 | - self::MODE => self::MODE_EXPLICIT ]; |
|
| 15 | + self::URI => '', |
|
| 16 | + self::MODE => self::MODE_EXPLICIT ]; |
|
| 17 | 17 | |
| 18 | 18 | public function __construct($id, $uri, $mode = 1) |
| 19 | 19 | { |
@@ -4,16 +4,16 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class FluidNamespace |
| 6 | 6 | { |
| 7 | - final public const ID = 'id' ; |
|
| 8 | - final public const URI = 'uri' ; |
|
| 7 | + final public const ID = 'id'; |
|
| 8 | + final public const URI = 'uri'; |
|
| 9 | 9 | final public const MODE = 'mode'; |
| 10 | 10 | |
| 11 | 11 | final public const MODE_IMPLICIT = 0; |
| 12 | 12 | final public const MODE_EXPLICIT = 1; |
| 13 | 13 | |
| 14 | - private array $config = [ self::ID => '', |
|
| 14 | + private array $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 | { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $id = $this->id(); |
| 43 | 43 | |
| 44 | - if (! empty($id)) { |
|
| 44 | + if (!empty($id)) { |
|
| 45 | 45 | $id .= ':'; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $nodes = \explode('/', (string) $xpath); |
| 53 | 53 | |
| 54 | 54 | foreach ($nodes as $node) { |
| 55 | - if (! empty($node)) { |
|
| 55 | + if (!empty($node)) { |
|
| 56 | 56 | // An XPath query can have multiple slashes. |
| 57 | 57 | // Example: //target |
| 58 | 58 | $new_xpath .= "{$id}{$node}"; |