Re: [PHP-DEV] Ensure correct signatures for PHP magic methods

2020-01-05 Thread G. P. B.
On Sun, 5 Jan 2020 at 18:44, Gabriel Caruso wrote: > Hello Internals, > > I have a PR proposing to start checking the signatures for PHP magic > methods in the next major version of PHP: > https://github.com/php/php-src/pull/4177. The idea for this PR came from > https://bugs.php.net/bug.php?id=6

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread tyson andre
I have a work in progress wrapper for allowing const-like syntax for global constants `static const X = $dynamicExpression;`. This can be seen in https://github.com/TysonAndre/php-src/pull/10 This is basically a wrapper around if (!defined(...)) { define(...); } If anyone's planning to implement c

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Mike Schinkel
> On Jan 5, 2020, at 3:17 PM, Rowan Tommins wrote: > > They seem a poor example of something that you would later want to "evolve" > using the proposed new feature. An enum is, by definition, a set of values > that covers all possibilities, often with completely arbitrary values. Yet you calle

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Rowan Tommins
On 05/01/2020 19:08, Mike Schinkel wrote: How are enums a terrible example? They are exactly my use-case. PHP does not have declared enums, so class constants suffice. They seem a poor example of something that you would later want to "evolve" using the proposed new feature. An enum is, by de

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Mike Schinkel
Another use-case that just occurred to me is to support testing: class Api { const URL: string{ return $_ENV['EXAMPLE_API_URL'] ?? 'https://api.example.com'; } } -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Mike Schinkel
> On Jan 5, 2020, at 1:24 PM, Rowan Tommins wrote: > >> class Environments { >>const PRODUCTION = 'master'; >>const STAGING = 'stage'; >>const TESTING = 'test'; >>const DEVELOPMENT = 'dev'; >> } How are enums a terrible example? They are exactly my use-case. PHP does not have de

Re: [PHP-DEV] Autoloading functions/consts without a performance impact

2020-01-05 Thread Rowan Tommins
On 05/01/2020 18:03, tyson andre wrote: Yes, I'm saying that the autoloader should be called for each lookup, so autoloading of Foo\strlen should come between checking if Foo\strlen is defined, and checking if \strlen is defined. That would be the intuitive approach for a language, but as mentio

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Mike Schinkel
> On Jan 5, 2020, at 12:02 PM, Larry Garfield wrote: > > I am saying that the behavior of a constant is that it is... constant. A > proper constant is evaluated at compile time and appears as a literal in the > final runtime code, with no dereferencing. AIUI, `const` in PHP does exactly > th

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Rowan Tommins
On 04/01/2020 22:40, Mike Schinkel wrote: Add in the "initialise on first read", and you end up with 4 lines per pseudo-constant vs 5 per method: But then you give an example which exaggerates in the other direction. No, I gave an example of exactly what it would like if I wrote it: one lin

Re: [PHP-DEV] Autoloading functions/consts without a performance impact

2020-01-05 Thread tyson andre
> Yes, I'm saying that the autoloader should be called for each lookup, so > autoloading of Foo\strlen should come between checking if Foo\strlen is > defined, and checking if \strlen is defined. That would be the intuitive approach for a language, but as mentioned earlier, it would significantly

[PHP-DEV] Ensure correct signatures for PHP magic methods

2020-01-05 Thread Gabriel Caruso
Hello Internals, I have a PR proposing to start checking the signatures for PHP magic methods in the next major version of PHP: https://github.com/php/php-src/pull/4177. The idea for this PR came from https://bugs.php.net/bug.php?id=69718. I'd like to hear your opinion before putting more effort

Re: [PHP-DEV] Initializing constants once, with code?

2020-01-05 Thread Larry Garfield
On Sat, Jan 4, 2020, at 3:25 PM, Mike Schinkel wrote: > > On Jan 3, 2020, at 2:52 PM, Larry Garfield wrote: > > > > There's two broad reasons I think this is a bad idea. > > > > 1) Constants are one thing. Function calls are another. They serve > > different purposes. Trying to mutate them i

[PHP-DEV] SSL stream context 'local_pk' issue?

2020-01-05 Thread Kosit Supanyo
Hi Internals First of all, Happy new year! I've found that everytime `stream_socket_accept()` accepts a SSL/TLS connection, it always read 'local_cert' and 'local_pk' files despite being read and verified before by `stream_socket_server()`. There's no problem with 'local_cert' but 'local_pk' beca