Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106526 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 73048 invoked from network); 10 Aug 2019 15:44:26 -0000 Received: from unknown (HELO mail-lj1-f194.google.com) (209.85.208.194) by pb1.pair.com with SMTP; 10 Aug 2019 15:44:26 -0000 Received: by mail-lj1-f194.google.com with SMTP id v24so94700197ljg.13 for ; Sat, 10 Aug 2019 06:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MeTV0RLRxcfl9xEhQgAX6tzAsseI0xkRTDa7n7JLkCo=; b=KMB9NAfuQr/ahm6jFMmQrATSbsyMuRzLk84FxGn9XBFhbb3PZYhdVHLK9AqDdNsR3b eMVJxXgwF3kO97WLzyaVmn0gYHbNP4SZMUO7X3WH0obJqFXJUbIpw/tfDFcBc8d3pFR/ lFDcT97pRy1YaWGrT1ompf3mVghgSIezHls8WTk6pw7pKGSHXPiS6EPCpA8ogBUseQTQ +kg6/bln5X5Uv0TavrlIdO/mNwQwkNzSv5K6VGT0kYQTID1vFQGFGhMM0bJ8Z1m70H6l 10QzxrfVmrmC+FmnyaJa7ssURD1axNJ2YsqrYjeajW6+mbG79zeh4MCwLce4h59V40M+ 4PrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MeTV0RLRxcfl9xEhQgAX6tzAsseI0xkRTDa7n7JLkCo=; b=TTteW8vlh0hsH5kLeb5eKl4fL2XhcHfvlKR2z4dHbLLJoKskNkx1JfwL9lKumJAxKf tNOW1vMZJ9EaUCsjBozVpKjVJBO4Ie8OvNKc9IlpJdm89gwzIa+65JuOxEOTYcjqFOUP ni62qL+QdF2vHCwEw2qZ88TRrwMTU51l9X7A474SBYeiJdXPhkG4gospTRfv+v9eJ7Xj MYVbipqnwjgepzI1roDmk7+FcvloI5N7nttOFpTzKT0fl/HxCtywWEJF9iv87w/T+WjZ 6siRa56NLhu3Dj/p5sODwRenRx3Bl+mZOk8oRsYh/j0mInE9ECw/ZO2+65LDjRdKs02g yQxw== X-Gm-Message-State: APjAAAU8PtjP6uA5uIHZ4tcoiGjYPHNrbXKAii/GU9p5pmgqaEBmSkzb wA2RlWqk+YF90UKcLjzjZVR/NgqELWv6bB2oZtOnVv2dlgy9+A== X-Google-Smtp-Source: APXvYqx+p88BP2MMxaFXJ6l/9lMjI5cSRzD4wQtpxwJtmho369RPKfJquANgqhkKB+MOR6h5usBI9ZjPosbg62FLICo= X-Received: by 2002:a2e:7c15:: with SMTP id x21mr14216965ljc.55.1565442724831; Sat, 10 Aug 2019 06:12:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 10 Aug 2019 15:11:47 +0200 Message-ID: To: Stephen Reay Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000087a746058fc30980" Subject: Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types From: nikita.ppv@gmail.com (Nikita Popov) --00000000000087a746058fc30980 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Aug 10, 2019 at 2:00 PM Stephen Reay wrote: > > > On 10 Aug 2019, at 17:56, Nikita Popov wrote: > > > > Hi, > > > > Lack of type information for internal functions in Reflection is a > > long-standing issue. In PHP 8 we finally have all the necessary technic= al > > groundwork done to support argument and return type annotations on > internal > > functions at scale. > > > > The only thing left is to actually add those type annotations ... to ma= ny > > hundreds of functions. This is something everyone can help with, as it > does > > not need expertise in C. > > > > I've opened a sample PR to show the process: > > https://github.com/php/php-src/pull/4499 > > > > 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). > > > > For example, the first function, set_time_limit is defined in > > > https://github.com/php/php-src/blob/172c71980df0fe4c9d62c3365f0a2cdb139e3= e86/main/main.c#L1501 > . > > We see that it accepts an "l" parameter, which is an int. We see that i= t > > uses RETVAL_TRUE and RETVAL_FALSE, which means the return value is a > bool. > > > > 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". > > > > Any help would be appreciated :) > > > > 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 th= at > the generator script understands? > You can do the same as in the source code: #ifdef HAVE_LDAP_SASL function ldap_sasl_bind(...) {} #endif These conditions will be carried over in the generated code. Nikita --00000000000087a746058fc30980--