Bug #76581 [Asn]: Multi-level parent/self does not get correctly resolved

From: Date: Thu, 05 Jul 2018 18:02:54 +0000
Subject: Bug #76581 [Asn]: Multi-level parent/self does not get correctly resolved
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216151@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76581&edit=1 ID: 76581 Updated by: kalle@php.net Reported by: levim@php.net Summary: Multi-level parent/self does not get correctly resolved Status: Assigned Type: Bug Package: Class/Object related PHP Version: 7.3.0alpha2 Assigned To: levim Block user comment: N Private report: N New Comment: I agree that the decl of B::m(B $s) : parent should error out if B does not extend another class, the decl of C::m(parent $s) : A makes sense, but the error should happen earlier to show the real issue. Previous Comments: ------------------------------------------------------------------------ [2018-07-04 23:46:22] levim@php.net Looking at this more I think perhaps the real bug is when defining B::m(): parent that it doesn't error. In most (all?) other contexts parent refers to class inheritance, not interface inheritance. ------------------------------------------------------------------------ [2018-07-04 23:32:38] levim@php.net Description: ------------ This affects all PHP 7.X versions to date (7.3 alpha 1). Test script: --------------- https://3v4l.org/Od72V <?php interface A { function m(B $s): self; } class B implements A { function m(self $s): parent { return $this; } } class C extends B { function m(parent $s): A { return $this; } } ?> Expected result: ---------------- No error. Actual result: -------------- Fatal error: Declaration of C::m(B $s): A must be compatible with B::m(B $s): parent in % on line %d ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76581&edit=1

« previous php.bugs (#216151) next »