Design Patterns PHP - Strategy Java

1) What have we done?

For clarity we refactor code. We renamed the class "Context" into "ContextA1B1"

A1 - means that it implements method "doA" in version 1
B1 - means that it implements method "doB" in version 1
A2 - means that it implements method "doA" in version 2
B2 - means that it implements method "doB" in version 2


class ContextA1B1
{
    public function doA()
    {
        echo 'DoingA ver1' . PHP_EOL;
    }

    public function doB()
    {
        echo 'DoingB ver1' . PHP_EOL;
    }
}




We created also two subclasses:


class ContextA1B2 extends ContextA1B1
{
    public function doB()
    {
        echo 'DoingB ver2' . PHP_EOL;
    }
}

class ContextA2B1 extends ContextA1B1
{
    public function doA()
    {
        echo 'DoingA ver2' . PHP_EOL;
    }
}

$context = new ContextA1B1();
$context->doA();
$context->doB();

$context = new ContextA2B1();
$context->doA();
$context->doB();

$context = new ContextA1B2();
$context->doA();
$context->doB();




2) Is everything ok?

Theoretically yes, we can implement another version of this method, but let's see step3.