@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param array $arguments Options that influence the construction of the XML document. |
| 70 | 70 | * |
| 71 | - * @return FluidXml A new FluidXml instance. |
|
| 71 | + * @return FluidContext A new FluidXml instance. |
|
| 72 | 72 | */ |
| 73 | 73 | function fluidify(...$arguments) |
| 74 | 74 | { |
@@ -85,6 +85,9 @@ discard block |
||
| 85 | 85 | return new FluidNamespace(...$arguments); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | +/** |
|
| 89 | + * @param string $string |
|
| 90 | + */ |
|
| 88 | 91 | function is_an_xml_string($string) |
| 89 | 92 | { |
| 90 | 93 | // Removes any empty new line at the beginning, |
@@ -143,12 +146,16 @@ discard block |
||
| 143 | 146 | * $xml->query("/doc")->query("book[@id='123']"); |
| 144 | 147 | * ``` |
| 145 | 148 | * |
| 146 | - * @param string $xpath The XPath to execute. |
|
| 149 | + * @param string[] $xpath The XPath to execute. |
|
| 147 | 150 | * |
| 148 | 151 | * @return FluidContext The context associated to the DOMNodeList. |
| 149 | 152 | */ |
| 150 | 153 | public function query(...$xpath); |
| 151 | 154 | public function times($times, callable $fn = null); |
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @return FluidContext |
|
| 158 | + */ |
|
| 152 | 159 | public function each(callable $fn); |
| 153 | 160 | |
| 154 | 161 | /** |
@@ -165,9 +172,6 @@ discard block |
||
| 165 | 172 | * ``` |
| 166 | 173 | * |
| 167 | 174 | * @param string|array $child The child/children to add. |
| 168 | - * @param string $value The child text content. |
|
| 169 | - * @param bool $switchContext Whether to return the current context |
|
| 170 | - * or the context of the created node. |
|
| 171 | 175 | * |
| 172 | 176 | * @return FluidContext The context associated to the DOMNodeList. |
| 173 | 177 | */ |
@@ -182,6 +186,10 @@ discard block |
||
| 182 | 186 | public function remove(...$xpath); |
| 183 | 187 | public function xml($strip = false); |
| 184 | 188 | // Aliases: |
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @return FluidContext |
|
| 192 | + */ |
|
| 185 | 193 | public function add($child, ...$optionals); |
| 186 | 194 | public function prepend($sibling, ...$optionals); |
| 187 | 195 | public function insertSiblingBefore($sibling, ...$optionals); |
@@ -478,6 +486,10 @@ discard block |
||
| 478 | 486 | return new FluidContext($context, $this->namespaces); |
| 479 | 487 | } |
| 480 | 488 | |
| 489 | + /** |
|
| 490 | + * @param FluidContext $helpContext |
|
| 491 | + * @param FluidContext $newContext |
|
| 492 | + */ |
|
| 481 | 493 | protected function chooseContext($helpContext, $newContext) |
| 482 | 494 | { |
| 483 | 495 | // If the two contextes are diffent, the user has requested |
@@ -876,6 +888,10 @@ discard block |
||
| 876 | 888 | return new FluidContext($context, $this->namespaces); |
| 877 | 889 | } |
| 878 | 890 | |
| 891 | + /** |
|
| 892 | + * @param string $name |
|
| 893 | + * @param string $value |
|
| 894 | + */ |
|
| 879 | 895 | protected function createElement($name, $value = null) |
| 880 | 896 | { |
| 881 | 897 | // The DOMElement instance must be different for every node, |
@@ -1211,6 +1227,9 @@ discard block |
||
| 1211 | 1227 | protected $context; |
| 1212 | 1228 | protected $times; |
| 1213 | 1229 | |
| 1230 | + /** |
|
| 1231 | + * @param FluidContext $context |
|
| 1232 | + */ |
|
| 1214 | 1233 | public function __construct($context, $times) |
| 1215 | 1234 | { |
| 1216 | 1235 | $this->context = $context; |
@@ -136,7 +136,6 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * ```php |
| 138 | 138 | * $xml = fluidxml(); |
| 139 | - |
|
| 140 | 139 | * $xml->query("/doc/book[@id='123']"); |
| 141 | 140 | * |
| 142 | 141 | * // Relative queries are valid. |
@@ -156,7 +155,6 @@ discard block |
||
| 156 | 155 | * |
| 157 | 156 | * ```php |
| 158 | 157 | * $xml = fluidxml(); |
| 159 | - |
|
| 160 | 158 | * $xml->appendChild('title', 'The Theory Of Everything'); |
| 161 | 159 | * $xml->appendChild([ 'author' => 'S. Hawking' ]); |
| 162 | 160 | * |
@@ -234,8 +232,8 @@ discard block |
||
| 234 | 232 | class FluidXml implements FluidInterface |
| 235 | 233 | { |
| 236 | 234 | use FluidNamespaceTrait, |
| 237 | - FluidXmlShadowTrait, // For compatibility with PHP 5.6. |
|
| 238 | - FluidContextShadowTrait; // For compatibility with PHP 5.6. |
|
| 235 | + FluidXmlShadowTrait, // For compatibility with PHP 5.6. |
|
| 236 | + FluidContextShadowTrait; // For compatibility with PHP 5.6. |
|
| 239 | 237 | |
| 240 | 238 | const ROOT_NODE = 'doc'; |
| 241 | 239 | |
@@ -266,9 +264,9 @@ discard block |
||
| 266 | 264 | public function __construct($root = null, $options = []) |
| 267 | 265 | { |
| 268 | 266 | $defaults = [ 'root' => self::ROOT_NODE, |
| 269 | - 'version' => '1.0', |
|
| 270 | - 'encoding' => 'UTF-8', |
|
| 271 | - 'stylesheet' => null ]; |
|
| 267 | + 'version' => '1.0', |
|
| 268 | + 'encoding' => 'UTF-8', |
|
| 269 | + 'stylesheet' => null ]; |
|
| 272 | 270 | |
| 273 | 271 | if (\is_string($root)) { |
| 274 | 272 | // The root option can be specified as first argument |
@@ -292,9 +290,9 @@ discard block |
||
| 292 | 290 | |
| 293 | 291 | if ($opts['stylesheet']) { |
| 294 | 292 | $attrs = "type=\"text/xsl\" " |
| 295 | - . "encoding=\"{$opts['encoding']}\" " |
|
| 296 | - . "indent=\"yes\" " |
|
| 297 | - . "href=\"{$opts['stylesheet']}\""; |
|
| 293 | + . "encoding=\"{$opts['encoding']}\" " |
|
| 294 | + . "indent=\"yes\" " |
|
| 295 | + . "href=\"{$opts['stylesheet']}\""; |
|
| 298 | 296 | $stylesheet = new \DOMProcessingInstruction('xml-stylesheet', $attrs); |
| 299 | 297 | |
| 300 | 298 | $this->dom->insertBefore($stylesheet, $this->dom->documentElement); |
@@ -493,7 +491,7 @@ discard block |
||
| 493 | 491 | class FluidContext implements FluidInterface, \ArrayAccess, \Iterator |
| 494 | 492 | { |
| 495 | 493 | use FluidNamespaceTrait, |
| 496 | - FluidContextShadowTrait; // For compatibility with PHP 5.6. |
|
| 494 | + FluidContextShadowTrait; // For compatibility with PHP 5.6. |
|
| 497 | 495 | |
| 498 | 496 | private $dom; |
| 499 | 497 | private $nodes = []; |
@@ -1142,8 +1140,8 @@ discard block |
||
| 1142 | 1140 | const MODE_EXPLICIT = 1; |
| 1143 | 1141 | |
| 1144 | 1142 | private $config = [ self::ID => '', |
| 1145 | - self::URI => '', |
|
| 1146 | - self::MODE => self::MODE_EXPLICIT ]; |
|
| 1143 | + self::URI => '', |
|
| 1144 | + self::MODE => self::MODE_EXPLICIT ]; |
|
| 1147 | 1145 | |
| 1148 | 1146 | public function __construct($id, $uri, $mode = 1) |
| 1149 | 1147 | { |