On 10/08/2019 11:56, Nikita Popov wrote:
Lack of type information for internal functions in Reflection is a
long-standing issue. In PHP 8 we finally have all the necessary technical
groundwork done to support argument and return type annotations on internal
functions at scale.

Well I tried to put together a very very ugly hack-job of a C tokeniser/parser that could infer types based on a combination of old-style ZPP and macros used to access them (https://github.com/marandall/cpti) but too many hours later I came to the conclusion that to get the job done properly would probably require building out a full C AST parser to be able to handle things like default values.

I did notice a few things in the process of making it (not least that IMO GD needs several hundred things changing to throw UnexpectedValueExceptions).

I noticed that in some cases, the internal constants don't match the userland constants, for example the array functions use PHP_SORT_REGULAR but the userland variants are just SORT_REGULAR. Which one would be used for the stubs? In the example from Nikita the flag names do match (PHP_OUTPUT_HANDLER_STDFLAGS).

I noticed you're documenting them as string|false rather than string|bool. I assume this is something to do with parsing "false" to be an error condition?

Before I re-clone the php-src repo and start editing, I just wanted to check if there had been any consideration to opening up the protocol style to add basic comments?

One thing I did see in the GD library with _php_image_create_from is that ZPP is different depending on logical expressions, rather than pre-processor statements. How should these be handled?

Mark Randall

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to