Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread M. W. Moe
Hello, i) was intentional. ii) Not our fault, we do not have this function in our code-base and won't ever; we would not even dare 8). Cheers! On Mon, Apr 8, 2019 at 7:44 AM Dan Ackroyd wrote: > On Mon, 8 Apr 2019 at 04:21, M. W. Moe wrote: > > > > Hello, > > > > looks like you are living

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Pedro Magalhães
On Mon, Apr 8, 2019 at 6:05 AM David Rodrigues wrote: > Current solution: > > $itemsPerPage = Input::get('itemsPerPage') ?: null; > $itemsPerPage = $itemsPerPage !== null ? (int) $itemsPerPage : null; > > $paginator->setItemsPerPage($itemsPerPage); // OK > > With this new feature: just... > >

[PHP-DEV] Re: Optimize zend_string equality check with hash key

2019-04-08 Thread Andrea Faulds
Hi Benjamin, Benjamin Coutu wrote: if (ZSTR_H(s1) && ZSTR_H(s1) != ZSTR_H(s2)) { return 0; } Should that not be like this?: if (ZSTR_H(s1) && ZSTR_H(s2) && ZSTR_H(s1) != ZSTR_H(s2)) { It would be possible the other string also has no hash value. Otherwise this sounds

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Claude Pache
> Le 8 avr. 2019 à 07:05, David Rodrigues a écrit : > > And about "settype($variable, "?int")" it was requested on original mailing > by Claude Pache. PHP has several ways to perform casting: 1. (int) $foo 2. settype($foo, 'int'); 3. intval($foo) They are occasions where the programmer will

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Claude Pache
> Le 8 avr. 2019 à 12:24, Stephen Reay a écrit : > > if your target ’type’ is `?int` and you pass an empty string, wouldn’t you > expect to get `null` rather than `0` ? You should get the same value than you get in: ```php declare(strict_types=0); function foo(?int $x) { return $x;

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Dan Ackroyd
On Mon, 8 Apr 2019 at 06:05, David Rodrigues wrote: > > Question: why just not check if $itemsPerPage is set like: > ... > Answer: because in this example we could do that (although the new solution > is much more practical). Well, I disagree on that. That code is perfectly fine to me, and

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Dan Ackroyd
On Mon, 8 Apr 2019 at 04:21, M. W. Moe wrote: > > Hello, > > looks like you are living in a pig stall; php would be benefit from type > safety when explicitly required. > > Regards. Hi Moe, It seems you: i) accidentally hit reply, instead of reply all. This is an easy mistake to make. ii)

[PHP-DEV] Re: Convert ext/xml to use an object instead of resource

2019-04-08 Thread Nikita Popov
On Thu, Mar 21, 2019 at 3:39 PM Nikita Popov wrote: > On Tue, Feb 12, 2019 at 4:00 PM Nikita Popov wrote: > >> Hi internals, >> >> The ext/xml extension currently has GC issues, see >> https://bugs.php.net/bug.php?id=76874. The tl;dr is that uses of >> xml_parser will usually result in a cyclic

[PHP-DEV] Re: [RFC] Arrow functions / short closures

2019-04-08 Thread Nikita Popov
On Wed, Mar 13, 2019 at 4:56 PM Nikita Popov wrote: > Hi internals, > > Motivated by the recent list comprehensions RFC, I think it's time we took > another look at short closures: > > https://wiki.php.net/rfc/arrow_functions_v2 > > This is based on a previous (withdrawn) proposal by Levi & Bob.

Re: [PHP-DEV] [RFC] Spread Operator in Array Expression v0.2

2019-04-08 Thread Nikita Popov
On Thu, Apr 4, 2019 at 4:15 PM CHU Zhaowei wrote: > Hi internals, > > Thanks for the people who joined the discussion of my [RFC: Spread > Operator in Array Expression]( > https://wiki.php.net/rfc/spread_operator_for_array). The biggest change > is I have dropped the support for string keys in

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Benjamin Morel
> if your target ’type’ is `?int` and you pass an empty string, wouldn’t you expect to get `null` rather than `0` ? I'd personally expect an `Error`, but this is not very much in line with current casting semantics. You have a point here, there is no clear answer for this edge case. Maybe

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Stephen Reay
> On 8 Apr 2019, at 16:35, Benjamin Morel wrote: > >> register_cast_function('?int', 'castToIntOrNull'); > > I would quite oppose such a generic implementation, as it might have > unexpected consequences in other parts of the codebase : it's a global > configuration set at runtime. > > I

Re: [PHP-DEV] PHP 7.4 segfaults

2019-04-08 Thread Matteo Beccati
Hi Nikita, On 08/04/2019 10:36, Nikita Popov wrote: On Wed, Apr 3, 2019 at 2:48 PM Matteo Beccati > wrote: I've identified two different kinds: one in zend_assign_to_variable and the other one during shutdown. Here are the backtraces:

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-08 Thread Benjamin Morel
> register_cast_function('?int', 'castToIntOrNull'); I would quite oppose such a generic implementation, as it might have unexpected consequences in other parts of the codebase : it's a global configuration set at runtime. I quite like the idea of nullable casting though, as I've come across a

Re: [PHP-DEV] PHP 7.4 segfaults

2019-04-08 Thread Nikita Popov
On Wed, Apr 3, 2019 at 2:48 PM Matteo Beccati wrote: > Hi dmitry, internals, > > As I wrote somewhere else, I've finally been able to find time to update > the Bamboo instance I've been using during the past few years to run > daily PHP builds, run their test suites and use them to run test

Re: [PHP-DEV] Allow number_format() have three args

2019-04-08 Thread Nikita Popov
On Mon, Apr 8, 2019 at 9:51 AM David Rodrigues wrote: > Currently number_format() could accept one, two or four args. If three args > is passed then you will receive "wrong parameter count for number_format()" > error (ArgumentCountError). > > It have four parameters: float $number, int

[PHP-DEV] Allow number_format() have three args

2019-04-08 Thread David Rodrigues
Currently number_format() could accept one, two or four args. If three args is passed then you will receive "wrong parameter count for number_format()" error (ArgumentCountError). It have four parameters: float $number, int $decimals, string $dec_point and string $thousands_sep. * If one arg is