Bug #62464 [Com]: implementing two interfaces with same signature no longer gives a fatal error

2013-03-22 Thread pawel dot ulewicz at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62464edit=1

 ID: 62464
 Comment by: pawel dot ulewicz at gmail dot com
 Reported by:j dot henge-ernst at interexa dot de
 Summary:implementing two interfaces with same signature no
 longer gives a fatal error
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   linux
 PHP Version:5.3Git-2012-07-02 (Git)
 Block user comment: N
 Private report: N

 New Comment:

Any news about it?

I think the current behavior is ok(implementing two interfaces with same 
signatures should be possible), but it should be documented. 

Right now the documentation states clearly: A class cannot implement two 
interfaces that share function names, since it would cause ambiguity., so it 
looks like an undocumented feature(bug?) with uncertain status. I would use 
this in my code(and i'm not the only one, check the comments here: bug #33698), 
but i don't know if it's going to be removed in future versions or not.


Previous Comments:

[2012-08-07 22:41:44] valderrama dot christopher at gmail dot com

The certification guide states that a object can't implement two interfaces 
that 
share the same method, but the code still runs ok.

So if classes are going to be allowed two implement two interfaces that share 
the 
same method, I think that the certification exam should be changed to reflect 
this change.


[2012-07-02 22:11:54] j dot henge-ernst at interexa dot de

Your example is ok and should work correctly as both interfaces extend the same 
base interface and add different methods. In my given example AInterface and 
BInterface do not extend from a common interface. So the class which implements 
RewindableIterator, ReversableIterator must implement

from Iterator:
function current();
function key();
function next();
function valid();

from RewindableIterator:
function rewind();

from ReversableIterator:
function prev();

So lets change my example to:
interface AInterface {
/** @return Aclass[] */
public function getObjects();
}
interface BInterface {
/** @return Bclass[] */
public function getObjects();
}

class CClass implements AInterface, BInterface
{
public function getObjects() {
   return ???;
}
}
class AClass {
public function foo() { echo foo;}
}
class BClass {
public function bar() { echo bar;}
}


[2012-07-02 17:50:10] ni...@php.net

I'm not sure I see the problem. If the class satisfies both interfaces, why 
should there be an error?

E.g., consider:

interface Iterator {
function current();
function key();
function next();
function valid();
}

interface RewindableIterator extends Iterator {
function rewind();
}

interface ReversableIterator extends Iterator {
function prev();
}

class Foo implements RewindableIterator, ReversableIterator {
// ...
}

Why shouldn't the class be able to implement both, as long as the method 
declarations don't disagree?


[2012-07-02 16:11:52] j dot henge-ernst at interexa dot de

Description:

having two different interfaces with same method no longer causes a fatal error 
like in php 5.3.8. With fix for bug #43200 (my guess) it is now possible to 
inherit another interface which has the same method signature as a previous 
interface.

implementing an interface with methods which collide with a method name which 
is already implemented by another interface should cause an error.

From my point of OOP it does not make sense as the meaning of the colliding 
interface method do not express the same, else both interfaces with the same 
signature part should extend that base interface.

It's the opposite of bug #46705

Such a change of the language should not be done in a minor release.

Test script:
---
?php

interface AInterface {
public function getLogicalKey();
}
interface BInterface {
public function getLogicalKey();
}
class AClass implements AInterface {
public function getLogicalKey() { return 1; }
}
class BClass extends AClass implements BInterface { }


Expected result:

Fatal error: Can't inherit abstract function BInterface::getLogicalKey() 
(previously declared abstract in AInterface) in x.php on line 12








-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62464edit=1


Bug #62464 [Com]: implementing two interfaces with same signature no longer gives a fatal error

2012-08-07 Thread valderrama dot christopher at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62464edit=1

 ID: 62464
 Comment by: valderrama dot christopher at gmail dot com
 Reported by:j dot henge-ernst at interexa dot de
 Summary:implementing two interfaces with same signature no
 longer gives a fatal error
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   linux
 PHP Version:5.3Git-2012-07-02 (Git)
 Block user comment: N
 Private report: N

 New Comment:

The certification guide states that a object can't implement two interfaces 
that 
share the same method, but the code still runs ok.

So if classes are going to be allowed two implement two interfaces that share 
the 
same method, I think that the certification exam should be changed to reflect 
this change.


Previous Comments:

[2012-07-02 22:11:54] j dot henge-ernst at interexa dot de

Your example is ok and should work correctly as both interfaces extend the same 
base interface and add different methods. In my given example AInterface and 
BInterface do not extend from a common interface. So the class which implements 
RewindableIterator, ReversableIterator must implement

from Iterator:
function current();
function key();
function next();
function valid();

from RewindableIterator:
function rewind();

from ReversableIterator:
function prev();

So lets change my example to:
interface AInterface {
/** @return Aclass[] */
public function getObjects();
}
interface BInterface {
/** @return Bclass[] */
public function getObjects();
}

class CClass implements AInterface, BInterface
{
public function getObjects() {
   return ???;
}
}
class AClass {
public function foo() { echo foo;}
}
class BClass {
public function bar() { echo bar;}
}


[2012-07-02 17:50:10] ni...@php.net

I'm not sure I see the problem. If the class satisfies both interfaces, why 
should there be an error?

E.g., consider:

interface Iterator {
function current();
function key();
function next();
function valid();
}

interface RewindableIterator extends Iterator {
function rewind();
}

interface ReversableIterator extends Iterator {
function prev();
}

class Foo implements RewindableIterator, ReversableIterator {
// ...
}

Why shouldn't the class be able to implement both, as long as the method 
declarations don't disagree?


[2012-07-02 16:11:52] j dot henge-ernst at interexa dot de

Description:

having two different interfaces with same method no longer causes a fatal error 
like in php 5.3.8. With fix for bug #43200 (my guess) it is now possible to 
inherit another interface which has the same method signature as a previous 
interface.

implementing an interface with methods which collide with a method name which 
is already implemented by another interface should cause an error.

From my point of OOP it does not make sense as the meaning of the colliding 
interface method do not express the same, else both interfaces with the same 
signature part should extend that base interface.

It's the opposite of bug #46705

Such a change of the language should not be done in a minor release.

Test script:
---
?php

interface AInterface {
public function getLogicalKey();
}
interface BInterface {
public function getLogicalKey();
}
class AClass implements AInterface {
public function getLogicalKey() { return 1; }
}
class BClass extends AClass implements BInterface { }


Expected result:

Fatal error: Can't inherit abstract function BInterface::getLogicalKey() 
(previously declared abstract in AInterface) in x.php on line 12








-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62464edit=1


Bug #62464 [Com]: implementing two interfaces with same signature no longer gives a fatal error

2012-07-02 Thread ni...@php.net
Edit report at https://bugs.php.net/bug.php?id=62464edit=1

 ID: 62464
 Comment by: ni...@php.net
 Reported by:j dot henge-ernst at interexa dot de
 Summary:implementing two interfaces with same signature no
 longer gives a fatal error
 Status: Open
 Type:   Bug
 Package:Scripting Engine problem
 Operating System:   linux
 PHP Version:5.3Git-2012-07-02 (Git)
 Block user comment: N
 Private report: N

 New Comment:

I'm not sure I see the problem. If the class satisfies both interfaces, why 
should there be an error?

E.g., consider:

interface Iterator {
function current();
function key();
function next();
function valid();
}

interface RewindableIterator extends Iterator {
function rewind();
}

interface ReversableIterator extends Iterator {
function prev();
}

class Foo implements RewindableIterator, ReversableIterator {
// ...
}

Why shouldn't the class be able to implement both, as long as the method 
declarations don't disagree?


Previous Comments:

[2012-07-02 16:11:52] j dot henge-ernst at interexa dot de

Description:

having two different interfaces with same method no longer causes a fatal error 
like in php 5.3.8. With fix for bug #43200 (my guess) it is now possible to 
inherit another interface which has the same method signature as a previous 
interface.

implementing an interface with methods which collide with a method name which 
is already implemented by another interface should cause an error.

From my point of OOP it does not make sense as the meaning of the colliding 
interface method do not express the same, else both interfaces with the same 
signature part should extend that base interface.

It's the opposite of bug #46705

Such a change of the language should not be done in a minor release.

Test script:
---
?php

interface AInterface {
public function getLogicalKey();
}
interface BInterface {
public function getLogicalKey();
}
class AClass implements AInterface {
public function getLogicalKey() { return 1; }
}
class BClass extends AClass implements BInterface { }


Expected result:

Fatal error: Can't inherit abstract function BInterface::getLogicalKey() 
(previously declared abstract in AInterface) in x.php on line 12








-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62464edit=1