Bug #69467 [Opn->Ver]: Wrong checked for the interface by using Trait
| From: | requinix@php.net | Date: | Thu, 16 Apr 2015 09:18:13 +0000 |
| Subject: | Bug #69467 [Opn->Ver]: Wrong checked for the interface by using Trait | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192126@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69467&edit=1
ID: 69467
Updated by: requinix@php.net
Reported by: zeli dot box at gmail dot com
Summary: Wrong checked for the interface by using Trait
-Status: Open
+Status: Verified
Type: Bug
Package: Class/Object related
PHP Version: 5.4.39
Block user comment: N
Private report: N
New Comment:
http://3v4l.org/p303Q
I can't bisect but the first place I would look for the change is
https://github.com/php/php-src/commit/3f8c729e693c432b438cd33679182260d8732e30
Previous Comments:
------------------------------------------------------------------------
[2015-04-16 08:42:19] zeli dot box at gmail dot com
Description:
------------
Create an interface in the class:
1. Adding trait to the class
2. Implement interface methods in the trait, but making them private/protected
3. Create class object
4. Checking the object for the instance of interface returns true
This bug in php version > 5.4.10
But versions less than 5.4.10 was a fatal error:
"Fatal error: Access level to Foo::bad() must be public (as in class Baz)"
Test script:
---------------
interface Baz {
public function bad();
}
trait Bar{
protected function bad(){}
}
class Foo implements Baz{
use Bar;
}
$test = new Foo();
var_dump($test instanceof Baz);
Expected result:
----------------
Fatal error
Actual result:
--------------
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69467&edit=1