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

Update PHP-CS-Fixer to the latest version and enable parallelization #2222

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

sidz
Copy link
Contributor

@sidz sidz commented Jul 21, 2024

This PR updates PHP-CS-Fixer and enable parallelization.

Rules list which were applied:

  1) src/Query/GeoShapeProvided.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   2) src/Query/HasParent.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   3) src/Query/Simple.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   4) src/Query/GeoPolygon.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   5) src/Query/BoolQuery.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   6) src/Query/QueryString.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
   7) src/Query/GeoDistance.php (fully_qualified_strict_types, blank_line_after_namespace)
   8) src/Query/MultiMatch.php (no_superfluous_phpdoc_tags, phpdoc_trim_consecutive_blank_line_separation)
   9) src/Query/MoreLikeThis.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  10) src/Query/MatchPhrase.php (no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_trim_consecutive_blank_line_separation)
  11) src/Aggregation/WeightedAvg.php (no_superfluous_phpdoc_tags, phpdoc_trim_consecutive_blank_line_separation)
  12) src/Aggregation/ReverseNested.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  13) src/Aggregation/Traits/MissingTrait.php (no_superfluous_phpdoc_tags, phpdoc_trim_consecutive_blank_line_separation)
  14) src/Query/FunctionScore.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  15) src/Query/AbstractGeoDistance.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  16) src/Query/InnerHits.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  17) src/Query/CombinedFields.php (no_superfluous_phpdoc_tags, phpdoc_trim_consecutive_blank_line_separation)
  18) src/Query/MatchQuery.php (no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_trim_consecutive_blank_line_separation)
  19) src/Query/Script.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  20) src/Query/GeoShapePreIndexed.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  21) src/Multi/ResultSet.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  22) src/Util.php (string_implicit_backslashes)
  23) src/Bulk/ResponseSet.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  24) src/Bulk/Action/IndexDocument.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  25) src/Bulk/Action/DeleteDocument.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  26) src/Bulk/Action/UpdateDocument.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  27) src/Index.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  28) src/QueryBuilder/Facade.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  29) src/QueryBuilder/DSL/Query.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  30) src/Aggregation/AbstractSimpleAggregation.php (fully_qualified_strict_types, no_superfluous_phpdoc_tags, no_empty_phpdoc)
  31) src/Param.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  32) src/Suggest.php (fully_qualified_strict_types, no_superfluous_phpdoc_tags, no_empty_phpdoc)
  33) src/Script/AbstractScript.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  34) src/Script/Script.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  35) src/Script/ScriptId.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  36) src/Suggest/Phrase.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  37) tests/UtilTest.php (string_implicit_backslashes, no_superfluous_phpdoc_tags, phpdoc_trim)
  38) tests/Aggregation/TopHitsTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  39) tests/QueryTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  40) tests/ResultSet/ProcessingBuilderTest.php (fully_qualified_strict_types)
  41) src/Query/Ids.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  42) src/Query/HasChild.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  43) src/Result.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  44) src/Document.php (no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_trim, phpdoc_trim_consecutive_blank_line_separation)
  45) src/Processor/SetProcessor.php (no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_trim_consecutive_blank_line_separation)
  46) src/ResultSet/ChainProcessor.php (no_superfluous_phpdoc_tags, no_empty_phpdoc)
  47) src/Search.php (fully_qualified_strict_types, no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_types_order, phpdoc_trim, phpdoc_align)
  48) src/Client.php (no_superfluous_phpdoc_tags, no_empty_phpdoc, phpdoc_trim)
  49) src/Cluster/Settings.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  50) src/ResultSet.php (fully_qualified_strict_types)
  51) tests/BulkTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  52) tests/Exception/AbstractExceptionTest.php (string_implicit_backslashes)
  53) tests/ClientFunctionalTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  54) tests/Script/ScriptTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)
  55) tests/Script/ScriptIdTest.php (no_superfluous_phpdoc_tags, phpdoc_trim)

All rules are default one now and are part of @PhpCsFixer, except fully_qualified_strict_types.
I enabled it in a purpose. I'm planning to upgrade PHPUnit to 10.5 and migrate from doc blocks to attributes with the help of rectorphp.
So this rule will help me to fix code like:

#[\PHPUnit\Framework\Attributes\Group('unit')]

to be

use  PHPUnit\Framework\Attributes\Group;

#[Group('unit')]

Benefits of enabling parallelization:

- Found 0 of 425 files that can be fixed in 10.818 seconds, 22.000 MB memory used
+ Found 0 of 425 files that can be fixed in 5.513 seconds, 18.00 MB memory used

@sidz sidz force-pushed the update-php-cs-fixer branch 4 times, most recently from 2d574bf to 0d0cbd0 Compare July 21, 2024 19:48
Copy link
Owner

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall change LGTM, have left one question around the \ removal which shows up in several places and also needed test adjustments which makes me a bit nervous.

Is my understanding correct you want to get this in and follow on the phpunit change in a separate PR (my preference)

src/Util.php Outdated
@@ -67,7 +67,7 @@ public static function escapeDateMath($requestUri)

// '\\{' and '\\}' should not be escaped
if (\str_contains($uriSegment, '\\\\')) {
$escapedUriSegment = \str_replace(['\\\\%7B', '\\\\%7D'], ['\\\\{', '\\\\}'], $escapedUriSegment);
$escapedUriSegment = \str_replace(['\\\%7B', '\\\%7D'], ['\\\{', '\\\}'], $escapedUriSegment);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand this change and the one below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably I could explain better than described in the https://mlocati.github.io/php-cs-fixer-configurator/#version:3.59|fixer:string_implicit_backslashes.

I decided to disable this rule so code stay as it was before.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@sidz
Copy link
Contributor Author

sidz commented Jul 27, 2024

Is my understanding correct you want to get this in and follow on the phpunit change in a separate PR (my preference)

yes. This is my plan. Merge this PR and I could continue to work with phpunit migration

@ruflin ruflin merged commit 32b9cc1 into ruflin:8.x Aug 5, 2024
18 checks passed
@sidz sidz deleted the update-php-cs-fixer branch August 5, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants