Bug/Req:#61422顛 enble Type Hint autoloading
| From: | reeze | Date: | Tue, 01 May 2012 12:03:41 +0000 |
| Subject: | Bug/Req:#61422顛 enble Type Hint autoloading | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-60385@lists.php.net to get a copy of this message | ||
Hi internals:
danko reported this bug#61422: Lack of autoload on type hinting breaks class_alias。
now parmeter type hint DID NOT trying to autoload. I think allow it autoloading could be helpful.
BUGS&Commit for quick refer:
- https://bugs.php.net/bug.php?id=61422
- https://bugs.php.net/bug.php?id=39003
- http://svn.php.net/viewvc?view=revision&revision=220906
PROPOSAL(FR):
**I'm asking if we can enable type hint autoloading?**
I did some homework:
- Before FIX for #39003, parameter type hint will try to autoload the hint class if not found.
after this fix it will not. in bug#39003: the final result was DOC Problem, seems we all agreed
that it SHOULD autoloading.
- But in revision: http://svn.php.net/viewvc?view=revision&revision=220906
It was **FIXED**
I try to search RFC about typehint, I didn't find anything about it. It was commited really
long time ago
almost 6 years ago, it would be very nice if Antony Dovgal still remember it;)
REASON:
Here is my reason to ask whether we can enable it:
1. Autoload will only happened when function/method calling. so does any other autoloading,
I mean it wouldn't hurt performance.
2. Class will be used for sure, so trying to autoload it is reasonable:
- If we need check certain Class, then we have to use the class in function/method.
- most of time it already loaded*, so autoloading happened rarely.
3. If pass the wrong type and the hinted class not found this gives autoloader a change to handle
it
like the #61422' (https://bugs.php.net/bug.php?id=61422)s test script did. we can do something
if not found. since we use the class in
function/method, autoload the class is reasonable. most of the time we would not use the *FEATURE*,
but it could make it more flexible.
PATCH:
1. change zend_verify_arg_class_kind to autoload class
2. if class can't load, zend_fetch_class silently return (No fatal here) to give
zend_verify_arg_class_kind a chance
to report previous catchable_fatal_error eg:
Catchable fatal error: Argument 1 passed to func() must be an instance of AX, integer given。
a simple patch attached request for comment.
Finally, What do you guys think about it?
Thanks.
Best,
--
reeze | simpie.com