Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106524 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60890 invoked from network); 10 Aug 2019 14:33:17 -0000 Received: from unknown (HELO mail1.25mail.st) (206.123.115.54) by pb1.pair.com with SMTP; 10 Aug 2019 14:33:17 -0000 Received: from [10.0.1.86] (unknown [49.48.242.203]) by mail1.25mail.st (Postfix) with ESMTPSA id 17104604C3; Sat, 10 Aug 2019 12:00:49 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Sat, 10 Aug 2019 19:00:45 +0700 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Nikita Popov X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types From: php-lists@koalephant.com (Stephen Reay) > On 10 Aug 2019, at 17:56, Nikita Popov wrote: >=20 > Hi, >=20 > 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. >=20 > The only thing left is to actually add those type annotations ... to = many > hundreds of functions. This is something everyone can help with, as it = does > not need expertise in C. >=20 > I've opened a sample PR to show the process: > https://github.com/php/php-src/pull/4499 >=20 > Here, we take some existing arginfo structures in basic_functions.c = and > convert them into stubs in basic_functions.stub.php. We can take the > argument names from the existing arginfo. To figure out the types, we = need > to look at the implementation (the php.net documentation tends to lie = about > details). >=20 > For example, the first function, set_time_limit is defined in > = https://github.com/php/php-src/blob/172c71980df0fe4c9d62c3365f0a2cdb139e3e= 86/main/main.c#L1501. > We see that it accepts an "l" parameter, which is an int. We see that = it > uses RETVAL_TRUE and RETVAL_FALSE, which means the return value is a = bool. >=20 > Once this is done, we need to auto-generate new arginfo data. If you = have a > development setup, this is done automatically when running "make". > Otherwise, it's possible to manually run "php scripts/dev/gen_stub.php > ext/standard/basic_functions.stub.php". >=20 > Any help would be appreciated :) >=20 > Regards, > Nikita I=E2=80=99d like to help if I can. Some extensions have what appear to be conditional arginfo (for example = the LDAP extension, which I *assume* is to handle building against = different versions of underlying ldap library that support different = features) - is there a way / need to handle those in this stub format = that the generator script understands?=20 Cheers Stephen=