Doc #75449 [Asn->Csd]: Ignored return type for abstract methods, defined in traits
Edit report at https://bugs.php.net/bug.php?id=75449&edit=1
ID: 75449
Updated by: cmb@php.net
Reported by: alex dot rill at yandex dot ru
Summary: Ignored return type for abstract methods, defined in
traits
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Class/Object related
Operating System: Windows
PHP Version: 7.1.11
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
Previous Comments:
------------------------------------------------------------------------
[2018-11-28 12:41:44] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=346114
Log: Fix #75449: Ignored return type for abstract methods, defined in traits
------------------------------------------------------------------------
[2018-11-28 12:20:48] cmb@php.net
There has been some discussion about this on the internals@
mailing list[1], and it seem to me that Levi[2] is right.
Therefore I'm changing this to a documentation problem.
[1] <https://externals.io/message/103032>
[2] <https://externals.io/message/103032#103039>
------------------------------------------------------------------------
[2018-04-29 21:25:02] eric at ericstern dot com
I encountered this as well (discovered this report when filing my own bug, so I'm commenting
here rather than filing a dupe). Note that this is in no way specific to static methods.
A similar reproduce case: https://3v4l.org/AVSXN
And more importantly, a test case where the issue that should have been detected at compile-time
instead was left until runtime: https://3v4l.org/02d4a This is
the main use-case of abstract trait methods.
------------------------------------------------------------------------
[2017-11-22 23:28:08] pmmaga@php.net
Actually, after re-reading the page on traits, the usage of abstract methods for this purpose is
mentioned:
> Traits support the use of abstract methods in order to impose requirements upon the exhibiting
> class.
Given that, I am re-opening this bug.
------------------------------------------------------------------------
[2017-11-21 23:17:46] pmmaga@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected behavior. In your first example, the abstract function from the trait is overriden
by the function declared on your class. No inheritance rules are applied at all. It's not only
about the return value type.
In your second example, you are importing the abstract function to an abstract class. In that case,
the inheritance rules are applied when you are extending from that abstract class.
------------------------------------------------------------------------
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=75449
--
Edit this bug report at https://bugs.php.net/bug.php?id=75449&edit=1
Thread (2 messages)