php / doc-en

English PHP documentation
500 stars 729 forks source link

Contradiction in xml_set_default_handler() docs #1391

Open php4fan opened 2 years ago

php4fan commented 2 years ago

From manual page: https://php.net/function.xml-set-default-handler

It says:

Description xml_set_default_handler(XMLParser $parser, callable $handler): bool

Ok so $handler is a callable. We all know what a callable is: either a string which is the name of a function, an [$object, 'methodName'] pair, or an anonymous function definition.

But then it says:

handler handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

Wait, so must it be a string? Or is this just a leftover from an older version when callables didn't exist and it actually had to be a string with a function name?

damianwadley commented 2 years ago

Looks like a leftover: I don't see it requiring a string, just a generic array/object/stringable value.

But I do see that it accepts any array/object/stringable value for that handler, meaning it hasn't switched to more modern support that only allows valid callbacks. https://3v4l.org/0kBnZ

cmb69 commented 2 years ago

Yeah, that code could need some TLC.

Girgias commented 2 years ago

I'm going to look into the C code to improve it and will handle the docs at the same time.

nielsdos commented 1 year ago

Similarly, xml_set_element_handler etc say stuff like "The function named by start_handler", which is also slightly inaccurate.