Doc #75482 [NEW]: silent resolve/redefine trait conflict
| From: | bscheshir at gmail dot com | Date: | Fri, 03 Nov 2017 14:20:05 +0000 |
| Subject: | Doc #75482 [NEW]: silent resolve/redefine trait conflict | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-15209@lists.php.net to get a copy of this message | ||
From: bscheshir at gmail dot com
Operating system:
PHP version: 7.2.0RC5
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:silent resolve/redefine trait conflict
Description:
------------
---
From manual page: http://www.php.net/language.oop5.traits
---
https://3v4l.org/g5HRH
how about same methods in C and C1?
this is some hard to understand
and I can't find example in docs
Unexpected redefinition last(?)-trait method to class method
Test script:
---------------
<?php
trait ATrait {
public function a(){
return 'Aa';
}
}
trait BTrait {
public function a(){
return 'Ba';
}
}
class C {
use ATrait{
a as aa;
}
use BTrait{
a as ba;
}
public function a() {
return static::aa() . static::ba();
}
}
$o = new C;
echo $o->a(), "\n";
class C1 {
use BTrait{
a as ba;
}
use ATrait{
a as aa;
}
public function a() {
return static::aa() . static::ba();
}
}
$o = new C1;
echo $o->a(), "\n";
class D {
use ATrait{
ATrait::a as aa;
}
use BTrait{
BTrait::a as ba;
}
public function a() {
return static::aa() . static::ba();
}
}
$o = new D;
echo $o->a(), "\n";
Actual result:
--------------
AaAa
BaBa
AaBa
--
Edit bug report at https://bugs.php.net/bug.php?id=75482&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75482&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75482&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75482&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75482&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75482&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75482&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75482&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75482&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75482&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75482&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75482&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75482&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75482&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75482&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75482&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75482&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75482&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75482&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75482&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75482&r=mysqlcfg