You can 1. return a object with 'attribute' and 'hasAttribute' functions and use it like $my_object.call_function, 'call_function' will be first parameter of (has)attribute or 2. create another function that takes this object as parameter and executes it from php.