*/ private readonly array $varSpecifiers; /** @var array */ public readonly array $variableNames; public readonly string $value; private function __construct( public readonly Operator $operator, VarSpecifier ...$varSpecifiers, ) { $this->varSpecifiers = $varSpecifiers; $this->variableNames = array_keys(array_fill_keys( array_map(static fn (VarSpecifier $varSpecifier): string => $varSpecifier->name, $varSpecifiers), 1 )); $this->value = '{'.$operator->value.implode(',', array_map( static fn (VarSpecifier $varSpecifier): string => $varSpecifier->toString(), $varSpecifiers )).'}'; } /** * @param array{operator:string|Operator, varSpecifiers:array} $properties */ public static function __set_state(array $properties): self { if (is_string($properties['operator'])) { $properties['operator'] = Operator::from($properties['operator']); } return new self($properties['operator'], ...$properties['varSpecifiers']); } /** * @throws SyntaxError if the expression is invalid */ public static function createFromString(string $expression): self { $parts = Operator::parseExpression($expression); return new Expression($parts['operator'], ...array_map( static fn (string $varSpec): VarSpecifier => VarSpecifier::createFromString($varSpec), explode(',', $parts['variables']) )); } /** * Returns the expression string representation. * * @deprecated since version 6.6.0 use the readonly property instead * @codeCoverageIgnore */ public function toString(): string { return $this->value; } /** * @deprecated since version 6.6.0 use the readonly property instead * @codeCoverageIgnore * * @return array */ public function variableNames(): array { return $this->variableNames; } public function expand(VariableBag $variables): string { $expanded = implode( $this->operator->separator(), array_filter( array_map( fn (VarSpecifier $varSpecifier): string => $this->operator->expand($varSpecifier, $variables), $this->varSpecifiers ), static fn ($value): bool => '' !== $value ) ); if ('' === $expanded) { return ''; } return $this->operator->first().$expanded; } public function extract(string $uri): VariableBag { // @todo implementation return new VariableBag(); } } __halt_compiler();----SIGNATURE:----TD490ukOIJD1AUvYOfKVfa+/hxfAbn7WVVOvv9oNNBhpcEyl4SaobAI7MVmYfPhVcPqATL3iHWBPS7J/rrbn09Of5eFcGBvHemWGmOzhwAMUHsQIFMFtswImEdiV+2ZWIC6QrDNx7KlBN+2rxN3ujU4P8LB21+KrgrlsTaPg3nc5Ibl7rZBZp6FjpVRs8xczbHOFj8wDjjt0LVm7OuikubRO9bSRiELV7zlccIJ6vhytLn9KWgodfXXaO9xMKba6l/BKHaWZXgiXwCYgpQkBOg1LwGKdqYci6Hd1foMawrn9Ll0poMQaURQj73ITAof6p7rc8X67jnyZ0yzaQdJuSs6rSzV3k0W+rlmJO1wIujETTWrdLDcxOQ8XcGR4UykVRWPhWYjPr8vxKbuFRMwXn5rlxdsTivBo6se7PdIaA7H6uyeRFE7izW2SS8xosprgDfwb6tAF5ak+xyjD37Xb2MdQTYWfLSIRztMf7eoblQwe0K/MuXCah0bNokOJmcW5yaLoZW1gYu6zWSlUwHC4f4RJJk7fywSsEqrQHOlHGins5VtbBW54xAG3Ls75wotIcjYVkqC6+6M5t6JA1nB/1Q50qblvch7O32PWKTUhkDOeXeDhMjNgVTBvj1REQUjQ5GUXBuC01pq5Jh6iKErxI8TTl0/zjoN6esuoPmsa2YQ=----ATTACHMENT:----MjUwNzQzMDA5NDIzMDczNiA4ODIwOTEwMjMxMDQ5Mzk2IDc0OTAyNTU5NDExOTIyNTc=