ObjectHooks.onCallMissingMethod
onCallMissingMethod($method, $arguments = []) -> any
Description
Add this method to your class to handle calling to methods that are not publicly defined.
Return Result.ok($value)
if the call was successful. Otherwise, return Result.fail()
, to trigger an error.
class MyClass { fn zDynamicCall($methodName, $args) { if $methodName == 'getSecretNumber' { return Result.ok(42) } return Result.fail() } } $object = MyClass() $object.getSecretNumber() //= 42