Skip to content

Commit

Permalink
Fix CS with PHP-CS-Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude authored and github-actions[bot] committed Jul 1, 2024
1 parent 79882cc commit f83c30a
Show file tree
Hide file tree
Showing 24 changed files with 159 additions and 149 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"8.3.8","version":"3.59.3","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"single_line":true},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"function_declaration":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_hidden_params":true,"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration":true,"nullable_type_declaration_for_default_null_value":true,"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"ordered_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"php_unit_fqcn_annotation":true,"phpdoc_align":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":{"skip_unlisted_annotations":true},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"array_indentation":true,"cast_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_push":true,"combine_nested_dirname":true,"dir_constant":true,"ereg_to_preg":true,"error_suppression":true,"fopen_flag_order":true,"fopen_flags":{"b_mode":false},"function_to_constant":true,"get_class_to_class_keyword":true,"implode_call":true,"is_null":true,"logical_operators":true,"long_to_shorthand_operator":true,"modernize_strpos":true,"modernize_types_casting":true,"native_constant_invocation":{"strict":false},"native_function_invocation":{"include":["@compiler_optimized"],"scope":"namespaced","strict":true},"no_alias_functions":true,"no_homoglyph_names":true,"no_php4_constructor":true,"no_unneeded_final_method":true,"no_useless_sprintf":true,"non_printable_character":true,"ordered_traits":true,"php_unit_construct":true,"php_unit_mock_short_will_return":true,"php_unit_set_up_tear_down_visibility":true,"php_unit_test_annotation":{"style":"annotation"},"self_accessor":true,"set_type_to_cast":true,"string_length_to_empty":true,"string_line_ending":true,"ternary_to_elvis_operator":true,"pow_to_exponentiation":true,"no_trailing_whitespace_in_string":true,"braces":{"allow_single_line_closure":true}},"hashes":{"src\/JMS\/ObjectRouting\/ObjectRouter.php":"28b20b7a7b8ab6f47600449807c59b4f","src\/JMS\/ObjectRouting\/Attribute\/ObjectRoute.php":"c21d2ee5f0476efd8567a03f75036248","src\/JMS\/ObjectRouting\/Exception\/RuntimeException.php":"6e2821a77a207e98a5b665ceb50146e2","src\/JMS\/ObjectRouting\/Exception\/Exception.php":"2da3b5414a5631f767c6ac63f9c81d23","src\/JMS\/ObjectRouting\/Exception\/XmlErrorException.php":"8c1cf2073ffbb285439038df05b022d2","src\/JMS\/ObjectRouting\/Metadata\/Driver\/XmlDriver.php":"ccdbaf104a07c41d17c2c288ac1e3731","src\/JMS\/ObjectRouting\/Metadata\/Driver\/PhpDriver.php":"8353e4d0be48e9e529b74d75936a553e","src\/JMS\/ObjectRouting\/Metadata\/Driver\/AttributeDriver.php":"f97675b0ec3d6e1d202e5b53917f34fc","src\/JMS\/ObjectRouting\/Metadata\/Driver\/YamlDriver.php":"0fc88b0d1a68652c04c94754f7fe4c59","src\/JMS\/ObjectRouting\/Metadata\/ClassMetadata.php":"9cb90afe0e92602637d10608d25281cb","src\/JMS\/ObjectRouting\/Twig\/RoutingExtension.php":"8eccb83032ac318a3904670f6af9064f","src\/JMS\/ObjectRouting\/RouterInterface.php":"e0a4222cc5ee68cc7001d4c93cb19a76","src\/JMS\/ObjectRouting\/Symfony\/Symfony22Adapter.php":"888661f26ec2a24c021726a7289c299e","tests\/bootstrap.php":"94c5fde333ebff7dbc0c7769f0c3ef20","tests\/JMS\/Tests\/ObjectRouting\/Resources\/config\/JMS.Tests.ObjectRouting.Metadata.Driver.Fixture.BlogPost.php":"55c2abfa1bb8e02bc0e4e1aa80d2d42f","tests\/JMS\/Tests\/ObjectRouting\/ObjectRouterTest.php":"799a001d8487813f813dae79919d8a6e","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/PhpDriverTest.php":"2767b53353b0bf6c72127efb9d591855","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/AttributeDriverTest.php":"0cc46fbe228e4126a465377b91e835cd","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/Fixture\/BlogPostWithAttributes.php":"aaf1b32a0c3d4304ddba2132ddb501d7","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/Fixture\/BlogPost.php":"99d1bd67a0b641012ca71e0fd3ab7174","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/XmlDriverTest.php":"15fea5da3b0762f1496dc219573f236b","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/Driver\/YamlDriverTest.php":"081fc99cb8050c3eee1b92feee3ce174","tests\/JMS\/Tests\/ObjectRouting\/Metadata\/ClassMetadataTest.php":"4da1e2dc51cc28c7d30317d288b76e6c","tests\/JMS\/Tests\/ObjectRouting\/Symfony\/Symfony22AdapterTest.php":"6c6806ee90a05d06fb1f40f857648c23"}}
8 changes: 4 additions & 4 deletions src/JMS/ObjectRouting/Attribute/ObjectRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

