Skip to content

Commit e1cdb78

Browse files
authored
Merge pull request #32 from samsonasik/update-to-php81-syntax
Update to use PHP 8.1 syntax
2 parents efce32b + deec483 commit e1cdb78

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/Extension/EscaperExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class EscaperExtension implements ExtensionInterface
1212
{
13-
private Escaper $escaper;
13+
private readonly Escaper $escaper;
1414

1515
public function __construct(?string $encoding = null)
1616
{

src/Extension/UrlExtension.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
/** @psalm-import-type UrlGeneratorOptions from UrlHelperInterface */
1515
class UrlExtension implements ExtensionInterface
1616
{
17-
public function __construct(private UrlHelper $urlHelper, private ServerUrlHelper $serverUrlHelper)
18-
{
17+
public function __construct(
18+
private readonly UrlHelper $urlHelper,
19+
private readonly ServerUrlHelper $serverUrlHelper
20+
) {
1921
}
2022

2123
/**

test/PlatesRendererFactoryTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getConfigurationPaths(): array
6161

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

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

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

103103
$found = [];
104104
foreach ($paths as $path) {

test/PlatesRendererTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public function setUp(): void
3737

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

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

@@ -52,7 +52,7 @@ public function assertTemplatePathNamespace(
5252
TemplatePath $templatePath,
5353
?string $message = null
5454
): void {
55-
$message = $message ?? sprintf(
55+
$message ??= sprintf(
5656
'Failed to assert TemplatePath namespace matched %s',
5757
var_export($namespace, true)
5858
);
@@ -61,7 +61,7 @@ public function assertTemplatePathNamespace(
6161

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

@@ -70,7 +70,7 @@ public function assertEqualTemplatePath(
7070
TemplatePath $received,
7171
?string $message = null
7272
): void {
73-
$message = $message ?? 'Failed to assert TemplatePaths are equal';
73+
$message ??= 'Failed to assert TemplatePaths are equal';
7474
if (
7575
$expected->getPath() !== $received->getPath()
7676
|| $expected->getNamespace() !== $received->getNamespace()

0 commit comments

Comments
 (0)