Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR]
| From: | Zeev Suraski | Date: | Tue, 01 Apr 2003 07:37:16 +0000 |
| Subject: | Re: Re: Type hints revisited [IllegalArgumentException instead of E_ERROR] | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-564@lists.php.net to get a copy of this message | ||
At 16:32 31/03/2003, Wez Furlong wrote:
Yes, but when using call_user_function, __call(), and RPC servers, you don't always know what function you are calling at the time you write the script.I'd argue that it makes sense that the function in that case will not use type hints, then, and use instanceof based checking if necessary. Feeding a function with certain restrictions to an API that may feed it anything is a bad programming practice, IMHO. You should only be sending such functions based on the knowledge that the caller will be calling them with a certain convention. E.g., if the caller expects them to belong to a certain interface or class.
Thats where is_callable()/function_exists() are extremely useful.I think that we may need some sort of a method_implements_interface() callback to make this set of tools complete. Zeev