Corveda / PHPSandbox

A PHP-based sandboxing library with a full suite of configuration and validation options.
https://phpsandbox.org
Other
220 stars 46 forks source link

defineFunc mangles callables #28

Open edhaase opened 1 year ago

edhaase commented 1 year ago

https://github.com/Corveda/PHPSandbox/blob/main/src/PHPSandbox.php#L2670

If you attempt to pass a non-static method callable in, for instance: [$instance, 'methodName'] it passes the callable typehint, then gets nuked by whatever that condition block is all about, and then throws an exception about being uncallable. Why?

And attempting to pass a nested array does not pass the callable typehint. I can workaround this by passing a closure to perform the same work, but this is still an issue.

In theory this would also break static class method calls in array syntax as well, possibly leading to bizarre or even dangerous behavior if the class name is still callable or invokable.

If instance methods are unsupported or otherwise should not be used, they should be checked for properly. Please do not mangle my callable.