Bug #51225 [Opn->Bgs]: cannot define a class with the same name as an interface

From: Date: Sun, 07 Mar 2010 23:02:25 +0000
Subject: Bug #51225 [Opn->Bgs]: cannot define a class with the same name as an interface
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148376@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51225&edit=1

 ID:               51225
 Updated by:       kalle@php.net
 Reported by:      tony at marston-home dot demon dot co dot uk
 Summary:          cannot define a class with the same name as an
                   interface
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Class/Object related
 Operating System: Windows XP
 PHP Version:      5.2.13

 New Comment:

Thats how the OO is designed, internally is interfaces just a class with
an additional flag.

So no bug here


Previous Comments:
------------------------------------------------------------------------
[2010-03-06 18:50:41] tony at marston-home dot demon dot co dot uk

Description:
------------
When I try to define a particular class it fails with "cannot redeclare
class ...". When I check with class_exists('...') it returns false, but
I still cannot create it. I eventually found some previous code which
uses the same name to define an interface.

Test script:
---------------
Interface Singleton{public static function instance();}
if (class_exists('Singleton')) {
    $reason = 'class already exists';
} else {
    class Singleton{
        static function getInstance(){
            return true;
        }
    }
}

Expected result:
----------------
If it is not possible to define a class and an interface with the same
name, then the class_exists() function should also include interface
names.

If it IS possible to have a class and an interface with the same name,
then the compiler should NOT reject the second reference.



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51225&edit=1


Thread (13 messages)

« previous php.bugs (#148376) next »