Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106536 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6131 invoked from network); 11 Aug 2019 06:04:33 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 11 Aug 2019 06:04:33 -0000 To: internals@lists.php.net References: Date: Sun, 11 Aug 2019 04:32:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Posted-By: 94.4.34.143 Subject: Re: Call for participation: Annotating internal function argument andreturn types From: markyr@gmail.com (Mark Randall) Message-ID: 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