I have discovered through a bug report a case where having explicitly nullable parameters would be of value.
<?php
interface Foo {
public function bar(array $baz = null);
}
class Hello implements Foo {
public function bar(array $baz = array()) {}
}
?>
You can theoretically change the default value in a sub-type, but in this case moving away from the default value of null breaks because the subtype no longer permits null. It is important to realize that we previously allowed this behavior since PHP 5.1 but was fixed in 7.0.6.
If instead we had nullable types separately from default values of null this could change to:
<?php
class Hello implements Foo {
public function bar(array | null $baz = []) {}
}
?>
(or a short-form ?array $baz = [] if short-form passes)
This preserves the ability to be null but changes the default value. Of course, there may be other code changes necessary to future-proof their code but there current code would now work without having to rewrite any method bodies (just signatures).
In light of this I kindly request that RFCs that add nullable types for only return values be withdrawn. So that Union Types and [Nullable Types][3] can go forward unhindered.
Hi,
The BC break in PHP-7.0 was introduced by commit ee9a78a033696ff9546fb1dbfecd28f20477b511
Author: Joe Watkins krakjoe@php.net
Date: Mon Mar 28 11:54:25 2016 +0100
Late, there were few more commits that changed and moved the problematic code.
Anatol, I think we should revert this before 7.0.6 release.
Thanks. Dmitry.
Quoted text · 31 lines
Am 28.04.2016 um 18:28 schrieb Dmitry Stogov dmitry@zend.com:
Hi,
The BC break in PHP-7.0 was introduced by commit ee9a78a033696ff9546fb1dbfecd28f20477b511
Author: Joe Watkins krakjoe@php.net
Date: Mon Mar 28 11:54:25 2016 +0100Late, there were few more commits that changed and moved the problematic code.
Anatol, I think we should revert this before 7.0.6 release.
Thanks. Dmitry.
From: morrison.levi@gmail.com morrison.levi@gmail.com on behalf of Levi Morrison levim@php.net Sent: Thursday, April 28, 2016 18:40
To: internals
Cc: Dmitry Stogov; Tom Worster
Subject: Request to withdraw RFC's for nullable types for only return valuesI have discovered through a bug report a case where having explicitly nullable parameters would be of value.
<?php
interface Foo {
public function bar(array $baz = null);
}class Hello implements Foo {
public function bar(array $baz = array()) {}
}?>
You can theoretically change the default value in a sub-type, but in this case moving away from the default value of null breaks because the subtype no longer permits null. It is important to realize that we previously allowed this behavior since PHP 5.1 but was fixed in 7.0.6.
If instead we had nullable types separately from default values of null this could change to:
<?php
class Hello implements Foo {
public function bar(array | null $baz = []) {}
}?>
(or a short-form
?array $baz = []if short-form passes)This preserves the ability to be null but changes the default value. Of course, there may be other code changes necessary to future-proof their code but there current code would now work without having to rewrite any method bodies (just signatures).
In light of this I kindly request that RFCs that add nullable types for only return values be withdrawn. So that Union Types and [Nullable Types][3] can go forward unhindered.
Hey Dmitry,
thanks for reverting… but
I've seen you had merged just straight up? I assume this was unintentional (as it should definitely remain fixed in 7.1). Thus I've reverted your changes in master (only) and added an appropriate NEWS entry there.
Thanks,
Bob
The problem is as Levi explained though Bob, don't we actually require nullables/unions for that case ?
Maybe we can move forward now, confident that by the time 7.1 is released we will have one of those things ?
The problems with that are, the RFC's for unions/intersections don't match the implementation, and none of us have a good idea how to implement the RFCs.
In addition, nobody can agree which nullable types RFC should go to vote, or how the whole nullable type question should be resolved.
Cheers
Joe
Quoted text · 38 lines
Am 28.04.2016 um 18:28 schrieb Dmitry Stogov dmitry@zend.com:
Hi,
The BC break in PHP-7.0 was introduced by commit ee9a78a033696ff9546fb1dbfecd28f20477b511
Author: Joe Watkins krakjoe@php.net
Date: Mon Mar 28 11:54:25 2016 +0100Late, there were few more commits that changed and moved the problematic code.
Anatol, I think we should revert this before 7.0.6 release.
Thanks. Dmitry.
From: morrison.levi@gmail.com morrison.levi@gmail.com on behalf of Levi Morrison levim@php.net
Sent: Thursday, April 28, 2016 18:40
To: internals
Cc: Dmitry Stogov; Tom Worster
Subject: Request to withdraw RFC's for nullable types for only return valuesI have discovered through a bug report a case where having explicitly nullable parameters would be of value.
<?php
interface Foo {
public function bar(array $baz = null);
}class Hello implements Foo {
public function bar(array $baz = array()) {}
}?>
You can theoretically change the default value in a sub-type, but in this case moving away from the default value of null breaks because the subtype no longer permits null. It is important to realize that we previously allowed this behavior since PHP 5.1 but was fixed in 7.0.6.
If instead we had nullable types separately from default values of null this could change to:
<?php
class Hello implements Foo {
public function bar(array | null $baz = []) {}
}?>
(or a short-form
?array $baz = []if short-form passes)This preserves the ability to be null but changes the default value. Of course, there may be other code changes necessary to future-proof their code but there current code would now work without having to rewrite any method bodies (just signatures).
In light of this I kindly request that RFCs that add nullable types for only return values be withdrawn. So that Union Types and [Nullable Types][3] can go forward unhindered.
Hey Dmitry,
thanks for reverting… but
I've seen you had merged just straight up? I assume this was unintentional (as it should definitely remain fixed in 7.1).
Thus I've reverted your changes in master (only) and added an appropriate NEWS entry there.Thanks,
Bob
Thanks for catching the BC break.
Fortunately, we didn't release 7.0.6 with this problem.
I see some sense in introducing that check, but changing behaviour requires RFC and definitely not allowed in minor versions.
I'm not going to withdraw https://wiki.php.net/rfc/nullable_return_types It doesn't prohibit usage of nullable for arguments, and even sets additional question.
Thanks. Dmitry.
Evening Dmitry,
This was discussed at length with bob, and I think nikita also, it seemed like a bug fix rather than a feature.
Happy for it to be moved into 7.1 ... sorry for dropping the ball there ...
Cheers
Joe
Quoted text · 28 lines
Thanks for catching the BC break.
Fortunately, we didn't release 7.0.6 with this problem.I see some sense in introducing that check, but changing behaviour requires RFC and definitely not allowed in minor versions.
I'm not going to withdraw https://wiki.php.net/rfc/nullable_return_types It doesn't prohibit usage of nullable for arguments, and even sets additional question.
Thanks. Dmitry.
From: morrison.levi@gmail.com morrison.levi@gmail.com on behalf of Levi Morrison levim@php.net
Sent: Thursday, April 28, 2016 6:40:59 PM To: internals
Cc: Dmitry Stogov; Tom Worster
Subject: Request to withdraw RFC's for nullable types for only return valuesI have discovered through a bug report a case where having explicitly nullable parameters would be of value.
<?php
interface Foo {
public function bar(array $baz = null);
}class Hello implements Foo {
public function bar(array $baz = array()) {}
}?>
You can theoretically change the default value in a sub-type, but in this case moving away from the default value of null breaks because the subtype no longer permits null. It is important to realize that we previously allowed this behavior since PHP 5.1 but was fixed in 7.0.6.
If instead we had nullable types separately from default values of null this could change to:
<?php
class Hello implements Foo {
public function bar(array | null $baz = []) {}
}?>
(or a short-form
?array $baz = []if short-form passes)This preserves the ability to be null but changes the default value. Of course, there may be other code changes necessary to future-proof their code but there current code would now work without having to rewrite any method bodies (just signatures).
In light of this I kindly request that RFCs that add nullable types for only return values be withdrawn. So that Union Types and [Nullable Types][3] can go forward unhindered.
Quoted text · 4 lines
Thanks for catching the BC break.
Fortunately, we didn't release 7.0.6 with this problem.I see some sense in introducing that check, but changing behaviour requires RFC and definitely not allowed in minor versions.
I'm not going to withdraw https://wiki.php.net/rfc/nullable_return_types It doesn't prohibit usage of nullable for arguments, and even sets additional question.
In that case: are you fine with my RFCs going to vote first (and soon)? We presently have four somewhat competing RFCs and need to work out voting order.
Tom: are you willing to withdraw or wait for my RFCs to vote first?