Bug->Doc #77294 [Opn]: Parent methods can "fulfill requirements" of child trait abstract methods

From: Date: Thu, 13 Dec 2018 17:22:22 +0000
Subject: Bug->Doc #77294 [Opn]: Parent methods can "fulfill requirements" of child trait abstract methods
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16213@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77294&edit=1 ID: 77294 Updated by: requinix@php.net Reported by: chasepeeler at gmail dot com -Summary: Abstract trait method implementation +Summary: Parent methods can "fulfill requirements" of child trait abstract methods Status: Open -Type: Bug +Type: Documentation Problem Package: Class/Object related Operating System: Windows PHP Version: 7.0.33 Block user comment: N Private report: N New Comment: Calling traits "copy/paste" is a simplification. They're more like mixins. As my edit to the summary suggests, what's happening is that the parent class is defining a method (via a trait, which is unimportant), the child's trait is defining a *requirement* of a method, and the parent is meeting the requirement. Surely this is more useful than the compiler raising an error, right? The "Abstract Trait Members" section already addresses this idea but could gain a sentence saying that the fulfilling can be done by a parent. And while someone's in there they can fix the "fullfill" spelling. Previous Comments: ------------------------------------------------------------------------ [2018-12-13 16:04:22] chasepeeler at gmail dot com Description: ------------ If a child class uses a trait with an abstract method, while it's parent class uses a trait with a defined method of the same name, the method from the parent classes trait will act as the implementation of the abstract method. The issue also exists in cases where a class uses two traits. One trait contains an abstract method while the other trait contains a defined method of the same name. When executed, the defined method will act as the implementation of the abstract method. I don't know if this is a bug or an undocumented feature. If it isn't a bug, then it breaks the "compiler assisted copy/paste rule" since copy/pasting the traits into the classes would cause an error. It also appears to violate the documented behavior in relation to conflict resolution: http://php.net/manual/en/language.oop5.traits.php#language.oop5.traits.conflict. If it isn't a bug, then the documentation needs to be updated to better explain this situation. Test script: --------------- https://3v4l.org/OKoTY ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77294&edit=1

« previous php.doc.bugs (#16213) next »