Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinsarca committed Jan 7, 2025
1 parent 177e9c0 commit 3181c5c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ protected function __construct(
protected array $anonymous,
)
{
// init built in types
self::$BUILTIN_TYPES ??= self::getBuiltInTypes();
// Set number of tokens
$this->count = count($tokens);
}
Expand Down Expand Up @@ -357,4 +355,9 @@ private static function getBuiltInTypes(): array

return $types;
}

final public static function init(): void
{
self::$BUILTIN_TYPES ??= self::getBuiltInTypes();
}
}
5 changes: 4 additions & 1 deletion src/AnonymousClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
#[Attribute\PreventBoxing]
final class AnonymousClassInfo extends AbstractInfo
{
public const PLACEHOLDER = "\x07{opis\x06class\x05name}\x07";
public const PLACEHOLDER = "\x07opis\x06anonymous@class\x05name\x07";

/**
* @var string Original class namespace
*/
private string $ns;

/**
* @var bool True if class was loaded
*/
private bool $loaded = false;

public function __construct(string $header, string $body, string $ns = '')
Expand Down
2 changes: 0 additions & 2 deletions src/AnonymousClassParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/
final class AnonymousClassParser extends AbstractParser
{
private const MATCH_PARAMS_OR_BODY = ['(', '{'];

private int $last = -1;

protected function __construct(
Expand Down
3 changes: 3 additions & 0 deletions src/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static function init(
}
}

// Init parser
AbstractParser::init();

// Init code stream protocol
CodeStream::init([ClosureInfo::class, AnonymousClassInfo::class]);

Expand Down

0 comments on commit 3181c5c

Please sign in to comment.