diff --git a/tests/aot/symfony/cache-static-coalesce-negation-precedence.phpt b/tests/aot/symfony/cache-static-coalesce-negation-precedence.phpt new file mode 100644 index 00000000..7b6a57c7 --- /dev/null +++ b/tests/aot/symfony/cache-static-coalesce-negation-precedence.phpt @@ -0,0 +1,37 @@ +--TEST-- +Symfony Cache style negated static coalesce assignment condition +--FILE-- + +--EXPECT-- +string(8) "fallback" +string(8) "fallback" +int(1) diff --git a/tests/aot/symfony/serializer-array-map-strval-first-class.phpt b/tests/aot/symfony/serializer-array-map-strval-first-class.phpt new file mode 100644 index 00000000..b152c53f --- /dev/null +++ b/tests/aot/symfony/serializer-array-map-strval-first-class.phpt @@ -0,0 +1,57 @@ +--TEST-- +Symfony Serializer style array_map(strval(...)) with Stringable values +--FILE-- +name; + } +} + +class SymfonyNotNormalizableValueCase extends RuntimeException +{ + private ?array $expectedTypes; + + public function __construct(?array $expectedTypes = null) + { + parent::__construct('not normalizable'); + + $this->expectedTypes = $expectedTypes ? array_map(strval(...), $expectedTypes) : $expectedTypes; + } + + public function getExpectedTypes(): ?array + { + return $this->expectedTypes; + } +} + +function main(): void +{ + $exception = new SymfonyNotNormalizableValueCase([ + 'int', + new SymfonyExpectedTypeName('uuid'), + 'array', + ]); + + var_dump($exception->getExpectedTypes()); + + $empty = new SymfonyNotNormalizableValueCase(); + var_dump($empty->getExpectedTypes()); +} +?> +--EXPECT-- +array(3) { + [0]=> + string(3) "int" + [1]=> + string(9) "type:uuid" + [2]=> + string(5) "array" +} +NULL diff --git a/tests/aot/symfony/service-locator-match-count-unpack.phpt b/tests/aot/symfony/service-locator-match-count-unpack.phpt new file mode 100644 index 00000000..478af94b --- /dev/null +++ b/tests/aot/symfony/service-locator-match-count-unpack.phpt @@ -0,0 +1,79 @@ +--TEST-- +Symfony ServiceLocator style match count with closure unpack +--FILE-- +serviceMap[$id] ?? [])) { + 0 => parent::get($id), + 1 => $this->serviceMap[$id][0], + default => ($this->factory)(...$this->serviceMap[$id]), + }; + } + + public function getProvidedServices(): array + { + return $this->serviceTypes ??= array_map(static fn () => '?', $this->serviceMap); + } +} + +function main(): void +{ + $locator = new SymfonyServiceLocatorCase( + static fn (string $class, string $method): string => $class . '::' . $method, + [ + 'missing' => [], + 'single' => ['ready'], + 'factory' => ['App\Service', 'build'], + ] + ); + + var_dump($locator->get('missing')); + var_dump($locator->get('single')); + var_dump($locator->get('factory')); + var_dump($locator->getProvidedServices()); + var_dump($locator->getProvidedServices()); +} +?> +--EXPECT-- +string(14) "parent:missing" +string(5) "ready" +string(18) "App\Service::build" +array(3) { + ["missing"]=> + string(1) "?" + ["single"]=> + string(1) "?" + ["factory"]=> + string(1) "?" +} +array(3) { + ["missing"]=> + string(1) "?" + ["single"]=> + string(1) "?" + ["factory"]=> + string(1) "?" +} diff --git a/tests/aot/symfony/workflow-array-dim-coalesce-assign-op.phpt b/tests/aot/symfony/workflow-array-dim-coalesce-assign-op.phpt new file mode 100644 index 00000000..ab2fc33c --- /dev/null +++ b/tests/aot/symfony/workflow-array-dim-coalesce-assign-op.phpt @@ -0,0 +1,54 @@ +--TEST-- +Symfony Workflow style array dim coalesce assignment followed by assign-op +--FILE-- + $nbToken) { + $this->mark($place, $nbToken); + } + } + + public function mark(string $place, int $nbToken = 1): void + { + if ($nbToken < 1) { + throw new InvalidArgumentException(sprintf('The number of tokens must be greater than 0, "%s" given.', $nbToken)); + } + + $this->places[$place] ??= 0; + $this->places[$place] += $nbToken; + } + + public function getPlaces(): array + { + return $this->places; + } +} + +function main(): void +{ + $marking = new SymfonyWorkflowMarkingCase(['draft' => 1]); + $marking->mark('draft', 2); + $marking->mark('review', 3); + + var_dump($marking->getPlaces()); + + try { + $marking->mark('invalid', 0); + } catch (InvalidArgumentException $e) { + echo $e->getMessage(), "\n"; + } +} +?> +--EXPECT-- +array(2) { + ["draft"]=> + int(3) + ["review"]=> + int(3) +} +The number of tokens must be greater than 0, "0" given.