Bug #71414 [NEW]: Fatal error when using interface trait and inheritance

From: Date: Tue, 19 Jan 2016 19:16:31 +0000
Subject: Bug #71414 [NEW]: Fatal error when using interface trait and inheritance
Groups: php.standards 
Request: Send a blank email to standards-+get-1009@lists.php.net to get a copy of this message
From:             krzysiekpiasecki at gmail dot com
Operating system: OS X 10.9.5
PHP version:      7.0.2
Package:          PHP Language Specification
Bug Type:         Bug
Bug description:Fatal error when using interface trait and inheritance

Description:
------------
Interface method override inherited method and implemented in a trait
causes fatal error

Test script:
---------------
interface InterfaceY {
    public function y(): string;
}

trait TraitY {
    public function y(): string {
    }
}

class X {
    public function y() {
    }
}

class Y extends X implements InterfaceY {
    use TraitY;
}


Expected result:
----------------
No fatal error. Method Y in TraitY is well defined

Actual result:
--------------
Fatal error:  Declaration of X::y() must be compatible with Y::y():
string


PS


__No fatal error__ when:


class Y extends X implements InterfaceY {
    use TraitY;
    public function y(): string {
    }
}

-- 
Edit bug report at https://bugs.php.net/bug.php?id=71414&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71414&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71414&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71414&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71414&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71414&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71414&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71414&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71414&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71414&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71414&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71414&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71414&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71414&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71414&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71414&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71414&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71414&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71414&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71414&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71414&r=mysqlcfg



Thread (1 message)

  • krzysiekpiasecki at gmail dot com
« previous php.standards (#1009) next »