# 5.4.3 type hint handling

- Thread: https://externals.io/message/60720
- Original archive: https://news-web.php.net/php.internals/60720
- Started by Anatoliy Belsky on 2012-06-01T21:03:18+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #60720 — Anatoliy Belsky — 2012-06-01T21:03:18+00:00

URL: https://externals.io/message/60720#60720

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

---

## #60722 — Felipe Pena — 2012-06-01T22:46:44+00:00

URL: https://externals.io/message/60720#60722 · In reply to: #60720

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 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();
>
>

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

---

## #60724 — Anatoliy Belsky — 2012-06-02T10:41:03+00:00

URL: https://externals.io/message/60720#60724 · In reply to: #60722

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>:
> > […]
>
> 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

---

## #60725 — Hannes Magnusson — 2012-06-02T11:04:49+00:00

URL: https://externals.io/message/60720#60725 · In reply to: #60724

> 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

---

## #60726 — Anatoliy Belsky — 2012-06-02T11:40:05+00:00

URL: https://externals.io/message/60720#60726 · In reply to: #60725

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


> 
> > […]
>
> 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
