diff --git a/.idea/php.xml b/.idea/php.xml index 52a40a49..21198210 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -150,6 +150,8 @@ + + diff --git a/bootstrap.php b/bootstrap.php index f023d7ab..4445932b 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,4 +1,5 @@ logger->info($message, $context); } #[\Override] - public function error(\Stringable|string $message, array $context = []): void + public function error(string|\Stringable $message, array $context = []): void { $this->logger->error($message, $context); } #[\Override] - public function emergency(\Stringable|string $message, array $context = []): void + public function emergency(string|\Stringable $message, array $context = []): void { $this->logger->emergency($message, $context); } #[\Override] - public function alert(\Stringable|string $message, array $context = []): void + public function alert(string|\Stringable $message, array $context = []): void { $this->logger->alert($message, $context); } #[\Override] - public function critical(\Stringable|string $message, array $context = []): void + public function critical(string|\Stringable $message, array $context = []): void { $this->logger->critical($message, $context); } #[\Override] - public function warning(\Stringable|string $message, array $context = []): void + public function warning(string|\Stringable $message, array $context = []): void { $this->logger->warning($message, $context); } #[\Override] - public function notice(\Stringable|string $message, array $context = []): void + public function notice(string|\Stringable $message, array $context = []): void { $this->logger->notice($message, $context); } #[\Override] - public function debug(\Stringable|string $message, array $context = []): void + public function debug(string|\Stringable $message, array $context = []): void { $this->logger->debug($message, $context); } #[\Override] - public function log($level, \Stringable|string $message, array $context = []): void + public function log($level, string|\Stringable $message, array $context = []): void { $this->logger->log($level, $message, $context); } diff --git a/src/Events/External.php b/src/Events/External.php index a3033ab2..cf670ee2 100644 --- a/src/Events/External.php +++ b/src/Events/External.php @@ -1,4 +1,5 @@ $s !== 'null'), $isNullable); } - public function getUnionOrType(): Union|string + public function getUnionOrType(): string|Union { if (count($this->types) > 1) { return new Union($this->types); diff --git a/src/Gateway/Graph/AstVisitor.php b/src/Gateway/Graph/AstVisitor.php index 89379e1e..cf5c7568 100644 --- a/src/Gateway/Graph/AstVisitor.php +++ b/src/Gateway/Graph/AstVisitor.php @@ -308,7 +308,7 @@ private function extractAttributes(Node\AttributeGroup ...$group): array return $attributes; } - private function extractValue(Node\Arg $arg): string|int|float + private function extractValue(Node\Arg $arg): float|int|string { $value = $arg->value; return match (true) { @@ -337,7 +337,7 @@ private function determineKind(): void } private function extractTypes( - null|Node|Node\ComplexType|Node\Identifier|Node\Name|string $node, + Node|Node\ComplexType|Node\Identifier|Node\Name|string|null $node, ): array { $types = match (true) { is_string($node) => [$this->deUse($node)], diff --git a/src/Gateway/Graph/GraphGenerator.php b/src/Gateway/Graph/GraphGenerator.php index d55bc882..53577ab5 100644 --- a/src/Gateway/Graph/GraphGenerator.php +++ b/src/Gateway/Graph/GraphGenerator.php @@ -48,7 +48,7 @@ private function deUse(string $name): string return $this->uses[$name] ?? $name; } - private function extractValue(Node\Arg $arg): string|int|float + private function extractValue(Node\Arg $arg): float|int|string { $value = $arg->value; return match (true) { @@ -79,7 +79,7 @@ private function extractAttributes(Node\AttributeGroup ...$group): array } private function extractTypes( - null|Node|Node\ComplexType|Node\Identifier|Node\Name|string $node, + Node|Node\ComplexType|Node\Identifier|Node\Name|string|null $node, bool $deuse = true, ): string { $uses = $deuse ? $this->deUse(...) : static fn($x) => $x; diff --git a/src/Gateway/Graph/MetaParser.php b/src/Gateway/Graph/MetaParser.php index 7ceaab7f..bd7dca97 100644 --- a/src/Gateway/Graph/MetaParser.php +++ b/src/Gateway/Graph/MetaParser.php @@ -1,4 +1,5 @@ $part) { $lines = implode("\n\t", $part); $typeType = explode(':', $type); - $typeType = trim(end($typeType)); + $typeType = mb_trim(end($typeType)); $final[] = << $part) { $lines = implode("\n\t", $part); $typeType = explode(':', $type); - $typeType = trim(end($typeType)); + $typeType = mb_trim(end($typeType)); if ($this->knownTypes[$typeType] ?? false) { $type = str_replace($typeType, $this->lookupType($typeType)?->getGraphQlType(nullable: true), $type); @@ -164,7 +164,7 @@ public function renderTypes(): string GQL; } - return trim(implode("\n", array_filter($final))) . "\n"; + return mb_trim(implode("\n", array_filter($final))) . "\n"; } public function lookupType(string|Union $type): SchemaRendererInterface|null diff --git a/src/Glue/Provenance.php b/src/Glue/Provenance.php index c7b6128b..fe650f72 100644 --- a/src/Glue/Provenance.php +++ b/src/Glue/Provenance.php @@ -1,4 +1,5 @@ Level::Error, }); -if(($_SERVER['SERVER_PROTOCOL'] ?? null) !== 'DPHP/1.0') { +if (($_SERVER['SERVER_PROTOCOL'] ?? null) !== 'DPHP/1.0') { http_response_code(400); $logger->critical('Invalid request protocol', [$_SERVER['SERVER_PROTOCOL'] ?? null]); die(); diff --git a/src/OrchestrationContext.php b/src/OrchestrationContext.php index 00b24c73..a7759a49 100644 --- a/src/OrchestrationContext.php +++ b/src/OrchestrationContext.php @@ -205,7 +205,7 @@ public function continueAsNew(array $args = []): never throw new Unwind(); } - public function createTimer(DateTimeImmutable|DateInterval $fireAt): DurableFuture + public function createTimer(DateInterval|DateTimeImmutable $fireAt): DurableFuture { if ($fireAt instanceof DateInterval) { $fireAt = $this->getCurrentTime()->add($fireAt); @@ -488,7 +488,7 @@ public function __construct(private OrchestrationContextInterface $context, $log parent::__construct($logger); } - public function debug(Stringable|string $message, array $context = []): void + public function debug(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -497,7 +497,7 @@ public function debug(Stringable|string $message, array $context = []): void parent::debug($message, $context); } - public function critical(Stringable|string $message, array $context = []): void + public function critical(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -505,7 +505,7 @@ public function critical(Stringable|string $message, array $context = []): void parent::critical($message, $context); } - public function warning(Stringable|string $message, array $context = []): void + public function warning(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -514,7 +514,7 @@ public function warning(Stringable|string $message, array $context = []): void parent::warning($message, $context); } - public function info(Stringable|string $message, array $context = []): void + public function info(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -523,7 +523,7 @@ public function info(Stringable|string $message, array $context = []): void parent::info($message, $context); } - public function alert(Stringable|string $message, array $context = []): void + public function alert(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -532,7 +532,7 @@ public function alert(Stringable|string $message, array $context = []): void parent::alert($message, $context); } - public function emergency(Stringable|string $message, array $context = []): void + public function emergency(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -541,7 +541,7 @@ public function emergency(Stringable|string $message, array $context = []): void parent::emergency($message, $context); } - public function notice(Stringable|string $message, array $context = []): void + public function notice(string|Stringable $message, array $context = []): void { if ($this->context->isReplaying()) { return; @@ -564,7 +564,7 @@ public function __construct( $this->history->historicalTaskResults->setCurrentTime(MonotonicClock::current()->now()); } - public function entityOp(string|EntityId $id, Closure $operation): mixed + public function entityOp(EntityId|string $id, Closure $operation): mixed { $func = new ReflectionFunction($operation); if ($func->getNumberOfParameters() !== 1) { diff --git a/src/OrchestrationContextInterface.php b/src/OrchestrationContextInterface.php index 5f7d4f91..56b48952 100644 --- a/src/OrchestrationContextInterface.php +++ b/src/OrchestrationContextInterface.php @@ -76,7 +76,7 @@ public function signalEntity(EntityId $entityId, string $operation, array $args * @param Closure(T): V $operation * @return V */ - public function entityOp(string|EntityId $id, Closure $operation): mixed; + public function entityOp(EntityId|string $id, Closure $operation): mixed; /** * Determines if an entity is locked. Returns true if the entity is locked. diff --git a/src/Proxy/Generator.php b/src/Proxy/Generator.php index 0e19b812..c575540f 100644 --- a/src/Proxy/Generator.php +++ b/src/Proxy/Generator.php @@ -132,7 +132,7 @@ abstract protected function impureSignal(ReflectionMethod $method): string; abstract protected function impureCall(ReflectionMethod $method, bool $isHook = false): string; - protected function getTypes(ReflectionNamedType|ReflectionUnionType|ReflectionIntersectionType|null $type): string + protected function getTypes(ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null $type): string { if ($type instanceof ReflectionNamedType) { $nullable = $type->allowsNull() ? '?' : ''; diff --git a/src/Proxy/ImpureException.php b/src/Proxy/ImpureException.php index 83c3489e..35d1acde 100644 --- a/src/Proxy/ImpureException.php +++ b/src/Proxy/ImpureException.php @@ -1,4 +1,5 @@ name = trim($name); + $this->name = mb_trim($name); if (empty($this->name)) { throw new LogicException('Orchestration name must not be empty'); diff --git a/src/State/EntityHistory.php b/src/State/EntityHistory.php index e4af7e32..b3172f03 100644 --- a/src/State/EntityHistory.php +++ b/src/State/EntityHistory.php @@ -288,7 +288,7 @@ private function finalize(Event $event): Generator $this->history[$event->eventId] = $this->debugHistory ? $event : $now; $this->history = array_filter( $this->history, - static fn(int|bool|Event $value) => is_int($value) ? $value > $cutoff : $value, + static fn(bool|Event|int $value) => is_int($value) ? $value > $cutoff : $value, ); $this->status = $this->status->with(lastUpdated: MonotonicClock::current()->now()); diff --git a/src/State/EntrypointLocatorTrait.php b/src/State/EntrypointLocatorTrait.php index 50d56ad4..1195ba1d 100644 --- a/src/State/EntrypointLocatorTrait.php +++ b/src/State/EntrypointLocatorTrait.php @@ -1,4 +1,5 @@ $future) { // see if we have a match already - if($this->results[$this->getReadKey()] ?? false and $this->results[$this->getReadKey()]->match[$idx] ?? false) { + if ($this->results[$this->getReadKey()] ?? false and $this->results[$this->getReadKey()]->match[$idx] ?? false) { continue; } @@ -212,7 +212,7 @@ private function readFutures(array $futures): array $completedInOrder = []; if (array_key_exists($this->readKey, $this->results)) { - foreach($this->results[$this->readKey]->order as $idx) { + foreach ($this->results[$this->readKey]->order as $idx) { /** @var DurableFuture $handler */ $handler = $futures[$idx]; $result = $this->results[$this->readKey]->match[$idx]; @@ -253,7 +253,7 @@ public function getCurrentTime(): DateTimeImmutable public function isReading(): bool { $this->currentRead ??= 0; - if(++$this->currentRead > $this->readHead) { + if (++$this->currentRead > $this->readHead) { $this->readHead = $this->currentRead; return false; } diff --git a/src/State/Ids/StateId.php b/src/State/Ids/StateId.php index a4839cce..d6ad8192 100644 --- a/src/State/Ids/StateId.php +++ b/src/State/Ids/StateId.php @@ -60,7 +60,7 @@ public static function fromInstance(OrchestrationInstance $instance): self return self::fromArgs(id: "orchestration:{$instance}"); } - public static function fromActivityId(UuidInterface|string $activityId): self + public static function fromActivityId(string|UuidInterface $activityId): self { return self::fromArgs(id: "activity:{$activityId}"); } @@ -154,7 +154,7 @@ public function isOrchestrationId(): bool return str_starts_with($this->id, 'orchestration:'); } - public function __invoke(string|StateId|OrchestrationInstance|EntityId|UuidInterface $id): self + public function __invoke(EntityId|OrchestrationInstance|StateId|string|UuidInterface $id): self { if (is_string($id)) { return new self($id); diff --git a/src/State/OrchestrationHistory.php b/src/State/OrchestrationHistory.php index 5fab49c5..cf91ed39 100644 --- a/src/State/OrchestrationHistory.php +++ b/src/State/OrchestrationHistory.php @@ -152,7 +152,7 @@ private function addEventToHistory(Event $event): void $now = time(); $cutoff = $now - 3600; // 1 hour $this->history[$event->eventId] = $this->debugHistory ? $event : $now; - $this->history = array_filter($this->history, static fn(int|bool|Event $value) => is_int($value) ? $value > $cutoff : $value); + $this->history = array_filter($this->history, static fn(bool|Event|int $value) => is_int($value) ? $value > $cutoff : $value); } public function applyStartOrchestration(StartOrchestration $event, Event $original): Generator diff --git a/src/State/ParameterFillerTrait.php b/src/State/ParameterFillerTrait.php index 20da3989..5d16bf8d 100644 --- a/src/State/ParameterFillerTrait.php +++ b/src/State/ParameterFillerTrait.php @@ -1,4 +1,5 @@ &$entry) { - if(!is_array($entry)) { + foreach ($arguments as $name => &$entry) { + if (!is_array($entry)) { continue; } - if(is_numeric($name)) { + if (is_numeric($name)) { $parameter = $method->getParameters()[$name]; - if($parameter->getType()?->isBuiltin()) { + if ($parameter->getType()?->isBuiltin()) { continue; } $entry = Serializer::deserialize($entry, $parameter->getType()); } else { - foreach($method->getParameters() as $parameter) { + foreach ($method->getParameters() as $parameter) { if ($parameter->getName() === $name) { - if($parameter->getType()?->isBuiltin() && $parameter->getType()?->getName() === 'array') { + if ($parameter->getType()?->isBuiltin() && $parameter->getType()?->getName() === 'array') { // todo: deserialize arrays break; } diff --git a/src/State/ReceivedSet.php b/src/State/ReceivedSet.php index 4a11f0d5..e7678e66 100644 --- a/src/State/ReceivedSet.php +++ b/src/State/ReceivedSet.php @@ -1,4 +1,5 @@ addType($newer->getPhpType(), $newer); - expect(trim($tm->renderTypes()))->toBe( + expect(mb_trim($tm->renderTypes()))->toBe( <<<'GQL' scalar DateTime scalar Void @@ -180,7 +180,7 @@ public function __invoke(OrchestrationContextInterface $context): array $tm = new TypeManager(); $tm->addType($newer->getPhpType(), $newer); - expect(trim($tm->renderTypes()))->toBe( + expect(mb_trim($tm->renderTypes()))->toBe( <<<'GQL' scalar DateTime type Status { @@ -240,7 +240,7 @@ enum RuntimeStatus { $tm->addType($file1->getPhpType(), $file1); $tm->addType($file2->getPhpType(), $file2); - expect(trim($tm->renderTypes()))->toBe( + expect(mb_trim($tm->renderTypes()))->toBe( <<<'GQL' scalar DateTime scalar Void diff --git a/tests/Unit/TypeTests.php b/tests/Unit/TypeTests.php index f52d3d7b..7525e460 100644 --- a/tests/Unit/TypeTests.php +++ b/tests/Unit/TypeTests.php @@ -1,4 +1,5 @@