Hi,
I'm experiencing an issue adding type hints to the function prototypes.
The following definition gives the "unknown typehint" error when invoking
a function
ZEND_BEGIN_ARG_INFO_EX(arg_info_trader_adosc, 0, 0, 4)
ZEND_ARG_TYPE_INFO(0, high, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, low, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, close, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, volume, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, fastPeriod, IS_LONG, 1)
ZEND_ARG_TYPE_INFO(0, slowPeriod, IS_LONG, 1)
ZEND_END_ARG_INFO();
The reason I trip up on this is to generate the xml doc proto for the
extension. Therefore I'm using the extended ZEND_ARG_INFO version. Without
type hints there are no param types in the xml.
Quickly looking at the sources I realize that 5.4.3 has an explicit type
hint check which was previously ignored in 5.3
http://lxr.php.net/opengrok/xref/PHP_5_4/Zend/zend_execute.c#600
The reason of writing this is not to start a new discussion about scalar
types, for God's sake not :), but just to point at the collision with the
current core and doc generator. A simple way to fix this would be to
restore the old 5.3 behaviour just passing on scalar types. Or may be
there were a simple solution for this, despite 5.4.3 is already issued?
Cheers
Anatoliy
Hi,
2012/6/1 Anatoliy Belsky ab@php.net:
Hi,
I'm experiencing an issue adding type hints to the function prototypes.
The following definition gives the "unknown typehint" error when invoking
a functionZEND_BEGIN_ARG_INFO_EX(arg_info_trader_adosc, 0, 0, 4)
ZEND_ARG_TYPE_INFO(0, high, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, low, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, close, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, volume, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, fastPeriod, IS_LONG, 1)
ZEND_ARG_TYPE_INFO(0, slowPeriod, IS_LONG, 1)
ZEND_END_ARG_INFO();
We do not use ZEND_ARG_TYPE_INFO() with scalar types that are not
covered with the type hint supports. (i.e. string, integer, double,
resource)
--
Regards,
Felipe Pena
Hi Felipe,
that's ok but doesn't answer the question with the doc generator :) .
Another issue with this were "php --re" where people would want to look at
the param list. imho it looks more consistent in 5.3 .
Cheers
Anatoliy
Hi,
2012/6/1 Anatoliy Belsky ab@php.net:
Hi,
I'm experiencing an issue adding type hints to the function prototypes.
The following definition gives the "unknown typehint" error when
invoking
a functionZEND_BEGIN_ARG_INFO_EX(arg_info_trader_adosc, 0, 0, 4)
ZEND_ARG_TYPE_INFO(0, high, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, low, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, close, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, volume, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, fastPeriod, IS_LONG, 1)
ZEND_ARG_TYPE_INFO(0, slowPeriod, IS_LONG, 1)
ZEND_END_ARG_INFO();We do not use ZEND_ARG_TYPE_INFO() with scalar types that are not
covered with the type hint supports. (i.e. string, integer, double,
resource)--
Regards,
Felipe Pena
Hi Felipe,
that's ok but doesn't answer the question with the doc generator :) .
Another issue with this were "php --re" where people would want to look at
the param list. imho it looks more consistent in 5.3 .
The doc generator only supports array and class typehints.
Everything else will default to "mixed" (IIRC) and you'll need to edit
the template afterwards.
These typehints you are trying to use, if allowed, would actually
reject "10" for IS_LONG before the function would ever be executed. I
highly doubt that is what you want.
-Hannes
Hi Hannes,
ah, now i see. The generator has worked on 5.3 with the erroneous type
hints. But all that IS_LONG turned into "<type>array</type>". And on 5.4
as i've mentioned previously, it gives "unknown typehint" when invoking
the corresponding function. No way around to edit the doc templates
manually though :) .
imho a module shouldn't be allowed to compile when known scalar types are
defined in the arg info. Just to avoid confusion.
Thanks for clearing this guys.
Regards
Anatoliy
Hi Felipe,
that's ok but doesn't answer the question with the doc generator :) .
Another issue with this were "php --re" where people would want to look
at
the param list. imho it looks more consistent in 5.3 .The doc generator only supports array and class typehints.
Everything else will default to "mixed" (IIRC) and you'll need to edit
the template afterwards.These typehints you are trying to use, if allowed, would actually
reject "10" for IS_LONG before the function would ever be executed. I
highly doubt that is what you want.-Hannes