@@ -160,18 +160,17 @@ public function detectCharset(Options $options, string $defaultCharset, Abstract
160160 */
161161 private function parseTag (Options $ options , Content $ content , int $ size ): TagDTO
162162 {
163- $ return = [];
164163 if ($ content ->char () != '< ' ) {
165164 // we are not at the beginning of a tag
166- return new TagDTO ();
165+ return TagDTO:: makeFromPrimitives ();
167166 }
168167
169168 // check if this is a closing tag
170169 try {
171170 $ content ->fastForward (1 );
172171 } catch (ContentLengthException $ exception ) {
173172 // we are at the end of the file
174- return new TagDTO ();
173+ return TagDTO:: makeFromPrimitives ();
175174 }
176175 if ($ content ->char () == '/ ' ) {
177176 return $ this ->makeEndTag ($ content , $ options );
@@ -188,7 +187,7 @@ private function parseTag(Options $options, Content $content, int $size): TagDTO
188187 $ tag = \strtolower ($ content ->copyByToken (StringToken::SLASH (), true ));
189188 if (\trim ($ tag ) == '' ) {
190189 // no tag found, invalid < found
191- return new TagDTO ();
190+ return TagDTO:: makeFromPrimitives ();
192191 }
193192 }
194193 $ node = new HtmlNode ($ tag );
@@ -220,10 +219,7 @@ private function parseTag(Options $options, Content $content, int $size): TagDTO
220219 $ content ->fastForward (1 );
221220 }
222221
223- $ return ['status ' ] = true ;
224- $ return ['node ' ] = $ node ;
225-
226- return new TagDTO ($ return );
222+ return TagDTO::makeFromPrimitives (true , false , $ node );
227223 }
228224
229225 /**
@@ -249,7 +245,6 @@ private function detectHTML5Charset(Encode $encode, AbstractNode $root): bool
249245 */
250246 private function makeEndTag (Content $ content , Options $ options ): TagDTO
251247 {
252- $ return = [];
253248 $ tag = $ content ->fastForward (1 )
254249 ->copyByToken (StringToken::SLASH (), true );
255250 // move to end of tag
@@ -259,15 +254,10 @@ private function makeEndTag(Content $content, Options $options): TagDTO
259254 // check if this closing tag counts
260255 $ tag = \strtolower ($ tag );
261256 if (\in_array ($ tag , $ options ->getSelfClosing (), true )) {
262- $ return ['status ' ] = true ;
263-
264- return new TagDTO ($ return );
257+ return TagDTO::makeFromPrimitives (true );
265258 }
266- $ return ['status ' ] = true ;
267- $ return ['closing ' ] = true ;
268- $ return ['tag ' ] = \strtolower ($ tag );
269259
270- return new TagDTO ( $ return );
260+ return TagDTO:: makeFromPrimitives ( true , true , null , \strtolower ( $ tag ) );
271261 }
272262
273263 /**
0 commit comments