mercredi 18 août 2021

Symfony interface extends another interface instead of implement

I'm working with symfony, and I'm trying to apply SOLID principles and practicing Design Patterns for Code refactoring.

I have 2 questions :

  1. what design patterns should i always use when using Symfony or other php framework
  2. Why an interface extends another interface instead of implementing it ?

For example :

<?php

namespace Doctrine\Bundle\DoctrineBundle\EventSubscriber;

use Doctrine\Common\EventSubscriber;

interface EventSubscriberInterface extends EventSubscriber
{
}

namespace Doctrine\Common;

/**
 * An EventSubscriber knows himself what events he is interested in.
 * If an EventSubscriber is added to an EventManager, the manager invokes
 * {@link getSubscribedEvents} and registers the subscriber as a listener for all
 * returned events.
 */
interface EventSubscriber
{
    /**
     * Returns an array of events this subscriber wants to listen to.
     *
     * @return string[]
     */
    public function getSubscribedEvents();
}

Why i can't just implement the interface or extends a class or abstract class instead of an interface ?

Aucun commentaire:

Enregistrer un commentaire