Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



3.0k

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.



1.1k
Accepted
answer


3.0k
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: http://php.net/manual/en/language.oop5.interfaces.php, see 2nd example... ;) Wojciech Ślawski is right - those are basics of inheritance of Interfaces.



3.0k
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



3.0k
edited Jul '17

phil6700: http://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