Completed
Push — master ( 3f00ec...1044f8 )
by Daniele
02:34
created
source/FluidXml.php 2 patches
Doc Comments   +72 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
  *
72 72
  * @param array $arguments Options that influence the construction of the XML document.
73 73
  *
74
- * @return FluidXml A new FluidXml instance.
74
+ * @return FluidContext A new FluidXml instance.
75 75
  */
76 76
 function fluidify(...$arguments)
77 77
 {
@@ -88,6 +88,9 @@  discard block
 block discarded – undo
88 88
         return new FluidNamespace(...$arguments);
89 89
 }
90 90
 
91
+/**
92
+ * @param string $string
93
+ */
91 94
 function is_an_xml_string($string)
92 95
 {
93 96
         // Removes any empty new line at the beginning,
@@ -534,7 +537,7 @@  discard block
 block discarded – undo
534 537
          * $xml->query("/doc")->query("book[@id='123']");
535 538
          * ```
536 539
          *
537
-         * @param string $xpath The XPath to execute.
540
+         * @param string[] $xpath The XPath to execute.
538 541
          *
539 542
          * @return FluidContext The context associated to the DOMNodeList.
540 543
          */
@@ -573,8 +576,16 @@  discard block
 block discarded – undo
573 576
         public function appendCdata($text);
574 577
         public function remove(...$xpath);
575 578
         public function xml($strip = false);
579
+
580
+        /**
581
+         * @return SaveableTrait
582
+         */
576 583
         public function save($file, $strip = false);
577 584
         // Aliases:
585
+
586
+        /**
587
+         * @return FluidContext
588
+         */
578 589
         public function add($child, ...$optionals);
579 590
         public function prepend($sibling, ...$optionals);
580 591
         public function insertSiblingBefore($sibling, ...$optionals);
@@ -651,6 +662,9 @@  discard block
 block discarded – undo
651 662
         private $context;
652 663
         private $times;
653 664
 
665
+        /**
666
+         * @param FluidContext $context
667
+         */
654 668
         public function __construct($document, $handler, $context, $times)
655 669
         {
656 670
                 $this->document = $document;
@@ -683,6 +697,9 @@  discard block
 block discarded – undo
683 697
         private $dom;
684 698
         private $namespaces;
685 699
 
700
+        /**
701
+         * @param FluidDocument $document
702
+         */
686 703
         public function __construct($document)
687 704
         {
688 705
                 $this->document   = $document;
@@ -924,6 +941,10 @@  discard block
 block discarded – undo
924 941
                 return $context;
925 942
         }
926 943
 
944
+        /**
945
+         * @param string $k
946
+         * @param string $v
947
+         */
927 948
         protected function insertSpecialContent($parent, $k, $v)
928 949
         {
929 950
                 // The user has passed an element text content:
@@ -941,6 +962,10 @@  discard block
 block discarded – undo
941 962
                 return [];
942 963
         }
943 964
 
965
+        /**
966
+         * @param string $k
967
+         * @param string $v
968
+         */
944 969
         protected function insertSpecialAttribute($parent, $k, $v)
945 970
         {
946 971
                 // The user has passed an attribute name and an attribute value:
@@ -952,6 +977,10 @@  discard block
 block discarded – undo
952 977
                 return [];
953 978
         }
954 979
 
980
+        /**
981
+         * @param string $k
982
+         * @param string $v
983
+         */
955 984
         protected function insertStringString($parent, $k, $v, $fn)
956 985
         {
957 986
                 // The user has passed an element name and an element value:
@@ -963,6 +992,9 @@  discard block
 block discarded – undo
963 992
                 return [ $el ];
964 993
         }
965 994
 
995
+        /**
996
+         * @param string $k
997
+         */
966 998
         protected function insertStringMixed($parent, $k, $v, $fn, &$optionals)
967 999
         {
968 1000
                 // The user has passed one of these two cases:
@@ -979,6 +1011,9 @@  discard block
 block discarded – undo
979 1011
                 return [ $el ];
980 1012
         }
981 1013
 
1014
+        /**
1015
+         * @param integer $k
1016
+         */
982 1017
         protected function insertIntegerArray($parent, $k, $v, $fn, &$optionals)
983 1018
         {
984 1019
                 // The user has passed a wrapper array:
@@ -995,6 +1030,10 @@  discard block
 block discarded – undo
995 1030
                 return $context;
996 1031
         }
997 1032
 
1033
+        /**
1034
+         * @param integer $k
1035
+         * @param string $v
1036
+         */
998 1037
         protected function insertIntegerString($parent, $k, $v, $fn)
999 1038
         {
1000 1039
                 // The user has passed a node name without a node value:
@@ -1006,6 +1045,10 @@  discard block
 block discarded – undo
1006 1045
                 return [ $el ];
1007 1046
         }
1008 1047
 
1048
+        /**
1049
+         * @param integer $k
1050
+         * @param string $v
1051
+         */
1009 1052
         protected function insertIntegerXml($parent, $k, $v, $fn)
1010 1053
         {
1011 1054
                 // The user has passed an XML document instance:
@@ -1035,6 +1078,10 @@  discard block
 block discarded – undo
1035 1078
                 return $this->attachNodes($parent, $nodes, $fn);
1036 1079
         }
1037 1080
 
1081
+        /**
1082
+         * @param integer $k
1083
+         * @param \DOMDocument $v
1084
+         */
1038 1085
         protected function insertIntegerDomdocument($parent, $k, $v, $fn)
1039 1086
         {
1040 1087
                 // A DOMDocument can have multiple root nodes.
@@ -1046,26 +1093,46 @@  discard block
 block discarded – undo
1046 1093
                 // return $this->attachNodes($parent, $v->documentElement, $fn);
1047 1094
         }
1048 1095
 
1096
+        /**
1097
+         * @param integer $k
1098
+         * @param \DOMNodeList $v
1099
+         */
1049 1100
         protected function insertIntegerDomnodelist($parent, $k, $v, $fn)
1050 1101
         {
1051 1102
                 return $this->attachNodes($parent, $v, $fn);
1052 1103
         }
1053 1104
 
1105
+        /**
1106
+         * @param integer $k
1107
+         * @param \DOMNode $v
1108
+         */
1054 1109
         protected function insertIntegerDomnode($parent, $k, $v, $fn)
1055 1110
         {
1056 1111
                 return $this->attachNodes($parent, $v, $fn);
1057 1112
         }
1058 1113
 
1114
+        /**
1115
+         * @param integer $k
1116
+         * @param \SimpleXMLElement $v
1117
+         */
1059 1118
         protected function insertIntegerSimplexml($parent, $k, $v, $fn)
1060 1119
         {
1061 1120
                 return $this->attachNodes($parent, \dom_import_simplexml($v), $fn);
1062 1121
         }
1063 1122
 
1123
+        /**
1124
+         * @param integer $k
1125
+         * @param FluidXml $v
1126
+         */
1064 1127
         protected function insertIntegerFluidxml($parent, $k, $v, $fn)
1065 1128
         {
1066 1129
                 return $this->attachNodes($parent, $v->dom()->documentElement, $fn);
1067 1130
         }
1068 1131
 
1132
+        /**
1133
+         * @param integer $k
1134
+         * @param FluidContext $v
1135
+         */
1069 1136
         protected function insertIntegerFluidcontext($parent, $k, $v, $fn)
1070 1137
         {
1071 1138
                 return $this->attachNodes($parent, $v->asArray(), $fn);
@@ -1450,6 +1517,9 @@  discard block
 block discarded – undo
1450 1517
                 return $set;
1451 1518
         }
1452 1519
 
1520
+        /**
1521
+         * @param callable $fn
1522
+         */
1453 1523
         protected function callfn($fn, $args)
1454 1524
         {
1455 1525
                 if ($fn instanceof \Closure) {
Please login to merge, or discard this patch.
Indentation   +14 added lines, -16 removed lines patch added patch discarded remove patch
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 class FluidXml implements FluidInterface
139 139
 {
140 140
         use NewableTrait,
141
-            SaveableTrait,
142
-            ReservedCallTrait,          // For compatibility with PHP 5.6.
143
-            ReservedCallStaticTrait;    // For compatibility with PHP 5.6.
141
+                SaveableTrait,
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
 
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
         public function __construct($root = null, $options = [])
166 166
         {
167 167
                 $defaults = [ 'root'       => self::ROOT_NODE,
168
-                              'version'    => '1.0',
169
-                              'encoding'   => 'UTF-8',
170
-                              'stylesheet' => null ];
168
+                                'version'    => '1.0',
169
+                                'encoding'   => 'UTF-8',
170
+                                'stylesheet' => null ];
171 171
 
172 172
                 if (\is_string($root)) {
173 173
                         // The root option can be specified as first argument
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 
199 199
                 if (! empty($opts['stylesheet'])) {
200 200
                         $attrs = 'type="text/xsl" '
201
-                               . "encoding=\"{$opts['encoding']}\" "
202
-                               . 'indent="yes" '
203
-                               . "href=\"{$opts['stylesheet']}\"";
201
+                                . "encoding=\"{$opts['encoding']}\" "
202
+                                . 'indent="yes" '
203
+                                . "href=\"{$opts['stylesheet']}\"";
204 204
                         $stylesheet = new \DOMProcessingInstruction('xml-stylesheet', $attrs);
205 205
 
206 206
                         $doc->dom->insertBefore($stylesheet, $doc->dom->documentElement);
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
         const MODE_EXPLICIT = 1;
446 446
 
447 447
         private $config = [ self::ID   => '',
448
-                            self::URI  => '',
449
-                            self::MODE => self::MODE_EXPLICIT ];
448
+                                self::URI  => '',
449
+                                self::MODE => self::MODE_EXPLICIT ];
450 450
 
451 451
         public function __construct($id, $uri, $mode = 1)
452 452
         {
@@ -527,7 +527,6 @@  discard block
 block discarded – undo
527 527
          *
528 528
          * ```php
529 529
          * $xml = fluidxml();
530
-
531 530
          * $xml->query("/doc/book[@id='123']");
532 531
          *
533 532
          * // Relative queries are valid.
@@ -547,7 +546,6 @@  discard block
 block discarded – undo
547 546
          *
548 547
          * ```php
549 548
          * $xml = fluidxml();
550
-
551 549
          * $xml->appendChild('title', 'The Theory Of Everything');
552 550
          * $xml->appendChild([ 'author' => 'S. Hawking' ]);
553 551
          *
@@ -1075,9 +1073,9 @@  discard block
 block discarded – undo
1075 1073
 class FluidContext implements FluidInterface, \ArrayAccess, \Iterator
1076 1074
 {
1077 1075
         use NewableTrait,
1078
-            SaveableTrait,
1079
-            ReservedCallTrait,          // For compatibility with PHP 5.6.
1080
-            ReservedCallStaticTrait;    // For compatibility with PHP 5.6.
1076
+                SaveableTrait,
1077
+                ReservedCallTrait,          // For compatibility with PHP 5.6.
1078
+                ReservedCallStaticTrait;    // For compatibility with PHP 5.6.
1081 1079
 
1082 1080
         private $document;
1083 1081
         private $handler;
Please login to merge, or discard this patch.