Guilliam,

On Fri, Mar 25, 2022 at 6:35 AM Guilliam Xavier <guilliam.xav...@gmail.com>
wrote:

> Hi Mark,
>
> On Wed, Mar 23, 2022 at 11:55 PM Mark Niebergall <mbnieberg...@gmail.com>
> wrote:
>
>> (...)
>>
>> Another example I often see in my projects could be used with a similar
>> example:
>>
>> ```
>> abstract class Bird
>> {
>>     public const bool CAN_FLY;
>>     public const string FAMILY;
>>     public function canFly(): bool
>>     {
>>         return self::CAN_FLY;
>>     }
>> }
>> final class EmperorPenguin extends Bird
>> {
>>     public const bool CAN_FLY = false;
>>     public const string FAMILY = 'penguin';
>> }
>> ```
>>
>
> I had this "need" too (and used abstract static methods where the
> implementations just return a literal value...).
>
> Just 2 remarks: in abstract class Bird, shouldn't it be:
> - "*abstract* public const bool CAN_FLY;" (and same for FAMILY)
> - "return *static*::CAN_FLY;"
> ?
>

I intentionally left `abstract` out of `public const bool CAN_FLY;` in the
`abstract class` for consistency with the implementation with `interface`,
which would also have to be `public const bool CAN_FLY;`. Currently
`abstract` is only used in front of methods `abstract function doThing():
bool;`. Open to discussion - which way is ideal or preferred? That could be
included as a subset of an RFC vote if a consensus during discussion isn't
reached.

Good correction, yes, `return static::CAN_FLY;` in that example in the
concrete child class.



>
> Regards,
>
> --
> Guilliam Xavier
>

Reply via email to