From 11fe596b0cf4723e32559d14891996ea1384eb05 Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Tue, 7 May 2024 23:30:22 +0200 Subject: [PATCH] Revert "minor - fix allergy for type casting" This reverts commit cd2adad5943ccc3fcf6841d0ce06b74ffedbcc8c. --- src/Runner/Parallel/ParallelisationException.php | 2 +- src/Runner/Parallel/ProcessFactory.php | 2 +- src/Runner/Parallel/ProcessPool.php | 10 +++++----- tests/Runner/Parallel/ParallelisationExceptionTest.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Runner/Parallel/ParallelisationException.php b/src/Runner/Parallel/ParallelisationException.php index 6c40a48d153..28a4b8ab9b7 100644 --- a/src/Runner/Parallel/ParallelisationException.php +++ b/src/Runner/Parallel/ParallelisationException.php @@ -25,7 +25,7 @@ final class ParallelisationException extends \RuntimeException { public static function forUnknownIdentifier(ProcessIdentifier $identifier): self { - return new self(sprintf('Unknown process identifier: %s.', $identifier->__toString())); + return new self('Unknown process identifier: '.(string) $identifier); } /** diff --git a/src/Runner/Parallel/ProcessFactory.php b/src/Runner/Parallel/ProcessFactory.php index 20426e5fa7b..d737b5c3880 100644 --- a/src/Runner/Parallel/ProcessFactory.php +++ b/src/Runner/Parallel/ProcessFactory.php @@ -80,7 +80,7 @@ public function getCommandArgs(int $serverPort, ProcessIdentifier $identifier, R '--port', (string) $serverPort, '--identifier', - escapeshellarg($identifier->__toString()), + escapeshellarg((string) $identifier), ]; if ($runnerConfig->isDryRun()) { diff --git a/src/Runner/Parallel/ProcessPool.php b/src/Runner/Parallel/ProcessPool.php index 02b8431ab1b..d48f9edcd18 100644 --- a/src/Runner/Parallel/ProcessPool.php +++ b/src/Runner/Parallel/ProcessPool.php @@ -45,21 +45,21 @@ public function __construct(ServerInterface $server, ?callable $onServerClose = public function getProcess(ProcessIdentifier $identifier): Process { - if (!isset($this->processes[$identifier->__toString()])) { + if (!isset($this->processes[(string) $identifier])) { throw ParallelisationException::forUnknownIdentifier($identifier); } - return $this->processes[$identifier->__toString()]; + return $this->processes[(string) $identifier]; } public function addProcess(ProcessIdentifier $identifier, Process $process): void { - $this->processes[$identifier->__toString()] = $process; + $this->processes[(string) $identifier] = $process; } public function endProcessIfKnown(ProcessIdentifier $identifier): void { - if (!isset($this->processes[$identifier->__toString()])) { + if (!isset($this->processes[(string) $identifier])) { return; } @@ -77,7 +77,7 @@ private function endProcess(ProcessIdentifier $identifier): void { $this->getProcess($identifier)->quit(); - unset($this->processes[$identifier->__toString()]); + unset($this->processes[(string) $identifier]); if (0 === \count($this->processes)) { $this->server->close(); diff --git a/tests/Runner/Parallel/ParallelisationExceptionTest.php b/tests/Runner/Parallel/ParallelisationExceptionTest.php index 134932b7afe..b3e8f83601f 100644 --- a/tests/Runner/Parallel/ParallelisationExceptionTest.php +++ b/tests/Runner/Parallel/ParallelisationExceptionTest.php @@ -30,7 +30,7 @@ public function testCreateForUnknownIdentifier(): void $identifier = ProcessIdentifier::fromRaw('php-cs-fixer_parallel_foo'); $exception = ParallelisationException::forUnknownIdentifier($identifier); - self::assertSame('Unknown process identifier: php-cs-fixer_parallel_foo.', $exception->getMessage()); + self::assertSame('Unknown process identifier: php-cs-fixer_parallel_foo', $exception->getMessage()); self::assertSame(0, $exception->getCode()); }