@@ -268,7 +268,7 @@ public function clear(): void
268268 $ pathPart = 'stubs/ ' . dirname ($ relativeStubPath ) . '/ ' . str_replace ('\\' , '/ ' , $ namespacedName ) . '.php ' ;
269269 $ targetStubPath = __DIR__ . '/../ ' . $ pathPart ;
270270
271- if ($ stmt instanceof Node \Stmt \Class_ || $ stmt instanceof Node \Stmt \Interface_ || $ stmt instanceof Node \Stmt \Trait_) {
271+ if ($ stmt instanceof Node \Stmt \Class_ || $ stmt instanceof Node \Stmt \Interface_ || $ stmt instanceof Node \Stmt \Trait_ || $ stmt instanceof Node \ Stmt \Enum_ ) {
272272 if (array_key_exists (strtolower ($ namespacedName ), $ classes )) {
273273 continue ;
274274 }
@@ -279,6 +279,7 @@ public function clear(): void
279279 continue ;
280280 }
281281 $ functions [strtolower ($ namespacedName )] = $ pathPart ;
282+ $ stmt = $ this ->filterFunctionPhpDocs ($ stmt );
282283 }
283284
284285 $ originalStmt = $ stmt ;
@@ -790,6 +791,44 @@ private function filterClassPhpDocs(Node\Stmt\ClassLike $class): Node\Stmt\Class
790791 return $ class ;
791792 }
792793
794+ private function filterFunctionPhpDocs (Node \Stmt \Function_ $ function ): Node \Stmt \Function_
795+ {
796+ $ namespacedName = $ function ->namespacedName ->toString ();
797+ if (in_array ($ namespacedName , [
798+ 'xml_set_element_handler ' ,
799+ 'xml_set_character_data_handler ' ,
800+ 'xml_set_processing_instruction_handler ' ,
801+ 'xml_set_default_handler ' ,
802+ 'xml_set_unparsed_entity_decl_handler ' ,
803+ 'xml_set_notation_decl_handler ' ,
804+ 'xml_set_external_entity_ref_handler ' ,
805+ 'xml_set_start_namespace_decl_handler ' ,
806+ 'xml_set_end_namespace_decl_handler ' ,
807+ ], true )) {
808+ $ comments = $ function ->getAttribute ('comments ' );
809+ if (null !== $ comments ) {
810+ $ function ->setAttribute ('comments ' , array_map (
811+ fn (Comment \Doc $ doc ): Comment \Doc => new Comment \Doc (
812+ str_replace (
813+ '@param callable $ ' ,
814+ '@param callable|string|null $ ' ,
815+ $ doc ->getText (),
816+ ),
817+ $ doc ->getStartLine (),
818+ $ doc ->getStartFilePos (),
819+ $ doc ->getStartTokenPos (),
820+ $ doc ->getEndLine (),
821+ $ doc ->getEndFilePos (),
822+ $ doc ->getEndTokenPos (),
823+ ),
824+ $ comments
825+ ));
826+ }
827+ }
828+
829+ return $ function ;
830+ }
831+
793832 private function parseDocComment (string $ docComment ): PhpDocNode
794833 {
795834 $ tokens = new TokenIterator ($ this ->phpDocLexer ->tokenize ($ docComment ));
0 commit comments