diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84def9006494f08a9965c53f3f916914bae969e4..e33438ae503f9f7a84a901f8c446dfb74510723c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: "Checkout" diff --git a/.gitignore b/.gitignore index dd9244babaa8870e924902ccddccf33d7054e251..9f62f2cbb7fea11c90292e5e343ff98d37e0caa8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ /.php-cs-fixer.php /.php-cs-fixer.cache /composer.lock -/.phpunit.result.cache +/.phpunit.cache diff --git a/.phive/phars.xml b/.phive/phars.xml index b13bf497053f658d7339979947fd720178fa834f..f5eca895a3bac90d759a604dafb6d0ef88a39029 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <phive xmlns="https://phar.io/phive"> - <phar name="php-cs-fixer" version="^3.0" installed="3.16.0" location="./tools/php-cs-fixer" copy="true"/> - <phar name="psalm" version="^5.0" installed="5.11.0" location="./tools/psalm" copy="true"/> - <phar name="composer" version="^2.0.3" installed="2.5.5" location="./tools/composer" copy="true"/> + <phar name="php-cs-fixer" version="^3.0" installed="3.24.0" location="./tools/php-cs-fixer" copy="true"/> + <phar name="psalm" version="^5.0" installed="5.15.0" location="./tools/psalm" copy="true"/> + <phar name="composer" version="^2.0.3" installed="2.5.8" location="./tools/composer" copy="true"/> </phive> diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 1a225c8f873ac26da7109d91554c2ff20f54acce..4c5b1abc218fc579a8ce992620069ed888deaf4f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -26,10 +26,18 @@ $config->setFinder($finder) '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', ], ], 'blank_line_after_namespace' => true, + 'blank_lines_before_namespace' => [ + 'max_line_breaks' => 1, + 'min_line_breaks' => 0, + ], 'blank_line_before_statement' => [ 'statements' => [ 'break', @@ -106,9 +114,10 @@ $config->setFinder($finder) '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 +131,8 @@ $config->setFinder($finder) '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, @@ -143,7 +154,6 @@ $config->setFinder($finder) '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 +164,15 @@ $config->setFinder($finder) '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, @@ -179,7 +189,9 @@ $config->setFinder($finder) '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 +199,7 @@ $config->setFinder($finder) '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 +230,9 @@ $config->setFinder($finder) ], '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 +240,7 @@ $config->setFinder($finder) '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 +264,7 @@ $config->setFinder($finder) 'uses', ], ], + 'phpdoc_param_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, 'phpdoc_separation' => true, @@ -257,7 +272,7 @@ $config->setFinder($finder) '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 +294,20 @@ $config->setFinder($finder) '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 +317,18 @@ $config->setFinder($finder) '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' => [ diff --git a/ChangeLog.md b/ChangeLog.md index 2d6d9d5fe3674e22ccbaaa396d942f3f1d5ccb03..e2ddc6468744b3120e0ed787e5b7b2539222e1be 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [4.1.0] - 2023-08-31 + +### Added + +* [#81](https://github.com/sebastianbergmann/php-file-iterator/issues/81): Accept `array|string $paths` in `Facade::getFilesAsArray()` + ## [4.0.2] - 2023-05-07 ### Fixed @@ -144,6 +150,7 @@ No changes * [#23](https://github.com/sebastianbergmann/php-file-iterator/pull/23): Added support for wildcards (glob) in exclude +[4.1.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.0.2...4.1.0 [4.0.2]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.0.1...4.0.2 [4.0.1]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.0.0...4.0.1 [4.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.6...4.0.0 diff --git a/phpunit.xml b/phpunit.xml index c567f145abca050b707c88d924dadadef27114e5..9f8393da394b824f0fd92b7e216d45ab31695c16 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,6 +2,7 @@ <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" + cacheDirectory=".phpunit.cache" executionOrder="depends,defects" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true" @@ -10,12 +11,14 @@ failOnWarning="true" colors="true"> <testsuites> - <testsuite name="default"> - <directory suffix="Test.php">tests/unit</directory> + <testsuite name="unit"> + <directory>tests/unit</directory> </testsuite> </testsuites> - <source> + <source restrictDeprecations="true" + restrictNotices="true" + restrictWarnings="true"> <include> <directory>src</directory> </include> diff --git a/src/Facade.php b/src/Facade.php index b0f9fc0a7426329566fab228136f7955a1f991f9..b782bf96a3daa24d3748e98630719b08ccef268e 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -20,15 +20,16 @@ use SplFileInfo; final class Facade { /** - * @psalm-param list<string>|string $suffixes - * @psalm-param list<string>|string $prefixes - * @psalm-param list<string> $exclude + * @psalm-param list<non-empty-string>|non-empty-string $paths + * @psalm-param list<non-empty-string>|string $suffixes + * @psalm-param list<non-empty-string>|string $prefixes + * @psalm-param list<non-empty-string> $exclude * - * @psalm-return list<string> + * @psalm-return list<non-empty-string> */ - public function getFilesAsArray(string $path, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): array + public function getFilesAsArray(array|string $paths, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): array { - $iterator = (new Factory)->getFileIterator($path, $suffixes, $prefixes, $exclude); + $iterator = (new Factory)->getFileIterator($paths, $suffixes, $prefixes, $exclude); $files = []; diff --git a/src/Factory.php b/src/Factory.php index db4edefecbeec9459db48e9abc1355027ba3e331..35f9ca08d17d221067f3188bd9ef4f982700f015 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -29,10 +29,10 @@ use RecursiveIteratorIterator; final class Factory { /** - * @psalm-param list<string>|string $paths - * @psalm-param list<string>|string $suffixes - * @psalm-param list<string>|string $prefixes - * @psalm-param list<string> $exclude + * @psalm-param list<non-empty-string>|non-empty-string $paths + * @psalm-param list<non-empty-string>|string $suffixes + * @psalm-param list<non-empty-string>|string $prefixes + * @psalm-param list<non-empty-string> $exclude */ public function getFileIterator(array|string $paths, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): AppendIterator { @@ -83,9 +83,9 @@ final class Factory } /** - * @psalm-param list<string> $paths + * @psalm-param list<non-empty-string> $paths * - * @psalm-return list<string> + * @psalm-return list<non-empty-string> */ private function resolveWildcards(array $paths): array {