php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26867 get_declared_classes() does not return interfaces
Submitted: 2004-01-10 19:36 UTC Modified: 2005-05-02 11:30 UTC
From: jaba at inbox dot lv Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.0.0b3 (beta3) OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jaba at inbox dot lv
New email:
PHP Version: OS:

 

 [2004-01-10 19:36 UTC] jaba at inbox dot lv
Description:
------------
At PHP5 we have a nice thing called interface. get_declared_classes() returns an array of all - abstract and non-abstract classes, but the array does not contain my interfaces. If interface is loaded by __autoload just like classes, shouldn't it be loaded into classes register too? Is there any way to check is it interface or what?

Reproduce code:
---------------
<?php

interface Dao {
function Open();
function Close();
}

echo "<p>class_exists('Dao') says that Dao ";
echo ( class_exists('Dao') ? 'is defined' : 'is not defined' );

$classes = get_declared_classes();
echo "<p>get_declared_classes() says that Dao ";
echo ( in_array('Dao',$classes) ? 'is defined' : 'is not defined' );

?>

Expected result:
----------------
class_exists('Dao') says that Dao is defined

get_declared_classes() says that Dao is not defined

Actual result:
--------------
class_exists('Dao') says that Dao is defined

get_declared_classes() says that Dao is defined

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-10 19:37 UTC] jaba at inbox dot lv
I mixed up expected with actual results.
 [2004-01-11 10:22 UTC] sniper@php.net
Use get_declared_interfaces()

 [2004-01-11 10:57 UTC] jaba at inbox dot lv
If this behaviour of get_declared_classes() is considered ok, then what about class_exists()? Then we need interface_exists(), don't we? And we shoud have false returned  if class_exists() called for an interface! Otherwise it turns out that word "class" is not used clearly: in class_exists() it includes interfaces, but in get_declared_classes() - no more!
 [2005-05-02 11:30 UTC] andrey@php.net
As far as I remember interface_exists() was added in 5.0.2 . In 5.0.0 and 5.0.1 class_exists() used to return TRUE when asked for a existing interface. Starting 5.0.2 class_exists() doesn't do that anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 12 05:01:28 2024 UTC