Hi,

On 14.10.23 13:54, Niels Dossche wrote:
Hi Tim

On 10/14/23 12:30, Tim Düsterhus wrote:
Hi

On 10/13/23 00:39, Niels Dossche wrote:
Please let me know your thoughts.
What does calling ->registerPHPFunctions() do when it's called more than once? 
Will the existing allow-list be overwritten or amended?

i.e.

$xpath->registerPHPFunctions([
   'strtoupper',
]);
$xpath->registerPHPFunctions([
   'ucfirst',
]);

will I be able to:

(a) Call ucfirst(), but not strtoupper()
(b) Call both
You can call both, it's additive.

As it's not clear what these functions do wouldn't it make more sense to introduce new / more clear functions and deprecate the old?

Like:

->addXPathCallable(string $alias, callable $fn);
->getXPathCallables(): array<string, callable>
->removeXPathCallable(string $alias);

And is it really necessary to be able to register all functions? Also what would happen in this case with functions included later? Would they also be callable or only the functions known at the point of registering?

Best regards
Tim Düsterhus
Cheers
Niels


Best,
Marc

Reply via email to