Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-25 Thread Stanislav Malyshev
Hi! > Scalar types declarations were introduced in PHP 7.0 but it was not > possible to pass null as a default value to function/method. It was > finally done by a small workaround described in documentation as "The > declaration can be made to accept NULL values if the default value of > the para

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-25 Thread Niklas Keller
2017-02-25 16:12 GMT+01:00 Andrea Faulds : > Hi, > > Rowan Collins wrote: > >> On 23 February 2017 09:15:27 GMT+00:00, "Michał" wrote: >> >>> And what about situation when someone is forcing >>> declare(strict_types=1)? I think, it's really a good place to force >>> proper types. Including nulls.

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-25 Thread Andrea Faulds
Hi, Rowan Collins wrote: On 23 February 2017 09:15:27 GMT+00:00, "Michał" wrote: And what about situation when someone is forcing declare(strict_types=1)? I think, it's really a good place to force proper types. Including nulls. strict_types controls the behaviour of *calling* functions, but

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-23 Thread Levi Morrison
On Wed, Feb 22, 2017 at 2:18 PM, Michał wrote: > a(string $test=null) // incorrect type, should throw error > > There is no reason, except of backwards compatibility, to keep this > behaviour. It's too late to change this in 7.1, maybe even in 7.2. But, what > is Your opinion? Should it be preserv

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-23 Thread Rowan Collins
On 23 February 2017 09:15:27 GMT+00:00, "Michał" wrote: >And what about situation when someone is forcing >declare(strict_types=1)? I think, it's really a good place to force >proper types. Including nulls. strict_types controls the behaviour of *calling* functions, but the check here would ha

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-23 Thread Michał
Indeed, it's far too early to think about forcing people to change all their code to the ? notation. I'm also not convinced of the value even once that's established; it's not like "Foo $foo = null" can ever mean *something different* from "?Foo $foo = null", it would just be an error. Maybe i

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-23 Thread Rowan Collins
On 23 February 2017 07:23:02 GMT+00:00, Andrey Andreev wrote: >Hi, > >On Wed, Feb 22, 2017 at 11:18 PM, Michał wrote: > >> "The >declaration >> can be made to accept NULL values if the default value of the >parameter is >> set to NULL". > >This isn't just a PHP 7 work-around for null types, it ha

Re: [PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-22 Thread Andrey Andreev
Hi, On Wed, Feb 22, 2017 at 11:18 PM, Michał wrote: > Hello PHP internals, > Scalar types declarations were introduced in PHP 7.0 but it was not > possible to pass null as a default value to function/method. It was finally > done by a small workaround described in documentation as "The declarati

[PHP-DEV] Nullable types and strict type-hinting with default null value

2017-02-22 Thread Michał
Hello PHP internals, Scalar types declarations were introduced in PHP 7.0 but it was not possible to pass null as a default value to function/method. It was finally done by a small workaround described in documentation as "The declaration can be made to accept NULL values if the default value o