Version: v0.7.1 - Beta.  We welcome contributors & feedback.

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

See Also