@@ -67,8 +67,7 @@ class htmldoc extends config implements \ArrayAccess, \Iterator {
6767 * @param string $var The name of the property to retrieve, currently 'length' and output
6868 * @return mixed The number of children in the object for length, the output config, or null if the parameter doesn't exist
6969 */
70- #[\ReturnTypeWillChange]
71- public function __get (string $ var ) {
70+ public function __get (string $ var ) : mixed {
7271 if ($ var === 'config ' ) {
7372 return $ this ->config ;
7473 } elseif ($ var === 'length ' ) {
@@ -92,7 +91,7 @@ public function toArray() : array {
9291 * @param mixed $i The key to be updated, can be a string or integer
9392 * @param mixed $value The value of the array key in the children array to be updated
9493 */
95- public function offsetSet ($ i , $ value ) : void {
94+ public function offsetSet (mixed $ i , mixed $ value ) : void {
9695 $ this ->children [$ i ] = $ value ;
9796 }
9897
@@ -102,7 +101,7 @@ public function offsetSet($i, $value) : void {
102101 * @param mixed $i The key to be checked
103102 * @return bool Whether the key exists in the config array
104103 */
105- public function offsetExists ($ i ) : bool {
104+ public function offsetExists (mixed $ i ) : bool {
106105 return isset ($ this ->children [$ i ]);
107106 }
108107
@@ -111,7 +110,7 @@ public function offsetExists($i) : bool {
111110 *
112111 * @param mixed $i The key to be removed
113112 */
114- public function offsetUnset ($ i ) : void {
113+ public function offsetUnset (mixed $ i ) : void {
115114 unset($ this ->children [$ i ]);
116115 }
117116
@@ -121,8 +120,7 @@ public function offsetUnset($i) : void {
121120 * @param mixed $i The key to be accessed, can be a string or integer
122121 * @return mixed An HTMLdoc object containing the child node at the requested position or null if there is no child at the requested position
123122 */
124- #[\ReturnTypeWillChange]
125- public function offsetGet ($ i ) { // return reference so you can set it like an array
123+ public function offsetGet (mixed $ i ) : mixed { // return reference so you can set it like an array
126124 if (isset ($ this ->children [$ i ])) {
127125 $ obj = new htmldoc ($ this ->config );
128126 $ obj ->collection ([$ this ->children [$ i ]]);
@@ -136,8 +134,7 @@ public function offsetGet($i) { // return reference so you can set it like an ar
136134 *
137135 * @return mixed An HTMLdoc object containing the child node at the current pointer position or null if there are no children
138136 */
139- #[\ReturnTypeWillChange]
140- public function current () {
137+ public function current () : mixed {
141138 if (isset ($ this ->children [$ this ->pointer ])) {
142139 $ obj = new htmldoc ($ this ->config );
143140 $ obj ->collection ([$ this ->children [$ this ->pointer ]]);
@@ -151,8 +148,7 @@ public function current() {
151148 *
152149 * @return mixed The current pointer position
153150 */
154- #[\ReturnTypeWillChange]
155- public function key () {
151+ public function key () : mixed {
156152 return $ this ->pointer ;
157153 }
158154
@@ -191,7 +187,7 @@ public function valid() : bool {
191187 * @param ?string &$error A reference to any user error that is generated
192188 * @return string|false The loaded HTML, or false on error
193189 */
194- public function open (string $ url , $ context = null , ?string &$ error = null ) {
190+ public function open (string $ url , $ context = null , ?string &$ error = null ) : string | false {
195191
196192 // check resource
197193 if ($ context !== null && !\is_resource ($ context )) {
@@ -295,9 +291,9 @@ protected function isEncodingValid(string $charset) : bool {
295291 * Parses an array of tokens into an HTML document
296292 *
297293 * @param string|htmldoc $html A string of HTML, or an htmldoc object
298- * @return bool| array An array of node objects or false on error
294+ * @return array|false An array of node objects or false on error
299295 */
300- protected function parse ($ html ) {
296+ protected function parse (string | htmldoc $ html ) : array | false {
301297
302298 // convert string to nodes
303299 if (\is_string ($ html )) {
@@ -346,9 +342,9 @@ public function cache(string $key, array $values) : void {
346342 * Retrieves the tag object at the specified index, or all children of type tag
347343 *
348344 * @param int $index The index of the child tag to retrieve
349- * @return mixed A tag object if index is specified, or an array of tag objects, or null if the specified index doesn't exist or the object is empty
345+ * @return tag|array|null A tag object if index is specified, or an array of tag objects, or null if the specified index doesn't exist or the object is empty
350346 */
351- public function get (int $ index = null ) {
347+ public function get (int $ index = null ) : tag | array | null {
352348
353349 // build children that are tags
354350 $ children = [];
@@ -599,7 +595,7 @@ public function html(array $options = []) : string {
599595 * @param string|htmldoc $html A string of HTML, or an htmldoc object
600596 * @return htmldoc The current htmldoc object with the nodes appended
601597 */
602- public function append ($ html ) : htmldoc {
598+ public function append (string | htmldoc $ html ) : htmldoc {
603599 if (($ nodes = $ this ->parse ($ html )) !== false ) {
604600 foreach ($ this ->children AS $ item ) {
605601 if (\get_class ($ item ) === 'hexydec \\html \\tag ' ) {
@@ -616,7 +612,7 @@ public function append($html) : htmldoc {
616612 * @param string|htmldoc $html A string of HTML, or an htmldoc object
617613 * @return htmldoc The current htmldoc object with the nodes appended
618614 */
619- public function prepend ($ html ) : htmldoc {
615+ public function prepend (string | htmldoc $ html ) : htmldoc {
620616 if (($ nodes = $ this ->parse ($ html )) !== false ) {
621617 foreach ($ this ->children AS $ item ) {
622618 if (\get_class ($ item ) === 'hexydec \\html \\tag ' ) {
@@ -633,7 +629,7 @@ public function prepend($html) : htmldoc {
633629 * @param string|htmldoc $html A string of HTML, or an htmldoc object
634630 * @return htmldoc The current htmldoc object with the nodes appended
635631 */
636- public function before ($ html ) : htmldoc {
632+ public function before (string | htmldoc $ html ) : htmldoc {
637633 if (($ nodes = $ this ->parse ($ html )) !== false ) {
638634 foreach ($ this ->children AS $ item ) {
639635 if (\get_class ($ item ) === 'hexydec \\html \\tag ' ) {
@@ -650,7 +646,7 @@ public function before($html) : htmldoc {
650646 * @param string|htmldoc $html A string of HTML, or an htmldoc object
651647 * @return htmldoc The current htmldoc object with the nodes appended
652648 */
653- public function after ($ html ) : htmldoc {
649+ public function after (string | htmldoc $ html ) : htmldoc {
654650 if (($ nodes = $ this ->parse ($ html )) !== false ) {
655651 foreach ($ this ->children AS $ item ) {
656652 if (\get_class ($ item ) === 'hexydec \\html \\tag ' ) {
@@ -664,10 +660,10 @@ public function after($html) : htmldoc {
664660 /**
665661 * Removes all top level nodes, or if $selector is specified, the nodes matched by the selector
666662 *
667- * @param string $selector A CSS selector to refine the nodes to delete or null to delete top level nodes
663+ * @param ? string $selector A CSS selector to refine the nodes to delete or null to delete top level nodes
668664 * @return htmldoc The current htmldoc object with the requested nodes deleted
669665 */
670- public function remove (string $ selector = null ) : htmldoc {
666+ public function remove (? string $ selector = null ) : htmldoc {
671667 $ obj = $ selector ? $ this ->find ($ selector ) : $ this ;
672668 foreach ($ obj ->children AS $ item ) {
673669 if (\get_class ($ item ) === 'hexydec \\html \\tag ' ) {
@@ -682,9 +678,9 @@ public function remove(string $selector = null) : htmldoc {
682678 *
683679 * @param string|null $file The file location to save the document to, or null to just return the compiled code
684680 * @param array $options An array indicating output options, this is merged with htmldoc::$output
685- * @return string|bool The compiled HTML, or false if the file could not be saved
681+ * @return string|false The compiled HTML, or false if the file could not be saved
686682 */
687- public function save (string $ file = null , array $ options = []) {
683+ public function save (? string $ file = null , array $ options = []) : string | false {
688684
689685 // compile html
690686 $ html = $ this ->html ($ options );
0 commit comments