We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How is this possible?

It's zephir code, it doesn't check for interfaces methods when compiling classes if they implement them really, it's kind of stupid, sure, but it is as it is. Just create issue best.



5.1k

Hello

redis.zep not use cphalcon/phalcon/session/adapterinterface.zep, it use cphalcon/phalcon/session/adapter.zep

cphalcon/phalcon/session/adapter.zep has fonction destroy implemented declared in the interface :


public function destroy(boolean removeData = false) -> boolean
    {
        if removeData {
            this->removeSessionData();
        }

        let this->_started = false;
        return session_destroy();
    }

function destroy in redis is an another independent function

edited Jul '17

Still cphalcon/phalcon/session/adapter.zep implements cphalcon/phalcon/session/adapterinterface.zep so body of method should be the same across all adapters. It's justa bug, if you will try to extend Redis adapter in php code you will have most likely exception there.



3.3k
Accepted
answer


5.1k
edited Jul '17

Still cphalcon/phalcon/session/adapter.zep implements cphalcon/phalcon/session/adapterinterface.zep so body of method should be the same across all adapters. It's justa bug, if you will try to extend Redis adapter in php code you will have most likely exception there.

redis.zep not implements but extends adapter.zep

so I do not think it's mandatory

cphalcon/phalcon/session/adapter.zep must implements all abstract function cphalcon/phalcon/session/adapterinterface.zep but not cphalcon/phalcon/session/adapter/redis.zep

With heritage this function just override the parent function, and can require other parameters

it's the difference between extends (herit) and implements (interfaces)

edited Jul '17

It is mandatory, even when extends it has to have same method body as in interface. If it extends class which implements some interface, it must implement this interface too.

edited Jul '17

phil6700: https://php.net/manual/en/language.oop5.interfaces.php, see 2nd example... ;) Wojciech Ślawski is right - those are basics of inheritance of Interfaces.



5.1k
edited Jul '17

it's specific to Zephir ?

For more than 20 years, i do it in java and I did it in C++ without any problems. It is usually to add an additional parameter and do something before calling the parent function.

EDIT : Oups sorry, i'm confused, I confuse with abstract classes

i use abstract class in my projects not interface and I always forget that we can not overload the functions in php



5.1k
edited Jul '17

phil6700: https://php.net/manual/en/language.oop5.interfaces.php, see 2nd example... ;) Wojciech Ślawski is right - those are basics of inheritance of Interfaces.

Sorry but second exemple just use implements for final class not extends, they extends just an interface, not a class