/*
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -28,7 +28,7 @@ final class ObjectRoute
public $name;

/** @var array */
public $params = array();
public $params = [];

public function __construct(string $type, string $name, array $params = [])
{
Expand Down
4 changes: 1 addition & 3 deletions src/JMS/ObjectRouting/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace JMS\ObjectRouting\Exception;


interface Exception
{

}
}
4 changes: 1 addition & 3 deletions src/JMS/ObjectRouting/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace JMS\ObjectRouting\Exception;


class RuntimeException extends \RuntimeException implements Exception
{

}
}
9 changes: 4 additions & 5 deletions src/JMS/ObjectRouting/Exception/XmlErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

namespace JMS\ObjectRouting\Exception;


class XmlErrorException extends RuntimeException
{
private $xmlError;

public function __construct(\LibXMLError $error)
{
switch ($error->level) {
case LIBXML_ERR_WARNING:
case \LIBXML_ERR_WARNING:
$level = 'WARNING';
break;
case LIBXML_ERR_FATAL:
case \LIBXML_ERR_FATAL:
$level = 'FATAL';
break;
case LIBXML_ERR_ERROR:
case \LIBXML_ERR_ERROR:
$level = 'ERROR';
break;
default:
Expand All @@ -30,4 +29,4 @@ public function getXmlError()
{
return $this->xmlError;
}
}
}
21 changes: 10 additions & 11 deletions src/JMS/ObjectRouting/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

/*
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -23,14 +23,14 @@

class ClassMetadata extends MergeableClassMetadata
{
public $routes = array();
public $routes = [];

public function addRoute($type, $name, array $params = array())
public function addRoute($type, $name, array $params = [])
{
$this->routes[$type] = array(
$this->routes[$type] = [
'name' => $name,
'params' => $params,
);
];
}

public function merge(MergeableInterface $object): void
Expand All @@ -42,10 +42,10 @@ public function merge(MergeableInterface $object): void
public function serialize(): string
{
return serialize(
array(
[
$this->routes,
parent::serialize(),
)
]
);
}

Expand All @@ -54,9 +54,8 @@ public function unserialize($str): void
list(
$this->routes,
$parentStr
) = unserialize($str);
) = unserialize($str);

parent::unserialize($parentStr);
}

}
6 changes: 3 additions & 3 deletions src/JMS/ObjectRouting/Metadata/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

/*
* Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down
5 changes: 2 additions & 3 deletions src/JMS/ObjectRouting/Metadata/Driver/PhpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

namespace JMS\ObjectRouting\Metadata\Driver;


use JMS\ObjectRouting\Exception\RuntimeException;
use JMS\ObjectRouting\Metadata\ClassMetadata;
use Metadata\Driver\AbstractFileDriver;

/**
* Class PhpDriver
* @package JMS\ObjectRouting\Metadata\Driver
* Class PhpDriver.
*
* @author Sebastian Kroczek <sk@xbug.de>
*/
class PhpDriver extends AbstractFileDriver
Expand Down
23 changes: 8 additions & 15 deletions src/JMS/ObjectRouting/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,21 @@

namespace JMS\ObjectRouting\Metadata\Driver;


use JMS\ObjectRouting\Exception\RuntimeException;
use JMS\ObjectRouting\Exception\XmlErrorException;
use JMS\ObjectRouting\Metadata\ClassMetadata;
use Metadata\Driver\AbstractFileDriver;

/**
* Class XmlDriver
* @package JMS\ObjectRouting\Metadata\Driver
* Class XmlDriver.
*
* @author Sebastian Kroczek <sk@xbug.de>
*/
class XmlDriver extends AbstractFileDriver
{

/**
* Parses the content of the file, and converts it to the desired metadata.
*
* @param \ReflectionClass $class
* @param string $file
*
* @return \Metadata\ClassMetadata|null
*/
protected function loadMetadataFromFile(\ReflectionClass $class, string $file): ?ClassMetadata
Expand All @@ -57,23 +52,23 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file):
$metadata->fileResources[] = $class->getFileName();

if (null !== $xmlRootName = $elem->attributes()->{'xml-root-name'}) {
$metadata->xmlRootName = (string)$xmlRootName;
$metadata->xmlRootName = (string) $xmlRootName;
}
if (null !== $xmlRootNamespace = $elem->attributes()->{'xml-root-namespace'}) {
$metadata->xmlRootNamespace = (string)$xmlRootNamespace;
$metadata->xmlRootNamespace = (string) $xmlRootNamespace;
}

foreach ($elem->xpath('./route') as $r) {
if ('' === $type = (string)$r->attributes()->{'type'}) {
if ('' === $type = (string) $r->attributes()->{'type'}) {
throw new RuntimeException('Could not find attribute "type" inside XML element.');
}
if ('' === $name = (string)$r->attributes()->{'name'}) {
if ('' === $name = (string) $r->attributes()->{'name'}) {
throw new RuntimeException('Could not find attribute "name" inside XML element.');
}

$params = array();
$params = [];
foreach ($r->xpath('./param') as $p) {
$params[(string)$p->attributes()] = (string)$p;
$params[(string) $p->attributes()] = (string) $p;
}

$metadata->addRoute($type, $name, $params);
Expand All @@ -84,8 +79,6 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file):

/**
* Returns the extension of the file.
*
* @return string
*/
protected function getExtension(): string
{
Expand Down
17 changes: 4 additions & 13 deletions src/JMS/ObjectRouting/Metadata/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,15 @@
use Symfony\Component\Yaml\Yaml;

/**
* Class YamlDriver
* @package JMS\ObjectRouting\Metadata\Driver
* Class YamlDriver.
*
* @author Sebastian Kroczek <sk@xbug.de>
*/
class YamlDriver extends AbstractFileDriver
{


/**
* Parses the content of the file, and converts it to the desired metadata.
*
* @param \ReflectionClass $class
* @param string $file
*
* @return \Metadata\ClassMetadata|null
*/
protected function loadMetadataFromFile(\ReflectionClass $class, string $file): ?ClassMetadata
Expand All @@ -48,27 +43,23 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file):
throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file));
}


$config = $config[$name];
$metadata = new ClassMetadata($name);
$metadata->fileResources[] = $file;
$metadata->fileResources[] = $class->getFileName();

foreach ($config as $type => $value) {
if (!array_key_exists('name', $value)) {
if (!\array_key_exists('name', $value)) {
throw new RuntimeException('Could not find key "type" inside yaml element.');
}
$metadata->addRoute($type, $value['name'], array_key_exists('params', $value) ? $value['params'] : array());
$metadata->addRoute($type, $value['name'], \array_key_exists('params', $value) ? $value['params'] : []);
}

return $metadata;

}

/**
* Returns the extension of the file.
*
* @return string
*/
protected function getExtension(): string
{
Expand Down
Loading

0 comments on commit f83c30a

Please sign in to comment.