@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | { |
140 | 140 | use NewableTrait, |
141 | 141 | SaveableTrait, |
142 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
143 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
142 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
143 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
144 | 144 | |
145 | 145 | const ROOT_NODE = 'doc'; |
146 | 146 | |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | |
150 | 150 | public static function load($document) |
151 | 151 | { |
152 | - if (\is_string($document) && ! is_an_xml_string($document)) { |
|
152 | + if (\is_string($document) && !is_an_xml_string($document)) { |
|
153 | 153 | $file = $document; |
154 | 154 | $document = \file_get_contents($file); |
155 | 155 | |
156 | 156 | // file_get_contents returns false if it can't read. |
157 | - if (! $document) { |
|
157 | + if (!$document) { |
|
158 | 158 | throw new \Exception("File '$file' not accessible."); |
159 | 159 | } |
160 | 160 | } |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | |
165 | 165 | public function __construct($root = null, $options = []) |
166 | 166 | { |
167 | - $defaults = [ 'root' => self::ROOT_NODE, |
|
167 | + $defaults = ['root' => self::ROOT_NODE, |
|
168 | 168 | 'version' => '1.0', |
169 | 169 | 'encoding' => 'UTF-8', |
170 | - 'stylesheet' => null ]; |
|
170 | + 'stylesheet' => null]; |
|
171 | 171 | |
172 | 172 | if (\is_string($root)) { |
173 | 173 | // The root option can be specified as first argument |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | |
193 | 193 | $this->handler = new FluidInsertionHandler($doc); |
194 | 194 | |
195 | - if (! empty($opts['root'])) { |
|
195 | + if (!empty($opts['root'])) { |
|
196 | 196 | $this->appendSibling($opts['root']); |
197 | 197 | } |
198 | 198 | |
199 | - if (! empty($opts['stylesheet'])) { |
|
199 | + if (!empty($opts['stylesheet'])) { |
|
200 | 200 | $attrs = 'type="text/xsl" ' |
201 | 201 | . "encoding=\"{$opts['encoding']}\" " |
202 | 202 | . 'indent="yes" ' |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $namespaces = []; |
235 | 235 | |
236 | 236 | if (\is_string($arguments[0])) { |
237 | - $args = [ $arguments[0], $arguments[1] ]; |
|
237 | + $args = [$arguments[0], $arguments[1]]; |
|
238 | 238 | |
239 | 239 | if (isset($arguments[2])) { |
240 | 240 | $args[] = $arguments[2]; |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | |
438 | 438 | class FluidNamespace |
439 | 439 | { |
440 | - const ID = 'id' ; |
|
441 | - const URI = 'uri' ; |
|
440 | + const ID = 'id'; |
|
441 | + const URI = 'uri'; |
|
442 | 442 | const MODE = 'mode'; |
443 | 443 | |
444 | 444 | const MODE_IMPLICIT = 0; |
445 | 445 | const MODE_EXPLICIT = 1; |
446 | 446 | |
447 | - private $config = [ self::ID => '', |
|
447 | + private $config = [self::ID => '', |
|
448 | 448 | self::URI => '', |
449 | - self::MODE => self::MODE_EXPLICIT ]; |
|
449 | + self::MODE => self::MODE_EXPLICIT]; |
|
450 | 450 | |
451 | 451 | public function __construct($id, $uri, $mode = 1) |
452 | 452 | { |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | { |
485 | 485 | $id = $this->id(); |
486 | 486 | |
487 | - if (! empty($id)) { |
|
487 | + if (!empty($id)) { |
|
488 | 488 | $id .= ':'; |
489 | 489 | } |
490 | 490 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $nodes = \explode('/', $xpath); |
496 | 496 | |
497 | 497 | foreach ($nodes as $node) { |
498 | - if (! empty($node)) { |
|
498 | + if (!empty($node)) { |
|
499 | 499 | // An XPath query can have multiple slashes. |
500 | 500 | // Example: //target |
501 | 501 | $new_xpath .= "{$id}{$node}"; |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | { |
630 | 630 | $status = \file_put_contents($file, $this->xml($strip)); |
631 | 631 | |
632 | - if (! $status) { |
|
632 | + if (!$status) { |
|
633 | 633 | throw new \Exception("The file '$file' is not writable."); |
634 | 634 | } |
635 | 635 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | { |
688 | 688 | $this->document = $document; |
689 | 689 | $this->dom = $document->dom; |
690 | - $this->namespaces =& $document->namespaces; |
|
690 | + $this->namespaces = & $document->namespaces; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | public function insertElement(&$nodes, $element, &$optionals, $fn, $orig_context) |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | // offers to the user and is the same of: |
710 | 710 | // 1. appending a child switching the context |
711 | 711 | // 2. setting the attributes over the new context. |
712 | - if (! empty($attributes)) { |
|
712 | + if (!empty($attributes)) { |
|
713 | 713 | $new_context->setAttribute($attributes); |
714 | 714 | } |
715 | 715 | |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | |
724 | 724 | protected function handleOptionals($element, &$optionals) |
725 | 725 | { |
726 | - if (! \is_array($element)) { |
|
727 | - $element = [ $element ]; |
|
726 | + if (!\is_array($element)) { |
|
727 | + $element = [$element]; |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | $switch_context = false; |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | - return [ $element, $attributes, $switch_context ]; |
|
750 | + return [$element, $attributes, $switch_context]; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | $v_is_string = \is_string($v); |
769 | 769 | $v_is_xml = $v_is_string && is_an_xml_string($v); |
770 | 770 | $k_is_special = $k_is_string && $k[0] === '@'; |
771 | - $k_isnt_special = ! $k_is_special; |
|
772 | - $v_isnt_string = ! $v_is_string; |
|
773 | - $v_isnt_xml = ! $v_is_xml; |
|
771 | + $k_isnt_special = !$k_is_special; |
|
772 | + $v_isnt_string = !$v_is_string; |
|
773 | + $v_isnt_xml = !$v_is_xml; |
|
774 | 774 | /////////////////////////////////////////////////////// |
775 | 775 | |
776 | 776 | if ($k_is_string && $k_isnt_special && $v_is_string && $v_isnt_xml) { |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | } |
791 | 791 | |
792 | 792 | ///////////////////////////////////////////////////// |
793 | - $k_is_special_a = $k_is_special && ! $k_is_special_c; |
|
793 | + $k_is_special_a = $k_is_special && !$k_is_special_c; |
|
794 | 794 | ///////////////////////////////////////////////////// |
795 | 795 | |
796 | 796 | if ($k_is_special_a && $v_is_string) { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | $v_is_domnode = $v instanceof \DOMNode; |
843 | 843 | /////////////////////////////////////// |
844 | 844 | |
845 | - if ($k_is_integer && ! $v_is_domdoc && $v_is_domnode) { |
|
845 | + if ($k_is_integer && !$v_is_domdoc && $v_is_domnode) { |
|
846 | 846 | return $this->insertIntegerDomnode($parent, $k, $v, $fn, $optionals); |
847 | 847 | } |
848 | 848 | |
@@ -910,8 +910,8 @@ discard block |
||
910 | 910 | |
911 | 911 | protected function attachNodes($parent, $nodes, $fn) |
912 | 912 | { |
913 | - if (! \is_array($nodes) && ! $nodes instanceof \Traversable) { |
|
914 | - $nodes = [ $nodes ]; |
|
913 | + if (!\is_array($nodes) && !$nodes instanceof \Traversable) { |
|
914 | + $nodes = [$nodes]; |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | $context = []; |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | $el = $this->createElement($k, $v); |
961 | 961 | $el = $fn($parent, $el); |
962 | 962 | |
963 | - return [ $el ]; |
|
963 | + return [$el]; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | protected function insertStringMixed($parent, $k, $v, $fn, &$optionals) |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | // they are supplied, so 'appendChild' is the perfect operation. |
977 | 977 | $this->newContext($el)->appendChild($v, ...$optionals); |
978 | 978 | |
979 | - return [ $el ]; |
|
979 | + return [$el]; |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | protected function insertIntegerArray($parent, $k, $v, $fn, &$optionals) |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | $el = $this->createElement($v); |
1004 | 1004 | $el = $fn($parent, $el); |
1005 | 1005 | |
1006 | - return [ $el ]; |
|
1006 | + return [$el]; |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | protected function insertIntegerXml($parent, $k, $v, $fn) |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | { |
1077 | 1077 | use NewableTrait, |
1078 | 1078 | SaveableTrait, |
1079 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
1080 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
1079 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
1080 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
1081 | 1081 | |
1082 | 1082 | private $document; |
1083 | 1083 | private $handler; |
@@ -1089,14 +1089,14 @@ discard block |
||
1089 | 1089 | $this->document = $document; |
1090 | 1090 | $this->handler = $handler; |
1091 | 1091 | |
1092 | - if (! \is_array($context) && ! $context instanceof \Traversable) { |
|
1092 | + if (!\is_array($context) && !$context instanceof \Traversable) { |
|
1093 | 1093 | // DOMDocument, DOMElement and DOMNode are not iterable. |
1094 | 1094 | // DOMNodeList and FluidContext are iterable. |
1095 | - $context = [ $context ]; |
|
1095 | + $context = [$context]; |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | foreach ($context as $n) { |
1099 | - if (! $n instanceof \DOMNode) { |
|
1099 | + if (!$n instanceof \DOMNode) { |
|
1100 | 1100 | throw new \Exception('Node type not recognized.'); |
1101 | 1101 | } |
1102 | 1102 | |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | // the user has passed two arguments: |
1310 | 1310 | // 1. is the attribute name |
1311 | 1311 | // 2. is the attribute value |
1312 | - if (! \is_array($arguments[0])) { |
|
1312 | + if (!\is_array($arguments[0])) { |
|
1313 | 1313 | $attrs = [$arguments[0] => $arguments[1]]; |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | $found = ($r === $u) || $found; |
1443 | 1443 | } |
1444 | 1444 | |
1445 | - if (! $found) { |
|
1445 | + if (!$found) { |
|
1446 | 1446 | $set[] = $r; |
1447 | 1447 | } |
1448 | 1448 | } |