From 89e9bd75bcdbfd686232c3ac06faac882069eef7 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 6 Sep 2024 12:17:49 +0200 Subject: [PATCH] Use Docker image provided by friends-of-php/php-cs-fixer (#16) Co-authored-by: mpdude --- .github/workflows/fix-cs-php.yml | 4 +++- src/JMS/ObjectRouting/Exception/XmlErrorException.php | 2 +- src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php | 4 ++-- src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php | 2 +- src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php | 2 +- src/JMS/ObjectRouting/ObjectRouter.php | 6 +++--- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/fix-cs-php.yml b/.github/workflows/fix-cs-php.yml index 4e30909..fc9f2bd 100644 --- a/.github/workflows/fix-cs-php.yml +++ b/.github/workflows/fix-cs-php.yml @@ -21,7 +21,9 @@ jobs: ref: ${{ github.head_ref }} - name: Run PHP-CS-Fixer - uses: docker://oskarstark/php-cs-fixer-ga + uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3.62.0-php8.3 + with: + args: "fix --show-progress=dots" - name: Commit and push back changes uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/src/JMS/ObjectRouting/Exception/XmlErrorException.php b/src/JMS/ObjectRouting/Exception/XmlErrorException.php index 0f8499b..30963b8 100644 --- a/src/JMS/ObjectRouting/Exception/XmlErrorException.php +++ b/src/JMS/ObjectRouting/Exception/XmlErrorException.php @@ -21,7 +21,7 @@ public function __construct(\LibXMLError $error) default: $level = 'UNKNOWN'; } - parent::__construct(sprintf('[%s] %s in %s (line: %d, column: %d)', $level, $error->message, $error->file, $error->line, $error->column)); + parent::__construct(\sprintf('[%s] %s in %s (line: %d, column: %d)', $level, $error->message, $error->file, $error->line, $error->column)); $this->xmlError = $error; } diff --git a/src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php b/src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php index 680c197..bcedcba 100644 --- a/src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php +++ b/src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php @@ -33,10 +33,10 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file): { $metadata = require $file; if (!$metadata instanceof ClassMetadata) { - throw new RuntimeException(sprintf('The file %s was expected to return an instance of ClassMetadata, but returned %s.', $file, json_encode($metadata))); + throw new RuntimeException(\sprintf('The file %s was expected to return an instance of ClassMetadata, but returned %s.', $file, json_encode($metadata))); } if ($metadata->name !== $class->name) { - throw new RuntimeException(sprintf('The file %s was expected to return metadata for class %s, but instead returned metadata for class %s.', $class->name, $metadata->name)); + throw new RuntimeException(\sprintf('The file %s was expected to return metadata for class %s, but instead returned metadata for class %s.', $class->name, $metadata->name)); } return $metadata; diff --git a/src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php b/src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php index bd0b4c2..1c90159 100644 --- a/src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php +++ b/src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php @@ -45,7 +45,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file): } $metadata = new ClassMetadata($name = $class->name); if (!$elems = $elem->xpath("./class[@name = '".$name."']")) { - throw new RuntimeException(sprintf('Could not find class %s inside XML element.', $name)); + throw new RuntimeException(\sprintf('Could not find class %s inside XML element.', $name)); } $elem = reset($elems); $metadata->fileResources[] = $file; diff --git a/src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php b/src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php index e627221..6951025 100644 --- a/src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php +++ b/src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php @@ -40,7 +40,7 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file): $config = Yaml::parse(file_get_contents($file)); if (!isset($config[$name = $class->name])) { - throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)); + throw new RuntimeException(\sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file)); } $config = $config[$name]; diff --git a/src/JMS/ObjectRouting/ObjectRouter.php b/src/JMS/ObjectRouting/ObjectRouter.php index 55204c6..9bd2a6a 100644 --- a/src/JMS/ObjectRouting/ObjectRouter.php +++ b/src/JMS/ObjectRouting/ObjectRouter.php @@ -65,17 +65,17 @@ public function __construct(RouterInterface $router, MetadataFactoryInterface $m public function generate($type, $object, $absolute = false, array $extraParams = []) { if (!\is_object($object)) { - throw new \InvalidArgumentException(sprintf('$object must be an object, but got "%s".', \gettype($object))); + throw new \InvalidArgumentException(\sprintf('$object must be an object, but got "%s".', \gettype($object))); } /** @var $metadata ClassMetadata */ $metadata = $this->metadataFactory->getMetadataForClass($object::class); if (null === $metadata) { - throw new \RuntimeException(sprintf('There were no object routes defined for class "%s".', $object::class)); + throw new \RuntimeException(\sprintf('There were no object routes defined for class "%s".', $object::class)); } if (!isset($metadata->routes[$type])) { - throw new \RuntimeException(sprintf('The object of class "%s" has no route with type "%s". Available types: %s', $object::class, $type, implode(', ', array_keys($metadata->routes)))); + throw new \RuntimeException(\sprintf('The object of class "%s" has no route with type "%s". Available types: %s', $object::class, $type, implode(', ', array_keys($metadata->routes)))); } $route = $metadata->routes[$type];