On Mon, Jul 8, 2024 at 1:12 PM Stephen Reay <php-li...@koalephant.com>
wrote:

>
>
> So really the question should be: why do you feel the need to *disallow* a
> combination that has no technical issues, and works already? If you're
> going to disallow abstract why not disallow any class inheritance at all?
> Because that's what abstract relates to: class hierarchy. Why remove some
> support but keep the rest?
>
>
>
Exactly what I wanted to say for this topic. Have a look at this example
that could be very similar in production code in some systems:

<?php

interface A {
    public static function run();
    public static function stop();
}

abstract class B implements A {
    public static function run() {
        static::create();
        static::start();
    }
}

class C extends B {
    public static function create() {
        echo "Create\n";
    }

    public static function start() {
        echo "Start\n";
    }

    public static function stop() {
        echo "Stop\n";
    }
}

function execute($class) {
    if (!is_subclass_of($class, A::class)) {
        throw new RuntimeException("Class must implement A interface");
    }

    $class::run();
    $class::stop();
};

execute(C::class);

If we support inheritance for static classes, we should allow static on
both interface and abstract classes.

Alex

Reply via email to