From 5b945c01dfff0853d3e14a0ad37f256b398de910 Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:32:13 +0100 Subject: [PATCH 1/6] Installing phpcsfixer --- .php-cs-fixer.cache | 1 + .php-cs-fixer.php | 18 ++++++++++++++++++ aliases | 3 +++ composer.json | 3 ++- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .php-cs-fixer.cache create mode 100644 .php-cs-fixer.php diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..673afed --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.1.31","version":"3.68.5:v3.68.5#7bedb718b633355272428c60736dc97fb96daf27","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_definition":{"single_line":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":{"anonymous_class":false},"no_blank_lines_after_class_opening":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_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":true,"single_space_around_construct":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_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,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ignore"},"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_class_element_per_statement":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"align_multiline_comment":true,"backtick_to_shell_exec":true,"blank_line_before_statement":{"statements":["return"]},"class_attributes_separation":{"elements":{"method":"one"}},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":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,"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_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_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":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":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]]},"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_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays","match","parameters"]},"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"array_indentation":true,"array_syntax":true,"cast_spaces":true},"hashes":{"tests\/Write_Test.php":"3a10d30d33d6dde3982b0beca949b38d","tests\/Move_Test.php":"3ff32ebfcfd033deb53900471ba303e3","tests\/DeleteDirectory_Test.php":"4b56066480000d2f98348e227b2079e6","tests\/GetLastModified_Test.php":"7d99949ee61d2e5b1ef0919a8497fd44","tests\/GetFileSize_Test.php":"44fb82fcc512194c060d02851d49ec23","tests\/FileExists_Test.php":"45b41d89b5e0853c613cbc5641ecd4ce","tests\/Copy_Test.php":"580272ea047b3a3e9680f13da2d043c4","tests\/CacheTestCase.php":"2029f5ded900daeac8979c3c8819ce51","tests\/CacheItemsTrait_Test.php":"73522365c1575661ca0c580d894a0427","tests\/GetMimetype_Test.php":"e043b37e7c4b9aa17aa059713e4357d1","tests\/ListContents_Test.php":"c6fe684e6097a91a4d5cc575389aab76","tests\/GetChecksum_Test.php":"b4b2b20c0d1fa18bab06f9727cde2a33","tests\/SetVisibility_Test.php":"308c097cfc6bcde573b275f1508b07bd","tests\/Read_Test.php":"fd62726804d9ae80018517088c21cf89","tests\/Delete_Test.php":"e29d09a2710cf5f471dde3d55a69f11e","tests\/CreateDirectory_Test.php":"6e38ff404b07ffebf0f109761a371220","tests\/GetVisibility_Test.php":"6240c9468d91dd8239b3186a25c9c7ca","tests\/DirectoryExists_Test.php":"e3b80e33a6a334d1b00e2078f8669fea","tests\/CacheAdapter_Test.php":"a333bde38ffb3c4acd11a72021740b6c",".php-cs-fixer.php":"507c7109c1ce2364cd3bc92b80462316","src\/CacheAdapter.php":"06212f350410c1859a5b49db6de6de7d","src\/CacheItemsTrait.php":"f6f1aabfee10f93b22ba01165cb6a323"}} \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..09c6d75 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,18 @@ +ignoreDotFiles(false) + ->ignoreVCSIgnored(true) + ->in(__DIR__); + +return (new Config()) + ->setRules([ + '@PSR12' => true, + '@Symfony' => true, + 'phpdoc_to_comment' => false, + 'concat_space' => ['spacing' => 'one'], + ]) + ->setFinder($finder); diff --git a/aliases b/aliases index e1de027..a9c03a7 100644 --- a/aliases +++ b/aliases @@ -4,3 +4,6 @@ alias php='d php "$@"' alias composer='d composer "$@"' alias phpstan='d vendor/bin/phpstan analyze "$@"' alias phpunit='d vendor/bin/phpunit "$@"' +alias phpcsfixer='d vendor/friendsofphp/php-cs-fixer/php-cs-fixer "$@"' + +alias reload='. ./aliases' diff --git a/composer.json b/composer.json index c8ab380..9c508fb 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "league/flysystem-adapter-test-utilities": "^3.15", "league/flysystem-memory": "^3.15", "symfony/cache": "^6.3|^7.0", - "league/flysystem-aws-s3-v3": "^3.15" + "league/flysystem-aws-s3-v3": "^3.15", + "friendsofphp/php-cs-fixer": "^3.68" }, "suggest": { "symfony/cache": "Ready to use adapters for the most common caching backends" From 0c272ad8f8e99b2211f6574011fcfc362fc64282 Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:37:22 +0100 Subject: [PATCH 2/6] removing cache file --- .gitignore | 10 ++++++---- .php-cs-fixer.cache | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 .php-cs-fixer.cache diff --git a/.gitignore b/.gitignore index 11e9c13..cf7e963 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -composer.lock -vendor -.phpunit.cache -.env +/composer.lock +/vendor +/.phpunit.cache +/.php-cs-fixer.cache + +.env \ No newline at end of file diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 673afed..0000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.1.31","version":"3.68.5:v3.68.5#7bedb718b633355272428c60736dc97fb96daf27","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"class_definition":{"single_line":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":{"anonymous_class":false},"no_blank_lines_after_class_opening":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_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":true,"single_space_around_construct":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_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,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ignore"},"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_class_element_per_statement":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":{"stick_comment_to_next_continuous_control_statement":true},"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"align_multiline_comment":true,"backtick_to_shell_exec":true,"blank_line_before_statement":{"statements":["return"]},"class_attributes_separation":{"elements":{"method":"one"}},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":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,"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_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_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":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":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]]},"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_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays","match","parameters"]},"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"array_indentation":true,"array_syntax":true,"cast_spaces":true},"hashes":{"tests\/Write_Test.php":"3a10d30d33d6dde3982b0beca949b38d","tests\/Move_Test.php":"3ff32ebfcfd033deb53900471ba303e3","tests\/DeleteDirectory_Test.php":"4b56066480000d2f98348e227b2079e6","tests\/GetLastModified_Test.php":"7d99949ee61d2e5b1ef0919a8497fd44","tests\/GetFileSize_Test.php":"44fb82fcc512194c060d02851d49ec23","tests\/FileExists_Test.php":"45b41d89b5e0853c613cbc5641ecd4ce","tests\/Copy_Test.php":"580272ea047b3a3e9680f13da2d043c4","tests\/CacheTestCase.php":"2029f5ded900daeac8979c3c8819ce51","tests\/CacheItemsTrait_Test.php":"73522365c1575661ca0c580d894a0427","tests\/GetMimetype_Test.php":"e043b37e7c4b9aa17aa059713e4357d1","tests\/ListContents_Test.php":"c6fe684e6097a91a4d5cc575389aab76","tests\/GetChecksum_Test.php":"b4b2b20c0d1fa18bab06f9727cde2a33","tests\/SetVisibility_Test.php":"308c097cfc6bcde573b275f1508b07bd","tests\/Read_Test.php":"fd62726804d9ae80018517088c21cf89","tests\/Delete_Test.php":"e29d09a2710cf5f471dde3d55a69f11e","tests\/CreateDirectory_Test.php":"6e38ff404b07ffebf0f109761a371220","tests\/GetVisibility_Test.php":"6240c9468d91dd8239b3186a25c9c7ca","tests\/DirectoryExists_Test.php":"e3b80e33a6a334d1b00e2078f8669fea","tests\/CacheAdapter_Test.php":"a333bde38ffb3c4acd11a72021740b6c",".php-cs-fixer.php":"507c7109c1ce2364cd3bc92b80462316","src\/CacheAdapter.php":"06212f350410c1859a5b49db6de6de7d","src\/CacheItemsTrait.php":"f6f1aabfee10f93b22ba01165cb6a323"}} \ No newline at end of file From 4471760b4df3098245fe4260fd03977738aaf2e3 Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:38:02 +0100 Subject: [PATCH 3/6] removed symfony rules --- .php-cs-fixer.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 09c6d75..fec1088 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -11,8 +11,6 @@ return (new Config()) ->setRules([ '@PSR12' => true, - '@Symfony' => true, - 'phpdoc_to_comment' => false, 'concat_space' => ['spacing' => 'one'], ]) ->setFinder($finder); From 6eb00389d79de683044a29a9804aaf849ba4c4c3 Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:41:38 +0100 Subject: [PATCH 4/6] files fixed --- .php-cs-fixer.php | 1 + src/CacheItemsTrait.php | 4 ++-- tests/CacheAdapter_Test.php | 2 +- tests/CacheTestCase.php | 6 +++--- tests/Copy_Test.php | 6 +++--- tests/CreateDirectory_Test.php | 4 ++-- tests/DeleteDirectory_Test.php | 6 +++--- tests/Delete_Test.php | 6 +++--- tests/DirectoryExists_Test.php | 6 +++--- tests/GetChecksum_Test.php | 12 ++++++------ tests/GetFileSize_Test.php | 8 ++++---- tests/GetLastModified_Test.php | 8 ++++---- tests/GetMimetype_Test.php | 10 +++++----- tests/GetVisibility_Test.php | 10 +++++----- tests/ListContents_Test.php | 2 +- tests/Move_Test.php | 6 +++--- tests/Read_Test.php | 10 +++++----- tests/SetVisibility_Test.php | 6 +++--- tests/Write_Test.php | 6 +++--- 19 files changed, 60 insertions(+), 59 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index fec1088..efbe5d5 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -12,5 +12,6 @@ ->setRules([ '@PSR12' => true, 'concat_space' => ['spacing' => 'one'], + 'new_with_parentheses' => false, ]) ->setFinder($finder); diff --git a/src/CacheItemsTrait.php b/src/CacheItemsTrait.php index 1f99fcf..4cbaf17 100644 --- a/src/CacheItemsTrait.php +++ b/src/CacheItemsTrait.php @@ -21,8 +21,8 @@ */ trait CacheItemsTrait { - static string $CACHE_KEY_PREFIX = 'flysystem_item_'; - static string $CACHE_KEY_HASH_SALT = '563ce5132194441b'; + public static string $CACHE_KEY_PREFIX = 'flysystem_item_'; + public static string $CACHE_KEY_HASH_SALT = '563ce5132194441b'; protected function getCacheItem(string $path): CacheItemInterface { diff --git a/tests/CacheAdapter_Test.php b/tests/CacheAdapter_Test.php index 5a6e9c4..fc925fa 100644 --- a/tests/CacheAdapter_Test.php +++ b/tests/CacheAdapter_Test.php @@ -31,7 +31,7 @@ public function writing_and_reading_files_with_special_path(string $path): void /** * "Override" function from parent which is not static and thus incompatible with phpunit 10 * @todo Remove when https://github.com/thephpleague/flysystem-adapter-test-utilities/commit/bf4c950b176bbefcc49c443cdab1ffb62a9fef5c is tagged (version >= 3.16?) - * @return Generator + * @return Generator */ public static function filenameProvider2(): Generator { diff --git a/tests/CacheTestCase.php b/tests/CacheTestCase.php index 2968d77..0006624 100644 --- a/tests/CacheTestCase.php +++ b/tests/CacheTestCase.php @@ -57,7 +57,7 @@ public function setUp(): void } /** - * @param array $items + * @param array $items */ protected function setupCache(array $items): void { @@ -71,7 +71,7 @@ protected function setupCache(array $items): void } /** - * @param array $items + * @param array $items */ protected function setupFiles(array $items): void { @@ -81,7 +81,7 @@ protected function setupFiles(array $items): void } /** - * @param array $items + * @param array $items */ protected function assertCachedItems(array $items): void { diff --git a/tests/Copy_Test.php b/tests/Copy_Test.php index 75dcc78..9db1eb6 100644 --- a/tests/Copy_Test.php +++ b/tests/Copy_Test.php @@ -10,7 +10,7 @@ class Copy_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -27,7 +27,7 @@ public function copy_ok(string $source, FileAttributes|null $expectedSourceCache } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -36,7 +36,7 @@ public static function dataProvider(): iterable yield 'cache item is created' => ['non-cached-file', \null, new FileAttributes('destination')]; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_copy(): void diff --git a/tests/CreateDirectory_Test.php b/tests/CreateDirectory_Test.php index 863f650..bdc0236 100644 --- a/tests/CreateDirectory_Test.php +++ b/tests/CreateDirectory_Test.php @@ -7,7 +7,7 @@ class CreateDirectory_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -21,7 +21,7 @@ public function directory_is_cached_after_creating(string $path): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable diff --git a/tests/DeleteDirectory_Test.php b/tests/DeleteDirectory_Test.php index a3e4104..b8d6042 100644 --- a/tests/DeleteDirectory_Test.php +++ b/tests/DeleteDirectory_Test.php @@ -6,7 +6,7 @@ class DeleteDirectory_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -20,7 +20,7 @@ public function directory_is_not_cached_deleting(string $path): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -41,7 +41,7 @@ public function nested_files_are_purged_from_cache(): void ]); } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_delete(): void diff --git a/tests/Delete_Test.php b/tests/Delete_Test.php index 0fa41f8..0ba1b1e 100644 --- a/tests/Delete_Test.php +++ b/tests/Delete_Test.php @@ -6,7 +6,7 @@ class Delete_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -20,7 +20,7 @@ public function file_is_not_cached_deleting(string $path): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -29,7 +29,7 @@ public static function dataProvider(): iterable yield 'non cached file stays uncached' => ['non-cached-file']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_delete(): void diff --git a/tests/DirectoryExists_Test.php b/tests/DirectoryExists_Test.php index 0ba5887..2e2e590 100644 --- a/tests/DirectoryExists_Test.php +++ b/tests/DirectoryExists_Test.php @@ -6,7 +6,7 @@ class DirectoryExists_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -18,7 +18,7 @@ public function directory_exists_ok(string $path, bool $expectedResult): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -30,7 +30,7 @@ public static function dataProvider(): iterable yield 'file is not a directory' => ['fully-cached-file', false]; } - /** + /** * @test */ public function directory_is_cached_after_checking_filesystem(): void diff --git a/tests/GetChecksum_Test.php b/tests/GetChecksum_Test.php index 7fdaa0b..eebdaad 100644 --- a/tests/GetChecksum_Test.php +++ b/tests/GetChecksum_Test.php @@ -23,7 +23,7 @@ public function setUp(): void ]); } - /** + /** * @test * @dataProvider dataProvider */ @@ -35,7 +35,7 @@ public function get_checksum(string $path, string $expectedChecksum): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -45,7 +45,7 @@ public static function dataProvider(): iterable yield 'file is not cached' => ['non-cached-file', md5('0123456789')]; } - /** + /** * @test * @dataProvider aws_dataProvider */ @@ -62,7 +62,7 @@ public function with_mock_aws_adapter(string $path, string $expectedChecksum): v } /** - * + * * @return iterable> */ public static function aws_dataProvider(): iterable @@ -84,7 +84,7 @@ public function error(string $path): void } /** - * + * * @return iterable> */ public static function errorDataProvider(): iterable @@ -94,7 +94,7 @@ public static function errorDataProvider(): iterable yield 'Path is directory (non-cached)' => ['non-cached-directory']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_get(): void diff --git a/tests/GetFileSize_Test.php b/tests/GetFileSize_Test.php index e608cb9..aa4aaec 100644 --- a/tests/GetFileSize_Test.php +++ b/tests/GetFileSize_Test.php @@ -6,7 +6,7 @@ class GetFileSize_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -18,7 +18,7 @@ public function get_fileSize(string $path, int $expectedFileSize): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -41,7 +41,7 @@ public function error(string $path): void } /** - * + * * @return iterable> */ public static function errorDataProvider(): iterable @@ -51,7 +51,7 @@ public static function errorDataProvider(): iterable yield 'Path is directory (non-cached)' => ['non-cached-directory']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_get(): void diff --git a/tests/GetLastModified_Test.php b/tests/GetLastModified_Test.php index 4506d85..b73e2ee 100644 --- a/tests/GetLastModified_Test.php +++ b/tests/GetLastModified_Test.php @@ -6,7 +6,7 @@ class GetLastModified_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -18,7 +18,7 @@ public function get_lastModified(string $path): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -38,7 +38,7 @@ public function error(string $path): void } /** - * + * * @return iterable> */ public static function errorDataProvider(): iterable @@ -48,7 +48,7 @@ public static function errorDataProvider(): iterable yield 'Path is directory (non-cached)' => ['non-cached-directory']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_get(): void diff --git a/tests/GetMimetype_Test.php b/tests/GetMimetype_Test.php index 7ac1f1e..49cdded 100644 --- a/tests/GetMimetype_Test.php +++ b/tests/GetMimetype_Test.php @@ -10,7 +10,7 @@ class GetMimetype_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -22,7 +22,7 @@ public function get_mimetype(string $path, StorageAttributes $expectedResult): v } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -32,7 +32,7 @@ public static function dataProvider(): iterable yield 'file is not cached but exists in the filesystem' => ['non-cached-file.txt', new FileAttributes('non-cached-file.txt', mimeType: 'text/plain')]; } - /** + /** * @test */ public function file_is_cached_after_checking_filesystem(): void @@ -57,7 +57,7 @@ public function error(string $path): void } /** - * + * * @return iterable> */ public static function errorDataProvider(): iterable @@ -67,7 +67,7 @@ public static function errorDataProvider(): iterable yield 'Path is directory (non-cached)' => ['non-cached-directory']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_get(): void diff --git a/tests/GetVisibility_Test.php b/tests/GetVisibility_Test.php index 68e56b1..d272ed3 100644 --- a/tests/GetVisibility_Test.php +++ b/tests/GetVisibility_Test.php @@ -9,7 +9,7 @@ class GetVisibility_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -21,7 +21,7 @@ public function get_visibility(string $path, StorageAttributes $expectedResult): } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -31,7 +31,7 @@ public static function dataProvider(): iterable yield 'file is not cached but exists in the filesystem' => ['non-cached-file', new FileAttributes('non-cached-file', visibility: Visibility::PUBLIC)]; } - /** + /** * @test */ public function file_is_cached_after_checking_filesystem(): void @@ -56,7 +56,7 @@ public function error(string $path): void } /** - * + * * @return iterable> */ public static function errorDataProvider(): iterable @@ -66,7 +66,7 @@ public static function errorDataProvider(): iterable yield 'Path is directory (non-cached)' => ['non-cached-directory']; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_get(): void diff --git a/tests/ListContents_Test.php b/tests/ListContents_Test.php index 8b1a0dc..f068f66 100644 --- a/tests/ListContents_Test.php +++ b/tests/ListContents_Test.php @@ -7,7 +7,7 @@ class ListContents_Test extends CacheTestCase { - /** + /** * @test */ public function content_list_is_cached(): void diff --git a/tests/Move_Test.php b/tests/Move_Test.php index 220e713..33d76ca 100644 --- a/tests/Move_Test.php +++ b/tests/Move_Test.php @@ -9,7 +9,7 @@ class Move_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -26,7 +26,7 @@ public function move_ok(string $source, FileAttributes $expectedDestinationCache } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -35,7 +35,7 @@ public static function dataProvider(): iterable yield 'cache item is created' => ['non-cached-file', new FileAttributes('destination')]; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_move(): void diff --git a/tests/Read_Test.php b/tests/Read_Test.php index 9969f9d..7b2b55f 100644 --- a/tests/Read_Test.php +++ b/tests/Read_Test.php @@ -8,7 +8,7 @@ class Read_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -21,7 +21,7 @@ public function file_is_cached_after_reading(string $path, int|null $expectedSiz ]); } - /** + /** * @test * @dataProvider dataProvider */ @@ -35,7 +35,7 @@ public function file_is_cached_after_reading_stream(string $path, int|null $expe } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -45,7 +45,7 @@ public static function dataProvider(): iterable yield 'cached file attributes are unchanged after reading' => ['fully-cached-file', 10, Visibility::PUBLIC]; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_read(): void @@ -61,7 +61,7 @@ public function cache_is_purged_after_unsuccessful_read(): void } } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_readStream(): void diff --git a/tests/SetVisibility_Test.php b/tests/SetVisibility_Test.php index 0c9e120..54a4778 100644 --- a/tests/SetVisibility_Test.php +++ b/tests/SetVisibility_Test.php @@ -9,7 +9,7 @@ class SetVisibility_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -23,7 +23,7 @@ public function set_visibility_ok(string $path, string $visibility, StorageAttri } /** - * + * * @return iterable> */ public static function dataProvider(): iterable @@ -36,7 +36,7 @@ public static function dataProvider(): iterable // yield 'cached directory, set private' => ['cached-directory', Visibility::PRIVATE, new DirectoryAttributes('fully-cached-file', visibility: Visibility::PRIVATE)]; } - /** + /** * @test */ public function cache_is_purged_after_unsuccessful_set(): void diff --git a/tests/Write_Test.php b/tests/Write_Test.php index 47def45..506d3db 100644 --- a/tests/Write_Test.php +++ b/tests/Write_Test.php @@ -8,7 +8,7 @@ class Write_Test extends CacheTestCase { - /** + /** * @test * @dataProvider dataProvider */ @@ -21,7 +21,7 @@ public function file_is_cached_after_writing(string $path): void ]); } - /** + /** * @test * @dataProvider dataProvider */ @@ -37,7 +37,7 @@ public function file_is_cached_after_writing_stream(string $path): void } /** - * + * * @return iterable> */ public static function dataProvider(): iterable From b96fce05806632cbe02054661f3d520e43dbd5ec Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:43:50 +0100 Subject: [PATCH 5/6] cleanup a @todo --- tests/CacheAdapter_Test.php | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/tests/CacheAdapter_Test.php b/tests/CacheAdapter_Test.php index fc925fa..7dcf4d0 100644 --- a/tests/CacheAdapter_Test.php +++ b/tests/CacheAdapter_Test.php @@ -18,36 +18,4 @@ protected static function createFilesystemAdapter(): FilesystemAdapter return new CacheAdapter($fileSystemAdapter, $cache); } - - /** - * @test - * @dataProvider filenameProvider2 - */ - public function writing_and_reading_files_with_special_path(string $path): void - { - parent::writing_and_reading_files_with_special_path($path); - } - - /** - * "Override" function from parent which is not static and thus incompatible with phpunit 10 - * @todo Remove when https://github.com/thephpleague/flysystem-adapter-test-utilities/commit/bf4c950b176bbefcc49c443cdab1ffb62a9fef5c is tagged (version >= 3.16?) - * @return Generator - */ - public static function filenameProvider2(): Generator - { - yield "a path with square brackets in filename 1" => ["some/file[name].txt"]; - yield "a path with square brackets in filename 2" => ["some/file[0].txt"]; - yield "a path with square brackets in filename 3" => ["some/file[10].txt"]; - yield "a path with square brackets in dirname 1" => ["some[name]/file.txt"]; - yield "a path with square brackets in dirname 2" => ["some[0]/file.txt"]; - yield "a path with square brackets in dirname 3" => ["some[10]/file.txt"]; - yield "a path with curly brackets in filename 1" => ["some/file{name}.txt"]; - yield "a path with curly brackets in filename 2" => ["some/file{0}.txt"]; - yield "a path with curly brackets in filename 3" => ["some/file{10}.txt"]; - yield "a path with curly brackets in dirname 1" => ["some{name}/filename.txt"]; - yield "a path with curly brackets in dirname 2" => ["some{0}/filename.txt"]; - yield "a path with curly brackets in dirname 3" => ["some{10}/filename.txt"]; - yield "a path with space in dirname" => ["some dir/filename.txt"]; - yield "a path with space in filename" => ["somedir/file name.txt"]; - } } From cd5d8192bbb0a46bc56c6ab9e50877c6a1cd0ffc Mon Sep 17 00:00:00 2001 From: Jakob Givoni Date: Wed, 12 Feb 2025 15:46:24 +0100 Subject: [PATCH 6/6] adding to github actions --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36c569e..d43af51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,3 +68,36 @@ jobs: - name: Run unit tests run: docker exec mycontainer vendor/bin/phpunit + + job3: + strategy: + matrix: + php_version: ["8.1"] + name: PhpCsFixer code style checker ${{ matrix.php_version }} + runs-on: ubuntu-latest + steps: + - name: Checkout codebase + uses: actions/checkout@v3 + + - name: Enable caching + uses: satackey/action-docker-layer-caching@v0.0.11 + # Deprecation warnings are expected... + continue-on-error: true + + - name: Build image + run: docker image build . -f Dockerfile -t myimage:latest --build-arg PHP_VERSION=${{ matrix.php_version }} + + - name: Launch container + run: docker run -d -v "$(pwd)/:/app" --name mycontainer myimage:latest tail -f /dev/null + + - name: Check PHP version + run: docker exec mycontainer php -v + + - name: Check composer.json validity + run: docker exec mycontainer composer validate + + - name: Install dependencies + run: docker exec mycontainer composer install + + - name: Run unit tests + run: docker exec mycontainer vendor/friendsofphp/php-cs-fixer/php-cs-fixer check