Skip to content

Commit 6d8d1e3

Browse files
committed
Simplify property memoization for Flyweight pattern by replacing it with ??=
1 parent 3c4bcf2 commit 6d8d1e3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Type/Regex/RegexGroupParser.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ public function __construct(
5353

5454
public function parseGroups(string $regex): ?RegexAstWalkResult
5555
{
56-
if (self::$parser === null) {
57-
/** @throws void */
58-
self::$parser = Llk::load(new Read(__DIR__ . '/../../../resources/RegexGrammar.pp'));
59-
}
56+
/** @throws void */
57+
self::$parser ??= Llk::load(new Read(__DIR__ . '/../../../resources/RegexGrammar.pp'));
6058

6159
try {
6260
Strings::match('', $regex);

0 commit comments

Comments
 (0)