Skip to content

Commit b8b44fe

Browse files
committed
Merge branch 'master' of github.com:hexydec/htmldoc
2 parents 9fddf12 + c2dac69 commit b8b44fe

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/htmldoc.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,29 @@ public function offsetUnset($i) : void {
118118
* Retrieves a value from the configuration array with the specified key
119119
*
120120
* @param string|integer $i The key to be accessed, can be a string or integer
121-
* @return mixed The requested value or null if the key doesn't exist
121+
* @return htmldoc|null The child node at the requested position or null if there is no child at the requested position
122122
*/
123-
public function offsetGet(mixed $i) : mixed { // return reference so you can set it like an array
124-
return $this->children[$i] ?? null;
123+
public function offsetGet(mixed $i) : ?htmldoc { // return reference so you can set it like an array
124+
if (isset($this->children[$i])) {
125+
$obj = new htmldoc($this->config);
126+
$obj->collection([$this->children[$i]]);
127+
return $obj;
128+
}
129+
return null;
125130
}
126131

127132
/**
128133
* Retrieve the document node in the current position
129134
*
130-
* @return tag|text|comment|doctype|null The child node at the current pointer position or null if there are no children
135+
* @return htmldoc|null The child node at the current pointer position or null if there are no children
131136
*/
132-
public function current() : mixed {
133-
return $this->children[$this->pointer] ?? null;
137+
public function current() : ?htmldoc {
138+
if (isset($this->children[$this->pointer])) {
139+
$obj = new htmldoc($this->config);
140+
$obj->collection([$this->children[$this->pointer]]);
141+
return $obj;
142+
}
143+
return null;
134144
}
135145

136146
/**

0 commit comments

Comments
 (0)