php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33732 behavior of constants in class and interface extending
Submitted: 2005-07-17 10:41 UTC Modified: 2005-11-23 10:27 UTC
Votes:9
Avg. Score:4.6 ± 0.7
Reproduced:6 of 7 (85.7%)
Same Version:3 (50.0%)
Same OS:4 (66.7%)
From: lukas dot starecek at centrum dot cz Assigned: dmitry
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1CVS-2005-11-23 OS: Linux
Private report: No CVE-ID:
 [2005-07-17 10:41 UTC] lukas dot starecek at centrum dot cz
Description:
------------
If interface define any constants, then it's not possible (due to error) implement this interface in any class and extend any other class with this interface.

Reproduce code:
---------------
interface iA {

    const cA = 'const of iA';
}

class A implements iA {
}

class B extends A implements iA {
}

$b = new B();
echo iA::cA;
echo A::cA;
echo B::cA;

----- Another example -----

interface iA {

    const cA = 'const of iA';
}

class A implements iA {
}

interface iB extends iA {
}

class B extends A implements iB {
}

$b = new B();
echo iA::cA;
echo A::cA;
echo iB::cA;
echo B::cA;

Expected result:
----------------
const of iA
const of iA
const of iA

----- Another example -----

const of iA
const of iA
const of iA
const of iA

Actual result:
--------------
Fatal error: Cannot inherit previously-inherited constant cA from interface iA

----- Another example -----

Fatal error: Cannot inherit previously-inherited constant cA from interface iB

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-29 18:38 UTC] daniel dot gorski at develnet dot org
This bug is _still_ contained in 5.1.0RC4.

regards dtg
 [2005-11-08 00:40 UTC] daniel dot gorski at develnet dot org
Is there any chance to fix this before 5.1? Zend is going enterprise I've heard ...

Please take a look at this issue. I really can not imagine that this is very hard to implement.

Thank you.
 [2005-11-23 00:38 UTC] johannes@php.net
Dmitry can you check this?
 [2005-11-23 10:27 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_1 and PHP_5_0.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 06:02:27 2014 UTC