damianopetrungaro / clean-architecture

Package for isolate your domain code from framework dependency using DDD concepts.
MIT License
96 stars 20 forks source link

equals method in ReflectionEnum should be type-hinted #14

Closed garak closed 6 years ago

garak commented 6 years ago

I'm implementing ReflectionEnum, so I added the method:

<?php

namespace Foo;

use Damianopetrungaro\CleanArchitecture\Common\Enum\ReflectionEnum;

class Bar extends ReflectionEnum
{
    private const BAZ = 1;

    public  function equals($enum): bool
    {
        return $this->value === $enum->getValue();
    }
}

Problem is I cannot really use $enum->getValue(), unless $enum is type-hinted against ReflectionEnum

damianopetrungaro commented 6 years ago

Hey @garak thank you for the issue! Yeah, seem that on abstract methods isn't possible to add type hint on the child class.

I guess we should just add the Enum type hint on it. public function equals(Enum $enum): bool If you have any other suggestion feel free to help, PR is welcome if you're free!

garak commented 6 years ago

What about this?

    public  function equals(ReflectionEnum $enum): bool
    {
        return $this->value === $enum->getValue();
    }
damianopetrungaro commented 6 years ago

ReflectionEnum is an implementation of the interface Enum.

If we are going to type hint it I prefer using the interface, so custom implementation are will be supported 😄

damianopetrungaro commented 6 years ago

@garak are you free to work on it? Otherwise, I'll schedule some time next week 😄

garak commented 6 years ago

See #15

damianopetrungaro commented 6 years ago

Ty @garak for improving this package!