@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | function is_an_xml_string($string) |
| 82 | 82 | { |
| 83 | - if (! \is_string($string)) { |
|
| 83 | + if (!\is_string($string)) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | $namespaces = []; |
| 245 | 245 | |
| 246 | 246 | if (\is_string($arguments[0])) { |
| 247 | - $args = [ $arguments[0], $arguments[1] ]; |
|
| 247 | + $args = [$arguments[0], $arguments[1]]; |
|
| 248 | 248 | |
| 249 | 249 | if (isset($arguments[2])) { |
| 250 | 250 | $args[] = $arguments[2]; |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | use FluidNamespaceTrait, |
| 271 | 271 | NewableTrait, |
| 272 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 273 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 272 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 273 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 274 | 274 | |
| 275 | 275 | const ROOT_NODE = 'doc'; |
| 276 | 276 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | public static function load($document) |
| 280 | 280 | { |
| 281 | - if (\is_string($document) && ! is_an_xml_string($document)) { |
|
| 281 | + if (\is_string($document) && !is_an_xml_string($document)) { |
|
| 282 | 282 | // Removes any empty new line at the beginning, |
| 283 | 283 | // otherwise the first character check fails. |
| 284 | 284 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $document = \file_get_contents($file); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if (! $is_file || ! $is_readable || ! $document) { |
|
| 293 | + if (!$is_file || !$is_readable || !$document) { |
|
| 294 | 294 | throw new \Exception("File '$file' not accessible."); |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | public function __construct($root = null, $options = []) |
| 302 | 302 | { |
| 303 | - $defaults = [ 'root' => self::ROOT_NODE, |
|
| 303 | + $defaults = ['root' => self::ROOT_NODE, |
|
| 304 | 304 | 'version' => '1.0', |
| 305 | 305 | 'encoding' => 'UTF-8', |
| 306 | - 'stylesheet' => null ]; |
|
| 306 | + 'stylesheet' => null]; |
|
| 307 | 307 | |
| 308 | 308 | if (\is_string($root)) { |
| 309 | 309 | // The root option can be specified as first argument |
@@ -497,14 +497,14 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | protected function newContext($context = null) |
| 499 | 499 | { |
| 500 | - if (! $context) { |
|
| 500 | + if (!$context) { |
|
| 501 | 501 | $context = $this->dom->documentElement; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | // If the user has requested ['root' => null] at construction time |
| 505 | 505 | // the 'documentElement' property is null because we have not created |
| 506 | 506 | // a root node yet. |
| 507 | - if (! $context) { |
|
| 507 | + if (!$context) { |
|
| 508 | 508 | // Whether there is not a root node, the DOMDocument is |
| 509 | 509 | // promoted as root node. |
| 510 | 510 | $context = $this->dom; |
@@ -529,8 +529,8 @@ discard block |
||
| 529 | 529 | { |
| 530 | 530 | use FluidNamespaceTrait, |
| 531 | 531 | NewableTrait, |
| 532 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 533 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 532 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
| 533 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
| 534 | 534 | |
| 535 | 535 | private $dom; |
| 536 | 536 | private $nodes = []; |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | public function __construct($context, array $namespaces = []) |
| 540 | 540 | { |
| 541 | - if (! \is_array($context)) { |
|
| 542 | - $context = [ $context ]; |
|
| 541 | + if (!\is_array($context)) { |
|
| 542 | + $context = [$context]; |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | foreach ($context as $n) { |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if (! empty($namespaces)) { |
|
| 563 | + if (!empty($namespaces)) { |
|
| 564 | 564 | $this->namespace(...\array_values($namespaces)); |
| 565 | 565 | } |
| 566 | 566 | } |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if (! $found) { |
|
| 692 | + if (!$found) { |
|
| 693 | 693 | $unique_results[] = $r; |
| 694 | 694 | } |
| 695 | 695 | } |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | // appendChild($child, $value?, $attributes? = [], $switchContext? = false) |
| 745 | 745 | public function appendChild($child, ...$optionals) |
| 746 | 746 | { |
| 747 | - return $this->insertElement($child, $optionals, [ static::class, 'doAppendChild' ]); |
|
| 747 | + return $this->insertElement($child, $optionals, [static::class, 'doAppendChild']); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | // Alias of appendChild(). |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | public function prependSibling($sibling, ...$optionals) |
| 762 | 762 | { |
| 763 | - return $this->insertElement($sibling, $optionals, [ static::class, 'doPrependSibling' ]); |
|
| 763 | + return $this->insertElement($sibling, $optionals, [static::class, 'doPrependSibling']); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | // Alias of prependSibling(). |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | public function appendSibling($sibling, ...$optionals) |
| 785 | 785 | { |
| 786 | - return $this->insertElement($sibling, $optionals, [ static::class, 'doAppendSibling' ]); |
|
| 786 | + return $this->insertElement($sibling, $optionals, [static::class, 'doAppendSibling']); |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | // Alias of appendSibling(). |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | // the user has passed two arguments: |
| 812 | 812 | // 1. is the attribute name |
| 813 | 813 | // 2. is the attribute value |
| 814 | - if (! \is_array($arguments[0])) { |
|
| 814 | + if (!\is_array($arguments[0])) { |
|
| 815 | 815 | $attrs = [$arguments[0] => $arguments[1]]; |
| 816 | 816 | } |
| 817 | 817 | |
@@ -935,8 +935,8 @@ discard block |
||
| 935 | 935 | |
| 936 | 936 | protected function handleOptionals($element, array $optionals) |
| 937 | 937 | { |
| 938 | - if (! \is_array($element)) { |
|
| 939 | - $element = [ $element ]; |
|
| 938 | + if (!\is_array($element)) { |
|
| 939 | + $element = [$element]; |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | $switch_context = false; |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | - return [ $element, $attributes, $switch_context ]; |
|
| 962 | + return [$element, $attributes, $switch_context]; |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | protected function insertElement($element, array $optionals, callable $fn) |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | // offers to the user and is the same of: |
| 984 | 984 | // 1. appending a child switching the context |
| 985 | 985 | // 2. setting the attributes over the new context. |
| 986 | - if (! empty($attributes)) { |
|
| 986 | + if (!empty($attributes)) { |
|
| 987 | 987 | $context->setAttribute($attributes); |
| 988 | 988 | } |
| 989 | 989 | |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | |
| 997 | 997 | protected function handleInsertion(...$arguments) |
| 998 | 998 | { |
| 999 | - $check_sequence = [ 'specialContentHandler', |
|
| 999 | + $check_sequence = ['specialContentHandler', |
|
| 1000 | 1000 | 'specialAttributeHandler', |
| 1001 | 1001 | 'stringStringHandler', |
| 1002 | 1002 | 'stringMixedHandler', |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | 'integerDomnodeHandler', |
| 1009 | 1009 | 'integerSimplexmlHandler', |
| 1010 | 1010 | 'integerFluidxmlHandler', |
| 1011 | - 'integerFluidcontextHandler' ]; |
|
| 1011 | + 'integerFluidcontextHandler']; |
|
| 1012 | 1012 | |
| 1013 | 1013 | foreach ($check_sequence as $check) { |
| 1014 | 1014 | $ret = $this->$check(...$arguments); |
@@ -1055,8 +1055,8 @@ discard block |
||
| 1055 | 1055 | |
| 1056 | 1056 | protected function attachNodes($parent, $nodes, $fn) |
| 1057 | 1057 | { |
| 1058 | - if (! \is_array($nodes) && ! $nodes instanceof \Traversable) { |
|
| 1059 | - $nodes = [ $nodes ]; |
|
| 1058 | + if (!\is_array($nodes) && !$nodes instanceof \Traversable) { |
|
| 1059 | + $nodes = [$nodes]; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | $context = []; |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | |
| 1072 | 1072 | protected function specialContentHandler($parent, $k, $v) |
| 1073 | 1073 | { |
| 1074 | - if (! \is_string($k) || $k !== '@'|| ! \is_string($v)) { |
|
| 1074 | + if (!\is_string($k) || $k !== '@' || !\is_string($v)) { |
|
| 1075 | 1075 | return false; |
| 1076 | 1076 | } |
| 1077 | 1077 | |
@@ -1092,7 +1092,7 @@ discard block |
||
| 1092 | 1092 | |
| 1093 | 1093 | protected function specialAttributeHandler($parent, $k, $v) |
| 1094 | 1094 | { |
| 1095 | - if (! \is_string($k) || $k[0] !== '@' || ! \is_string($v)) { |
|
| 1095 | + if (!\is_string($k) || $k[0] !== '@' || !\is_string($v)) { |
|
| 1096 | 1096 | return false; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | |
| 1108 | 1108 | protected function stringStringHandler($parent, $k, $v, $fn) |
| 1109 | 1109 | { |
| 1110 | - if (! \is_string($k) || ! \is_string($v)) { |
|
| 1110 | + if (!\is_string($k) || !\is_string($v)) { |
|
| 1111 | 1111 | return false; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1117,12 +1117,12 @@ discard block |
||
| 1117 | 1117 | $el = $this->createElement($k, $v); |
| 1118 | 1118 | $el = \call_user_func($fn, $parent, $el); |
| 1119 | 1119 | |
| 1120 | - return [ $el ]; |
|
| 1120 | + return [$el]; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | protected function stringMixedHandler($parent, $k, $v, $fn, $optionals) |
| 1124 | 1124 | { |
| 1125 | - if (! \is_string($k) || \is_string($v)) { |
|
| 1125 | + if (!\is_string($k) || \is_string($v)) { |
|
| 1126 | 1126 | return false; |
| 1127 | 1127 | } |
| 1128 | 1128 | |
@@ -1137,12 +1137,12 @@ discard block |
||
| 1137 | 1137 | // they are supplied, so 'appendChild' is the perfect operation. |
| 1138 | 1138 | $this->newContext($el)->appendChild($v, ...$optionals); |
| 1139 | 1139 | |
| 1140 | - return [ $el ]; |
|
| 1140 | + return [$el]; |
|
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | 1143 | protected function integerArrayHandler($parent, $k, $v, $fn, $optionals) |
| 1144 | 1144 | { |
| 1145 | - if (! \is_int($k) || ! \is_array($v)) { |
|
| 1145 | + if (!\is_int($k) || !\is_array($v)) { |
|
| 1146 | 1146 | return false; |
| 1147 | 1147 | } |
| 1148 | 1148 | |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | |
| 1163 | 1163 | protected function integerStringNotXmlHandler($parent, $k, $v, $fn) |
| 1164 | 1164 | { |
| 1165 | - if (! \is_int($k) || ! \is_string($v) || is_an_xml_string($v)) { |
|
| 1165 | + if (!\is_int($k) || !\is_string($v) || is_an_xml_string($v)) { |
|
| 1166 | 1166 | return false; |
| 1167 | 1167 | } |
| 1168 | 1168 | |
@@ -1172,12 +1172,12 @@ discard block |
||
| 1172 | 1172 | $el = $this->createElement($v); |
| 1173 | 1173 | $el = \call_user_func($fn, $parent, $el); |
| 1174 | 1174 | |
| 1175 | - return [ $el ]; |
|
| 1175 | + return [$el]; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | protected function integerXmlHandler($parent, $k, $v, $fn) |
| 1179 | 1179 | { |
| 1180 | - if (! \is_int($k) || ! is_an_xml_string($v)) { |
|
| 1180 | + if (!\is_int($k) || !is_an_xml_string($v)) { |
|
| 1181 | 1181 | return false; |
| 1182 | 1182 | } |
| 1183 | 1183 | |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | |
| 1211 | 1211 | protected function integerDomdocumentHandler($parent, $k, $v, $fn) |
| 1212 | 1212 | { |
| 1213 | - if (! \is_int($k) || ! $v instanceof \DOMDocument) { |
|
| 1213 | + if (!\is_int($k) || !$v instanceof \DOMDocument) { |
|
| 1214 | 1214 | return false; |
| 1215 | 1215 | } |
| 1216 | 1216 | |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | |
| 1226 | 1226 | protected function integerDomnodelistHandler($parent, $k, $v, $fn) |
| 1227 | 1227 | { |
| 1228 | - if (! \is_int($k) || ! $v instanceof \DOMNodeList) { |
|
| 1228 | + if (!\is_int($k) || !$v instanceof \DOMNodeList) { |
|
| 1229 | 1229 | return false; |
| 1230 | 1230 | } |
| 1231 | 1231 | |
@@ -1234,7 +1234,7 @@ discard block |
||
| 1234 | 1234 | |
| 1235 | 1235 | protected function integerDomnodeHandler($parent, $k, $v, $fn) |
| 1236 | 1236 | { |
| 1237 | - if (! \is_int($k) || ! $v instanceof \DOMNode) { |
|
| 1237 | + if (!\is_int($k) || !$v instanceof \DOMNode) { |
|
| 1238 | 1238 | return false; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
@@ -1243,7 +1243,7 @@ discard block |
||
| 1243 | 1243 | |
| 1244 | 1244 | protected function integerSimplexmlHandler($parent, $k, $v, $fn) |
| 1245 | 1245 | { |
| 1246 | - if (! \is_int($k) || ! $v instanceof \SimpleXMLElement) { |
|
| 1246 | + if (!\is_int($k) || !$v instanceof \SimpleXMLElement) { |
|
| 1247 | 1247 | return false; |
| 1248 | 1248 | } |
| 1249 | 1249 | |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | |
| 1253 | 1253 | protected function integerFluidxmlHandler($parent, $k, $v, $fn) |
| 1254 | 1254 | { |
| 1255 | - if (! \is_int($k) || ! $v instanceof FluidXml) { |
|
| 1255 | + if (!\is_int($k) || !$v instanceof FluidXml) { |
|
| 1256 | 1256 | return false; |
| 1257 | 1257 | } |
| 1258 | 1258 | |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | |
| 1262 | 1262 | protected function integerFluidcontextHandler($parent, $k, $v, $fn) |
| 1263 | 1263 | { |
| 1264 | - if (! \is_int($k) || ! $v instanceof FluidContext) { |
|
| 1264 | + if (!\is_int($k) || !$v instanceof FluidContext) { |
|
| 1265 | 1265 | return false; |
| 1266 | 1266 | } |
| 1267 | 1267 | |
@@ -1271,16 +1271,16 @@ discard block |
||
| 1271 | 1271 | |
| 1272 | 1272 | class FluidNamespace |
| 1273 | 1273 | { |
| 1274 | - const ID = 'id' ; |
|
| 1275 | - const URI = 'uri' ; |
|
| 1274 | + const ID = 'id'; |
|
| 1275 | + const URI = 'uri'; |
|
| 1276 | 1276 | const MODE = 'mode'; |
| 1277 | 1277 | |
| 1278 | 1278 | const MODE_IMPLICIT = 0; |
| 1279 | 1279 | const MODE_EXPLICIT = 1; |
| 1280 | 1280 | |
| 1281 | - private $config = [ self::ID => '', |
|
| 1281 | + private $config = [self::ID => '', |
|
| 1282 | 1282 | self::URI => '', |
| 1283 | - self::MODE => self::MODE_EXPLICIT ]; |
|
| 1283 | + self::MODE => self::MODE_EXPLICIT]; |
|
| 1284 | 1284 | |
| 1285 | 1285 | public function __construct($id, $uri, $mode = 1) |
| 1286 | 1286 | { |