Bug #72119 [Com]: Interface declaration compatibility regression with default values
[email protected] ("rowan dot collins at gmail dot com")
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=72119&edit=1
ID: 72119
Comment by: rowan dot collins at gmail dot com
Reported by: ben dot davies at gmail dot com
Summary: Interface declaration compatibility regression with
default values
Status: Not a bug
Type: Bug
Package: PHP Language Specification
PHP Version: 7.0.6
Assigned To: levim
Block user comment: N
Private report: N
New Comment:
Given that it has the potential to break existing code, I think it would make more sense to fix it in 7.1, when people will be expecting to check changelogs and update code. Breaking compatibility in a patch release will just lead to people not trusting the official releases, and thus not getting important security fixes, which is in nobody's interest.
Previous Comments:
------------------------------------------------------------------------
[2016-04-28 16:42:51] [email protected]
Correct; it should never have worked in the first place though;
While it technically is a BC break, I personally think this was in the first place an important (long-term) bugfix. [which thus shouldn't be reverted in 7.0.7]
------------------------------------------------------------------------
[2016-04-28 16:34:14] [email protected]
The original problem was introduced by attempt to fix #71428 (that expects exactly the opposite behavior) in commit ee9a78a033696ff9546fb1dbfecd28f20477b511
------------------------------------------------------------------------
[2016-04-28 15:26:30] ben dot davies at gmail dot com
Hi both,
No doubt you are both correct, but this appears to be a BC break.
This works in every version of php up to 7.0.6.
https://3v4l.org/VhEtd
Thanks
------------------------------------------------------------------------
[2016-04-28 15:23:48] [email protected]
I have confirmed that this is not a bug. The reason is that in the interface you are permitted to pass null:
<?php
$Foo->bar(null);
?>
However, in the implementing class Hello it would not be permitted. Everything permitted in the parent must also be permitted in the child, thus it is not a bug.
------------------------------------------------------------------------
[2016-04-28 15:22:29] [email protected]
This is not a bug; your code is a LSP violation which had been fixed in bug #71428.
In the concrete example, the Foo::bar() function can be passed null, but Hello::bar() cannot.
[This is something we try to fix with nullable parameters/null unions in 7.1.]
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=72119
--
Edit this bug report at https://bugs.php.net/bug.php?id=72119&edit=1