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