Bug #68597 [NEW]: Wrong Strict report when overriding a Trait property
From: pedronaroga at gmail dot com
Operating system: Windows
PHP version: 5.5.19
Package: Class/Object related
Bug Type: Bug
Bug description:Wrong Strict report when overriding a Trait property
Description:
------------
Just recently I came up with the following E_STRICT report:
Strict standards: Declaration of
Portal_IndexController::getUsuarioLogado() should be compatible with
Sicneo\Controller\Action::getUsuarioLogado($fields = NULL).
I got very confused when I checked my code and saw that
Sicneo\Controller\Action did not have a 'getUsuarioLogado' function.
After a couple of minutes, I found out that Portal_IndexController was
using a trait that had already defined a 'getUsuarioLogado' function,
with the default null value to a $fields parameter.
The strict message should point to the trait instead of pointing out to
the parent class.
Test script:
---------------
trait MyTrait {
public function myFunction($test = null) {}
}
class MyParentClass {
}
class MyChildClass extends MyParentClass {
use MyTrait;
public function myFunction() { }
}
$obj = new MyChildClass;
$obj->myFunction();
Actual result:
--------------
Strict standards: Declaration of MyChildClass::myFunction() should be
compatible with MyParentClass::myFunction($test = NULL) in [...]
--
Edit bug report at https://bugs.php.net/bug.php?id=68597&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68597&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68597&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68597&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68597&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68597&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68597&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68597&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68597&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68597&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68597&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68597&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68597&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68597&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68597&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68597&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68597&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68597&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68597&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68597&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68597&r=mysqlcfg
Thread (3 messages)
- pedronaroga at gmail dot com