Skip to content

Commit 623e0c9

Browse files
committed
php style fixes, pt 2
1 parent dafea34 commit 623e0c9

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

phpstan.neon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ parameters:
66
treatPhpDocTypesAsCertain: false
77
excludePaths:
88
analyse:
9-
- tests/*
9+
- tests/*
10+
- src/Twig/*

src/Laravel/DotCmsHelpers.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ public function htmlAttr(array $attrs): string
5959
*/
6060
public function rewriteContainerIdentifier(ContainerRef $containerRef, string $newHost): ContainerRef
6161
{
62-
if (isset($containerRef->identifier)) {
63-
$containerRef->identifier = str_replace('//demo.dotcms.com/', "//$newHost/", $containerRef->identifier);
62+
// Since ContainerRef properties are readonly, we need to create a new instance
63+
$newIdentifier = $containerRef->identifier;
64+
if ($newIdentifier !== '') {
65+
$newIdentifier = str_replace('//demo.dotcms.com/', "//$newHost/", $newIdentifier);
6466
}
6567

66-
return $containerRef;
68+
return new ContainerRef(
69+
identifier: $newIdentifier,
70+
uuid: $containerRef->uuid,
71+
historyUUIDs: $containerRef->historyUUIDs,
72+
contentlets: $containerRef->contentlets,
73+
acceptTypes: $containerRef->acceptTypes,
74+
maxContentlets: $containerRef->maxContentlets,
75+
variantId: $containerRef->variantId,
76+
);
6777
}
6878
}

src/Twig/DotCMSExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public function __construct(
1919
) {
2020
}
2121

22+
/**
23+
* @return array<TwigFunction>
24+
*/
2225
public function getFunctions(): array
2326
{
2427
return [

0 commit comments

Comments
 (0)