Zephir Interface extends other interfaces.

Hi there.

I was looking for Zephir forum or something similar, but was not able to find it, so I'm posting my question here.

I'm trying to do this:

interface CollectionInterface extends \IteratorAggregate, \Countable

but seems like Zephir does not like this,

interface CollectionInterface extends \IteratorAggregate, \Countable

===========================================^

Is this currently supported, whats the right syntax?

Thanks.



34.6k

hi you can uploade your source ?



8.5k
edited Apr '14

interface CollectionInterface extends \IteratorAggregate, \Countable {

}



34.6k
edited Apr '14

Hi

For example use L'interface IteratorAggregate

    class NormalizeChars implements \IteratorAggregate{

            public function getIterator()
            {
                var test;
                let test = [];
                return new \ArrayIterator(test);
            }
    }

For information https://github.com/phalcon/zephir/issues/124



8.5k

Hi Duy,

Thanks for your reply, but that does not solve my issue about an interface extending multiples interfaces.



34.6k

Hi

      namespace Abc;

      class NormalizeChars implements \IteratorAggregate,\Countable
      {

                public function getIterator()
                {
                    var test;
                    let test = [];
                    return new \ArrayIterator(test);
                }


                public function count()
                {
                    return 1;
                } 
      }


8.5k

Thanks again.

Here is the thing, for every time you need to implement a Collection you need to write:

implements \IteratorAggregate,\Countable

Having a CollectionInterface that implements both interfaces, gives you the ability to just wite:

class NormalizeChars implements CollectionInterface

as many times collections you want to implement, also if you want to define a new method in your interface you can add the definition to the CollectionInterface, forcing every other class that implement CollectionIterface to implement the new method.