Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use PHP 8.1 syntax #32

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Extension/EscaperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class EscaperExtension implements ExtensionInterface
{
private Escaper $escaper;
private readonly Escaper $escaper;

public function __construct(?string $encoding = null)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Extension/UrlExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
/** @psalm-import-type UrlGeneratorOptions from UrlHelperInterface */
class UrlExtension implements ExtensionInterface
{
public function __construct(private UrlHelper $urlHelper, private ServerUrlHelper $serverUrlHelper)
{
public function __construct(
private readonly UrlHelper $urlHelper,
private readonly ServerUrlHelper $serverUrlHelper
) {
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/PlatesRendererFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getConfigurationPaths(): array

public function assertPathsHasNamespace(?string $namespace, array $paths, ?string $message = null): void
{
$message = $message ?? sprintf('Paths do not contain namespace %s', $namespace ?? 'null');
$message ??= sprintf('Paths do not contain namespace %s', $namespace ?? 'null');

$found = false;
foreach ($paths as $path) {
Expand All @@ -80,7 +80,7 @@ public function assertPathNamespaceCount(
array $paths,
?string $message = null
): void {
$message = $message ?? sprintf('Did not find %d paths with namespace %s', $expected, $namespace ?? 'null');
$message ??= sprintf('Did not find %d paths with namespace %s', $expected, $namespace ?? 'null');

$count = 0;
foreach ($paths as $path) {
Expand All @@ -98,7 +98,7 @@ public function assertPathNamespaceContains(
array $paths,
?string $message = null
): void {
$message = $message ?? sprintf('Did not find path %s in namespace %s', $expected, $namespace ?? '');
$message ??= sprintf('Did not find path %s in namespace %s', $expected, $namespace ?? '');

$found = [];
foreach ($paths as $path) {
Expand Down
10 changes: 5 additions & 5 deletions test/PlatesRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public function setUp(): void

public function assertTemplatePath(string $path, TemplatePath $templatePath, ?string $message = null): void
{
$message = $message ?? sprintf('Failed to assert TemplatePath contained path %s', $path);
$message ??= sprintf('Failed to assert TemplatePath contained path %s', $path);
$this->assertEquals($path, $templatePath->getPath(), $message);
}

public function assertTemplatePathString(string $path, TemplatePath $templatePath, ?string $message = null): void
{
$message = $message ?? sprintf('Failed to assert TemplatePath casts to string path %s', $path);
$message ??= sprintf('Failed to assert TemplatePath casts to string path %s', $path);
$this->assertEquals($path, (string) $templatePath, $message);
}

Expand All @@ -52,7 +52,7 @@ public function assertTemplatePathNamespace(
TemplatePath $templatePath,
?string $message = null
): void {
$message = $message ?? sprintf(
$message ??= sprintf(
'Failed to assert TemplatePath namespace matched %s',
var_export($namespace, true)
);
Expand All @@ -61,7 +61,7 @@ public function assertTemplatePathNamespace(

public function assertEmptyTemplatePathNamespace(TemplatePath $templatePath, ?string $message = null): void
{
$message = $message ?? 'Failed to assert TemplatePath namespace was empty';
$message ??= 'Failed to assert TemplatePath namespace was empty';
$this->assertEmpty($templatePath->getNamespace(), $message);
}

Expand All @@ -70,7 +70,7 @@ public function assertEqualTemplatePath(
TemplatePath $received,
?string $message = null
): void {
$message = $message ?? 'Failed to assert TemplatePaths are equal';
$message ??= 'Failed to assert TemplatePaths are equal';
if (
$expected->getPath() !== $received->getPath()
|| $expected->getNamespace() !== $received->getNamespace()
Expand Down