3a6fb9f08766f06e9d6de4ecb2ea3bbc6e992e03
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 declare(strict_types=1);
4
5 namespace CuyZ\Valinor\Definition\Repository\Cache\Compiler;
6
7 use CuyZ\Valinor\Definition\PropertyDefinition;
8
9 /** @internal */
10 final class PropertyDefinitionCompiler
11 {
12 public function __construct(
13 private TypeCompiler $typeCompiler,
14 private AttributesCompiler $attributesCompiler
15 ) {}
16
17 public function compile(PropertyDefinition $property): string
18 {
19 $type = $this->typeCompiler->compile($property->type());
20 $hasDefaultValue = var_export($property->hasDefaultValue(), true);
21 $defaultValue = var_export($property->defaultValue(), true);
22 $isPublic = var_export($property->isPublic(), true);
23 $attributes = $this->attributesCompiler->compile($property->attributes());
24
25 return <<<PHP
26 new \CuyZ\Valinor\Definition\PropertyDefinition(
27 '{$property->name()}',
28 '{$property->signature()}',
29 $type,
30 $hasDefaultValue,
31 $defaultValue,
32 $isPublic,
33 $attributes
34 )
35 PHP;
36 }
37 }