diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 497b16f..b3a5b54 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -25,6 +25,10 @@ 'backtick_to_shell_exec' => true, 'binary_operator_spaces' => [ 'operators' => [ + '*=' => 'align_single_space_minimal', + '+=' => 'align_single_space_minimal', + '-=' => 'align_single_space_minimal', + '/=' => 'align_single_space_minimal', '=' => 'align_single_space_minimal', '=>' => 'align_single_space_minimal', ], @@ -57,6 +61,14 @@ 'yield_from', ], ], + 'blank_lines_before_namespace' => [ + 'max_line_breaks' => 1, + 'min_line_breaks' => 0, + ], + 'braces_position' => [ + 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end', + 'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end', + ], 'cast_spaces' => true, 'class_attributes_separation' => [ 'elements' => [ @@ -70,15 +82,11 @@ 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'combine_nested_dirname' => true, - 'compact_nullable_typehint' => true, + 'compact_nullable_type_declaration' => true, 'concat_space' => ['spacing' => 'one'], 'constant_case' => true, 'control_structure_braces' => true, 'control_structure_continuation_position' => true, - 'curly_braces_position' => [ - 'anonymous_functions_opening_brace' => 'next_line_unless_newline_at_signature_end', - 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end', - ], 'declare_equal_normalize' => ['space' => 'none'], 'declare_parentheses' => true, 'declare_strict_types' => true, @@ -94,7 +102,6 @@ 'fully_qualified_strict_types' => true, 'function_declaration' => true, 'function_to_constant' => true, - 'function_typehint_space' => true, 'get_class_to_class_keyword' => true, 'global_namespace_import' => [ 'import_classes' => true, @@ -106,9 +113,10 @@ 'implode_call' => true, 'include' => true, 'increment_style' => [ - 'style' => PhpCsFixer\Fixer\Operator\IncrementStyleFixer::STYLE_POST, + 'style' => 'post', ], 'indentation_type' => true, + 'integer_literal_case' => true, 'is_null' => true, 'lambda_not_used_import' => true, 'line_ending' => true, @@ -122,6 +130,8 @@ 'method_argument_space' => [ 'on_multiline' => 'ensure_fully_multiline', ], + 'method_chaining_indentation' => true, + 'modernize_strpos' => true, 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => true, @@ -132,10 +142,10 @@ '@internal', ], ], - 'native_function_type_declaration_casing' => true, - 'new_with_braces' => [ - 'named_class' => false, + 'native_type_declaration_casing' => true, + 'new_with_parentheses' => [ 'anonymous_class' => false, + 'named_class' => false, ], 'no_alias_functions' => true, 'no_alias_language_construct_call' => true, @@ -143,7 +153,6 @@ 'no_binary_string' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_before_namespace' => true, 'no_break_comment' => true, 'no_closing_tag' => true, 'no_empty_comment' => true, @@ -154,15 +163,15 @@ 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_mixed_echo_print' => ['use' => 'print'], - 'no_multiple_statements_per_line' => true, 'no_multiline_whitespace_around_double_arrow' => true, + 'no_multiple_statements_per_line' => true, 'no_null_property_initialization' => true, 'no_php4_constructor' => true, 'no_short_bool_cast' => true, 'no_singleline_whitespace_before_semicolons' => true, + 'no_space_around_double_colon' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => true, - 'no_spaces_inside_parenthesis' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => [ 'allow_mixed' => true, @@ -171,15 +180,17 @@ 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_trailing_whitespace_in_string' => true, + 'no_unneeded_braces' => true, 'no_unneeded_control_parentheses' => true, - 'no_unneeded_curly_braces' => true, 'no_unneeded_final_method' => true, 'no_unneeded_import_alias' => true, 'no_unreachable_default_argument_value' => true, 'no_unset_cast' => true, 'no_unset_on_property' => true, 'no_unused_imports' => true, + 'no_useless_concat_operator' => true, 'no_useless_else' => true, + 'no_useless_nullsafe_operator' => true, 'no_useless_return' => true, 'no_useless_sprintf' => true, 'no_whitespace_before_comma_in_array' => true, @@ -187,6 +198,7 @@ 'non_printable_character' => true, 'normalize_index_brace' => true, 'object_operator_without_whitespace' => true, + 'octal_notation' => true, 'operator_linebreak' => [ 'only_booleans' => true, 'position' => 'end', @@ -217,9 +229,9 @@ ], 'ordered_imports' => [ 'imports_order' => [ - PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CONST, - PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_FUNCTION, - PhpCsFixer\Fixer\Import\OrderedImportsFixer::IMPORT_TYPE_CLASS, + 'const', + 'function', + 'class', ] ], 'ordered_interfaces' => [ @@ -227,6 +239,7 @@ 'order' => 'alpha', ], 'ordered_traits' => true, + 'ordered_types' => true, 'php_unit_set_up_tear_down_visibility' => true, 'php_unit_test_case_static_method_calls' => [ 'call_type' => 'this', @@ -250,6 +263,7 @@ 'uses', ], ], + 'phpdoc_param_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, 'phpdoc_separation' => true, @@ -257,7 +271,7 @@ 'phpdoc_summary' => true, 'phpdoc_tag_casing' => true, 'phpdoc_tag_type' => true, - 'phpdoc_to_comment' => true, + 'phpdoc_to_comment' => false, 'phpdoc_trim' => true, 'phpdoc_trim_consecutive_blank_line_separation' => true, 'phpdoc_types' => ['groups' => ['simple', 'meta']], @@ -279,15 +293,20 @@ 'single_class_element_per_statement' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, + 'single_line_comment_spacing' => true, 'single_quote' => true, 'single_space_around_construct' => true, 'single_trait_insert_per_statement' => true, 'space_after_semicolon' => true, + 'spaces_inside_parentheses' => [ + 'space' => 'none', + ], 'standardize_increment' => true, 'standardize_not_equals' => true, 'statement_indentation' => true, 'static_lambda' => true, 'strict_param' => true, + 'string_length_to_empty'=> true, 'string_line_ending' => true, 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, @@ -297,13 +316,18 @@ 'ternary_to_null_coalescing' => true, 'trailing_comma_in_multiline' => [ 'elements' => [ - 'arrays' + 'arguments', + 'arrays', + 'match', ] ], 'trim_array_spaces' => true, - 'types_spaces' => [ - 'space' => 'none', + 'type_declaration_spaces' => [ + 'elements' => [ + 'function', + ], ], + 'types_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => [ @@ -316,4 +340,6 @@ 'whitespace_after_comma_in_array' => true, ]); +$config->setCacheFile(__DIR__ . '/.php-cs-fixer.cache/' . sha1(@trim((string) @shell_exec('git rev-parse --abbrev-ref HEAD')))); + return $config; diff --git a/src/ArrayComparator.php b/src/ArrayComparator.php index 07eba9d..7550832 100644 --- a/src/ArrayComparator.php +++ b/src/ArrayComparator.php @@ -56,7 +56,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $exporter->shortenedExport($value) + $exporter->shortenedExport($value), ); $equal = false; @@ -71,25 +71,25 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $exporter->shortenedExport($value) + $exporter->shortenedExport($value), ); $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $exporter->shortenedExport($actual[$key]) + $exporter->shortenedExport($actual[$key]), ); } catch (ComparisonFailure $e) { $expectedAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : $exporter->shortenedExport($e->getExpected()) + $e->getExpectedAsString() ? $this->indent($e->getExpectedAsString()) : $exporter->shortenedExport($e->getExpected()), ); $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $e->getActualAsString() ? $this->indent($e->getActualAsString()) : $exporter->shortenedExport($e->getActual()) + $e->getActualAsString() ? $this->indent($e->getActualAsString()) : $exporter->shortenedExport($e->getActual()), ); $equal = false; @@ -100,7 +100,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actualAsString .= sprintf( " %s => %s\n", $exporter->export($key), - $exporter->shortenedExport($value) + $exporter->shortenedExport($value), ); $equal = false; @@ -115,7 +115,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $expectedAsString, $actualAsString, - 'Failed asserting that two arrays are equal.' + 'Failed asserting that two arrays are equal.', ); } } diff --git a/src/DOMNodeComparator.php b/src/DOMNodeComparator.php index b57aef1..e78a401 100644 --- a/src/DOMNodeComparator.php +++ b/src/DOMNodeComparator.php @@ -42,7 +42,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $expectedAsString, $actualAsString, - sprintf("Failed asserting that two DOM %s are equal.\n", $type) + sprintf("Failed asserting that two DOM %s are equal.\n", $type), ); } } diff --git a/src/DateTimeComparator.php b/src/DateTimeComparator.php index b32c0af..16792d7 100644 --- a/src/DateTimeComparator.php +++ b/src/DateTimeComparator.php @@ -54,7 +54,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $this->dateTimeToString($expected), $this->dateTimeToString($actual), - 'Failed asserting that two DateTime objects are equal.' + 'Failed asserting that two DateTime objects are equal.', ); } } diff --git a/src/NumericComparator.php b/src/NumericComparator.php index 576c839..3d783ed 100644 --- a/src/NumericComparator.php +++ b/src/NumericComparator.php @@ -49,8 +49,8 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, sprintf( 'Failed asserting that %s matches expected %s.', $exporter->export($actual), - $exporter->export($expected) - ) + $exporter->export($expected), + ), ); } } diff --git a/src/ObjectComparator.php b/src/ObjectComparator.php index 09fc78d..95f97ed 100644 --- a/src/ObjectComparator.php +++ b/src/ObjectComparator.php @@ -42,8 +42,8 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, sprintf( '%s is not instance of expected class "%s".', $exporter->export($actual), - $expected::class - ) + $expected::class, + ), ); } @@ -66,7 +66,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $delta, $canonicalize, $ignoreCase, - $processed + $processed, ); } catch (ComparisonFailure $e) { throw new ComparisonFailure( @@ -75,7 +75,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, // replace "Array" with "MyClass object" substr_replace($e->getExpectedAsString(), $expected::class . ' Object', 0, 5), substr_replace($e->getActualAsString(), $actual::class . ' Object', 0, 5), - 'Failed asserting that two objects are equal.' + 'Failed asserting that two objects are equal.', ); } } diff --git a/src/ResourceComparator.php b/src/ResourceComparator.php index 91440ce..1699562 100644 --- a/src/ResourceComparator.php +++ b/src/ResourceComparator.php @@ -35,7 +35,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $expected, $actual, $exporter->export($expected), - $exporter->export($actual) + $exporter->export($actual), ); } } diff --git a/src/ScalarComparator.php b/src/ScalarComparator.php index 50a71ac..79c5045 100644 --- a/src/ScalarComparator.php +++ b/src/ScalarComparator.php @@ -59,7 +59,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $exporter->export($expected), $exporter->export($actual), - 'Failed asserting that two strings are equal.' + 'Failed asserting that two strings are equal.', ); } @@ -73,8 +73,8 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, sprintf( 'Failed asserting that %s matches expected %s.', $exporter->export($actual), - $exporter->export($expected) - ) + $exporter->export($expected), + ), ); } } diff --git a/src/SplObjectStorageComparator.php b/src/SplObjectStorageComparator.php index 144622d..a1eeda3 100644 --- a/src/SplObjectStorageComparator.php +++ b/src/SplObjectStorageComparator.php @@ -37,7 +37,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $exporter->export($expected), $exporter->export($actual), - 'Failed asserting that two objects are equal.' + 'Failed asserting that two objects are equal.', ); } } @@ -49,7 +49,7 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, $actual, $exporter->export($expected), $exporter->export($actual), - 'Failed asserting that two objects are equal.' + 'Failed asserting that two objects are equal.', ); } } diff --git a/src/TypeComparator.php b/src/TypeComparator.php index 8e9dfac..67994e9 100644 --- a/src/TypeComparator.php +++ b/src/TypeComparator.php @@ -35,8 +35,8 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, sprintf( '%s does not match expected type "%s".', (new Exporter)->shortenedExport($actual), - gettype($expected) - ) + gettype($expected), + ), ); } } diff --git a/tests/ArrayComparatorTest.php b/tests/ArrayComparatorTest.php index 902a913..8e16b53 100644 --- a/tests/ArrayComparatorTest.php +++ b/tests/ArrayComparatorTest.php @@ -124,7 +124,7 @@ protected function setUp(): void public function testAcceptsSucceeds(): void { $this->assertTrue( - $this->comparator->accepts([], []) + $this->comparator->accepts([], []), ); } @@ -132,7 +132,7 @@ public function testAcceptsSucceeds(): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } diff --git a/tests/ComparisonFailureTest.php b/tests/ComparisonFailureTest.php index fca3b2a..0c302cf 100644 --- a/tests/ComparisonFailureTest.php +++ b/tests/ComparisonFailureTest.php @@ -29,7 +29,7 @@ public function testComparisonFailure(): void $actual, '|' . $expected, '|' . $actual, - $message + $message, ); $this->assertSame($actual, $failure->getActual()); diff --git a/tests/DOMNodeComparatorTest.php b/tests/DOMNodeComparatorTest.php index acb4d81..77eee99 100644 --- a/tests/DOMNodeComparatorTest.php +++ b/tests/DOMNodeComparatorTest.php @@ -117,7 +117,7 @@ public static function assertEqualsFailsProvider(): array public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - (new DOMNodeComparator)->accepts($expected, $actual) + (new DOMNodeComparator)->accepts($expected, $actual), ); } @@ -125,7 +125,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new DOMNodeComparator)->accepts($expected, $actual) + (new DOMNodeComparator)->accepts($expected, $actual), ); } diff --git a/tests/DateTimeComparatorTest.php b/tests/DateTimeComparatorTest.php index 0469bc4..c7a4726 100644 --- a/tests/DateTimeComparatorTest.php +++ b/tests/DateTimeComparatorTest.php @@ -145,8 +145,8 @@ public function testAcceptsSucceeds(): void $this->assertTrue( (new DateTimeComparator)->accepts( new DateTime, - new DateTime - ) + new DateTime, + ), ); } @@ -154,7 +154,7 @@ public function testAcceptsSucceeds(): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new DateTimeComparator)->accepts($expected, $actual) + (new DateTimeComparator)->accepts($expected, $actual), ); } diff --git a/tests/ExceptionComparatorTest.php b/tests/ExceptionComparatorTest.php index 514fc2d..852bde2 100644 --- a/tests/ExceptionComparatorTest.php +++ b/tests/ExceptionComparatorTest.php @@ -89,7 +89,7 @@ protected function setUp(): void public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } @@ -97,7 +97,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } diff --git a/tests/MockObjectComparatorTest.php b/tests/MockObjectComparatorTest.php index 6c7aa8f..b15e6c8 100644 --- a/tests/MockObjectComparatorTest.php +++ b/tests/MockObjectComparatorTest.php @@ -123,7 +123,7 @@ protected function setUp(): void public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } @@ -131,7 +131,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } diff --git a/tests/NumericComparatorTest.php b/tests/NumericComparatorTest.php index ff1b8cd..50d7ed4 100644 --- a/tests/NumericComparatorTest.php +++ b/tests/NumericComparatorTest.php @@ -30,13 +30,13 @@ public static function acceptsSucceedsProvider(): array [5, 10], [8, '0'], ['10', 0], - [0x74c3b00c, 42], - [0755, 0777], + [0x74C3B00C, 42], + [0o755, 0o777], [8, 5.0], [5.0, 8], [5, 5], ['4.5', 5], - [0x539, 02471], + [0x539, 0o2471], [0, 5.0], [5.0, 0], ['5', 4.5], @@ -64,7 +64,7 @@ public static function assertEqualsSucceedsProvider(): array [1337, 1337], ['1337', 1337], [0x539, 1337], - [02471, 1337], + [0o2471, 1337], [1337, 1338, 1], ['1337', 1340, 5], [INF, INF], @@ -117,7 +117,7 @@ public static function assertEqualsFailsProvider(): array public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - (new NumericComparator)->accepts($expected, $actual) + (new NumericComparator)->accepts($expected, $actual), ); } @@ -125,7 +125,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new NumericComparator)->accepts($expected, $actual) + (new NumericComparator)->accepts($expected, $actual), ); } diff --git a/tests/ObjectComparatorTest.php b/tests/ObjectComparatorTest.php index ff878b6..5097680 100644 --- a/tests/ObjectComparatorTest.php +++ b/tests/ObjectComparatorTest.php @@ -103,7 +103,7 @@ protected function setUp(): void public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } @@ -111,7 +111,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - $this->comparator->accepts($expected, $actual) + $this->comparator->accepts($expected, $actual), ); } diff --git a/tests/ResourceComparatorTest.php b/tests/ResourceComparatorTest.php index 64f28e4..5939780 100644 --- a/tests/ResourceComparatorTest.php +++ b/tests/ResourceComparatorTest.php @@ -72,7 +72,7 @@ public static function assertEqualsFailsProvider(): array public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - (new ResourceComparator)->accepts($expected, $actual) + (new ResourceComparator)->accepts($expected, $actual), ); } @@ -80,7 +80,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new ResourceComparator)->accepts($expected, $actual) + (new ResourceComparator)->accepts($expected, $actual), ); } diff --git a/tests/ScalarComparatorTest.php b/tests/ScalarComparatorTest.php index ef708de..bc71021 100644 --- a/tests/ScalarComparatorTest.php +++ b/tests/ScalarComparatorTest.php @@ -115,7 +115,7 @@ public static function assertEqualsFailsProvider(): array public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - (new ScalarComparator)->accepts($expected, $actual) + (new ScalarComparator)->accepts($expected, $actual), ); } @@ -123,7 +123,7 @@ public function testAcceptsSucceeds($expected, $actual): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new ScalarComparator)->accepts($expected, $actual) + (new ScalarComparator)->accepts($expected, $actual), ); } diff --git a/tests/SplObjectStorageComparatorTest.php b/tests/SplObjectStorageComparatorTest.php index 6a1970f..75b576b 100644 --- a/tests/SplObjectStorageComparatorTest.php +++ b/tests/SplObjectStorageComparatorTest.php @@ -81,8 +81,8 @@ public function testAcceptsSucceeds(): void $this->assertTrue( (new SplObjectStorageComparator)->accepts( new SplObjectStorage, - new SplObjectStorage - ) + new SplObjectStorage, + ), ); } @@ -90,7 +90,7 @@ public function testAcceptsSucceeds(): void public function testAcceptsFails($expected, $actual): void { $this->assertFalse( - (new SplObjectStorageComparator)->accepts($expected, $actual) + (new SplObjectStorageComparator)->accepts($expected, $actual), ); } diff --git a/tests/TypeComparatorTest.php b/tests/TypeComparatorTest.php index d3fcf1e..2095d05 100644 --- a/tests/TypeComparatorTest.php +++ b/tests/TypeComparatorTest.php @@ -63,7 +63,7 @@ public static function assertEqualsFailsProvider(): array public function testAcceptsSucceeds($expected, $actual): void { $this->assertTrue( - (new TypeComparator)->accepts($expected, $actual) + (new TypeComparator)->accepts($expected, $actual), ); }