@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param array $arguments Options that influence the construction of the XML document. |
63 | 63 | * |
64 | - * @return FluidXml A new FluidXml instance. |
|
64 | + * @return FluidContext A new FluidXml instance. |
|
65 | 65 | */ |
66 | 66 | function fluidify(...$arguments) |
67 | 67 | { |
@@ -140,12 +140,16 @@ discard block |
||
140 | 140 | * $xml->query("/doc")->query("book[@id='123']"); |
141 | 141 | * ``` |
142 | 142 | * |
143 | - * @param string $xpath The XPath to execute. |
|
143 | + * @param string[] $xpath The XPath to execute. |
|
144 | 144 | * |
145 | 145 | * @return FluidContext The context associated to the DOMNodeList. |
146 | 146 | */ |
147 | 147 | public function query(...$xpath); |
148 | 148 | public function times($times, callable $fn = null); |
149 | + |
|
150 | + /** |
|
151 | + * @return FluidContext |
|
152 | + */ |
|
149 | 153 | public function each(callable $fn); |
150 | 154 | |
151 | 155 | /** |
@@ -162,9 +166,6 @@ discard block |
||
162 | 166 | * ``` |
163 | 167 | * |
164 | 168 | * @param string|array $child The child/children to add. |
165 | - * @param string $value The child text content. |
|
166 | - * @param bool $switchContext Whether to return the current context |
|
167 | - * or the context of the created node. |
|
168 | 169 | * |
169 | 170 | * @return FluidContext The context associated to the DOMNodeList. |
170 | 171 | */ |
@@ -179,6 +180,10 @@ discard block |
||
179 | 180 | public function remove(...$xpath); |
180 | 181 | public function xml($strip = false); |
181 | 182 | // Aliases: |
183 | + |
|
184 | + /** |
|
185 | + * @return FluidContext |
|
186 | + */ |
|
182 | 187 | public function add($child, ...$optionals); |
183 | 188 | public function prepend($sibling, ...$optionals); |
184 | 189 | public function insertSiblingBefore($sibling, ...$optionals); |
@@ -513,6 +518,10 @@ discard block |
||
513 | 518 | return new FluidContext($context, $this->namespaces); |
514 | 519 | } |
515 | 520 | |
521 | + /** |
|
522 | + * @param FluidContext $help_context |
|
523 | + * @param FluidContext $new_context |
|
524 | + */ |
|
516 | 525 | protected function chooseContext($help_context, $new_context) |
517 | 526 | { |
518 | 527 | // If the two contextes are diffent, the user has requested |
@@ -1014,6 +1023,10 @@ discard block |
||
1014 | 1023 | throw new \Exception('XML document not supported.'); |
1015 | 1024 | } |
1016 | 1025 | |
1026 | + /** |
|
1027 | + * @param string $name |
|
1028 | + * @param string $value |
|
1029 | + */ |
|
1017 | 1030 | protected function createElement($name, $value = null) |
1018 | 1031 | { |
1019 | 1032 | // The DOMElement instance must be different for every node, |
@@ -1342,6 +1355,9 @@ discard block |
||
1342 | 1355 | private $context; |
1343 | 1356 | private $times; |
1344 | 1357 | |
1358 | + /** |
|
1359 | + * @param FluidContext $context |
|
1360 | + */ |
|
1345 | 1361 | public function __construct($context, $times) |
1346 | 1362 | { |
1347 | 1363 | $this->context = $context; |
@@ -133,7 +133,6 @@ discard block |
||
133 | 133 | * |
134 | 134 | * ```php |
135 | 135 | * $xml = fluidxml(); |
136 | - |
|
137 | 136 | * $xml->query("/doc/book[@id='123']"); |
138 | 137 | * |
139 | 138 | * // Relative queries are valid. |
@@ -153,7 +152,6 @@ discard block |
||
153 | 152 | * |
154 | 153 | * ```php |
155 | 154 | * $xml = fluidxml(); |
156 | - |
|
157 | 155 | * $xml->appendChild('title', 'The Theory Of Everything'); |
158 | 156 | * $xml->appendChild([ 'author' => 'S. Hawking' ]); |
159 | 157 | * |
@@ -268,9 +266,9 @@ discard block |
||
268 | 266 | class FluidXml implements FluidInterface |
269 | 267 | { |
270 | 268 | use FluidNamespaceTrait, |
271 | - NewableTrait, |
|
272 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
273 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
269 | + NewableTrait, |
|
270 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
271 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
274 | 272 | |
275 | 273 | const ROOT_NODE = 'doc'; |
276 | 274 | |
@@ -301,9 +299,9 @@ discard block |
||
301 | 299 | public function __construct($root = null, $options = []) |
302 | 300 | { |
303 | 301 | $defaults = [ 'root' => self::ROOT_NODE, |
304 | - 'version' => '1.0', |
|
305 | - 'encoding' => 'UTF-8', |
|
306 | - 'stylesheet' => null ]; |
|
302 | + 'version' => '1.0', |
|
303 | + 'encoding' => 'UTF-8', |
|
304 | + 'stylesheet' => null ]; |
|
307 | 305 | |
308 | 306 | if (\is_string($root)) { |
309 | 307 | // The root option can be specified as first argument |
@@ -327,9 +325,9 @@ discard block |
||
327 | 325 | |
328 | 326 | if ($opts['stylesheet']) { |
329 | 327 | $attrs = 'type="text/xsl" ' |
330 | - . "encoding=\"{$opts['encoding']}\" " |
|
331 | - . 'indent="yes" ' |
|
332 | - . "href=\"{$opts['stylesheet']}\""; |
|
328 | + . "encoding=\"{$opts['encoding']}\" " |
|
329 | + . 'indent="yes" ' |
|
330 | + . "href=\"{$opts['stylesheet']}\""; |
|
333 | 331 | $stylesheet = new \DOMProcessingInstruction('xml-stylesheet', $attrs); |
334 | 332 | |
335 | 333 | $this->dom->insertBefore($stylesheet, $this->dom->documentElement); |
@@ -528,9 +526,9 @@ discard block |
||
528 | 526 | class FluidContext implements FluidInterface, \ArrayAccess, \Iterator |
529 | 527 | { |
530 | 528 | use FluidNamespaceTrait, |
531 | - NewableTrait, |
|
532 | - ReservedCallTrait, // For compatibility with PHP 5.6. |
|
533 | - ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
529 | + NewableTrait, |
|
530 | + ReservedCallTrait, // For compatibility with PHP 5.6. |
|
531 | + ReservedCallStaticTrait; // For compatibility with PHP 5.6. |
|
534 | 532 | |
535 | 533 | private $dom; |
536 | 534 | private $nodes = []; |
@@ -990,18 +988,18 @@ discard block |
||
990 | 988 | protected function handleInsertion(...$arguments) |
991 | 989 | { |
992 | 990 | $check_sequence = [ 'specialContentHandler', |
993 | - 'specialAttributeHandler', |
|
994 | - 'stringStringHandler', |
|
995 | - 'stringMixedHandler', |
|
996 | - 'integerArrayHandler', |
|
997 | - 'integerStringNotXmlHandler', |
|
998 | - 'integerXmlHandler', |
|
999 | - 'integerDomdocumentHandler', |
|
1000 | - 'integerDomnodelistHandler', |
|
1001 | - 'integerDomnodeHandler', |
|
1002 | - 'integerSimplexmlHandler', |
|
1003 | - 'integerFluidxmlHandler', |
|
1004 | - 'integerFluidcontextHandler' ]; |
|
991 | + 'specialAttributeHandler', |
|
992 | + 'stringStringHandler', |
|
993 | + 'stringMixedHandler', |
|
994 | + 'integerArrayHandler', |
|
995 | + 'integerStringNotXmlHandler', |
|
996 | + 'integerXmlHandler', |
|
997 | + 'integerDomdocumentHandler', |
|
998 | + 'integerDomnodelistHandler', |
|
999 | + 'integerDomnodeHandler', |
|
1000 | + 'integerSimplexmlHandler', |
|
1001 | + 'integerFluidxmlHandler', |
|
1002 | + 'integerFluidcontextHandler' ]; |
|
1005 | 1003 | |
1006 | 1004 | foreach ($check_sequence as $check) { |
1007 | 1005 | $ret = $this->$check(...$arguments); |
@@ -1273,8 +1271,8 @@ discard block |
||
1273 | 1271 | const MODE_EXPLICIT = 1; |
1274 | 1272 | |
1275 | 1273 | private $config = [ self::ID => '', |
1276 | - self::URI => '', |
|
1277 | - self::MODE => self::MODE_EXPLICIT ]; |
|
1274 | + self::URI => '', |
|
1275 | + self::MODE => self::MODE_EXPLICIT ]; |
|
1278 | 1276 | |
1279 | 1277 | public function __construct($id, $uri, $mode = 1) |
1280 | 1278 | { |