Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-12 Thread Dik Takken
Hi,

I'd be happy to donate some time to this effort as well. If you just
assign me a file or directory (not too much at once please) I can create
a PR that covers that part of the code base.

Would that work for you?

Regards,
Dik

On 10-08-19 12: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 technical
> 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 many
> 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/172c71980df0fe4c9d62c3365f0a2cdb139e3e86/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.
> 
> 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
> 

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



Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-10 Thread Nikita Popov
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 technical
> > 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 many
> > 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/172c71980df0fe4c9d62c3365f0a2cdb139e3e86/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.
> >
> > 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’d 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?
>

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


Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-10 Thread Benjamin Morel
Hi,

Sorry if I’m missing something, but can’t the process be automated?

i.e. parse the C source files with a script to generate the stubs? If correctly 
done, this could be much less error-prone than manual handling.

Benjamin 

> Le 10 août 2019 à 14:00, Stephen Reay  a écrit :
> 

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



Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-10 Thread Stephen Reay


> 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 technical
> 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 many
> 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/172c71980df0fe4c9d62c3365f0a2cdb139e3e86/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.
> 
> 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’d 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? 


Cheers

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



Re: [PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-10 Thread Craig Duncan
I'm happy to help.

Am I correct in thinking that the best way to locate outstanding ones is to
to search for any instances of *ZEND_BEGIN_ARG_INFO* or
*ZEND_BEGIN_ARG_INFO_EX*
in *.c files?
As once they've been converted they'll only appear in stub and header files?


[PHP-DEV] Call for participation: Annotating internal function argument and return types

2019-08-10 Thread Nikita Popov
Hi,

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.

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.

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/172c71980df0fe4c9d62c3365f0a2cdb139e3e86/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.

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