php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54091 class_exists fail with a class name alias
Submitted: 2011-02-24 15:39 UTC Modified: 2011-02-25 10:36 UTC
From: jinmoku at hotmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
 [2011-02-24 15:39 UTC] jinmoku at hotmail dot com
Description:
------------
class_exists fail with a class name alias, ReflectionClass too

Test script:
---------------
use \stdClass as object;
var_dump(new object);
var_dump(class_exists('object'));

Expected result:
----------------
object(stdClass)#1 (0) {
}
bool(true)

Actual result:
--------------
object(stdClass)#1 (0) {
}
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-24 16:00 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2011-02-24 16:00 UTC] 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

http://php.net/manual/en/language.namespaces.dynamic.php
 [2011-02-24 16:14 UTC] jinmoku at hotmail dot com
Sorry, there is nothing about this in the documentation,
how I can make an instance of  this class if it's doesn't exists ???
it's not logical
 [2011-02-25 10:36 UTC] jinmoku at hotmail dot com
try another thing : 

use \PDO as mysql;
var_dump(method_exists('mysql', '__construct'));
var_dump(method_exists('\PDO', '__construct'));
/*
bool(false)
bool(true)
*/

something wrong no ?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 18:01:28 2024 UTC