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:
- Autoload will only happened when function/method calling. so does any other autoloading,
I mean it wouldn't hurt performance. - 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.
- 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:
- change zend_verify_arg_class_kind to autoload class
- 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
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=220906PROPOSAL(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:
- Autoload will only happened when function/method calling. so does any
other autoloading,
I mean it wouldn't hurt performance.- 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.- If pass the wrong type and the hinted class not found this gives
autoloader a change to handle it
like the #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:
- change zend_verify_arg_class_kind to autoload class
- 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?
Hi:
thanks for writing this, but I was a little confused, please
correct me if I mis-understand you.
if you pass a right instance of class to a function , how can that
class not be loaded already?
for example:
function foo(Foo_Bar $a) {
}
how can you pass a Foo_Bar instance to function foo without
Foo_Bar class already defined?
thanks
Thanks.
Best,reeze | simpie.com
--
Laruence Xinchen Hui
http://www.laruence.com/
Hi, Laruence:
I mean pass a wrong class object to a function/method. if the type
hinted Class didn't loaded, we
could try to load it. (if it's the right class, nothing happened), eg.
function func(NotFoundClass $a) {}
maybe we could pass another class instance.
$a = new DemoClass();
func($a);
It would be useful for class_alias like Bug#61422 requested.
It's a little narrow feature usage scenario,but it gives a way to handle
it. so I think
It might be useful。
if failed to autoload it raise E_CATCHABLE_FATAL, loaded class will simple
released
if user catch the E_CATABLE_FATAL, loaded class will be useful, since it
will be used later.
if loaded success everyone is happy.
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:
- Autoload will only happened when function/method calling. so does any
other autoloading,
I mean it wouldn't hurt performance.- 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.- If pass the wrong type and the hinted class not found this gives
autoloader a change to handle it
like the #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:
- change zend_verify_arg_class_kind to autoload class
- 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?
Hi:
thanks for writing this, but I was a little confused, please
correct me if I mis-understand you.if you pass a right instance of class to a function , how can that
class not be loaded already?for example:
function foo(Foo_Bar $a) {
}how can you pass a Foo_Bar instance to function foo without
Foo_Bar class already defined?thanks
Thanks.
Best,reeze | simpie.com
--
Laruence Xinchen Hui
http://www.laruence.com/
Hi, Laruence:
I mean pass a wrong class object to a function/method. if the type hinted
Class didn't loaded, we
could try to load it. (if it's the right class, nothing happened), eg.function func(NotFoundClass $a) {}
maybe we could pass another class instance.
$a = new DemoClass();
func($a);It would be useful for class_alias like Bug#61422 requested.
Hi:
class_alias does well with type hint now, the following script :
<?php
function b (Foo_Bar $a) {
echo 'okey';
}
class Dummy {
}
class_alias('Dummy', 'Foo_Bar');
b(new Dummy);
?>
works find now(5.3+), output :
"okey"
thanks
It's a little narrow feature usage scenario,but it gives a way to handle it.
so I think
It might be useful。
if failed to autoload it raise E_CATCHABLE_FATAL, loaded class will simple
released
if user catch the E_CATABLE_FATAL, loaded class will be useful, since it
will be used later.
if loaded success everyone is happy.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=220906PROPOSAL(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:
- Autoload will only happened when function/method calling. so does any
other autoloading,
I mean it wouldn't hurt performance.- 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.- If pass the wrong type and the hinted class not found this gives
autoloader a change to handle it
like the #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:
- change zend_verify_arg_class_kind to autoload class
- 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?
Hi:
thanks for writing this, but I was a little confused, please
correct me if I mis-understand you.if you pass a right instance of class to a function , how can that
class not be loaded already?for example:
function foo(Foo_Bar $a) {
}how can you pass a Foo_Bar instance to function foo without
Foo_Bar class already defined?thanks
Thanks.
Best,reeze | simpie.com
--
Laruence Xinchen Hui
http://www.laruence.com/
--
Laruence Xinchen Hui
http://www.laruence.com/
Hi everyone,
if you pass a right instance of class to a function , how can that
class not be loaded already?
for example: function foo(Foo_Bar $a) { } how can you pass a Foo_Bar instance to function foo without
Foo_Bar class already defined?
Because Foo_Bar could be defined under a different name, say,
Foo_Blah. Then, as soon as someone needed Foo_Bar, we would use
class_alias to add an alias. That is, as soon as someone tried using
Foo_Bar it would turn out that Foo_Bar and Foo_Blah are the same class
and all Foo_Blah objects are also Foo_Bar objects and everything is
cool. Therefore foo(new Foo_Blah()) would work (if there was autoload).
Please see the demo I provided at https://bugs.php.net/bug.php?id=61422
Then again, at least it's consistent with instanceof. Where calling
autoload by default is probably indeed unacceptable.
This is complicated.
--
Best regards,
Danko Alexeyev,
VeryPositive
+371 2648 3953
danko@very.lv
Skype: d.alexeyev
Hi!
Because Foo_Bar could be defined under a different name, say,
Foo_Blah. Then, as soon as someone needed Foo_Bar, we would use
class_alias to add an alias. That is, as soon as someone tried using
class_alias is a dirty hack. instanceof implies that the object is an
instance of specific class. If the class is not loaded, no object can be
an instance of it. So no autoloading is necessary.
Foo_Bar it would turn out that Foo_Bar and Foo_Blah are the same class
and all Foo_Blah objects are also Foo_Bar objects and everything is
cool. Therefore foo(new Foo_Blah()) would work (if there was autoload).Please see the demo I provided at https://bugs.php.net/bug.php?id=61422
I do not see how anything good can come out of encouraging stuff like this.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227