Welcome! Log In Create A New Profile


[PHP-DEV] Re: Change in type-hint representation

Posted by Dmitry Stogov 
Dmitry Stogov
[PHP-DEV] Re: Change in type-hint representation
January 12, 2017 09:10AM
On Jan 11, 2017 11:46 PM, Nikita Popov <[email protected]> wrote:
On Wed, Jan 11, 2017 at 1:07 PM, Dmitry Stogov <[email protected]<mailto:[email protected]>> wrote:


I propose to introduce a unified type representation (zend_type).

Now it's going to be used for typing of arguments and return values.

Later we should use it for properties and other things.


The main changes are in zend_types.h and zend_compile.h, the rest is just an adoption for new type representation.

I don't think we need RFC, because this is just an internal change that doesn't change behavior.

I got the idea working on typed properties together with Bob and Joe.


I think it would be better to introduce zend_type and then continue work on typed properties.

Any comments?

Thanks. Dmitry.

I like this. Two questions:

1. Can you please clarify what ZEND_TYPE_ENCODE_CLASS_CONST_* is for? Why does this not use the usual encoding for allow_null? Does the compiler not allow casts in initializers or something?

They are used for constant initializers. Compiler doesn't allow operations with addresses of constant strings, because they are assigned only by ld.

2. Is the use of zend_strings in arginfo of internal functions zts safe? I.e. does the function registration happen per-thread or do we reuse registered functions across threads? If that's the case we might run into issues with non-atomic RCs.

Good point. I'll check this.

Thanks. Dmitry.

Sorry, only registered users may post in this forum.

Click here to login