Skip to content

Commit

Permalink
Merge pull request #18 from samsonasik/apply-php74
Browse files Browse the repository at this point in the history
Apply PHP 7.4 syntax and typed property
  • Loading branch information
Ocramius authored Sep 14, 2022
2 parents 7533df2 + de6b8f2 commit 6c86500
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 36 deletions.
3 changes: 1 addition & 2 deletions src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class EscaperExtension implements ExtensionInterface
{
/** @var Escaper */
private $escaper;
private Escaper $escaper;

public function __construct(?string $encoding = null)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Extension/UrlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

class UrlExtension implements ExtensionInterface
{
/** @var ServerUrlHelper */
private $serverUrlHelper;
private ServerUrlHelper $serverUrlHelper;

/** @var UrlHelper */
private $urlHelper;
private UrlHelper $urlHelper;

public function __construct(UrlHelper $urlHelper, ServerUrlHelper $serverUrlHelper)
{
Expand Down
3 changes: 1 addition & 2 deletions src/PlatesRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class PlatesRenderer implements TemplateRendererInterface
{
use ArrayParametersTrait;

/** @var Engine */
private $template;
private Engine $template;

public function __construct(?Engine $template = null)
{
Expand Down
3 changes: 1 addition & 2 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

class ConfigProviderTest extends TestCase
{
/** @var ConfigProvider */
private $provider;
private ConfigProvider $provider;

protected function setUp(): void
{
Expand Down
35 changes: 20 additions & 15 deletions test/Extension/EscaperExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,30 @@ public function testRegistersEscaperFunctionsWithEngine(): void

$engine = $this->prophesize(Engine::class);
$engine
->registerFunction('escapeHtml', Argument::that(function ($argument) {
return is_array($argument) && $argument[0] instanceof Escaper && $argument[1] === 'escapeHtml';
}))->shouldBeCalled();
->registerFunction('escapeHtml', Argument::that(
static fn($argument) => is_array($argument) &&
$argument[0] instanceof Escaper && $argument[1] === 'escapeHtml'
))->shouldBeCalled();
$engine
->registerFunction('escapeHtmlAttr', Argument::that(function ($argument) {
return is_array($argument) && $argument[0] instanceof Escaper && $argument[1] === 'escapeHtmlAttr';
}))->shouldBeCalled();
->registerFunction('escapeHtmlAttr', Argument::that(
static fn($argument) => is_array($argument) &&
$argument[0] instanceof Escaper && $argument[1] === 'escapeHtmlAttr'
))->shouldBeCalled();
$engine
->registerFunction('escapeJs', Argument::that(function ($argument) {
return is_array($argument) && $argument[0] instanceof Escaper && $argument[1] === 'escapeJs';
}))->shouldBeCalled();
->registerFunction('escapeJs', Argument::that(
static fn($argument) => is_array($argument) &&
$argument[0] instanceof Escaper && $argument[1] === 'escapeJs'
))->shouldBeCalled();
$engine
->registerFunction('escapeCss', Argument::that(function ($argument) {
return is_array($argument) && $argument[0] instanceof Escaper && $argument[1] === 'escapeCss';
}))->shouldBeCalled();
->registerFunction('escapeCss', Argument::that(
static fn($argument) => is_array($argument) &&
$argument[0] instanceof Escaper && $argument[1] === 'escapeCss'
))->shouldBeCalled();
$engine
->registerFunction('escapeUrl', Argument::that(function ($argument) {
return is_array($argument) && $argument[0] instanceof Escaper && $argument[1] === 'escapeUrl';
}))->shouldBeCalled();
->registerFunction('escapeUrl', Argument::that(
static fn($argument) => is_array($argument) &&
$argument[0] instanceof Escaper && $argument[1] === 'escapeUrl'
))->shouldBeCalled();

$extension->register($engine->reveal());
}
Expand Down
3 changes: 1 addition & 2 deletions test/Extension/UrlExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class UrlExtensionTest extends TestCase
/** @var ServerUrlHelper|ProphecyInterface */
private $serverUrlHelper;

/** @var UrlExtension */
private $extension;
private UrlExtension $extension;

public function setUp(): void
{
Expand Down
5 changes: 2 additions & 3 deletions test/PlatesRendererFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class PlatesRendererFactoryTest extends TestCase
/** @var ContainerInterface|ProphecyInterface */
private $container;

/** @var bool */
private $errorCaught = false;
private bool $errorCaught = false;

public function setUp(): void
{
Expand Down Expand Up @@ -184,7 +183,7 @@ public function testExceptionIsRaisedIfMultiplePathsSpecifyDefaultNamespace(): v
$factory = new PlatesRendererFactory();

// phpcs:ignore WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps
set_error_handler(function (int $_errno, string $_errstr) {
set_error_handler(function (int $_errno, string $_errstr): void {
$this->errorCaught = true;
}, E_USER_WARNING);
$factory($this->container->reveal());
Expand Down
10 changes: 4 additions & 6 deletions test/PlatesRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class PlatesRendererTest extends TestCase
{
use ProphecyTrait;

/** @var Engine */
private $platesEngine;
private Engine $platesEngine;

/** @var bool */
private $error;
private bool $error;

public function setUp(): void
{
Expand Down Expand Up @@ -121,7 +119,7 @@ public function testAddingSecondPathWithoutNamespaceIsANoopAndRaisesWarning($ren
$path = array_shift($paths);

// phpcs:ignore WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps
set_error_handler(function (int $_errno, string $message) {
set_error_handler(function (int $_errno, string $message): bool {
$this->error = true;
$this->assertStringContainsString('duplicate', $message);
return true;
Expand Down Expand Up @@ -250,7 +248,7 @@ public function testAddParameterToOneTemplate(): void
$this->assertEquals($content, $result);

// phpcs:ignore WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps
set_error_handler(function (int $_errno, string $message) {
set_error_handler(function (int $_errno, string $message): bool {
$this->assertStringContainsString('Undefined variable: name', $message);
return true;
}, E_NOTICE);
Expand Down

0 comments on commit 6c86500

Please sign in to comment.