mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-03 21:47:25 +02:00
fix: add return types for all methods
This commit is contained in:
@@ -16,17 +16,17 @@ class ContextOrder
|
|||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setState(StateOrder $state)
|
public function setState(StateOrder $state): void
|
||||||
{
|
{
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function proceedToNext()
|
public function proceedToNext(): void
|
||||||
{
|
{
|
||||||
$this->state->proceedToNext($this);
|
$this->state->proceedToNext($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toString()
|
public function toString(): string
|
||||||
{
|
{
|
||||||
return $this->state->toString();
|
return $this->state->toString();
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns\Behavioral\State;
|
|||||||
|
|
||||||
class CreateOrder implements StateOrder
|
class CreateOrder implements StateOrder
|
||||||
{
|
{
|
||||||
public function proceedToNext(ContextOrder $context)
|
public function proceedToNext(ContextOrder $context): void
|
||||||
{
|
{
|
||||||
$context->setState(new ShippingOrder());
|
$context->setState(new ShippingOrder());
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns\Behavioral\State;
|
|||||||
|
|
||||||
class OrderDone implements StateOrder
|
class OrderDone implements StateOrder
|
||||||
{
|
{
|
||||||
public function proceedToNext(ContextOrder $context)
|
public function proceedToNext(ContextOrder $context): void
|
||||||
{
|
{
|
||||||
// there is nothing more to do
|
// there is nothing more to do
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns\Behavioral\State;
|
|||||||
|
|
||||||
class ShippingOrder implements StateOrder
|
class ShippingOrder implements StateOrder
|
||||||
{
|
{
|
||||||
public function proceedToNext(ContextOrder $context)
|
public function proceedToNext(ContextOrder $context): void
|
||||||
{
|
{
|
||||||
$context->setState(new OrderDone());
|
$context->setState(new OrderDone());
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns\Behavioral\State;
|
|||||||
|
|
||||||
interface StateOrder
|
interface StateOrder
|
||||||
{
|
{
|
||||||
public function proceedToNext(ContextOrder $context);
|
public function proceedToNext(ContextOrder $context): void;
|
||||||
|
|
||||||
public function toString(): string;
|
public function toString(): string;
|
||||||
}
|
}
|
||||||
|
@@ -9,14 +9,14 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class StateTest extends TestCase
|
class StateTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testIsCreatedWithStateCreated()
|
public function testIsCreatedWithStateCreated(): void
|
||||||
{
|
{
|
||||||
$orderContext = ContextOrder::create();
|
$orderContext = ContextOrder::create();
|
||||||
|
|
||||||
$this->assertSame('created', $orderContext->toString());
|
$this->assertSame('created', $orderContext->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanProceedToStateShipped()
|
public function testCanProceedToStateShipped(): void
|
||||||
{
|
{
|
||||||
$contextOrder = ContextOrder::create();
|
$contextOrder = ContextOrder::create();
|
||||||
$contextOrder->proceedToNext();
|
$contextOrder->proceedToNext();
|
||||||
@@ -24,7 +24,7 @@ class StateTest extends TestCase
|
|||||||
$this->assertSame('shipped', $contextOrder->toString());
|
$this->assertSame('shipped', $contextOrder->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanProceedToStateDone()
|
public function testCanProceedToStateDone(): void
|
||||||
{
|
{
|
||||||
$contextOrder = ContextOrder::create();
|
$contextOrder = ContextOrder::create();
|
||||||
$contextOrder->proceedToNext();
|
$contextOrder->proceedToNext();
|
||||||
@@ -33,7 +33,7 @@ class StateTest extends TestCase
|
|||||||
$this->assertSame('done', $contextOrder->toString());
|
$this->assertSame('done', $contextOrder->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testStateDoneIsTheLastPossibleState()
|
public function testStateDoneIsTheLastPossibleState(): void
|
||||||
{
|
{
|
||||||
$contextOrder = ContextOrder::create();
|
$contextOrder = ContextOrder::create();
|
||||||
$contextOrder->proceedToNext();
|
$contextOrder->proceedToNext();
|
||||||
|
Reference in New Issue
Block a user