Skip to content

Commit

Permalink
Merge pull request #28 from samsonasik/apply-php80
Browse files Browse the repository at this point in the history
Apply PHP 8.0 Syntax and constructor promotion
  • Loading branch information
Ocramius authored Oct 24, 2022
2 parents 004a8d7 + 52629f5 commit b073da7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ class Translator implements
I18nTranslatorInterface,
ValidatorTranslatorInterface
{
/** @var I18nTranslatorInterface */
protected $translator;

public function __construct(I18nTranslatorInterface $translator)
public function __construct(protected I18nTranslatorInterface $translator)
{
$this->translator = $translator;
}

/**
Expand Down
16 changes: 4 additions & 12 deletions test/Router/HttpRouterDelegatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ public function setUp(): void
public function testFactoryReturnsRouterUntouchedIfNotATranslatorAwareTreeRouteStack(): void
{
$router = (object) [];
$callback = function () use ($router): object {
return $router;
};
$callback = static fn(): object => $router;

$factory = new HttpRouterDelegatorFactory();
$this->assertSame($router, $factory(
Expand All @@ -50,9 +48,7 @@ public function testFactoryReturnsTranslatorAwareRouterWithTranslationsDisabledW
{
$router = $this->prophesize(TranslatorAwareTreeRouteStack::class);
$router->setTranslatorEnabled(false)->shouldBeCalled();
$callback = function () use ($router): RouteInterface {
return $router->reveal();
};
$callback = static fn(): RouteInterface => $router->reveal();

$this->container->has('MvcTranslator')->willReturn(false);
$this->container->has(TranslatorInterface::class)->willReturn(false);
Expand All @@ -74,9 +70,7 @@ public function testFactoryInjectsMvcTranslatorIntoRouterWhenPresentInContainer(
$router->setTranslatorEnabled(false)->shouldNotBeCalled();
$router->setTranslator($translator)->shouldBeCalled();

$callback = function () use ($router): RouteInterface {
return $router->reveal();
};
$callback = static fn(): RouteInterface => $router->reveal();

$this->container->has('MvcTranslator')->willReturn(true);
$this->container->get('MvcTranslator')->willReturn($translator);
Expand All @@ -99,9 +93,7 @@ public function testFactoryInjectsTranslatorInterfaceIntoRouterWhenPresentInCont
$router->setTranslatorEnabled(false)->shouldNotBeCalled();
$router->setTranslator($translator)->shouldBeCalled();

$callback = function () use ($router): RouteInterface {
return $router->reveal();
};
$callback = static fn(): RouteInterface => $router->reveal();

$this->container->has('MvcTranslator')->willReturn(false);
$this->container->has(TranslatorInterface::class)->willReturn(true);
Expand Down
3 changes: 1 addition & 2 deletions test/Router/TranslatorAwareTreeRouteStackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

class TranslatorAwareTreeRouteStackTest extends TestCase
{
/** @var string */
private $testFilesDir;
private string $testFilesDir;

private Translator $translator;

Expand Down

0 comments on commit b073da7

Please sign in to comment.