@@ -60,6 +60,7 @@ class DOMQuery extends DOM
6060 /**
6161 * The number of current matches.
6262 *
63+ * @var int
6364 * @see count()
6465 */
6566 public $ length = 0 ;
@@ -109,7 +110,7 @@ public function getOptions(): array
109110 * case that is not handled by find(':root') because there is no element
110111 * whose root can be found).
111112 *
112- * @param string $selector
113+ * @param string|null $selector
113114 * A selector. If this is supplied, QueryPath will navigate to the
114115 * document root and then run the query. (Added in QueryPath 2.0 Beta 2)
115116 *
@@ -151,7 +152,7 @@ public function find($selector): Query
151152 /**
152153 * @param $selector
153154 *
154- * @return $this
155+ * @return DOMQuery
155156 * @throws CSS\ParseException
156157 */
157158 public function findInPlace ($ selector )
@@ -267,14 +268,14 @@ public function count(): int
267268 * will be wrapped in a DOMQuery object. To learn more about iterating
268269 * in QueryPath, see {@link examples/techniques.php}.
269270 *
270- * @param int $index
271+ * @param int|null $index
271272 * If specified, then only this index value will be returned. If this
272273 * index is out of bounds, a NULL will be returned.
273274 * @param boolean $asObject
274275 * If this is TRUE, an SplObjectStorage object will be returned
275276 * instead of an array. This is the preferred method for extensions to use.
276277 *
277- * @return mixed
278+ * @return array<SplObjectStorage>|SplObjectStorage|null
278279 * If an index is passed, one element will be returned. If no index is
279280 * present, an array of all matches will be returned.
280281 * @see eq()
@@ -303,6 +304,8 @@ public function get($index = null, $asObject = false)
303304 *
304305 * If QP is currently pointed to a list of elements, this will get the
305306 * namespace of the first element.
307+ *
308+ * @return string
306309 */
307310 public function ns ()
308311 {
@@ -520,7 +523,8 @@ public function sort($comparator, $modifyDOM = false): Query
520523 * @param DOMElement $subject
521524 * The item to match.
522525 *
523- * @return mixed
526+ * @return int|false
527+ *
524528 * The index as an integer (if found), or boolean FALSE. Since 0 is a
525529 * valid index, you should use strong equality (===) to test..
526530 * @see get()
@@ -650,10 +654,11 @@ public function andSelf()
650654 *
651655 * By default, this is HTML 4.01, not XHTML. Use {@link xml()} for XHTML.
652656 *
653- * @param string $markup
657+ * @param null| string $markup
654658 * The text to insert.
655659 *
656- * @return mixed
660+ * @return DOMQuery|string|null
661+ *
657662 * A string if no markup was passed, or a DOMQuery if markup was passed.
658663 * @throws Exception
659664 * @throws QueryPath
@@ -707,7 +712,7 @@ public function html($markup = null)
707712 *
708713 * See html()
709714 *
710- * @param null $markup
715+ * @param null|string $markup
711716 *
712717 * @return null|DOMQuery|string
713718 * @throws QueryPath
@@ -775,7 +780,7 @@ public function html5($markup = null)
775780 * This would return the following:
776781 * @codetest <p>foo</p> test@endcode
777782 *
778- * @return string
783+ * @return string|null
779784 * Returns a string representation of the child nodes of the first
780785 * matched element.
781786 * @see html()
@@ -794,7 +799,7 @@ public function innerHTML()
794799 * This will return the children of the present match. For an example,
795800 * see {@link innerHTML()}.
796801 *
797- * @return string
802+ * @return string|null
798803 * Returns a string of XHTML that represents the children of the present
799804 * node.
800805 * @see innerXML()
@@ -833,7 +838,7 @@ public function innerXHTML()
833838 * This will return the children of the present match. For an example,
834839 * see {@link innerHTML()}.
835840 *
836- * @return string
841+ * @return string|null
837842 * Returns a string of XHTML that represents the children of the present
838843 * node.
839844 * @see innerXHTML()
@@ -871,6 +876,8 @@ public function innerXML()
871876 *
872877 * TODO: This is a very simple alteration of innerXML. Do we need better
873878 * support?
879+ *
880+ * @return string|null
874881 */
875882 public function innerHTML5 ()
876883 {
@@ -960,11 +967,11 @@ public function childrenText($separator = ' '): string
960967 /**
961968 * Get or set the text contents of a node.
962969 *
963- * @param string $text
970+ * @param string|null $text
964971 * If this is not NULL, this value will be set as the text of the node. It
965972 * will replace any existing content.
966973 *
967- * @return mixed
974+ * @return DOMQuery|string
968975 * A DOMQuery if $text is set, or the text content if no text
969976 * is passed in as a pram.
970977 * @see html()
@@ -995,7 +1002,7 @@ public function text($text = null)
9951002 *
9961003 * If $text is passed in, the text is inserted before each currently selected item.
9971004 *
998- * If no text is given, this will return the concatenated text after each selected element.
1005+ * If no text is given, this will return the concatenated text before each selected element.
9991006 *
10001007 * @code
10011008 * <?php
@@ -1009,11 +1016,11 @@ public function text($text = null)
10091016 * ?>
10101017 * @endcode
10111018 *
1012- * @param string $text
1019+ * @param string|null $text
10131020 * If this is set, it will be inserted before each node in the current set of
10141021 * selected items.
10151022 *
1016- * @return mixed
1023+ * @return DOMQuery|string
10171024 * Returns the DOMQuery object if $text was set, and returns a string (possibly empty)
10181025 * if no param is passed.
10191026 * @throws Exception
@@ -1038,6 +1045,35 @@ public function textBefore($text = null)
10381045 return $ buffer ;
10391046 }
10401047
1048+ /**
1049+ * Get or set the text after each selected item.
1050+ *
1051+ * If $text is passed in, the text is inserted after each currently selected item.
1052+ *
1053+ * If no text is given, this will return the concatenated text after each selected element.
1054+ *
1055+ * @code
1056+ * <?php
1057+ * $xml = '<?xml version="1.0"?><root>Foo<a>Bar</a><b>Baz</b><c/></root>';
1058+ *
1059+ * // This will return 'Baz'
1060+ * qp($xml, 'a')->textAfter();
1061+ *
1062+ * // This will insert 'Bin' right after <c/>.
1063+ * qp($xml, 'c')->textAfter('Bin');
1064+ * ?>
1065+ * @endcode
1066+ *
1067+ * @param string|null $text
1068+ * If this is set, it will be inserted after each node in the current set of
1069+ * selected items.
1070+ *
1071+ * @return DOMQuery|string
1072+ * Returns the DOMQuery object if $text was set, and returns a string (possibly empty)
1073+ * if no param is passed.
1074+ * @throws Exception
1075+ * @throws QueryPath
1076+ */
10411077 public function textAfter ($ text = null )
10421078 {
10431079 if (isset ($ text )) {
@@ -1072,9 +1108,9 @@ public function textAfter($text = null)
10721108 * @deprecated Just use attr(). There's no reason to use this on the server.
10731109 * @see attr()
10741110 *
1075- * @param string $value
1111+ * @param string|null $value
10761112 *
1077- * @return mixed
1113+ * @return DOMQuery|array|string|null
10781114 * Returns a DOMQuery if a string was passed in, and a string if no string
10791115 * was passed in. In the later case, an error will produce NULL.
10801116 */
@@ -1101,12 +1137,13 @@ public function val($value = null)
11011137 * This is a convenience function for fetching HTML in XML format.
11021138 * It does no processing of the markup (such as schema validation).
11031139 *
1104- * @param string $markup
1140+ * @param string|null $markup
11051141 * A string containing XML data.
11061142 *
1107- * @return mixed
1143+ * @return DOMQuery|string|null
11081144 * If markup is passed in, a DOMQuery is returned. If no markup is passed
11091145 * in, XML representing the first matched element is returned.
1146+ * @throws Exception
11101147 * @see html()
11111148 * @see innerXHTML()
11121149 */
@@ -1179,12 +1216,13 @@ public function xhtml($markup = null)
11791216 * In getter mode, the first element wrapped by this DOMNode object will be
11801217 * converted to an XML string and returned.
11811218 *
1182- * @param string $markup
1219+ * @param string|null $markup
11831220 * A string containing XML data.
11841221 *
1185- * @return mixed
1222+ * @return DOMQuery|string|null
11861223 * If markup is passed in, a DOMQuery is returned. If no markup is passed
11871224 * in, XML representing the first matched element is returned.
1225+ * @throws Exception
11881226 * @see xhtml()
11891227 * @see html()
11901228 * @see text()
@@ -1236,7 +1274,7 @@ public function xml($markup = null)
12361274 *
12371275 * This prints the entire document.
12381276 *
1239- * @param string $path
1277+ * @param string|null $path
12401278 * The path to the file into which the XML should be written. if
12411279 * this is NULL, data will be written to STDOUT, which is usually
12421280 * sent to the remote browser.
@@ -1282,7 +1320,7 @@ public function writeXML($path = null, $options = 0)
12821320 *
12831321 * Write the document to stdout (usually the client) or to a file.
12841322 *
1285- * @param string $path
1323+ * @param string|null $path
12861324 * The path to the file into which the XML should be written. if
12871325 * this is NULL, data will be written to STDOUT, which is usually
12881326 * sent to the remote browser.
@@ -1346,7 +1384,7 @@ public function writeHTML5($path = null)
13461384 * never @code<script/>@endcode). It will
13471385 * write the file as well-formed XML. No XHTML schema validation is done.
13481386 *
1349- * @param string $path
1387+ * @param string|null $path
13501388 * The filename of the file to write to.
13511389 *
13521390 * @return DOMQuery
@@ -1422,7 +1460,7 @@ public function writeXHTML($path = null)
14221460 * in most cases, parsed -- which is costly). Branching makes it possible to
14231461 * work on one document with multiple DOMNode objects.
14241462 *
1425- * @param string $selector
1463+ * @param string|null $selector
14261464 * If a selector is passed in, an additional {@link find()} will be executed
14271465 * on the branch before it is returned. (Added in QueryPath 2.0.)
14281466 *
@@ -1513,7 +1551,7 @@ public function __clone()
15131551 * Call extension methods.
15141552 *
15151553 * This function is used to invoke extension methods. It searches the
1516- * registered extenstensions for a matching function name. If one is found,
1554+ * registered extensions for a matching function name. If one is found,
15171555 * it is executed with the arguments in the $arguments array.
15181556 *
15191557 * @throws ReflectionException
@@ -1556,7 +1594,7 @@ public function __call($name, $arguments)
15561594 /**
15571595 * Get an iterator for the matches in this object.
15581596 *
1559- * @return Iterable
1597+ * @return Traversable
15601598 * Returns an iterator.
15611599 */
15621600 public function getIterator (): Traversable
0 commit comments