Bug #67114 [Com]: sometimes class_exists() does not works on a class using traits ...
| From: | php at sunyanzi dot me | Date: | Thu, 24 Apr 2014 01:54:25 +0000 |
| Subject: | Bug #67114 [Com]: sometimes class_exists() does not works on a class using traits ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185400@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67114&edit=1
ID: 67114
Comment by: php at sunyanzi dot me
Reported by: php at sunyanzi dot me
Summary: sometimes class_exists() does not works on a class
using traits ...
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: debian wheezy
PHP Version: 5.5.11
Block user comment: N
Private report: N
New Comment:
my mistake ... thank you for your comment ... i am appreciate for that ...
Previous Comments:
------------------------------------------------------------------------
[2014-04-23 18:25:47] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is a nifty case: Only "simple" classes are fully available after compile time,
classes with "complexer" things (interface,traits, ...) will be bound and made available
at runtime in the place where they are declared, else constructs like
<?php
include 'someinterface.php';
class C implements someinterfae {}
?>
won't work. same with traits.
------------------------------------------------------------------------
[2014-04-23 09:57:26] php at sunyanzi dot me
Description:
------------
function class_exists returns wrong result when a class used traits ...
in clear way ... just see code below ...
Test script:
---------------
<?php
var_dump( class_exists( 'baz' ) ); // true
var_dump( class_exists( 'bar' ) ); // false
trait foo { }
class bar {
use foo;
}
class baz {
}
var_dump( class_exists( 'bar' ) ); // true
Expected result:
----------------
bool(true)
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67114&edit=1