Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Docker image provided by friends-of-php/php-cs-fixer #16

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/fix-cs-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/JMS/ObjectRouting/Exception/XmlErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions src/JMS/ObjectRouting/ObjectRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down