diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 800a7b81a..ee94447c7 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -97,9 +97,12 @@ 'PhpCsFixer\\Console\\Command\\SelfUpdateCommand' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php', 'PhpCsFixer\\Console\\ConfigurationResolver' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php', 'PhpCsFixer\\Console\\Output\\ErrorOutput' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php', - 'PhpCsFixer\\Console\\Output\\NullOutput' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/NullOutput.php', - 'PhpCsFixer\\Console\\Output\\ProcessOutput' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutput.php', - 'PhpCsFixer\\Console\\Output\\ProcessOutputInterface' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutputInterface.php', + 'PhpCsFixer\\Console\\Output\\OutputContext' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/OutputContext.php', + 'PhpCsFixer\\Console\\Output\\Progress\\DotsOutput' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/DotsOutput.php', + 'PhpCsFixer\\Console\\Output\\Progress\\NullOutput' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/NullOutput.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputFactory' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputFactory.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputInterface' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputInterface.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputType' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputType.php', 'PhpCsFixer\\Console\\Report\\FixReport\\CheckstyleReporter' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/CheckstyleReporter.php', 'PhpCsFixer\\Console\\Report\\FixReport\\GitlabReporter' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php', 'PhpCsFixer\\Console\\Report\\FixReport\\JsonReporter' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JsonReporter.php', @@ -187,6 +190,7 @@ 'PhpCsFixer\\Fixer\\ArrayNotation\\NormalizeIndexBraceFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/NormalizeIndexBraceFixer.php', 'PhpCsFixer\\Fixer\\ArrayNotation\\TrimArraySpacesFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/TrimArraySpacesFixer.php', 'PhpCsFixer\\Fixer\\ArrayNotation\\WhitespaceAfterCommaInArrayFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php', + 'PhpCsFixer\\Fixer\\ArrayNotation\\YieldFromArrayToYieldsFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php', 'PhpCsFixer\\Fixer\\Basic\\BracesFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/BracesFixer.php', 'PhpCsFixer\\Fixer\\Basic\\CurlyBracesPositionFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php', 'PhpCsFixer\\Fixer\\Basic\\EncodingFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/EncodingFixer.php', @@ -311,6 +315,7 @@ 'PhpCsFixer\\Fixer\\LanguageConstruct\\GetClassToClassKeywordFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\IsNullFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/IsNullFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\NoUnsetOnPropertyFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NoUnsetOnPropertyFixer.php', + 'PhpCsFixer\\Fixer\\LanguageConstruct\\NullableTypeDeclarationFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NullableTypeDeclarationFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\SingleSpaceAfterConstructFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\SingleSpaceAroundConstructFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php', 'PhpCsFixer\\Fixer\\ListNotation\\ListSyntaxFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/ListNotation/ListSyntaxFixer.php', @@ -347,6 +352,7 @@ 'PhpCsFixer\\Fixer\\PhpTag\\NoClosingTagFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpTag/NoClosingTagFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitConstructFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderNameFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderNameFixer.php', + 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderReturnTypeFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderReturnTypeFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderStaticFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderStaticFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDedicateAssertFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDedicateAssertInternalTypeFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php', @@ -434,6 +440,7 @@ 'PhpCsFixer\\Fixer\\Whitespace\\NoWhitespaceInBlankLineFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\SingleBlankLineAtEofFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/SingleBlankLineAtEofFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\StatementIndentationFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php', + 'PhpCsFixer\\Fixer\\Whitespace\\TypeDeclarationSpacesFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypeDeclarationSpacesFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\TypesSpacesFixer' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php', 'PhpCsFixer\\Fixer\\WhitespacesAwareFixerInterface' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Fixer/WhitespacesAwareFixerInterface.php', 'PhpCsFixer\\Indicator\\PhpUnitTestCaseIndicator' => $vendorDir . '/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 9be6f1461..44dc94b6c 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -278,9 +278,12 @@ class ComposerStaticInit432d9322d3d4193d52e9a1d1ec2ff418 'PhpCsFixer\\Console\\Command\\SelfUpdateCommand' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php', 'PhpCsFixer\\Console\\ConfigurationResolver' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php', 'PhpCsFixer\\Console\\Output\\ErrorOutput' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php', - 'PhpCsFixer\\Console\\Output\\NullOutput' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/NullOutput.php', - 'PhpCsFixer\\Console\\Output\\ProcessOutput' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutput.php', - 'PhpCsFixer\\Console\\Output\\ProcessOutputInterface' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutputInterface.php', + 'PhpCsFixer\\Console\\Output\\OutputContext' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/OutputContext.php', + 'PhpCsFixer\\Console\\Output\\Progress\\DotsOutput' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/DotsOutput.php', + 'PhpCsFixer\\Console\\Output\\Progress\\NullOutput' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/NullOutput.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputFactory' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputFactory.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputInterface' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputInterface.php', + 'PhpCsFixer\\Console\\Output\\Progress\\ProgressOutputType' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputType.php', 'PhpCsFixer\\Console\\Report\\FixReport\\CheckstyleReporter' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/CheckstyleReporter.php', 'PhpCsFixer\\Console\\Report\\FixReport\\GitlabReporter' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php', 'PhpCsFixer\\Console\\Report\\FixReport\\JsonReporter' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JsonReporter.php', @@ -368,6 +371,7 @@ class ComposerStaticInit432d9322d3d4193d52e9a1d1ec2ff418 'PhpCsFixer\\Fixer\\ArrayNotation\\NormalizeIndexBraceFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/NormalizeIndexBraceFixer.php', 'PhpCsFixer\\Fixer\\ArrayNotation\\TrimArraySpacesFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/TrimArraySpacesFixer.php', 'PhpCsFixer\\Fixer\\ArrayNotation\\WhitespaceAfterCommaInArrayFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php', + 'PhpCsFixer\\Fixer\\ArrayNotation\\YieldFromArrayToYieldsFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php', 'PhpCsFixer\\Fixer\\Basic\\BracesFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/BracesFixer.php', 'PhpCsFixer\\Fixer\\Basic\\CurlyBracesPositionFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php', 'PhpCsFixer\\Fixer\\Basic\\EncodingFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Basic/EncodingFixer.php', @@ -492,6 +496,7 @@ class ComposerStaticInit432d9322d3d4193d52e9a1d1ec2ff418 'PhpCsFixer\\Fixer\\LanguageConstruct\\GetClassToClassKeywordFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/GetClassToClassKeywordFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\IsNullFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/IsNullFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\NoUnsetOnPropertyFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NoUnsetOnPropertyFixer.php', + 'PhpCsFixer\\Fixer\\LanguageConstruct\\NullableTypeDeclarationFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NullableTypeDeclarationFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\SingleSpaceAfterConstructFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAfterConstructFixer.php', 'PhpCsFixer\\Fixer\\LanguageConstruct\\SingleSpaceAroundConstructFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php', 'PhpCsFixer\\Fixer\\ListNotation\\ListSyntaxFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/ListNotation/ListSyntaxFixer.php', @@ -528,6 +533,7 @@ class ComposerStaticInit432d9322d3d4193d52e9a1d1ec2ff418 'PhpCsFixer\\Fixer\\PhpTag\\NoClosingTagFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpTag/NoClosingTagFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitConstructFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderNameFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderNameFixer.php', + 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderReturnTypeFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderReturnTypeFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDataProviderStaticFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderStaticFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDedicateAssertFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php', 'PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitDedicateAssertInternalTypeFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDedicateAssertInternalTypeFixer.php', @@ -615,6 +621,7 @@ class ComposerStaticInit432d9322d3d4193d52e9a1d1ec2ff418 'PhpCsFixer\\Fixer\\Whitespace\\NoWhitespaceInBlankLineFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\SingleBlankLineAtEofFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/SingleBlankLineAtEofFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\StatementIndentationFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php', + 'PhpCsFixer\\Fixer\\Whitespace\\TypeDeclarationSpacesFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypeDeclarationSpacesFixer.php', 'PhpCsFixer\\Fixer\\Whitespace\\TypesSpacesFixer' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php', 'PhpCsFixer\\Fixer\\WhitespacesAwareFixerInterface' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Fixer/WhitespacesAwareFixerInterface.php', 'PhpCsFixer\\Indicator\\PhpUnitTestCaseIndicator' => __DIR__ . '/..' . '/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 333226ec5..d63416c81 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -439,17 +439,17 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.19.2", - "version_normalized": "3.19.2.0", + "version": "v3.22.0", + "version_normalized": "3.22.0.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "210dd89560edb27a8e0d5086b734ac5b5fd4e0e4" + "reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/210dd89560edb27a8e0d5086b734ac5b5fd4e0e4", - "reference": "210dd89560edb27a8e0d5086b734ac5b5fd4e0e4", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/92b019f6c8d79aa26349d0db7671d37440dc0ff3", + "reference": "92b019f6c8d79aa26349d0db7671d37440dc0ff3", "shasum": "" }, "require": { @@ -473,6 +473,7 @@ "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.0", "mikey179/vfsstream": "^1.6.11", @@ -492,7 +493,7 @@ "ext-dom": "For handling output formats in XML", "ext-mbstring": "For handling non-UTF8 characters." }, - "time": "2023-06-25T16:42:58+00:00", + "time": "2023-07-16T23:08:06+00:00", "bin": [ "php-cs-fixer" ], @@ -526,7 +527,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.19.2" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.22.0" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 68247dc24..8d298c0b3 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '180ecf1118ea88d2e06dae67a108592158b4ae66', + 'reference' => 'e5dc22e13dafdd0a9d40968c995c269690913677', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '180ecf1118ea88d2e06dae67a108592158b4ae66', + 'reference' => 'e5dc22e13dafdd0a9d40968c995c269690913677', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -74,9 +74,9 @@ 'dev_requirement' => false, ), 'friendsofphp/php-cs-fixer' => array( - 'pretty_version' => 'v3.19.2', - 'version' => '3.19.2.0', - 'reference' => '210dd89560edb27a8e0d5086b734ac5b5fd4e0e4', + 'pretty_version' => 'v3.22.0', + 'version' => '3.22.0.0', + 'reference' => '92b019f6c8d79aa26349d0db7671d37440dc0ff3', 'type' => 'application', 'install_path' => __DIR__ . '/../friendsofphp/php-cs-fixer', 'aliases' => array(), diff --git a/vendor/friendsofphp/php-cs-fixer/CHANGELOG.md b/vendor/friendsofphp/php-cs-fixer/CHANGELOG.md index ea768a7a1..2993a52f0 100644 --- a/vendor/friendsofphp/php-cs-fixer/CHANGELOG.md +++ b/vendor/friendsofphp/php-cs-fixer/CHANGELOG.md @@ -3,6 +3,80 @@ CHANGELOG for PHP CS Fixer This file contains changelogs for stable releases only. +Changelog for v3.22.0 +--------------------- + +* DX: add proper test for `SelfAccessorFixer` must run before `SelfAccessorFixer` (#7153) +* DX: FixerFactoryTest - apply CS (#7154) +* feature: Introduce `PhpUnitDataProviderReturnTypeFixer` (#7156) +* feature: Introduce `YieldFromArrayToYieldsFixer` (#7114) + +Changelog for v3.21.3 +--------------------- + +* Revert "DX: encourage to provide wider description" (#7155) + +Changelog for v3.21.2 +--------------------- + +* docs: check format of FixerDefinition::getDescription() (#7127) +* DX: add phpstan/phpstan-strict-rules (#7143) +* DX: allow for progressive cache (#7132) +* DX: Copy-pasteable `class::getPriority` for phpDoc diffs (#7148) +* DX: do not allow linebreak at the beginning of code sample (#7126) +* DX: encourage to provide wider description (#7128) +* DX: fix function calls (#7136) +* DX: fix PHPDoc types issues (#7135) +* DX: improve `Tokens` checking for found tokens (#7139) +* DX: Make `AbstractFixerTestCase::getTestFile()` final (#7116) +* DX: make `array_search` call strict (#7145) +* DX: remove `empty` calls (#7138) +* DX: store cache to file only if content will get modified (#7151) +* DX: unify Preg:match in logical conditions (#7146) +* DX: use booleans in conditions (#7149) +* DX: Use ParaUnit to speed up tests (#6883) +* DX: Use relative fixture path as integration test case's name (#7147) +* DX: use strict assertions (#7144) +* DX: `AbstractIntegrationTestCase::provideIntegrationCases` - yield over array, better typehinting (#7150) + +Changelog for v3.21.1 +--------------------- + +experimental release + +* Require PHP ^8.0.1 + +Changelog for v3.21.0 +--------------------- + +* bug: Fix and enhance Gitlab reporter (#7089) +* bug: Import with different case must not be removed by non-risky fixer (#7095) +* bug: ordered imports fixer top group only (#7023) +* bug: `FinalPublicMethodForAbstractClassFixer` - fix for readonly classes (#7123) +* DX: do not nest ".editorconfig" files (#7112) +* DX: exclude Dockerfile from dist (#7113) +* DX: fix checkbashisms installation (#7102) +* DX: fix Smoke tests for various git default branch name (#7119) +* DX: Fix `FileRemovalTest` (do not fail when running it standalone) (#7104) +* DX: Progress output refactor (#6848) +* DX: Rename abstract test classes to `*TestCase` convention (#7100) +* DX: test all PHPUnit migration sets (#7107) +* DX: [Docker] Distinguish Alpine version between PHP versions (#7105) +* feature: Create cache path if it does not exist (#7109) +* feature: Introduce `NullableTypeDeclarationFixer` (#7002) +* feature: Introduce `TypeDeclarationSpacesFixer` (#7001) +* feature: `BlankLineBetweenImportGroupsFixer` - keep indent (#7122) +* minor: Parse callable using full phpdoc grammar (#7094) +* minor: PHP8.3 const type tokenizing (#7055) + +Changelog for v3.20.0 +--------------------- + +* DX: fix priority of `FinalClassFixer` (#7091) +* DX: use FAST_LINT_TEST_CASES=1 for CI run on macOS (#7092) +* feature: SingleLineEmptyBodyFixer - support interfaces, traits and enums (#7096) +* feature: `NullableTypeDeclarationForDefaultNullValue` - support for nullability in union types (#5819) + Changelog for v3.19.2 --------------------- diff --git a/vendor/friendsofphp/php-cs-fixer/Dockerfile b/vendor/friendsofphp/php-cs-fixer/Dockerfile deleted file mode 100644 index c7f8217fc..000000000 --- a/vendor/friendsofphp/php-cs-fixer/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -ARG PHP_VERSION - -FROM php:${PHP_VERSION}-cli-alpine3.16 - -ARG DOCKER_USER_ID -ARG DOCKER_GROUP_ID -ARG PHP_XDEBUG_VERSION - -# https://blog.codito.dev/2022/11/composer-binary-only-docker-images/ -# https://github.com/composer/docker/pull/250 -COPY --from=composer/composer:2-bin /composer /usr/local/bin/composer - -RUN if ! getent group "${DOCKER_GROUP_ID}" > /dev/null; \ - then addgroup -S -g "${DOCKER_GROUP_ID}" devs; \ - fi \ - && if ! getent passwd "${DOCKER_USER_ID}" > /dev/null; \ - then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \ - fi \ - # php extensions - && curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \ - && chmod +x /usr/local/bin/install-php-extensions \ - && sync \ - && install-php-extensions \ - pcntl \ - xdebug-${PHP_XDEBUG_VERSION} \ - # xdebug command - && curl --location --output /usr/local/bin/xdebug https://github.com/julienfalque/xdebug/releases/download/v2.0.0/xdebug \ - && chmod +x /usr/local/bin/xdebug - -COPY docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini diff --git a/vendor/friendsofphp/php-cs-fixer/composer.json b/vendor/friendsofphp/php-cs-fixer/composer.json index e3ea370f7..13158af21 100644 --- a/vendor/friendsofphp/php-cs-fixer/composer.json +++ b/vendor/friendsofphp/php-cs-fixer/composer.json @@ -40,6 +40,7 @@ "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.0", "mikey179/vfsstream": "^1.6.11", diff --git a/vendor/friendsofphp/php-cs-fixer/src/AbstractPhpdocToTypeDeclarationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/AbstractPhpdocToTypeDeclarationFixer.php index cfab3e460..4e595cce8 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/AbstractPhpdocToTypeDeclarationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/AbstractPhpdocToTypeDeclarationFixer.php @@ -201,7 +201,7 @@ protected function getCommonTypeFromAnnotation(Annotation $annotation, bool $isR if (false === $this->configuration['scalar_types']) { return null; } - } elseif (1 !== Preg::match('/^'.self::REGEX_CLASS.'$/', $commonType)) { + } elseif (!Preg::match('/^'.self::REGEX_CLASS.'$/', $commonType)) { return null; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Cache/FileCacheManager.php b/vendor/friendsofphp/php-cs-fixer/src/Cache/FileCacheManager.php index d17afb8c7..1e3f64dc1 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Cache/FileCacheManager.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Cache/FileCacheManager.php @@ -32,6 +32,8 @@ */ final class FileCacheManager implements CacheManagerInterface { + public const WRITE_FREQUENCY = 10; + private FileHandlerInterface $handler; private SignatureInterface $signature; @@ -40,6 +42,10 @@ final class FileCacheManager implements CacheManagerInterface private DirectoryInterface $cacheDirectory; + private int $writeCounter = 0; + + private bool $signatureWasUpdated = false; + /** * @var CacheInterface */ @@ -61,7 +67,9 @@ public function __construct( public function __destruct() { - $this->writeCache(); + if (true === $this->signatureWasUpdated || 0 !== $this->writeCounter) { + $this->writeCache(); + } } /** @@ -99,11 +107,14 @@ public function setFile(string $file, string $fileContent): void if ($this->isDryRun && $this->cache->has($file) && $this->cache->get($file) !== $hash) { $this->cache->clear($file); - - return; + } else { + $this->cache->set($file, $hash); } - $this->cache->set($file, $hash); + if (self::WRITE_FREQUENCY === ++$this->writeCounter) { + $this->writeCounter = 0; + $this->writeCache(); + } } private function readCache(): void @@ -112,6 +123,7 @@ private function readCache(): void if (null === $cache || !$this->signature->equals($cache->getSignature())) { $cache = new Cache($this->signature); + $this->signatureWasUpdated = true; } $this->cache = $cache; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Cache/FileHandler.php b/vendor/friendsofphp/php-cs-fixer/src/Cache/FileHandler.php index 059e6b426..675eed084 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Cache/FileHandler.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Cache/FileHandler.php @@ -77,9 +77,15 @@ public function write(CacheInterface $cache): void } else { $dir = \dirname($this->file); + // Ensure path is created, but ignore if already exists. FYI: ignore EA suggestion in IDE, + // `mkdir()` returns `false` for existing paths, so we can't mix it with `is_dir()` in one condition. + if (!is_dir($dir)) { + @mkdir($dir, 0777, true); + } + if (!is_dir($dir)) { throw new IOException( - sprintf('Directory of cache file "%s" does not exists.', $this->file), + sprintf('Directory of cache file "%s" does not exists and couldn\'t be created.', $this->file), 0, null, $this->file diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php index 113440266..55e7614cb 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Application.php @@ -39,8 +39,8 @@ */ final class Application extends BaseApplication { - public const VERSION = '3.19.2'; - public const VERSION_CODENAME = 'Triangle'; + public const VERSION = '3.22.0'; + public const VERSION_CODENAME = 'Chips & Pizza'; private ToolInfo $toolInfo; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DescribeCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DescribeCommand.php index eb2faf30d..5cb602278 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DescribeCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DescribeCommand.php @@ -52,9 +52,6 @@ #[AsCommand(name: 'describe')] final class DescribeCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'describe'; /** diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DocumentationCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DocumentationCommand.php index 95a7f57bf..18c5c317b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DocumentationCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/DocumentationCommand.php @@ -34,9 +34,6 @@ #[AsCommand(name: 'documentation')] final class DocumentationCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'documentation'; protected function configure(): void diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommand.php index e0a171695..d4f95d161 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/FixCommand.php @@ -19,10 +19,12 @@ use PhpCsFixer\ConfigurationException\InvalidConfigurationException; use PhpCsFixer\Console\ConfigurationResolver; use PhpCsFixer\Console\Output\ErrorOutput; -use PhpCsFixer\Console\Output\NullOutput; -use PhpCsFixer\Console\Output\ProcessOutput; +use PhpCsFixer\Console\Output\OutputContext; +use PhpCsFixer\Console\Output\Progress\ProgressOutputFactory; +use PhpCsFixer\Console\Output\Progress\ProgressOutputType; use PhpCsFixer\Console\Report\FixReport\ReportSummary; use PhpCsFixer\Error\ErrorsManager; +use PhpCsFixer\FixerFileProcessedEvent; use PhpCsFixer\Runner\Runner; use PhpCsFixer\ToolInfoInterface; use Symfony\Component\Console\Attribute\AsCommand; @@ -46,9 +48,6 @@ #[AsCommand(name: 'fix')] final class FixCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'fix'; private EventDispatcherInterface $eventDispatcher; @@ -61,6 +60,8 @@ final class FixCommand extends Command private ToolInfoInterface $toolInfo; + private ProgressOutputFactory $progressOutputFactory; + public function __construct(ToolInfoInterface $toolInfo) { parent::__construct(); @@ -70,6 +71,7 @@ public function __construct(ToolInfoInterface $toolInfo) $this->stopwatch = new Stopwatch(); $this->defaultConfig = new Config(); $this->toolInfo = $toolInfo; + $this->progressOutputFactory = new ProgressOutputFactory(); } /** @@ -97,6 +99,7 @@ public function getHelp(): string NOTE: the output for the following formats are generated in accordance with schemas * `checkstyle` follows the common `"checkstyle" XML schema `_ +* `gitlab` follows the `codeclimate JSON schema `_ * `json` follows the `own JSON schema `_ * `junit` follows the `JUnit XML schema from Jenkins `_ * `xml` follows the `own XML schema `_ @@ -263,7 +266,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $progressType = $resolver->getProgress(); $finder = new \ArrayIterator(iterator_to_array($resolver->getFinder())); if (null !== $stdErr && $resolver->configFinderIsOverridden()) { @@ -272,22 +274,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); } - if ('none' === $progressType || null === $stdErr) { - $progressOutput = new NullOutput(); - } else { - $progressOutput = new ProcessOutput( + $progressType = $resolver->getProgressType(); + $progressOutput = $this->progressOutputFactory->create( + $progressType, + new OutputContext( $stdErr, - $this->eventDispatcher, (new Terminal())->getWidth(), \count($finder) - ); - } + ) + ); $runner = new Runner( $finder, $resolver->getFixers(), $resolver->getDiffer(), - 'none' !== $progressType ? $this->eventDispatcher : null, + ProgressOutputType::NONE !== $progressType ? $this->eventDispatcher : null, $this->errorsManager, $resolver->getLinter(), $resolver->isDryRun(), @@ -296,9 +297,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $resolver->shouldStopOnViolation() ); + $this->eventDispatcher->addListener(FixerFileProcessedEvent::NAME, [$progressOutput, 'onFixerFileProcessed']); $this->stopwatch->start('fixFiles'); $changed = $runner->fix(); $this->stopwatch->stop('fixFiles'); + $this->eventDispatcher->removeListener(FixerFileProcessedEvent::NAME, [$progressOutput, 'onFixerFileProcessed']); $progressOutput->printLegend(); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/HelpCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/HelpCommand.php index 4b7cbf416..3874208dc 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/HelpCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/HelpCommand.php @@ -32,9 +32,6 @@ #[AsCommand(name: 'help')] final class HelpCommand extends BaseHelpCommand { - /** - * @var string - */ protected static $defaultName = 'help'; /** diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListFilesCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListFilesCommand.php index b036fbac4..935491167 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListFilesCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListFilesCommand.php @@ -33,9 +33,6 @@ #[AsCommand(name: 'list-files')] final class ListFilesCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'list-files'; private ConfigInterface $defaultConfig; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListSetsCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListSetsCommand.php index d3877259a..f56233465 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListSetsCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/ListSetsCommand.php @@ -36,9 +36,6 @@ #[AsCommand(name: 'list-sets')] final class ListSetsCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'list-sets'; protected function configure(): void diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php index 4f5c6a067..fed2ffa10 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Command/SelfUpdateCommand.php @@ -36,9 +36,6 @@ #[AsCommand(name: 'self-update')] final class SelfUpdateCommand extends Command { - /** - * @var string - */ protected static $defaultName = 'self-update'; private NewVersionCheckerInterface $versionChecker; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php b/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php index edfa14cf6..d6906953b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/ConfigurationResolver.php @@ -23,6 +23,7 @@ use PhpCsFixer\Cache\Signature; use PhpCsFixer\ConfigInterface; use PhpCsFixer\ConfigurationException\InvalidConfigurationException; +use PhpCsFixer\Console\Output\Progress\ProgressOutputType; use PhpCsFixer\Console\Report\FixReport\ReporterFactory; use PhpCsFixer\Console\Report\FixReport\ReporterInterface; use PhpCsFixer\Differ\DifferInterface; @@ -406,26 +407,27 @@ static function (string $rawPath) use ($cwd, $filesystem): string { /** * @throws InvalidConfigurationException */ - public function getProgress(): string + public function getProgressType(): string { if (null === $this->progress) { if (OutputInterface::VERBOSITY_VERBOSE <= $this->options['verbosity'] && 'txt' === $this->getFormat()) { $progressType = $this->options['show-progress']; - $progressTypes = ['none', 'dots']; if (null === $progressType) { - $progressType = $this->getConfig()->getHideProgress() ? 'none' : 'dots'; - } elseif (!\in_array($progressType, $progressTypes, true)) { + $progressType = $this->getConfig()->getHideProgress() + ? ProgressOutputType::NONE + : ProgressOutputType::DOTS; + } elseif (!\in_array($progressType, ProgressOutputType::AVAILABLE, true)) { throw new InvalidConfigurationException(sprintf( 'The progress type "%s" is not defined, supported are %s.', $progressType, - Utils::naturalLanguageJoin($progressTypes) + Utils::naturalLanguageJoin(ProgressOutputType::AVAILABLE) )); } $this->progress = $progressType; } else { - $this->progress = 'none'; + $this->progress = ProgressOutputType::NONE; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php index 926872aff..5cb8adb3c 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ErrorOutput.php @@ -101,7 +101,7 @@ public function listErrors(string $process, array $errors): void $this->output->writeln(sprintf(' Applied fixers: %s', implode(', ', $error->getAppliedFixers()))); $diff = $error->getDiff(); - if (!empty($diff)) { + if (null !== $diff) { $diffFormatter = new DiffConsoleFormatter( $this->isDecorated, sprintf( diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/OutputContext.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/OutputContext.php new file mode 100644 index 000000000..84a0ea6f8 --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/OutputContext.php @@ -0,0 +1,52 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Console\Output; + +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @internal + */ +final class OutputContext +{ + private ?OutputInterface $output; + private int $terminalWidth; + private int $filesCount; + + public function __construct( + ?OutputInterface $output, + int $terminalWidth, + int $filesCount + ) { + $this->output = $output; + $this->terminalWidth = $terminalWidth; + $this->filesCount = $filesCount; + } + + public function getOutput(): ?OutputInterface + { + return $this->output; + } + + public function getTerminalWidth(): int + { + return $this->terminalWidth; + } + + public function getFilesCount(): int + { + return $this->filesCount; + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutput.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/DotsOutput.php similarity index 67% rename from vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutput.php rename to vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/DotsOutput.php index 6d504b8e2..4df85f819 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutput.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/DotsOutput.php @@ -12,18 +12,18 @@ * with this source code in the file LICENSE. */ -namespace PhpCsFixer\Console\Output; +namespace PhpCsFixer\Console\Output\Progress; +use PhpCsFixer\Console\Output\OutputContext; use PhpCsFixer\FixerFileProcessedEvent; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Output writer to show the process of a FixCommand. + * Output writer to show the progress of a FixCommand using dots and meaningful letters. * * @internal */ -final class ProcessOutput implements ProcessOutputInterface +final class DotsOutput implements ProgressOutputInterface { /** * File statuses map. @@ -39,11 +39,8 @@ final class ProcessOutput implements ProcessOutputInterface FixerFileProcessedEvent::STATUS_LINT => ['symbol' => 'E', 'format' => '%s', 'description' => 'error'], ]; - private OutputInterface $output; - - private EventDispatcherInterface $eventDispatcher; - - private int $files; + /** @readonly */ + private OutputContext $context; private int $processedFiles = 0; @@ -52,22 +49,14 @@ final class ProcessOutput implements ProcessOutputInterface */ private $symbolsPerLine; - public function __construct(OutputInterface $output, EventDispatcherInterface $dispatcher, int $width, int $nbFiles) + public function __construct(OutputContext $context) { - $this->output = $output; - $this->eventDispatcher = $dispatcher; - $this->eventDispatcher->addListener(FixerFileProcessedEvent::NAME, [$this, 'onFixerFileProcessed']); - $this->files = $nbFiles; + $this->context = $context; // max number of characters per line // - total length x 2 (e.g. " 1 / 123" => 6 digits and padding spaces) // - 11 (extra spaces, parentheses and percentage characters, e.g. " x / x (100%)") - $this->symbolsPerLine = max(1, $width - \strlen((string) $this->files) * 2 - 11); - } - - public function __destruct() - { - $this->eventDispatcher->removeListener(FixerFileProcessedEvent::NAME, [$this, 'onFixerFileProcessed']); + $this->symbolsPerLine = max(1, $context->getTerminalWidth() - \strlen((string) $context->getFilesCount()) * 2 - 11); } /** @@ -93,24 +82,24 @@ public function __wakeup(): void public function onFixerFileProcessed(FixerFileProcessedEvent $event): void { $status = self::$eventStatusMap[$event->getStatus()]; - $this->output->write($this->output->isDecorated() ? sprintf($status['format'], $status['symbol']) : $status['symbol']); + $this->getOutput()->write($this->getOutput()->isDecorated() ? sprintf($status['format'], $status['symbol']) : $status['symbol']); ++$this->processedFiles; $symbolsOnCurrentLine = $this->processedFiles % $this->symbolsPerLine; - $isLast = $this->processedFiles === $this->files; + $isLast = $this->processedFiles === $this->context->getFilesCount(); if (0 === $symbolsOnCurrentLine || $isLast) { - $this->output->write(sprintf( - '%s %'.\strlen((string) $this->files).'d / %d (%3d%%)', + $this->getOutput()->write(sprintf( + '%s %'.\strlen((string) $this->context->getFilesCount()).'d / %d (%3d%%)', $isLast && 0 !== $symbolsOnCurrentLine ? str_repeat(' ', $this->symbolsPerLine - $symbolsOnCurrentLine) : '', $this->processedFiles, - $this->files, - round($this->processedFiles / $this->files * 100) + $this->context->getFilesCount(), + round($this->processedFiles / $this->context->getFilesCount() * 100) )); if (!$isLast) { - $this->output->writeln(''); + $this->getOutput()->writeln(''); } } } @@ -125,9 +114,14 @@ public function printLegend(): void continue; } - $symbols[$symbol] = sprintf('%s-%s', $this->output->isDecorated() ? sprintf($status['format'], $symbol) : $symbol, $status['description']); + $symbols[$symbol] = sprintf('%s-%s', $this->getOutput()->isDecorated() ? sprintf($status['format'], $symbol) : $symbol, $status['description']); } - $this->output->write(sprintf("\nLegend: %s\n", implode(', ', $symbols))); + $this->getOutput()->write(sprintf("\nLegend: %s\n", implode(', ', $symbols))); + } + + private function getOutput(): OutputInterface + { + return $this->context->getOutput(); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/NullOutput.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/NullOutput.php similarity index 61% rename from vendor/friendsofphp/php-cs-fixer/src/Console/Output/NullOutput.php rename to vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/NullOutput.php index 38b6999e1..7fc042494 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/NullOutput.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/NullOutput.php @@ -12,14 +12,20 @@ * with this source code in the file LICENSE. */ -namespace PhpCsFixer\Console\Output; +namespace PhpCsFixer\Console\Output\Progress; + +use PhpCsFixer\FixerFileProcessedEvent; /** * @internal */ -final class NullOutput implements ProcessOutputInterface +final class NullOutput implements ProgressOutputInterface { public function printLegend(): void { } + + public function onFixerFileProcessed(FixerFileProcessedEvent $event): void + { + } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputFactory.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputFactory.php new file mode 100644 index 000000000..703170fd0 --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputFactory.php @@ -0,0 +1,51 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Console\Output\Progress; + +use PhpCsFixer\Console\Output\OutputContext; + +/** + * @internal + */ +final class ProgressOutputFactory +{ + public function create(string $outputType, OutputContext $context): ProgressOutputInterface + { + if (null === $context->getOutput()) { + $outputType = ProgressOutputType::NONE; + } + + if (!$this->isBuiltInType($outputType)) { + throw new \InvalidArgumentException( + sprintf( + 'Something went wrong, "%s" output type is not supported', + $outputType + ) + ); + } + + return ProgressOutputType::NONE === $outputType + ? new NullOutput() + : new DotsOutput($context); + } + + private function isBuiltInType(string $outputType): bool + { + return \in_array($outputType, [ + ProgressOutputType::NONE, + ProgressOutputType::DOTS, + ], true); + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutputInterface.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputInterface.php similarity index 64% rename from vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutputInterface.php rename to vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputInterface.php index 80726c380..b5ab95173 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/ProcessOutputInterface.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputInterface.php @@ -12,12 +12,16 @@ * with this source code in the file LICENSE. */ -namespace PhpCsFixer\Console\Output; +namespace PhpCsFixer\Console\Output\Progress; + +use PhpCsFixer\FixerFileProcessedEvent; /** * @internal */ -interface ProcessOutputInterface +interface ProgressOutputInterface { public function printLegend(): void; + + public function onFixerFileProcessed(FixerFileProcessedEvent $event): void; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputType.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputType.php new file mode 100644 index 000000000..4c005f89d --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Output/Progress/ProgressOutputType.php @@ -0,0 +1,29 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Console\Output\Progress; + +/** + * @internal + */ +final class ProgressOutputType +{ + public const NONE = 'none'; + public const DOTS = 'dots'; + + public const AVAILABLE = [ + self::NONE, + self::DOTS, + ]; +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php index 974d66d11..073656ffb 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/GitlabReporter.php @@ -14,6 +14,8 @@ namespace PhpCsFixer\Console\Report\FixReport; +use SebastianBergmann\Diff\Chunk; +use SebastianBergmann\Diff\Parser; use Symfony\Component\Console\Formatter\OutputFormatter; /** @@ -27,6 +29,13 @@ */ final class GitlabReporter implements ReporterInterface { + private Parser $diffParser; + + public function __construct() + { + $this->diffParser = new Parser(); + } + public function getFormat(): string { return 'gitlab'; @@ -39,15 +48,21 @@ public function generate(ReportSummary $reportSummary): string { $report = []; foreach ($reportSummary->getChanged() as $fileName => $change) { + $diffs = $this->diffParser->parse($change['diff']); + $firstChunk = isset($diffs[0]) ? $diffs[0]->getChunks() : []; + $firstChunk = array_shift($firstChunk); foreach ($change['appliedFixers'] as $fixerName) { $report[] = [ + 'check_name' => $fixerName, 'description' => $fixerName, + 'categories' => ['Style'], 'fingerprint' => md5($fileName.$fixerName), 'severity' => 'minor', 'location' => [ 'path' => $fileName, 'lines' => [ - 'begin' => 0, // line numbers are required in the format, but not available to reports + 'begin' => $firstChunk instanceof Chunk ? $firstChunk->getStart() : 0, + 'end' => $firstChunk instanceof Chunk ? $firstChunk->getStartRange() : 0, ], ], ]; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JunitReporter.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JunitReporter.php index 1ee6997d3..631b28e97 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JunitReporter.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/JunitReporter.php @@ -38,7 +38,7 @@ public function generate(ReportSummary $reportSummary): string $dom = new \DOMDocument('1.0', 'UTF-8'); $testsuites = $dom->appendChild($dom->createElement('testsuites')); - /** @var \DomElement $testsuite */ + /** @var \DOMElement $testsuite */ $testsuite = $testsuites->appendChild($dom->createElement('testsuite')); $testsuite->setAttribute('name', 'PHP CS Fixer'); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/ReporterFactory.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/ReporterFactory.php index d091f441c..e4efd9907 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/ReporterFactory.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/FixReport/ReporterFactory.php @@ -23,9 +23,7 @@ */ final class ReporterFactory { - /** - * @var array - */ + /** @var array */ private array $reporters = []; public function registerBuiltInReporters(): self @@ -41,7 +39,7 @@ public function registerBuiltInReporters(): self $builtInReporters[] = sprintf( '%s\\%s%s', __NAMESPACE__, - $relativeNamespace ? $relativeNamespace.'\\' : '', + '' !== $relativeNamespace ? $relativeNamespace.'\\' : '', $file->getBasename('.php') ); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/ListSetsReport/ReporterFactory.php b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/ListSetsReport/ReporterFactory.php index cbbb7f4e8..45f2a26f2 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Console/Report/ListSetsReport/ReporterFactory.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Console/Report/ListSetsReport/ReporterFactory.php @@ -41,7 +41,7 @@ public function registerBuiltInReporters(): self $builtInReporters[] = sprintf( '%s\\%s%s', __NAMESPACE__, - $relativeNamespace ? $relativeNamespace.'\\' : '', + '' !== $relativeNamespace ? $relativeNamespace.'\\' : '', $file->getBasename('.php') ); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Differ/UnifiedDiffer.php b/vendor/friendsofphp/php-cs-fixer/src/Differ/UnifiedDiffer.php index 9a52cab47..36663aa19 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Differ/UnifiedDiffer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Differ/UnifiedDiffer.php @@ -30,7 +30,7 @@ public function diff(string $old, string $new, ?\SplFileInfo $file = null): stri } else { $filePath = $file->getRealPath(); - if (1 === Preg::match('/\s/', $filePath)) { + if (Preg::match('/\s/', $filePath)) { $filePath = '"'.$filePath.'"'; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Annotation.php b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Annotation.php index 9a3fbe7f4..234c1fe3b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Annotation.php +++ b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Annotation.php @@ -297,7 +297,7 @@ private function getTypesContent(): ?string $matches ); - $this->typesContent = 1 === $matchingResult + $this->typesContent = $matchingResult ? $matches['types'] : null; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Line.php b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Line.php index 0db50e828..1e6fa5b94 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Line.php +++ b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/Line.php @@ -59,7 +59,7 @@ public function getContent(): string */ public function containsUsefulContent(): bool { - return 0 !== Preg::match('/\\*\s*\S+/', $this->content) && '' !== trim(str_replace(['/', '*'], ' ', $this->content)); + return Preg::match('/\\*\s*\S+/', $this->content) && '' !== trim(str_replace(['/', '*'], ' ', $this->content)); } /** @@ -69,7 +69,7 @@ public function containsUsefulContent(): bool */ public function containsATag(): bool { - return 0 !== Preg::match('/\\*\s*@/', $this->content); + return Preg::match('/\\*\s*@/', $this->content); } /** @@ -119,7 +119,7 @@ public function addBlank(): void { $matched = Preg::match('/^(\h*\*)[^\r\n]*(\r?\n)$/', $this->content, $matches); - if (1 !== $matched) { + if (!$matched) { return; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/TypeExpression.php b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/TypeExpression.php index 866e528fe..fdf0a09a8 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/DocBlock/TypeExpression.php +++ b/vendor/friendsofphp/php-cs-fixer/src/DocBlock/TypeExpression.php @@ -63,13 +63,19 @@ final class TypeExpression \h*\} ) | - (? # callable syntax, e.g. `callable(string): bool` - (?(?i)(?:callable|\\\\?Closure)(?-i)\h*\(\h*) + (? # callable syntax, e.g. `callable(string, int...): bool` + (?(?&name)\h*\(\h*) (? - (?&types_inner) + (? + (?(?&types_inner)) + (?\h*&|) + (?\h*\.\.\.|) + (?\h*\$(?&identifier)|) + (?\h*=|) + ) (?: \h*,\h* - (?&types_inner) + (?&callable_argument) )* (?:\h*,\h*)? |) @@ -81,16 +87,14 @@ final class TypeExpression ) | (? # generic syntax, e.g.: `array` - (? - (?&name)+ - \h*<\h* - ) + (?(?&name)\h*<\h*) (? (?&types_inner) (?: \h*,\h* (?&types_inner) )* + (?:\h*,\h*)? ) \h*> ) @@ -272,9 +276,9 @@ public function getCommonType(): ?string $type = substr($type, 1); } - if (1 === Preg::match('/\[\h*\]$/', $type)) { + if (Preg::match('/\[\h*\]$/', $type)) { $type = 'array'; - } elseif (1 === Preg::match('/^(.+?)\h*[<{(]/', $type, $matches)) { + } elseif (Preg::match('/^(.+?)\h*[<{(]/', $type, $matches)) { $type = $matches[1]; } @@ -356,7 +360,7 @@ private function parse(): void $matches['generic_types'][0] ); } elseif ('' !== ($matches['callable'][0] ?? '') && $matches['callable'][1] === $nullableLength) { - $this->parseCommaSeparatedInnerTypes( + $this->parseCallableArgumentTypes( $index + \strlen($matches['callable_start'][0]), $matches['callable_arguments'][0] ); @@ -433,6 +437,38 @@ private function parseCommaSeparatedInnerTypes(int $startIndex, string $value): } } + private function parseCallableArgumentTypes(int $startIndex, string $value): void + { + $index = 0; + while (\strlen($value) !== $index) { + Preg::match( + '{\G(?:(?=1)0'.self::REGEX_TYPES.'|(?<_callable_argument>(?&callable_argument))(?:\h*,\h*|$))}', + $value, + $prematches, + 0, + $index + ); + $consumedValue = $prematches['_callable_argument']; + $consumedValueLength = \strlen($consumedValue); + $consumedCommaLength = \strlen($prematches[0]) - $consumedValueLength; + + $addedPrefix = 'Closure('; + Preg::match( + '{^'.self::REGEX_TYPES.'$}', + $addedPrefix.$consumedValue.'): void', + $matches, + PREG_OFFSET_CAPTURE + ); + + $this->innerTypeExpressions[] = [ + 'start_index' => $startIndex + $index, + 'expression' => $this->inner($matches['callable_argument_type'][0]), + ]; + + $index += $consumedValueLength + $consumedCommaLength; + } + } + private function parseArrayShapeInnerTypes(int $startIndex, string $value): void { $index = 0; @@ -515,11 +551,11 @@ private function normalize(string $type): string return $type; } - if (1 === Preg::match('/\[\]$/', $type)) { + if (Preg::match('/\[\]$/', $type)) { return 'array'; } - if (1 === Preg::match('/^(.+?)errors); + return [] === $this->errors; } public function report(Error $error): void diff --git a/vendor/friendsofphp/php-cs-fixer/src/FileReader.php b/vendor/friendsofphp/php-cs-fixer/src/FileReader.php index d71f5f76e..d4fb752cb 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/FileReader.php +++ b/vendor/friendsofphp/php-cs-fixer/src/FileReader.php @@ -64,7 +64,7 @@ private function readRaw(string $realPath): string throw new \RuntimeException(sprintf( 'Failed to read content from "%s".%s', $realPath, - $error ? ' '.$error['message'] : '' + null !== $error ? ' '.$error['message'] : '' )); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/AbstractPhpUnitFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/AbstractPhpUnitFixer.php index 0f3910ec2..9d90aba13 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/AbstractPhpUnitFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/AbstractPhpUnitFixer.php @@ -152,7 +152,7 @@ private function addInternalAnnotation(DocBlock $docBlock, Tokens $tokens, int $ private function makeDocBlockMultiLineIfNeeded(DocBlock $doc, Tokens $tokens, int $docBlockIndex, string $annotation): DocBlock { $lines = $doc->getLines(); - if (1 === \count($lines) && empty($doc->getAnnotationsOfType($annotation))) { + if (1 === \count($lines) && [] === $doc->getAnnotationsOfType($annotation)) { $indent = WhitespacesAnalyzer::detectIndent($tokens, $tokens->getNextNonWhitespace($docBlockIndex)); $doc->makeMultiLine($indent, $this->whitespacesConfig->getLineEnding()); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php index 4e236a96b..a9c7d0516 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/WhitespaceAfterCommaInArrayFixer.php @@ -85,8 +85,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } elseif ( $this->configuration['ensure_single_space'] && ' ' !== $tokens[$i + 1]->getContent() - && 1 === Preg::match('/^\h+$/', $tokens[$i + 1]->getContent()) - && (!$tokens[$i + 2]->isComment() || 1 === Preg::match('/^\h+$/', $tokens[$i + 3]->getContent())) + && Preg::match('/^\h+$/', $tokens[$i + 1]->getContent()) + && (!$tokens[$i + 2]->isComment() || Preg::match('/^\h+$/', $tokens[$i + 3]->getContent())) ) { $tokens[$i + 1] = new Token([T_WHITESPACE, ' ']); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php new file mode 100644 index 000000000..93dab6471 --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ArrayNotation/YieldFromArrayToYieldsFixer.php @@ -0,0 +1,175 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Fixer\ArrayNotation; + +use PhpCsFixer\AbstractFixer; +use PhpCsFixer\FixerDefinition\CodeSample; +use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\Token; +use PhpCsFixer\Tokenizer\Tokens; + +/** + * @author Kuba Werłos + */ +final class YieldFromArrayToYieldsFixer extends AbstractFixer +{ + public function getDefinition(): FixerDefinitionInterface + { + return new FixerDefinition( + 'Yield from array must be unpacked to series of yields.', + [new CodeSample('isTokenKindFound(T_YIELD_FROM); + } + + /** + * {@inheritdoc} + * + * Must run before BlankLineBeforeStatementFixer, NoExtraBlankLinesFixer, NoMultipleStatementsPerLineFixer, NoWhitespaceInBlankLineFixer, StatementIndentationFixer. + */ + public function getPriority(): int + { + return 0; + } + + protected function applyFix(\SplFileInfo $file, Tokens $tokens): void + { + /** + * @var array $inserts + */ + $inserts = []; + + foreach ($this->getYieldsFromToUnpack($tokens) as $index => [$startIndex, $endIndex]) { + $tokens->clearTokenAndMergeSurroundingWhitespace($index); + + if ($tokens[$startIndex]->equals('(')) { + $prevStartIndex = $tokens->getPrevMeaningfulToken($startIndex); + $tokens->clearTokenAndMergeSurroundingWhitespace($prevStartIndex); // clear `array` from `array(` + } + + $tokens->clearTokenAndMergeSurroundingWhitespace($startIndex); + $tokens->clearTokenAndMergeSurroundingWhitespace($endIndex); + + $arrayHasTrailingComma = false; + + $inserts[$startIndex] = [new Token([T_YIELD, 'yield']), new Token([T_WHITESPACE, ' '])]; + foreach ($this->findArrayItemCommaIndex( + $tokens, + $tokens->getNextMeaningfulToken($startIndex), + $tokens->getPrevMeaningfulToken($endIndex), + ) as $commaIndex) { + $nextItemIndex = $tokens->getNextMeaningfulToken($commaIndex); + + if ($nextItemIndex < $endIndex) { + $inserts[$nextItemIndex] = [new Token([T_YIELD, 'yield']), new Token([T_WHITESPACE, ' '])]; + $tokens[$commaIndex] = new Token(';'); + } else { + $arrayHasTrailingComma = true; + // array has trailing comma - we replace it with `;` (as it's best fit to put it) + $tokens[$commaIndex] = new Token(';'); + } + } + + // there was a trailing comma, so we do not need original `;` after initial array structure + if (true === $arrayHasTrailingComma) { + $tokens->clearTokenAndMergeSurroundingWhitespace($tokens->getNextMeaningfulToken($endIndex)); + } + } + + $tokens->insertSlices($inserts); + } + + /** + * @return array> + */ + private function getYieldsFromToUnpack(Tokens $tokens): array + { + $yieldsFromToUnpack = []; + $tokensCount = $tokens->count(); + $index = 0; + while (++$index < $tokensCount) { + if (!$tokens[$index]->isGivenKind(T_YIELD_FROM)) { + continue; + } + + $prevIndex = $tokens->getPrevMeaningfulToken($index); + if (!$tokens[$prevIndex]->equalsAny([';', '{', [T_OPEN_TAG]])) { + continue; + } + + $arrayStartIndex = $tokens->getNextMeaningfulToken($index); + + if (!$tokens[$arrayStartIndex]->isGivenKind([T_ARRAY, CT::T_ARRAY_SQUARE_BRACE_OPEN])) { + continue; + } + + if ($tokens[$arrayStartIndex]->isGivenKind(T_ARRAY)) { + $startIndex = $tokens->getNextTokenOfKind($arrayStartIndex, ['(']); + $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startIndex); + } else { + $startIndex = $arrayStartIndex; + $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ARRAY_SQUARE_BRACE, $startIndex); + } + + // is there any nested "yield from"? + if ([] !== $tokens->findGivenKind(T_YIELD_FROM, $startIndex, $endIndex)) { + continue; + } + + $yieldsFromToUnpack[$index] = [$startIndex, $endIndex]; + } + + return $yieldsFromToUnpack; + } + + /** + * @return iterable + */ + private function findArrayItemCommaIndex(Tokens $tokens, int $startIndex, int $endIndex): iterable + { + for ($index = $startIndex; $index <= $endIndex; ++$index) { + $token = $tokens[$index]; + + // skip nested (), [], {} constructs + $blockDefinitionProbe = Tokens::detectBlockType($token); + + if (null !== $blockDefinitionProbe && true === $blockDefinitionProbe['isStart']) { + $index = $tokens->findBlockEnd($blockDefinitionProbe['type'], $index); + + continue; + } + + if (!$tokens[$index]->equals(',')) { + continue; + } + + yield $index; + } + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php index 355f0f355..091e1b7f0 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/CurlyBracesPositionFixer.php @@ -215,7 +215,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void if ( ($allowSingleLineIfEmpty && !$tokenInsideBraces->isWhitespace() && !$tokenInsideBraces->isComment()) - || ($tokenInsideBraces->isWhitespace() && 1 === Preg::match('/\R/', $tokenInsideBraces->getContent())) + || ($tokenInsideBraces->isWhitespace() && Preg::match('/\R/', $tokenInsideBraces->getContent())) ) { $addNewlinesInsideBraces = true; @@ -255,7 +255,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } if ( $tokens[$previousTokenIndex]->isWhitespace() - && 1 === Preg::match('/\R/', $tokens[$previousTokenIndex]->getContent()) + && Preg::match('/\R/', $tokens[$previousTokenIndex]->getContent()) ) { $whitespace = ' '; } @@ -337,7 +337,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void for ($prevIndex = $closeBraceIndex - 1; $tokens->isEmptyAt($prevIndex); --$prevIndex); $prevToken = $tokens[$prevIndex]; - if ($prevToken->isWhitespace() && 1 === Preg::match('/\R/', $prevToken->getContent())) { + if ($prevToken->isWhitespace() && Preg::match('/\R/', $prevToken->getContent())) { continue; } @@ -398,7 +398,7 @@ private function isFollowedByNewLine(Tokens $tokens, int $index): bool for (++$index, $max = \count($tokens) - 1; $index < $max; ++$index) { $token = $tokens[$index]; if (!$token->isComment()) { - return $token->isWhitespace() && 1 === Preg::match('/\R/', $token->getContent()); + return $token->isWhitespace() && Preg::match('/\R/', $token->getContent()); } } @@ -409,7 +409,7 @@ private function hasCommentOnSameLine(Tokens $tokens, int $index): bool { $token = $tokens[$index + 1]; - if ($token->isWhitespace() && 1 !== Preg::match('/\R/', $token->getContent())) { + if ($token->isWhitespace() && !Preg::match('/\R/', $token->getContent())) { $token = $tokens[$index + 2]; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/NoMultipleStatementsPerLineFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/NoMultipleStatementsPerLineFixer.php index 271a57067..d5c0b1498 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/NoMultipleStatementsPerLineFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/NoMultipleStatementsPerLineFixer.php @@ -42,7 +42,7 @@ public function getDefinition(): FixerDefinitionInterface * {@inheritdoc} * * Must run before CurlyBracesPositionFixer. - * Must run after ControlStructureBracesFixer, NoEmptyStatementFixer. + * Must run after ControlStructureBracesFixer, NoEmptyStatementFixer, YieldFromArrayToYieldsFixer. */ public function getPriority(): int { @@ -74,7 +74,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $token = $tokens[$nextIndex]; if ($token->isWhitespace() || $token->isComment()) { - if (1 === Preg::match('/\R/', $token->getContent())) { + if (Preg::match('/\R/', $token->getContent())) { break; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/OctalNotationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/OctalNotationFixer.php index 52789aa35..a2f500ab5 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/OctalNotationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/OctalNotationFixer.php @@ -52,11 +52,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $content = $token->getContent(); - if (1 !== Preg::match('#^0[\d_]+$#', $content)) { + if (!Preg::match('#^0[\d_]+$#', $content)) { continue; } - $tokens[$index] = 1 === Preg::match('#^0+$#', $content) + $tokens[$index] = Preg::match('#^0+$#', $content) ? new Token([T_LNUMBER, '0']) : new Token([T_LNUMBER, '0o'.('_' === $content[1] ? '0' : '').substr($content, 1)]); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/PsrAutoloadingFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/PsrAutoloadingFixer.php index 55444b3ab..2f31f540f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/PsrAutoloadingFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/PsrAutoloadingFixer.php @@ -89,6 +89,11 @@ public function isRisky(): bool return true; } + /** + * {@inheritdoc} + * + * Must run before SelfAccessorFixer. + */ public function getPriority(): int { return -10; @@ -104,7 +109,7 @@ public function supports(\SplFileInfo $file): bool // ignore file with extension other than php ('php' !== $file->getExtension()) // ignore file with name that cannot be a class name - || 0 === Preg::match('/^'.TypeExpression::REGEX_IDENTIFIER.'$/', $file->getBasename('.php')) + || !Preg::match('/^'.TypeExpression::REGEX_IDENTIFIER.'$/', $file->getBasename('.php')) ) { return false; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/SingleLineEmptyBodyFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/SingleLineEmptyBodyFixer.php index 0e9478083..b0598de35 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/SingleLineEmptyBodyFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Basic/SingleLineEmptyBodyFixer.php @@ -18,6 +18,7 @@ use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; final class SingleLineEmptyBodyFixer extends AbstractFixer @@ -25,7 +26,7 @@ final class SingleLineEmptyBodyFixer extends AbstractFixer public function getDefinition(): FixerDefinitionInterface { return new FixerDefinition( - 'Empty body of class or function must be abbreviated as `{}` and placed on the same line as the previous symbol, separated by a space.', + 'Empty body of class, interface, trait, enum or function must be abbreviated as `{}` and placed on the same line as the previous symbol, separated by a single space.', [new CodeSample('isAnyTokenKindsFound([T_CLASS, T_FUNCTION]); + if (\defined('T_ENUM') && $tokens->isTokenKindFound(T_ENUM)) { // @TODO: drop condition when PHP 8.1+ is required + return true; + } + + return $tokens->isAnyTokenKindsFound([T_INTERFACE, T_CLASS, T_FUNCTION, T_TRAIT]); } protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { for ($index = $tokens->count() - 1; $index > 0; --$index) { - if (!$tokens[$index]->isGivenKind([T_CLASS, T_FUNCTION])) { + if (!$tokens[$index]->isGivenKind([...Token::getClassyTokenKinds(), T_FUNCTION])) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Casing/IntegerLiteralCaseFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Casing/IntegerLiteralCaseFixer.php index fe02659a2..f82ae647a 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Casing/IntegerLiteralCaseFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Casing/IntegerLiteralCaseFixer.php @@ -50,7 +50,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $content = $token->getContent(); - if (1 !== Preg::match('#^0[bxoBXO][0-9a-fA-F]+$#', $content)) { + if (!Preg::match('#^0[bxoBXO][0-9a-fA-F]+$#', $content)) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ClassDefinitionFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ClassDefinitionFixer.php index 66b04da3a..b0e226e4b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ClassDefinitionFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ClassDefinitionFixer.php @@ -306,11 +306,11 @@ private function getClassyDefinitionInfo(Tokens $tokens, int $classyIndex): arra if (!$tokens[$classyIndex]->isGivenKind(T_TRAIT)) { $extends = $tokens->findGivenKind(T_EXTENDS, $classyIndex, $openIndex); - $def['extends'] = \count($extends) ? $this->getClassyInheritanceInfo($tokens, key($extends), 'numberOfExtends') : false; + $def['extends'] = [] !== $extends ? $this->getClassyInheritanceInfo($tokens, key($extends), 'numberOfExtends') : false; if (!$tokens[$classyIndex]->isGivenKind(T_INTERFACE)) { $implements = $tokens->findGivenKind(T_IMPLEMENTS, $classyIndex, $openIndex); - $def['implements'] = \count($implements) ? $this->getClassyInheritanceInfo($tokens, key($implements), 'numberOfImplements') : false; + $def['implements'] = [] !== $implements ? $this->getClassyInheritanceInfo($tokens, key($implements), 'numberOfImplements') : false; $def['anonymousClass'] = $tokensAnalyzer->isAnonymousClass($classyIndex); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalClassFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalClassFixer.php index 95e0b34c8..e13cc8f48 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalClassFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalClassFixer.php @@ -44,6 +44,16 @@ class MyApp {} ); } + /** + * {@inheritdoc} + * + * Must run before ProtectedToPrivateFixer, SelfStaticAccessorFixer. + */ + public function getPriority(): int + { + return parent::getPriority(); + } + protected function createProxyFixers(): array { $fixer = new FinalInternalClassFixer(); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalInternalClassFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalInternalClassFixer.php index 5438b1679..c94fc86b5 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalInternalClassFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalInternalClassFixer.php @@ -262,7 +262,7 @@ private function isClassCandidateBasedOnPhpDoc(Tokens $tokens, int $index): ?boo $tags = []; foreach ($doc->getAnnotations() as $annotation) { - if (1 !== Preg::match('/@\S+(?=\s|$)/', $annotation->getContent(), $matches)) { + if (!Preg::match('/@\S+(?=\s|$)/', $annotation->getContent(), $matches)) { continue; } $tag = strtolower(substr(array_shift($matches), 1)); @@ -289,7 +289,7 @@ private function isClassCandidateBasedOnAttribute(Tokens $tokens, int $startInde while ($currentIndex < $endIndex && $currentIndex = $tokens->getNextMeaningfulToken($currentIndex)) { if (!$tokens[$currentIndex]->isGivenKind([T_STRING, T_NS_SEPARATOR])) { - if ($attributeString) { + if ('' !== $attributeString) { $attributeCandidates[$attributeString] = true; $attributeString = ''; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php index f4d7a441d..ed9a7ac7a 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/FinalPublicMethodForAbstractClassFixer.php @@ -71,7 +71,7 @@ public function start() public function isCandidate(Tokens $tokens): bool { - return $tokens->isAllTokenKindsFound([T_CLASS, T_ABSTRACT, T_PUBLIC, T_FUNCTION]); + return $tokens->isAllTokenKindsFound([T_ABSTRACT, T_PUBLIC, T_FUNCTION]); } public function isRisky(): bool @@ -81,11 +81,11 @@ public function isRisky(): bool protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { - $classes = array_keys($tokens->findGivenKind(T_CLASS)); + $abstracts = array_keys($tokens->findGivenKind(T_ABSTRACT)); - while ($classIndex = array_pop($classes)) { - $prevToken = $tokens[$tokens->getPrevMeaningfulToken($classIndex)]; - if (!$prevToken->isGivenKind(T_ABSTRACT)) { + while ($abstractIndex = array_pop($abstracts)) { + $classIndex = $tokens->getNextTokenOfKind($abstractIndex, [[T_CLASS], [T_FUNCTION]]); + if (!$tokens[$classIndex]->isGivenKind(T_CLASS)) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php index a38ee9c5c..1a07d79ec 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/NoPhp4ConstructorFixer.php @@ -138,7 +138,7 @@ private function fixConstructor(Tokens $tokens, string $className, int $classSta return; // no PHP4-constructor! } - if (!empty($php4['modifiers'][T_ABSTRACT]) || !empty($php4['modifiers'][T_STATIC])) { + if (isset($php4['modifiers'][T_ABSTRACT]) || isset($php4['modifiers'][T_STATIC])) { return; // PHP4 constructor can't be abstract or static } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedClassElementsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedClassElementsFixer.php index 2889086fa..09806959b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedClassElementsFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedClassElementsFixer.php @@ -228,7 +228,7 @@ public function AWs(){} Custom values: -- `method:*`: specify a single method name (e.g. `method:__invoke`) to set the order of that specific method' +- `method:*`: specify a single method name (e.g. `method:__invoke`) to set the order of that specific method.' ); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedTypesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedTypesFixer.php index d80a6d90d..e9ff943c9 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedTypesFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/OrderedTypesFixer.php @@ -86,6 +86,7 @@ public function bar(null|string|int $foo): string|int; * {@inheritdoc} * * Must run before TypesSpacesFixer. + * Must run after NullableTypeDeclarationFixer, NullableTypeDeclarationForDefaultNullValueFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ProtectedToPrivateFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ProtectedToPrivateFixer.php index d61cc0a1d..168bbb3b6 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ProtectedToPrivateFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/ProtectedToPrivateFixer.php @@ -55,7 +55,7 @@ protected function test() * {@inheritdoc} * * Must run before OrderedClassElementsFixer. - * Must run after FinalInternalClassFixer. + * Must run after FinalClassFixer, FinalInternalClassFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfAccessorFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfAccessorFixer.php index 11710ff9b..0af1d3eaa 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfAccessorFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfAccessorFixer.php @@ -59,6 +59,16 @@ public function isCandidate(Tokens $tokens): bool return $tokens->isAnyTokenKindsFound([T_CLASS, T_INTERFACE]); } + /** + * {@inheritdoc} + * + * Must run after PsrAutoloadingFixer. + */ + public function getPriority(): int + { + return -11; + } + public function isRisky(): bool { return true; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfStaticAccessorFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfStaticAccessorFixer.php index cd825b353..0bf56ab0d 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfStaticAccessorFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SelfStaticAccessorFixer.php @@ -117,7 +117,7 @@ public function isCandidate(Tokens $tokens): bool /** * {@inheritdoc} * - * Must run after FinalInternalClassFixer, FunctionToConstantFixer, PhpUnitTestCaseStaticMethodCallsFixer. + * Must run after FinalClassFixer, FinalInternalClassFixer, FunctionToConstantFixer, PhpUnitTestCaseStaticMethodCallsFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php index d3d839fb0..ec20f3cad 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ClassNotation/SingleTraitInsertPerStatementFixer.php @@ -83,7 +83,7 @@ private function fixTraitUse(Tokens $tokens, int $useTraitIndex, array $candidat $nextImportStartIndex = $tokens->getNextMeaningfulToken($commaIndex); if ($tokens[$nextImportStartIndex - 1]->isWhitespace()) { - if (1 === Preg::match('/\R/', $tokens[$nextImportStartIndex - 1]->getContent())) { + if (Preg::match('/\R/', $tokens[$nextImportStartIndex - 1]->getContent())) { array_unshift($inserts, clone $tokens[$useTraitIndex - 1]); } $tokens->clearAt($nextImportStartIndex - 1); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/CommentToPhpdocFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/CommentToPhpdocFixer.php index 35f027e2a..b5f7ffd62 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/CommentToPhpdocFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/CommentToPhpdocFixer.php @@ -136,7 +136,7 @@ function (bool $carry, int $index) use ($tokens): bool { if ($carry) { return true; } - if (1 !== Preg::match('~(?:#|//|/\*+|\R(?:\s*\*)?)\s*\@([a-zA-Z0-9_\\\\-]+)(?=\s|\(|$)~', $tokens[$index]->getContent(), $matches)) { + if (!Preg::match('~(?:#|//|/\*+|\R(?:\s*\*)?)\s*\@([a-zA-Z0-9_\\\\-]+)(?=\s|\(|$)~', $tokens[$index]->getContent(), $matches)) { return false; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/HeaderCommentFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/HeaderCommentFixer.php index 0bd6ebf8e..478d3ce10 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/HeaderCommentFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/HeaderCommentFixer.php @@ -163,7 +163,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $expectedLocation = $possibleLocation === $location; if (!$sameComment || !$expectedLocation) { - if ($expectedLocation ^ $sameComment) { + if ($expectedLocation xor $sameComment) { $this->removeHeader($tokens, $headerCurrentIndex); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/NoEmptyCommentFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/NoEmptyCommentFixer.php index 4d9e7e757..c2d6c7442 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/NoEmptyCommentFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/NoEmptyCommentFixer.php @@ -143,6 +143,6 @@ private function isEmptyComment(string $content): bool $type = $this->getCommentType($content); - return 1 === Preg::match($mapper[$type], $content); + return Preg::match($mapper[$type], $content); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentSpacingFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentSpacingFixer.php index 1776ec874..ecf09eca1 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentSpacingFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentSpacingFixer.php @@ -99,7 +99,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void // fix space between comment open and leading text private function fixCommentLeadingSpace(string $content, string $prefix): string { - if (0 !== Preg::match(sprintf('@^%s\h+.*$@', preg_quote($prefix, '@')), $content)) { + if (Preg::match(sprintf('@^%s\h+.*$@', preg_quote($prefix, '@')), $content)) { return $content; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentStyleFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentStyleFixer.php index c5cd91474..aaf81ed90 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentStyleFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Comment/SingleLineCommentStyleFixer.php @@ -135,7 +135,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void !$this->asteriskEnabled || str_contains($commentContent, '?>') || !str_starts_with($content, '/*') - || 1 === Preg::match('/[^\s\*].*\R.*[^\s\*]/s', $commentContent) + || Preg::match('/[^\s\*].*\R.*[^\s\*]/s', $commentContent) ) { continue; } @@ -143,7 +143,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $nextTokenIndex = $index + 1; if (isset($tokens[$nextTokenIndex])) { $nextToken = $tokens[$nextTokenIndex]; - if (!$nextToken->isWhitespace() || 1 !== Preg::match('/\R/', $nextToken->getContent())) { + if (!$nextToken->isWhitespace() || !Preg::match('/\R/', $nextToken->getContent())) { continue; } @@ -151,7 +151,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void } $content = '//'; - if (1 === Preg::match('/[^\s\*]/', $commentContent)) { + if (Preg::match('/[^\s\*]/', $commentContent)) { $content = '// '.Preg::replace('/[\s\*]*([^\s\*](?:.+[^\s\*])?)[\s\*]*/', '\1', $commentContent); } $tokens[$index] = new Token([$token->getId(), $content]); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/ControlStructureBracesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/ControlStructureBracesFixer.php index 2421e9735..0fd0d264a 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/ControlStructureBracesFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/ControlStructureBracesFixer.php @@ -130,12 +130,12 @@ private function findParenthesisEnd(Tokens $tokens, int $structureTokenIndex): i private function findStatementEnd(Tokens $tokens, int $parenthesisEndIndex): int { $nextIndex = $tokens->getNextMeaningfulToken($parenthesisEndIndex); - $nextToken = $tokens[$nextIndex]; - - if (!$nextToken) { + if (null === $nextIndex) { return $parenthesisEndIndex; } + $nextToken = $tokens[$nextIndex]; + if ($nextToken->equals('{')) { return $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $nextIndex); } @@ -150,13 +150,12 @@ private function findStatementEnd(Tokens $tokens, int $parenthesisEndIndex): int while (true) { $nextIndex = $tokens->getNextMeaningfulToken($endIndex); - $nextToken = isset($nextIndex) ? $tokens[$nextIndex] : null; - if ($nextToken && $nextToken->isGivenKind($this->getControlContinuationTokensForOpeningToken($openingTokenKind))) { + if (null !== $nextIndex && $tokens[$nextIndex]->isGivenKind($this->getControlContinuationTokensForOpeningToken($openingTokenKind))) { $parenthesisEndIndex = $this->findParenthesisEnd($tokens, $nextIndex); $endIndex = $this->findStatementEnd($tokens, $parenthesisEndIndex); - if ($nextToken->isGivenKind($this->getFinalControlContinuationTokensForOpeningToken($openingTokenKind))) { + if ($tokens[$nextIndex]->isGivenKind($this->getFinalControlContinuationTokensForOpeningToken($openingTokenKind))) { return $endIndex; } } else { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/IncludeFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/IncludeFixer.php index ff5b4a43c..6ad136038 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/IncludeFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/IncludeFixer.php @@ -64,7 +64,7 @@ private function clearIncludies(Tokens $tokens, array $includies): void $blocksAnalyzer = new BlocksAnalyzer(); foreach ($includies as $includy) { - if ($includy['end'] && !$tokens[$includy['end']]->isGivenKind(T_CLOSE_TAG)) { + if (!$tokens[$includy['end']]->isGivenKind(T_CLOSE_TAG)) { $afterEndIndex = $tokens->getNextNonWhitespace($includy['end']); if (null === $afterEndIndex || !$tokens[$afterEndIndex]->isComment()) { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/NoBreakCommentFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/NoBreakCommentFixer.php index 202ea4e7b..09b6b1ff0 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/NoBreakCommentFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/NoBreakCommentFixer.php @@ -205,7 +205,7 @@ private function isNoBreakComment(Token $token): bool $text = preg_quote($this->configuration['comment_text'], '~'); - return 1 === Preg::match("~^((//|#)\\s*{$text}\\s*)|(/\\*\\*?\\s*{$text}(\\s+.*)*\\*/)$~i", $token->getContent()); + return Preg::match("~^((//|#)\\s*{$text}\\s*)|(/\\*\\*?\\s*{$text}(\\s+.*)*\\*/)$~i", $token->getContent()); } private function insertCommentAt(Tokens $tokens, int $casePosition): void diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php index 52a45bd7b..23b523a8c 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/SwitchContinueToBreakFixer.php @@ -204,7 +204,7 @@ private function fixContinueWhenActsAsBreak(Tokens $tokens, int $continueIndex, $jump = bindec($jump); // binary - 0b1 } elseif (\strlen($jump) > 1 && '0' === $jump[0]) { $jump = octdec($jump); // octal 01 - } elseif (1 === Preg::match('#^\d+$#', $jump)) { // positive int + } elseif (Preg::match('#^\d+$#', $jump)) { // positive int $jump = (float) $jump; // cast to float, might be a number bigger than PHP max. int value } else { return $afterFollowingContinueIndex; // cannot process value, ignore diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/YodaStyleFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/YodaStyleFixer.php index 6b8a42285..10b57fbcd 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/YodaStyleFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/ControlStructure/YodaStyleFixer.php @@ -363,7 +363,7 @@ private function getCompareFixableInfo(Tokens $tokens, int $index, bool $yoda): $leftSideIsVariable = $this->isVariable($tokens, $left['start'], $left['end'], $strict); $rightSideIsVariable = $this->isVariable($tokens, $right['start'], $right['end'], $strict); - if (!($leftSideIsVariable ^ $rightSideIsVariable)) { + if (!($leftSideIsVariable xor $rightSideIsVariable)) { return null; // both are (not) variables, do not touch } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/FunctionTypehintSpaceFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/FunctionTypehintSpaceFixer.php index 218c9e263..132f7c134 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/FunctionTypehintSpaceFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/FunctionTypehintSpaceFixer.php @@ -14,18 +14,20 @@ namespace PhpCsFixer\Fixer\FunctionNotation; -use PhpCsFixer\AbstractFixer; +use PhpCsFixer\AbstractProxyFixer; +use PhpCsFixer\Fixer\DeprecatedFixerInterface; +use PhpCsFixer\Fixer\Whitespace\TypeDeclarationSpacesFixer; use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; -use PhpCsFixer\Tokenizer\Analyzer\Analysis\TypeAnalysis; -use PhpCsFixer\Tokenizer\Analyzer\FunctionsAnalyzer; use PhpCsFixer\Tokenizer\Tokens; /** * @author Dariusz Rumiński + * + * @deprecated */ -final class FunctionTypehintSpaceFixer extends AbstractFixer +final class FunctionTypehintSpaceFixer extends AbstractProxyFixer implements DeprecatedFixerInterface { public function getDefinition(): FixerDefinitionInterface { @@ -43,28 +45,16 @@ public function isCandidate(Tokens $tokens): bool return $tokens->isAnyTokenKindsFound([T_FUNCTION, T_FN]); } - protected function applyFix(\SplFileInfo $file, Tokens $tokens): void + public function getSuccessorsNames(): array { - $functionsAnalyzer = new FunctionsAnalyzer(); - - for ($index = $tokens->count() - 1; $index >= 0; --$index) { - $token = $tokens[$index]; - - if (!$token->isGivenKind([T_FUNCTION, T_FN])) { - continue; - } - - $arguments = $functionsAnalyzer->getFunctionArguments($tokens, $index); - - foreach (array_reverse($arguments) as $argument) { - $type = $argument->getTypeAnalysis(); + return array_keys($this->proxyFixers); + } - if (!$type instanceof TypeAnalysis) { - continue; - } + protected function createProxyFixers(): array + { + $fixer = new TypeDeclarationSpacesFixer(); + $fixer->configure(['elements' => ['function']]); - $tokens->ensureWhitespaceAtIndex($type->getEndIndex() + 1, 0, ' '); - } - } + return [$fixer]; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php index 3e0b00fd2..49eebf9a5 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/NullableTypeDeclarationForDefaultNullValueFixer.php @@ -22,7 +22,10 @@ use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\FixerDefinition\VersionSpecification; +use PhpCsFixer\FixerDefinition\VersionSpecificCodeSample; use PhpCsFixer\Tokenizer\Analyzer\Analysis\ArgumentAnalysis; +use PhpCsFixer\Tokenizer\Analyzer\Analysis\TypeAnalysis; use PhpCsFixer\Tokenizer\Analyzer\FunctionsAnalyzer; use PhpCsFixer\Tokenizer\CT; use PhpCsFixer\Tokenizer\Token; @@ -36,7 +39,7 @@ final class NullableTypeDeclarationForDefaultNullValueFixer extends AbstractFixe public function getDefinition(): FixerDefinitionInterface { return new FixerDefinition( - 'Adds or removes `?` before type declarations for parameters with a default `null` value.', + 'Adds or removes `?` before single type declarations or `|null` at the end of union types when parameters have a default `null` value.', [ new CodeSample( " false] ), + new VersionSpecificCodeSample( + " false] + ), + new VersionSpecificCodeSample( + " false] + ), ], 'Rule is applied only in a PHP 7.1+ environment.' ); @@ -58,17 +79,17 @@ public function isCandidate(Tokens $tokens): bool /** * {@inheritdoc} * - * Must run before NoUnreachableDefaultArgumentValueFixer. + * Must run before NoUnreachableDefaultArgumentValueFixer, NullableTypeDeclarationFixer, OrderedTypesFixer. */ public function getPriority(): int { - return 1; + return 3; } protected function createConfigurationDefinition(): FixerConfigurationResolverInterface { return new FixerConfigurationResolver([ - (new FixerOptionBuilder('use_nullable_type_declaration', 'Whether to add or remove `?` before type declarations for parameters with a default `null` value.')) + (new FixerOptionBuilder('use_nullable_type_declaration', 'Whether to add or remove `?` or `|null` to parameters with a default `null` value.')) ->setAllowedTypes(['bool']) ->setDefault(true) ->getOption(), @@ -112,8 +133,8 @@ private function fixFunctionParameters(Tokens $tokens, array $arguments): void // Skip, if the parameter // - doesn't have a type declaration !$argumentInfo->hasTypeAnalysis() - // type is a union - || str_contains($argumentInfo->getTypeAnalysis()->getName(), '|') + // - has a mixed or standalone null type + || \in_array(strtolower($argumentInfo->getTypeAnalysis()->getName()), ['mixed', 'null'], true) // - a default value is not null we can continue || !$argumentInfo->hasDefault() || 'null' !== strtolower($argumentInfo->getDefault()) ) { @@ -130,16 +151,83 @@ private function fixFunctionParameters(Tokens $tokens, array $arguments): void } } - if (true === $this->configuration['use_nullable_type_declaration']) { - if (!$argumentTypeInfo->isNullable() && 'mixed' !== $argumentTypeInfo->getName()) { - $tokens->insertAt($argumentTypeInfo->getStartIndex(), new Token([CT::T_NULLABLE_TYPE, '?'])); + $typeAnalysisName = $argumentTypeInfo->getName(); + if (str_contains($typeAnalysisName, '|') || str_contains($typeAnalysisName, '&')) { + $this->fixUnionTypeParameter($tokens, $argumentTypeInfo); + } else { + $this->fixSingleTypeParameter($tokens, $argumentTypeInfo); + } + } + } + + private function fixSingleTypeParameter(Tokens $tokens, TypeAnalysis $argumentTypeInfo): void + { + if (true === $this->configuration['use_nullable_type_declaration']) { + if (!$argumentTypeInfo->isNullable()) { + $tokens->insertAt($argumentTypeInfo->getStartIndex(), new Token([CT::T_NULLABLE_TYPE, '?'])); + } + } elseif ($argumentTypeInfo->isNullable()) { + $tokens->removeTrailingWhitespace($startIndex = $argumentTypeInfo->getStartIndex()); + $tokens->clearTokenAndMergeSurroundingWhitespace($startIndex); + } + } + + private function fixUnionTypeParameter(Tokens $tokens, TypeAnalysis $argumentTypeInfo): void + { + if (true === $this->configuration['use_nullable_type_declaration']) { + if ($argumentTypeInfo->isNullable()) { + return; + } + + $typeAnalysisName = $argumentTypeInfo->getName(); + $endIndex = $argumentTypeInfo->getEndIndex(); + + if (str_contains($typeAnalysisName, '&') && !str_contains($typeAnalysisName, '|')) { + $endIndex += 2; + $tokens->insertAt($argumentTypeInfo->getStartIndex(), new Token([CT::T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_OPEN, '('])); + $tokens->insertAt($endIndex, new Token([CT::T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_CLOSE, ')'])); + } + + $tokens->insertAt($endIndex + 1, [ + new Token([CT::T_TYPE_ALTERNATION, '|']), + new Token([T_STRING, 'null']), + ]); + } elseif ($argumentTypeInfo->isNullable()) { + $startIndex = $argumentTypeInfo->getStartIndex(); + + $index = $tokens->getNextTokenOfKind($startIndex - 1, [[T_STRING, 'null']], false); + + if ($index === $startIndex) { + $tokens->removeTrailingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); + + $index = $tokens->getNextMeaningfulToken($index); + if ($tokens[$index]->equals([CT::T_TYPE_ALTERNATION, '|'])) { + $tokens->removeTrailingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); } } else { - if ($argumentTypeInfo->isNullable()) { - $tokens->removeTrailingWhitespace($argumentTypeInfo->getStartIndex()); - $tokens->clearTokenAndMergeSurroundingWhitespace($argumentTypeInfo->getStartIndex()); + $tokens->removeLeadingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); + + $index = $tokens->getPrevMeaningfulToken($index); + if ($tokens[$index]->equals([CT::T_TYPE_ALTERNATION, '|'])) { + $tokens->removeLeadingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); } } + + $typeAnalysisName = $argumentTypeInfo->getName(); + + if (str_contains($typeAnalysisName, '&') && 1 === substr_count($typeAnalysisName, '|')) { + $index = $tokens->getNextTokenOfKind($startIndex - 1, [[CT::T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_OPEN]]); + $tokens->removeTrailingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); + + $index = $tokens->getPrevTokenOfKind($argumentTypeInfo->getEndIndex() + 1, [[CT::T_DISJUNCTIVE_NORMAL_FORM_TYPE_PARENTHESIS_CLOSE]]); + $tokens->removeLeadingWhitespace($index); + $tokens->clearTokenAndMergeSurroundingWhitespace($index); + } } } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/ReturnTypeDeclarationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/ReturnTypeDeclarationFixer.php index af950a302..356bf45c3 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/ReturnTypeDeclarationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/ReturnTypeDeclarationFixer.php @@ -55,7 +55,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@inheritdoc} * - * Must run after PhpdocToReturnTypeFixer, VoidReturnFixer. + * Must run after PhpUnitDataProviderReturnTypeFixer, PhpdocToReturnTypeFixer, VoidReturnFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/SingleLineThrowFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/SingleLineThrowFixer.php index 0d1e29ebc..9a8dee4a2 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/SingleLineThrowFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/FunctionNotation/SingleLineThrowFixer.php @@ -95,7 +95,7 @@ private function trimNewLines(Tokens $tokens, int $startIndex, int $endIndex): v } elseif (str_starts_with($content, '#')) { $content = '/*'.substr($content, 1).' */'; $tokens->clearAt($index + 1); - } elseif (0 !== Preg::match('/\R/', $content)) { + } elseif (Preg::match('/\R/', $content)) { $content = Preg::replace('/\R/', ' ', $content); } @@ -108,7 +108,7 @@ private function trimNewLines(Tokens $tokens, int $startIndex, int $endIndex): v continue; } - if (0 === Preg::match('/\R/', $content)) { + if (!Preg::match('/\R/', $content)) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/NoUnusedImportsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/NoUnusedImportsFixer.php index e073319a8..b2a481300 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/NoUnusedImportsFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/NoUnusedImportsFixer.php @@ -175,7 +175,7 @@ private function isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, Name if ($token->isComment() && Preg::match( - '/(?getShortName().'(?![[:alnum:]])/', + '/(?getShortName().'(?![[:alnum:]])/i', $token->getContent() ) ) { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/OrderedImportsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/OrderedImportsFixer.php index 4a60fcfb6..b69d38f61 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/OrderedImportsFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Import/OrderedImportsFixer.php @@ -188,49 +188,41 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $tokensAnalyzer = new TokensAnalyzer($tokens); $namespacesImports = $tokensAnalyzer->getImportUseIndexes(true); - if (0 === \count($namespacesImports)) { - return; - } + foreach (array_reverse($namespacesImports) as $usesPerNamespaceIndices) { + $count = \count($usesPerNamespaceIndices); - $usesOrder = []; - foreach ($namespacesImports as $uses) { - $usesOrder[] = $this->getNewOrder(array_reverse($uses), $tokens); - } - $usesOrder = array_replace(...$usesOrder); + if (0 === $count) { + continue; // nothing to sort + } - $usesOrder = array_reverse($usesOrder, true); - $mapStartToEnd = []; + if (1 === $count) { + $this->setNewOrder($tokens, $this->getNewOrder($usesPerNamespaceIndices, $tokens)); - foreach ($usesOrder as $use) { - $mapStartToEnd[$use['startIndex']] = $use['endIndex']; - } + continue; + } - // Now insert the new tokens, starting from the end - foreach ($usesOrder as $index => $use) { - $declarationTokens = Tokens::fromCode( - sprintf( - ' [$usesPerNamespaceIndices[0]]]; - $declarationTokens->clearRange(0, 2); // clear `clearAt(\count($declarationTokens) - 1); // clear `;` - $declarationTokens->clearEmptyTokens(); + // if there's some logic between two `use` statements, sort only imports grouped before that logic + for ($index = 0; $index < $count - 1; ++$index) { + $nextGroupUse = $tokens->getNextTokenOfKind($usesPerNamespaceIndices[$index], [';', [T_CLOSE_TAG]]); - $tokens->overrideRange($index, $mapStartToEnd[$index], $declarationTokens); - if ($use['group']) { - // a group import must start with `use` and cannot be part of comma separated import list - $prev = $tokens->getPrevMeaningfulToken($index); - if ($tokens[$prev]->equals(',')) { - $tokens[$prev] = new Token(';'); - $tokens->insertAt($prev + 1, new Token([T_USE, 'use'])); + if ($tokens[$nextGroupUse]->isGivenKind(T_CLOSE_TAG)) { + $nextGroupUse = $tokens->getNextTokenOfKind($usesPerNamespaceIndices[$index], [[T_OPEN_TAG]]); + } - if (!$tokens[$prev + 2]->isWhitespace()) { - $tokens->insertAt($prev + 2, new Token([T_WHITESPACE, ' '])); - } + $nextGroupUse = $tokens->getNextMeaningfulToken($nextGroupUse); + + if ($nextGroupUse !== $usesPerNamespaceIndices[$index + 1]) { + $groupUses[++$groupUsesOffset] = []; } + + $groupUses[$groupUsesOffset][] = $usesPerNamespaceIndices[$index + 1]; + } + + for ($index = $groupUsesOffset; $index >= 0; --$index) { + $this->setNewOrder($tokens, $this->getNewOrder($groupUses[$index], $tokens)); } } } @@ -329,8 +321,9 @@ private function getNewOrder(array $uses, Tokens $tokens): array $indices = []; $originalIndices = []; $lineEnding = $this->whitespacesConfig->getLineEnding(); + $usesCount = \count($uses); - for ($i = \count($uses) - 1; $i >= 0; --$i) { + for ($i = 0; $i < $usesCount; ++$i) { $index = $uses[$i]; $startIndex = $tokens->getTokenNotOfKindsSibling($index + 1, 1, [T_WHITESPACE]); @@ -481,7 +474,7 @@ private function getNewOrder(array $uses, Tokens $tokens): array $sortedGroups = []; foreach ($this->configuration['imports_order'] as $type) { - if (isset($groupedByTypes[$type]) && !empty($groupedByTypes[$type])) { + if (isset($groupedByTypes[$type]) && [] !== $groupedByTypes[$type]) { foreach ($groupedByTypes[$type] as $startIndex => $item) { $sortedGroups[$startIndex] = $item; } @@ -538,4 +531,51 @@ private function sortByAlgorithm(array $indices): array return $indices; } + + /** + * @param array $usesOrder + */ + private function setNewOrder(Tokens $tokens, array $usesOrder): void + { + $mapStartToEnd = []; + + foreach ($usesOrder as $use) { + $mapStartToEnd[$use['startIndex']] = $use['endIndex']; + } + + // Now insert the new tokens, starting from the end + foreach (array_reverse($usesOrder, true) as $index => $use) { + $code = sprintf( + 'clearRange(0, 2); // clear `clearAt(\count($declarationTokens) - 1); // clear `;` + $declarationTokens->clearEmptyTokens(); + + $tokens->overrideRange($index, $mapStartToEnd[$index], $declarationTokens); + + if ($use['group']) { + // a group import must start with `use` and cannot be part of comma separated import list + $prev = $tokens->getPrevMeaningfulToken($index); + if ($tokens[$prev]->equals(',')) { + $tokens[$prev] = new Token(';'); + $tokens->insertAt($prev + 1, new Token([T_USE, 'use'])); + + if (!$tokens[$prev + 2]->isWhitespace()) { + $tokens->insertAt($prev + 2, new Token([T_WHITESPACE, ' '])); + } + } + } + } + } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Indentation.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Indentation.php index cbf64c94b..0e370f20f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Indentation.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Indentation.php @@ -87,6 +87,6 @@ private function isNewLineToken(Tokens $tokens, int $index): bool return false; } - return (bool) Preg::match('/\R/', $this->computeNewLineContent($tokens, $index)); + return Preg::match('/\R/', $this->computeNewLineContent($tokens, $index)); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NullableTypeDeclarationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NullableTypeDeclarationFixer.php new file mode 100644 index 000000000..023d47bc7 --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/NullableTypeDeclarationFixer.php @@ -0,0 +1,334 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Fixer\LanguageConstruct; + +use PhpCsFixer\AbstractFixer; +use PhpCsFixer\Fixer\ConfigurableFixerInterface; +use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; +use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; +use PhpCsFixer\FixerConfiguration\FixerOptionBuilder; +use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\FixerDefinition\VersionSpecification; +use PhpCsFixer\FixerDefinition\VersionSpecificCodeSample; +use PhpCsFixer\Preg; +use PhpCsFixer\Tokenizer\Analyzer\Analysis\TypeAnalysis; +use PhpCsFixer\Tokenizer\Analyzer\FunctionsAnalyzer; +use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\Token; +use PhpCsFixer\Tokenizer\Tokens; +use PhpCsFixer\Tokenizer\TokensAnalyzer; + +/** + * @author John Paul E. Balandan, CPA + */ +final class NullableTypeDeclarationFixer extends AbstractFixer implements ConfigurableFixerInterface +{ + private const OPTION_SYNTAX_UNION = 'union'; + private const OPTION_SYNTAX_QUESTION_MARK = 'question_mark'; + + private int $candidateTokenKind; + + public function getDefinition(): FixerDefinitionInterface + { + return new FixerDefinition( + 'Nullable single type declaration should be standardised using configured syntax.', + [ + new VersionSpecificCodeSample( + " self::OPTION_SYNTAX_UNION] + ), + new VersionSpecificCodeSample( + ' self::OPTION_SYNTAX_QUESTION_MARK] + ), + ] + ); + } + + public function isCandidate(Tokens $tokens): bool + { + return \PHP_VERSION_ID >= 8_00_00 && $tokens->isTokenKindFound($this->candidateTokenKind); + } + + /** + * {@inheritdoc} + * + * Must run before OrderedTypesFixer, TypesSpacesFixer. + * Must run after NullableTypeDeclarationForDefaultNullValueFixer, SingleSpaceAroundConstructFixer. + */ + public function getPriority(): int + { + return 2; + } + + public function configure(array $configuration): void + { + parent::configure($configuration); + + $this->candidateTokenKind = self::OPTION_SYNTAX_QUESTION_MARK === $this->configuration['syntax'] + ? CT::T_TYPE_ALTERNATION // `|` -> `?` + : CT::T_NULLABLE_TYPE; // `?` -> `|` + } + + protected function createConfigurationDefinition(): FixerConfigurationResolverInterface + { + return new FixerConfigurationResolver([ + (new FixerOptionBuilder('syntax', 'Whether to use question mark (`?`) or explicit `null` union for nullable type.')) + ->setAllowedValues([self::OPTION_SYNTAX_UNION, self::OPTION_SYNTAX_QUESTION_MARK]) + ->setDefault(self::OPTION_SYNTAX_QUESTION_MARK) + ->getOption(), + ]); + } + + protected function applyFix(\SplFileInfo $file, Tokens $tokens): void + { + $functionsAnalyzer = new FunctionsAnalyzer(); + + foreach (array_reverse($this->getElements($tokens), true) as $index => $type) { + if ('property' === $type) { + $this->normalizePropertyType($tokens, $index); + + continue; + } + + $this->normalizeMethodReturnType($functionsAnalyzer, $tokens, $index); + $this->normalizeMethodArgumentType($functionsAnalyzer, $tokens, $index); + } + } + + /** + * @return array + * + * @phpstan-return array + */ + private function getElements(Tokens $tokens): array + { + $tokensAnalyzer = new TokensAnalyzer($tokens); + + $elements = array_map( + static function (array $element): string { + return 'method' === $element['type'] ? 'function' : $element['type']; + }, + array_filter( + $tokensAnalyzer->getClassyElements(), + static fn (array $element): bool => \in_array($element['type'], ['method', 'property'], true) + ) + ); + + foreach ($tokens as $index => $token) { + if ( + $token->isGivenKind(T_FN) + || ($token->isGivenKind(T_FUNCTION) && !isset($elements[$index])) + ) { + $elements[$index] = 'function'; + } + } + + return $elements; + } + + private function collectTypeAnalysis(Tokens $tokens, int $startIndex, int $endIndex): ?TypeAnalysis + { + $type = ''; + $typeStartIndex = $tokens->getNextMeaningfulToken($startIndex); + $typeEndIndex = $typeStartIndex; + + for ($i = $typeStartIndex; $i < $endIndex; ++$i) { + if ($tokens[$i]->isWhitespace() || $tokens[$i]->isComment()) { + continue; + } + + $type .= $tokens[$i]->getContent(); + $typeEndIndex = $i; + } + + return '' !== $type ? new TypeAnalysis($type, $typeStartIndex, $typeEndIndex) : null; + } + + private function isTypeNormalizable(TypeAnalysis $typeAnalysis): bool + { + if (!$typeAnalysis->isNullable()) { + return false; + } + + $type = $typeAnalysis->getName(); + + if (str_contains($type, '&')) { + return false; // skip DNF types + } + + if (!str_contains($type, '|')) { + return true; + } + + return 1 === substr_count($type, '|') && Preg::match('/(?:\|null$|^null\|)/i', $type); + } + + private function normalizePropertyType(Tokens $tokens, int $index): void + { + $propertyEndIndex = $index; + $propertyModifiers = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_STATIC, T_VAR]; + + if (\defined('T_READONLY')) { + $propertyModifiers[] = T_READONLY; // @TODO: Drop condition when PHP 8.1+ is required + } + + do { + $index = $tokens->getPrevMeaningfulToken($index); + } while (!$tokens[$index]->isGivenKind($propertyModifiers)); + + $propertyType = $this->collectTypeAnalysis($tokens, $index, $propertyEndIndex); + + if (null === $propertyType || !$this->isTypeNormalizable($propertyType)) { + return; + } + + $this->normalizeNullableType($tokens, $propertyType); + } + + private function normalizeMethodArgumentType(FunctionsAnalyzer $functionsAnalyzer, Tokens $tokens, int $index): void + { + foreach (array_reverse($functionsAnalyzer->getFunctionArguments($tokens, $index), true) as $argumentInfo) { + $argumentType = $argumentInfo->getTypeAnalysis(); + + if (null === $argumentType || !$this->isTypeNormalizable($argumentType)) { + continue; + } + + $this->normalizeNullableType($tokens, $argumentType); + } + } + + private function normalizeMethodReturnType(FunctionsAnalyzer $functionsAnalyzer, Tokens $tokens, int $index): void + { + $returnType = $functionsAnalyzer->getFunctionReturnType($tokens, $index); + + if (null === $returnType || !$this->isTypeNormalizable($returnType)) { + return; + } + + $this->normalizeNullableType($tokens, $returnType); + } + + private function normalizeNullableType(Tokens $tokens, TypeAnalysis $typeAnalysis): void + { + $type = $typeAnalysis->getName(); + + if (!str_contains($type, '|') && !str_contains($type, '&')) { + $type = ($typeAnalysis->isNullable() ? '?' : '').$type; + } + + $isQuestionMarkSyntax = self::OPTION_SYNTAX_QUESTION_MARK === $this->configuration['syntax']; + + if ($isQuestionMarkSyntax) { + $normalizedType = $this->convertToNullableType($type); + $normalizedTypeAsString = implode('', $normalizedType); + } else { + $normalizedType = $this->convertToExplicitUnionType($type); + $normalizedTypeAsString = implode('|', $normalizedType); + } + + if ($normalizedTypeAsString === $type) { + return; // nothing to fix + } + + $tokens->overrideRange( + $typeAnalysis->getStartIndex(), + $typeAnalysis->getEndIndex(), + $this->createTypeDeclarationTokens($normalizedType, $isQuestionMarkSyntax) + ); + } + + /** + * @return list + */ + private function convertToNullableType(string $type): array + { + if (str_starts_with($type, '?')) { + return [$type]; // no need to convert; already fixed + } + + return ['?', Preg::replace('/(?:\|null$|^null\|)/i', '', $type)]; + } + + /** + * @return list + */ + private function convertToExplicitUnionType(string $type): array + { + if (str_contains($type, '|')) { + return [$type]; // no need to convert; already fixed + } + + return ['null', substr($type, 1)]; + } + + /** + * @param list $types + * + * @return list + */ + private function createTypeDeclarationTokens(array $types, bool $isQuestionMarkSyntax): array + { + static $specialTypes = [ + '?' => [CT::T_NULLABLE_TYPE, '?'], + 'array' => [CT::T_ARRAY_TYPEHINT, 'array'], + 'callable' => [T_CALLABLE, 'callable'], + 'static' => [T_STATIC, 'static'], + ]; + + $count = \count($types); + $newTokens = []; + + foreach ($types as $index => $type) { + if (isset($specialTypes[$type])) { + $newTokens[] = new Token($specialTypes[$type]); + } else { + foreach (explode('\\', $type) as $nsIndex => $value) { + if (0 === $nsIndex && '' === $value) { + continue; + } + + if ($nsIndex > 0) { + $newTokens[] = new Token([T_NS_SEPARATOR, '\\']); + } + + $newTokens[] = new Token([T_STRING, $value]); + } + } + + if ($index <= $count - 2 && !$isQuestionMarkSyntax) { + $newTokens[] = new Token([CT::T_TYPE_ALTERNATION, '|']); + } + } + + return $newTokens; + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php index 2e7fa04b6..58911011f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/LanguageConstruct/SingleSpaceAroundConstructFixer.php @@ -255,7 +255,7 @@ function foo() { yield from baz(); } /** * {@inheritdoc} * - * Must run before BracesFixer, FunctionDeclarationFixer. + * Must run before BracesFixer, FunctionDeclarationFixer, NullableTypeDeclarationFixer. * Must run after ModernizeStrposFixer. */ public function getPriority(): int diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/BlankLineAfterNamespaceFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/BlankLineAfterNamespaceFixer.php index a6037d8e4..7c27bef6c 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/BlankLineAfterNamespaceFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/BlankLineAfterNamespaceFixer.php @@ -94,7 +94,7 @@ private function getIndexToEnsureBlankLineAfter(Tokens $tokens, int $index): int $token = $tokens[$nextIndex]; if ($token->isWhitespace()) { - if (1 === Preg::match('/\R/', $token->getContent())) { + if (Preg::match('/\R/', $token->getContent())) { break; } $nextNextIndex = $tokens->getNonEmptySibling($nextIndex, 1); @@ -120,7 +120,7 @@ private function getTokenToInsert(string $currentContent, bool $isLastIndex): To $ending = $this->whitespacesConfig->getLineEnding(); $emptyLines = $isLastIndex ? $ending : $ending.$ending; - $indent = 1 === Preg::match('/^.*\R( *)$/s', $currentContent, $matches) ? $matches[1] : ''; + $indent = Preg::match('/^.*\R( *)$/s', $currentContent, $matches) ? $matches[1] : ''; return new Token([T_WHITESPACE, $emptyLines.$indent]); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php index df59c5004..c5922dc7c 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/NamespaceNotation/CleanNamespaceFixer.php @@ -45,6 +45,16 @@ public function isCandidate(Tokens $tokens): bool return \PHP_VERSION_ID < 8_00_00 && $tokens->isTokenKindFound(T_NS_SEPARATOR); } + /** + * {@inheritdoc} + * + * Must run before PhpUnitDataProviderReturnTypeFixer. + */ + public function getPriority(): int + { + return 1; + } + protected function applyFix(\SplFileInfo $file, Tokens $tokens): void { $count = $tokens->count(); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/BinaryOperatorSpacesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/BinaryOperatorSpacesFixer.php index 001fef987..d167a954e 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/BinaryOperatorSpacesFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/BinaryOperatorSpacesFixer.php @@ -879,7 +879,7 @@ private function replacePlaceholders(Tokens $tokens, string $alignStrategy, stri self::ALIGN_SINGLE_SPACE_MINIMAL === $alignStrategy || self::ALIGN_SINGLE_SPACE_MINIMAL_BY_SCOPE === $alignStrategy ) { - if (1 !== Preg::match('/^\h+$/', $before)) { // if indent; do not move, leave to other fixer + if (!Preg::match('/^\h+$/', $before)) { // if indent; do not move, leave to other fixer $before = rtrim($before).' '; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php index 7495de72c..ddf0c2dfd 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Operator/NoSpaceAroundDoubleColonFixer.php @@ -26,7 +26,7 @@ public function getDefinition(): FixerDefinitionInterface { return new FixerDefinition( 'There must be no space around double colons (also called Scope Resolution Operator or Paamayim Nekudotayim).', - [new CodeSample("\ngetNextMeaningfulToken(max($operatorIndices)); for ($i = $nextIndex - 1; $i > max($operatorIndices); --$i) { - if ($tokens[$i]->isWhitespace() && 1 === Preg::match('/\R/u', $tokens[$i]->getContent())) { + if ($tokens[$i]->isWhitespace() && Preg::match('/\R/u', $tokens[$i]->getContent())) { $isWhitespaceBefore = $tokens[$prevIndex]->isWhitespace(); $inserts = $this->getReplacementsAndClear($tokens, $operatorIndices, -1); if ($isWhitespaceBefore) { @@ -240,7 +240,7 @@ private function fixMoveToTheEnd(Tokens $tokens, array $operatorIndices): void $nextIndex = $tokens->getNonEmptySibling(max($operatorIndices), 1); for ($i = $prevIndex + 1; $i < max($operatorIndices); ++$i) { - if ($tokens[$i]->isWhitespace() && 1 === Preg::match('/\R/u', $tokens[$i]->getContent())) { + if ($tokens[$i]->isWhitespace() && Preg::match('/\R/u', $tokens[$i]->getContent())) { $isWhitespaceAfter = $tokens[$nextIndex]->isWhitespace(); $inserts = $this->getReplacementsAndClear($tokens, $operatorIndices, 1); if ($isWhitespaceAfter) { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php index 5e2126acd..a3b8cf7ef 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitConstructFixer.php @@ -96,7 +96,7 @@ public function getPriority(): int protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $endIndex): void { // no assertions to be fixed - fast return - if (empty($this->configuration['assertions'])) { + if ([] === $this->configuration['assertions']) { return; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderReturnTypeFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderReturnTypeFixer.php new file mode 100644 index 000000000..9d46f829c --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitDataProviderReturnTypeFixer.php @@ -0,0 +1,120 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Fixer\PhpUnit; + +use PhpCsFixer\Fixer\AbstractPhpUnitFixer; +use PhpCsFixer\FixerDefinition\CodeSample; +use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Tokenizer\Analyzer\DataProviderAnalyzer; +use PhpCsFixer\Tokenizer\Analyzer\FunctionsAnalyzer; +use PhpCsFixer\Tokenizer\CT; +use PhpCsFixer\Tokenizer\Token; +use PhpCsFixer\Tokenizer\Tokens; + +/** + * @author Kuba Werłos + */ +final class PhpUnitDataProviderReturnTypeFixer extends AbstractPhpUnitFixer +{ + public function getDefinition(): FixerDefinitionInterface + { + return new FixerDefinition( + 'The return type of PHPUnit data provider must be `iterable`.', + [ + new CodeSample( + 'getDataProviders($tokens, $startIndex, $endIndex)) as $dataProviderAnalysis) { + $typeAnalysis = $functionsAnalyzer->getFunctionReturnType($tokens, $dataProviderAnalysis->getNameIndex()); + + if (null === $typeAnalysis) { + $argumentsStart = $tokens->getNextTokenOfKind($dataProviderAnalysis->getNameIndex(), ['(']); + $argumentsEnd = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $argumentsStart); + + $tokens->insertAt( + $argumentsEnd + 1, + [ + new Token([CT::T_TYPE_COLON, ':']), + new Token([T_WHITESPACE, ' ']), + new Token([T_STRING, 'iterable']), + ], + ); + + continue; + } + + if ('iterable' === $typeAnalysis->getName()) { + continue; + } + + $typeStartIndex = $tokens->getNextMeaningfulToken($typeAnalysis->getStartIndex() - 1); + $typeEndIndex = $typeAnalysis->getEndIndex(); + + // @TODO: drop condition and it's body when PHP 8+ is required + if ($tokens->generatePartialCode($typeStartIndex, $typeEndIndex) !== $typeAnalysis->getName()) { + continue; + } + + $tokens->overrideRange($typeStartIndex, $typeEndIndex, [new Token([T_STRING, 'iterable'])]); + } + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php index b408caf2b..4221fe92d 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php @@ -152,7 +152,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $allowedReplacementScenarios = (new ClassyAnalyzer())->isClassyInvocation($tokens, $currIndex) || $this->isImport($tokens, $currIndex); - if (!$allowedReplacementScenarios || 1 !== Preg::match($this->originalClassRegEx, $originalClass)) { + if (!$allowedReplacementScenarios || !Preg::match($this->originalClassRegEx, $originalClass)) { ++$currIndex; continue; @@ -204,9 +204,9 @@ private function generateReplacement(string $originalClassName): Tokens $parts = explode($delimiter, $string); $tokensArray = []; - while (!empty($parts)) { + while ([] !== $parts) { $tokensArray[] = new Token([T_STRING, array_shift($parts)]); - if (!empty($parts)) { + if ([] !== $parts) { $tokensArray[] = new Token([T_NS_SEPARATOR, '\\']); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php index bb8d64f54..f6fa1f0fe 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitNoExpectationAnnotationFixer.php @@ -216,7 +216,7 @@ private function extractContentFromAnnotation(Annotation $annotation): string { $tag = $annotation->getTag()->getName(); - if (1 !== Preg::match('/@'.$tag.'\s+(.+)$/s', $annotation->getContent(), $matches)) { + if (!Preg::match('/@'.$tag.'\s+(.+)$/s', $annotation->getContent(), $matches)) { return ''; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php index f435b3cfe..abee1f2ee 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php @@ -193,7 +193,7 @@ private function hasProperTestAnnotation(Tokens $tokens, int $index): bool $docBlockIndex = $this->getDocBlockIndex($tokens, $index); $doc = $tokens[$docBlockIndex]->getContent(); - return 1 === Preg::match('/\*\s+@test\b/', $doc); + return Preg::match('/\*\s+@test\b/', $doc); } private function removeTestPrefix(string $functionName): string diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/AlignMultilineCommentFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/AlignMultilineCommentFixer.php index e5ce6f700..e9a3d680d 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/AlignMultilineCommentFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/AlignMultilineCommentFixer.php @@ -120,11 +120,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $whitespace = Preg::replace('/\S/', '', $tokens[$previousIndex]->getContent()).$whitespace; } - if (1 !== Preg::match('/\R(\h*)$/', $whitespace, $matches)) { + if (!Preg::match('/\R(\h*)$/', $whitespace, $matches)) { continue; } - if ($token->isGivenKind(T_COMMENT) && 'all_multiline' !== $this->configuration['comment_type'] && 1 === Preg::match('/\R(?:\R|\s*[^\s\*])/', $token->getContent())) { + if ($token->isGivenKind(T_COMMENT) && 'all_multiline' !== $this->configuration['comment_type'] && Preg::match('/\R(?:\R|\s*[^\s\*])/', $token->getContent())) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php index 835a0eb31..6e7390144 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php @@ -107,7 +107,7 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn )); } - if (1 !== Preg::match('#^\S+$#', $to) || str_contains($to, '*/')) { + if (!Preg::match('#^\S+$#', $to) || str_contains($to, '*/')) { throw new InvalidOptionsException(sprintf( 'Tag "%s" cannot be replaced by invalid tag "%s".', $from, diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php index 79f1870c6..9dba2647f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php @@ -514,7 +514,7 @@ private function annotationIsSuperfluous( $regex = '{@return(?:\s+'.TypeExpression::REGEX_TYPES.')?(?:\s+(?(?!\*\/)\S+))?}s'; } - if (1 !== Preg::match($regex, $annotation->getContent(), $matches)) { + if (!Preg::match($regex, $annotation->getContent(), $matches)) { // Unable to match the annotation, it must be malformed or has unsupported format. // Either way we don't want to tinker with it. return false; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php index 863281695..908a4bc0b 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixer.php @@ -160,7 +160,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void foreach ($doc->getAnnotationsOfType('param') as $annotation) { $pregMatched = Preg::match('/^[^$]+(\$\w+).*$/s', $annotation->getContent(), $matches); - if (1 === $pregMatched) { + if ($pregMatched) { unset($arguments[$matches[1]]); } @@ -197,7 +197,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void array_splice( $lines, - $lastParamLine ? $lastParamLine + 1 : $linesCount - 1, + $lastParamLine > 0 ? $lastParamLine + 1 : $linesCount - 1, 0, $newLines ); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAlignFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAlignFixer.php index 8b3d5b654..963bd6597 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAlignFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAlignFixer.php @@ -249,7 +249,7 @@ private function fixDocBlock(DocBlock $docBlock): void continue; } - $hasStatic = $hasStatic || $item['static']; + $hasStatic |= '' !== $item['static']; $tagMax = max($tagMax, \strlen($item['tag'])); $hintMax = max($hintMax, \strlen($item['hint'])); $varMax = max($varMax, \strlen($item['var'])); @@ -302,7 +302,7 @@ private function fixDocBlock(DocBlock $docBlock): void $line .= $this->getIndent( $tagMax - \strlen($item['tag']) + 1, - $item['static'] ? 1 : 0 + '' !== $item['static'] ? 1 : 0 ) .($item['static'] ?: $this->getIndent(6 /* \strlen('static') */, 0)); $hintVerticalAlignIndent = 1; @@ -313,20 +313,20 @@ private function fixDocBlock(DocBlock $docBlock): void $line .= $this->getIndent( $hintVerticalAlignIndent, - $item['hint'] ? 1 : 0 + '' !== $item['hint'] ? 1 : 0 ) .$item['hint']; - if (!empty($item['var'])) { + if ('' !== $item['var']) { $line .= $this->getIndent(($hintMax ?: -1) - \strlen($item['hint']) + 1) .$item['var'] .( - !empty($item['desc']) + '' !== $item['desc'] ? $this->getIndent($varMax - \strlen($item['var']) + 1).$item['desc'] : '' ); - } elseif (!empty($item['desc'])) { + } elseif ('' !== $item['desc']) { $line .= $this->getIndent($hintMax - \strlen($item['hint']) + 1).$item['desc']; } @@ -338,18 +338,18 @@ private function fixDocBlock(DocBlock $docBlock): void /** * @TODO Introduce proper DTO instead of an array * - * @return null|array{indent: null|string, tag: null|string, hint: null|string, var: null|string, static: null|string, desc?: null|string} + * @return null|array{indent: null|string, tag: null|string, hint: string, var: null|string, static: string, desc?: null|string} */ private function getMatches(string $line, bool $matchCommentOnly = false): ?array { if (Preg::match($this->regex, $line, $matches)) { - if (!empty($matches['tag2'])) { + if (isset($matches['tag2']) && '' !== $matches['tag2']) { $matches['tag'] = $matches['tag2']; $matches['hint'] = $matches['hint2']; $matches['var'] = ''; } - if (!empty($matches['tag3'])) { + if (isset($matches['tag3']) && '' !== $matches['tag3']) { $matches['tag'] = $matches['tag3']; $matches['hint'] = $matches['hint3']; $matches['var'] = $matches['signature']; @@ -393,7 +393,7 @@ private function getIndent(int $verticalAlignIndent, int $leftAlignIndent = 1): } /** - * @param non-empty-list $items + * @param non-empty-list $items */ private function getLeftAlignedDescriptionIndent(array $items, int $index): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php index 309723283..130604bc4 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php @@ -95,8 +95,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $content = $annotation->getContent(); if ( - 1 !== Preg::match('/[.。]\h*$/u', $content) - || 0 !== Preg::match('/[.。](?!\h*$)/u', $content, $matches) + !Preg::match('/[.。]\h*$/u', $content) + || Preg::match('/[.。](?!\h*$)/u', $content, $matches) ) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocOrderByValueFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocOrderByValueFixer.php index ef78c0795..c3728efce 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocOrderByValueFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocOrderByValueFixer.php @@ -101,7 +101,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void if ( !$tokens[$index]->isGivenKind(T_DOC_COMMENT) - || 0 === Preg::match($findPattern, $tokens[$index]->getContent()) + || !Preg::match($findPattern, $tokens[$index]->getContent()) ) { continue; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocParamOrderFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocParamOrderFixer.php index 147ae6cd4..fb3f41240 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocParamOrderFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocParamOrderFixer.php @@ -133,7 +133,7 @@ private function rewriteDocBlock(DocBlock $doc, array $paramNames, array $paramA $otherAnnotations = $this->getOtherAnnotationsBetweenParams($doc, $paramAnnotations); // Append annotations found between param ones - if (\count($otherAnnotations)) { + if ([] !== $otherAnnotations) { array_push($orderedAnnotations, ...$otherAnnotations); } @@ -255,7 +255,7 @@ private function findParamAnnotationByIdentifier(array $paramAnnotations, string ++$blockLevel; } - if ($blockEndMatches) { + if (0 !== $blockEndMatches) { $blockLevel -= $blockEndMatches; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocSeparationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocSeparationFixer.php index 4f01e2c11..539f37b17 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocSeparationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocSeparationFixer.php @@ -303,7 +303,7 @@ private function isInGroup(string $tag, array $group): bool $tagInGroup = preg_quote($tagInGroup, '/'); $tagInGroup = str_replace('\\\\\*', '.*?', $tagInGroup); - if (1 === Preg::match("/^{$tagInGroup}$/", $tag)) { + if (Preg::match("/^{$tagInGroup}$/", $tag)) { return true; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php index f8e9d3af8..b10456f3a 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Phpdoc/PhpdocTypesOrderFixer.php @@ -141,12 +141,10 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void // fix @method parameters types $line = $doc->getLine($annotation->getStart()); - $line->setContent(Preg::replaceCallback('/(@method\s+.+?\s+\w+\()(.*)\)/', function (array $matches) { - $sorted = Preg::replaceCallback('/([^\s,]+)([\s]+\$[^\s,]+)/', function (array $matches): string { - return $this->sortJoinedTypes($matches[1]).$matches[2]; - }, $matches[2]); + $line->setContent(Preg::replaceCallback('/@method\s+'.TypeExpression::REGEX_TYPES.'\s+\K(?&callable)/', function (array $matches) { + $typeExpression = new TypeExpression($matches[0], null, []); - return $matches[1].$sorted.')'; + return implode('|', $this->sortTypes($typeExpression)); }, $line->getContent())); } @@ -189,11 +187,4 @@ function (TypeExpression $a, TypeExpression $b) use ($normalizeType): int { return $typeExpression->getTypes(); } - - private function sortJoinedTypes(string $types): string - { - $typeExpression = new TypeExpression($types, null, []); - - return implode('|', $this->sortTypes($typeExpression)); - } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/StringNotation/ExplicitStringVariableFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/StringNotation/ExplicitStringVariableFixer.php index 9f993f7f3..b7f2b5e10 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/StringNotation/ExplicitStringVariableFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/StringNotation/ExplicitStringVariableFixer.php @@ -41,11 +41,11 @@ public function getDefinition(): FixerDefinitionInterface EOT )], 'The reasoning behind this rule is the following:' - ."\n".'- When there are two valid ways of doing the same thing, using both is confusing, there should be a coding standard to follow' - ."\n".'- PHP manual marks `"$var"` syntax as implicit and `"${var}"` syntax as explicit: explicit code should always be preferred' - ."\n".'- Explicit syntax allows word concatenation inside strings, e.g. `"${var}IsAVar"`, implicit doesn\'t' - ."\n".'- Explicit syntax is easier to detect for IDE/editors and therefore has colors/highlight with higher contrast, which is easier to read' - ."\n".'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings' + ."\n".'- When there are two valid ways of doing the same thing, using both is confusing, there should be a coding standard to follow.' + ."\n".'- PHP manual marks `"$var"` syntax as implicit and `"${var}"` syntax as explicit: explicit code should always be preferred.' + ."\n".'- Explicit syntax allows word concatenation inside strings, e.g. `"${var}IsAVar"`, implicit doesn\'t.' + ."\n".'- Explicit syntax is easier to detect for IDE/editors and therefore has colors/highlight with higher contrast, which is easier to read.' + ."\n".'Backtick operator is skipped because it is harder to handle; you can use `backtick_to_shell_exec` fixer to normalize backticks to strings.' ); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php index a191ca2e9..11150b5e2 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBeforeStatementFixer.php @@ -238,7 +238,7 @@ function A() { /** * {@inheritdoc} * - * Must run after NoExtraBlankLinesFixer, NoUselessReturnFixer, ReturnAssignmentFixer. + * Must run after NoExtraBlankLinesFixer, NoUselessReturnFixer, ReturnAssignmentFixer, YieldFromArrayToYieldsFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBetweenImportGroupsFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBetweenImportGroupsFixer.php index b67de37c6..1976aefb3 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBetweenImportGroupsFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/BlankLineBetweenImportGroupsFixer.php @@ -19,8 +19,8 @@ use PhpCsFixer\FixerDefinition\CodeSample; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Tokenizer\Analyzer\WhitespacesAnalyzer; use PhpCsFixer\Tokenizer\CT; -use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; use PhpCsFixer\Tokenizer\TokensAnalyzer; @@ -154,12 +154,9 @@ private function ensureLine(Tokens $tokens, int $index): void } $index = $this->getInsertIndex($tokens, $index); + $indent = WhitespacesAnalyzer::detectIndent($tokens, $index); - if ($tokens[$index]->isWhitespace()) { - $tokens[$index] = new Token([T_WHITESPACE, $lineEnding]); - } else { - $tokens->insertSlices([$index + 1 => [new Token([T_WHITESPACE, $lineEnding])]]); - } + $tokens->ensureWhitespaceAtIndex($index, 1, $lineEnding.$indent); } private function getInsertIndex(Tokens $tokens, int $index): int diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/MethodChainingIndentationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/MethodChainingIndentationFixer.php index d0a848adc..2830246a5 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/MethodChainingIndentationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/MethodChainingIndentationFixer.php @@ -149,7 +149,7 @@ private function canBeMovedToNextLine(int $index, Tokens $tokens): bool continue; } - if ($tokens[$i]->isWhitespace() && 1 === Preg::match('/\R/', $tokens[$i]->getContent())) { + if ($tokens[$i]->isWhitespace() && Preg::match('/\R/', $tokens[$i]->getContent())) { return $hasCommentBefore; } } @@ -162,7 +162,7 @@ private function canBeMovedToNextLine(int $index, Tokens $tokens): bool */ private function getIndentAt(Tokens $tokens, int $index): ?string { - if (1 === Preg::match('/\R{1}(\h*)$/', $this->getIndentContentAt($tokens, $index), $matches)) { + if (Preg::match('/\R{1}(\h*)$/', $this->getIndentContentAt($tokens, $index), $matches)) { return $matches[1]; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php index 6f1869199..4062256f5 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoExtraBlankLinesFixer.php @@ -255,7 +255,7 @@ class Bar * {@inheritdoc} * * Must run before BlankLineBeforeStatementFixer. - * Must run after ClassAttributesSeparationFixer, CombineConsecutiveUnsetsFixer, EmptyLoopBodyFixer, EmptyLoopConditionFixer, FunctionToConstantFixer, ModernizeStrposFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoEmptyStatementFixer, NoUnusedImportsFixer, NoUselessElseFixer, NoUselessReturnFixer, NoUselessSprintfFixer, StringLengthToEmptyFixer. + * Must run after ClassAttributesSeparationFixer, CombineConsecutiveUnsetsFixer, EmptyLoopBodyFixer, EmptyLoopConditionFixer, FunctionToConstantFixer, ModernizeStrposFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoEmptyStatementFixer, NoUnusedImportsFixer, NoUselessElseFixer, NoUselessReturnFixer, NoUselessSprintfFixer, StringLengthToEmptyFixer, YieldFromArrayToYieldsFixer. */ public function getPriority(): int { @@ -330,7 +330,7 @@ private function removeBetweenUse(int $index): void private function removeMultipleBlankLines(int $index): void { - $expected = $this->tokens[$index - 1]->isGivenKind(T_OPEN_TAG) && 1 === Preg::match('/\R$/', $this->tokens[$index - 1]->getContent()) ? 1 : 2; + $expected = $this->tokens[$index - 1]->isGivenKind(T_OPEN_TAG) && Preg::match('/\R$/', $this->tokens[$index - 1]->getContent()) ? 1 : 2; $parts = Preg::split('/(.*\R)/', $this->tokens[$index]->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $count = \count($parts); diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php index 6b19241cc..c21ff39f9 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php @@ -63,8 +63,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void $token->isGivenKind(T_OPEN_TAG) && $tokens->offsetExists($index + 1) && $tokens[$index + 1]->isWhitespace() - && 1 === Preg::match('/(.*)\h$/', $token->getContent(), $openTagMatches) - && 1 === Preg::match('/^(\R)(.*)$/s', $tokens[$index + 1]->getContent(), $whitespaceMatches) + && Preg::match('/(.*)\h$/', $token->getContent(), $openTagMatches) + && Preg::match('/^(\R)(.*)$/s', $tokens[$index + 1]->getContent(), $whitespaceMatches) ) { $tokens[$index] = new Token([T_OPEN_TAG, $openTagMatches[1].$whitespaceMatches[1]]); $tokens->ensureWhitespaceAtIndex($index + 1, 0, $whitespaceMatches[2]); @@ -81,7 +81,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void // fix only multiline whitespaces or singleline whitespaces at the end of file if ($linesSize > 1 || !isset($tokens[$index + 1])) { - if (!$tokens[$index - 1]->isGivenKind(T_OPEN_TAG) || 1 !== Preg::match('/(.*)\R$/', $tokens[$index - 1]->getContent())) { + if (!$tokens[$index - 1]->isGivenKind(T_OPEN_TAG) || !Preg::match('/(.*)\R$/', $tokens[$index - 1]->getContent())) { $lines[0] = rtrim($lines[0], " \t"); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php index dcfe9dc36..e43013c4f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/NoWhitespaceInBlankLineFixer.php @@ -38,7 +38,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@inheritdoc} * - * Must run after AssignNullCoalescingToCoalesceEqualFixer, CombineConsecutiveIssetsFixer, CombineConsecutiveUnsetsFixer, FunctionToConstantFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoEmptyStatementFixer, NoUselessElseFixer, NoUselessReturnFixer. + * Must run after AssignNullCoalescingToCoalesceEqualFixer, CombineConsecutiveIssetsFixer, CombineConsecutiveUnsetsFixer, FunctionToConstantFixer, NoEmptyCommentFixer, NoEmptyPhpdocFixer, NoEmptyStatementFixer, NoUselessElseFixer, NoUselessReturnFixer, YieldFromArrayToYieldsFixer. */ public function getPriority(): int { diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php index 9adc7bec6..605efbbff 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/StatementIndentationFixer.php @@ -64,7 +64,7 @@ public function getDefinition(): FixerDefinitionInterface * {@inheritdoc} * * Must run before HeredocIndentationFixer. - * Must run after ClassAttributesSeparationFixer, CurlyBracesPositionFixer. + * Must run after ClassAttributesSeparationFixer, CurlyBracesPositionFixer, YieldFromArrayToYieldsFixer. */ public function getPriority(): int { @@ -564,7 +564,7 @@ private function isCommentWithFixableIndentation(Tokens $tokens, int $index): bo $indent = preg_quote($this->whitespacesConfig->getIndent(), '~'); - if (1 === Preg::match("~^(//|#)({$indent}.*)?$~", $tokens[$index]->getContent())) { + if (Preg::match("~^(//|#)({$indent}.*)?$~", $tokens[$index]->getContent())) { return false; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypeDeclarationSpacesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypeDeclarationSpacesFixer.php new file mode 100644 index 000000000..29cd7f5ab --- /dev/null +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypeDeclarationSpacesFixer.php @@ -0,0 +1,199 @@ + + * Dariusz Rumiński + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace PhpCsFixer\Fixer\Whitespace; + +use PhpCsFixer\AbstractFixer; +use PhpCsFixer\Fixer\ConfigurableFixerInterface; +use PhpCsFixer\FixerConfiguration\AllowedValueSubset; +use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver; +use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface; +use PhpCsFixer\FixerConfiguration\FixerOptionBuilder; +use PhpCsFixer\FixerDefinition\CodeSample; +use PhpCsFixer\FixerDefinition\FixerDefinition; +use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; +use PhpCsFixer\Tokenizer\Analyzer\Analysis\TypeAnalysis; +use PhpCsFixer\Tokenizer\Analyzer\FunctionsAnalyzer; +use PhpCsFixer\Tokenizer\Token; +use PhpCsFixer\Tokenizer\Tokens; +use PhpCsFixer\Tokenizer\TokensAnalyzer; + +/** + * @author Dariusz Rumiński + * @author John Paul E. Balandan, CPA + */ +final class TypeDeclarationSpacesFixer extends AbstractFixer implements ConfigurableFixerInterface +{ + public function getDefinition(): FixerDefinitionInterface + { + return new FixerDefinition( + 'Ensure single space between a variable and its type declaration in function arguments and properties.', + [ + new CodeSample( + ' (string) $c; + } +} +', + ['elements' => ['function']] + ), + new CodeSample( + ' ['property']] + ), + ] + ); + } + + public function isCandidate(Tokens $tokens): bool + { + return $tokens->isAnyTokenKindsFound([...Token::getClassyTokenKinds(), T_FN, T_FUNCTION]); + } + + protected function createConfigurationDefinition(): FixerConfigurationResolverInterface + { + return new FixerConfigurationResolver([ + (new FixerOptionBuilder('elements', 'Structural elements where the spacing after the type declaration should be fixed.')) + ->setAllowedTypes(['array']) + ->setAllowedValues([new AllowedValueSubset(['function', 'property'])]) + ->setDefault(['function', 'property']) + ->getOption(), + ]); + } + + protected function applyFix(\SplFileInfo $file, Tokens $tokens): void + { + $functionsAnalyzer = new FunctionsAnalyzer(); + + foreach (array_reverse($this->getElements($tokens), true) as $index => $type) { + if ('property' === $type && \in_array('property', $this->configuration['elements'], true)) { + $this->ensureSingleSpaceAtPropertyTypehint($tokens, $index); + + continue; + } + + if ('method' === $type && \in_array('function', $this->configuration['elements'], true)) { + $this->ensureSingleSpaceAtFunctionArgumentTypehint($functionsAnalyzer, $tokens, $index); + + // implicit continue; + } + } + } + + /** + * @return array + * + * @phpstan-return array + */ + private function getElements(Tokens $tokens): array + { + $tokensAnalyzer = new TokensAnalyzer($tokens); + + $elements = array_map( + static fn (array $element): string => $element['type'], + array_filter( + $tokensAnalyzer->getClassyElements(), + static fn (array $element): bool => \in_array($element['type'], ['method', 'property'], true) + ) + ); + + foreach ($tokens as $index => $token) { + if ( + $token->isGivenKind(T_FN) + || ($token->isGivenKind(T_FUNCTION) && !isset($elements[$index])) + ) { + $elements[$index] = 'method'; + } + } + + return $elements; + } + + private function ensureSingleSpaceAtFunctionArgumentTypehint(FunctionsAnalyzer $functionsAnalyzer, Tokens $tokens, int $index): void + { + foreach (array_reverse($functionsAnalyzer->getFunctionArguments($tokens, $index)) as $argumentInfo) { + $argumentType = $argumentInfo->getTypeAnalysis(); + + if (null === $argumentType) { + continue; + } + + $tokens->ensureWhitespaceAtIndex($argumentType->getEndIndex() + 1, 0, ' '); + } + } + + private function ensureSingleSpaceAtPropertyTypehint(Tokens $tokens, int $index): void + { + $propertyIndex = $index; + $propertyModifiers = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_STATIC, T_VAR]; + + if (\defined('T_READONLY')) { + $propertyModifiers[] = T_READONLY; // @TODO drop condition when PHP 8.1 is supported + } + + do { + $index = $tokens->getPrevMeaningfulToken($index); + } while (!$tokens[$index]->isGivenKind($propertyModifiers)); + + $propertyType = $this->collectTypeAnalysis($tokens, $index, $propertyIndex); + + if (null === $propertyType) { + return; + } + + $tokens->ensureWhitespaceAtIndex($propertyType->getEndIndex() + 1, 0, ' '); + } + + private function collectTypeAnalysis(Tokens $tokens, int $startIndex, int $endIndex): ?TypeAnalysis + { + $type = ''; + $typeStartIndex = $tokens->getNextMeaningfulToken($startIndex); + $typeEndIndex = $typeStartIndex; + + for ($i = $typeStartIndex; $i < $endIndex; ++$i) { + if ($tokens[$i]->isWhitespace() || $tokens[$i]->isComment()) { + continue; + } + + $type .= $tokens[$i]->getContent(); + $typeEndIndex = $i; + } + + return '' !== $type ? new TypeAnalysis($type, $typeStartIndex, $typeEndIndex) : null; + } +} diff --git a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php index 675c02f04..72d8e77e3 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Fixer/Whitespace/TypesSpacesFixer.php @@ -63,7 +63,7 @@ public function getDefinition(): FixerDefinitionInterface /** * {@inheritdoc} * - * Must run after OrderedTypesFixer. + * Must run after NullableTypeDeclarationFixer, OrderedTypesFixer. */ public function getPriority(): int { @@ -140,7 +140,7 @@ private function ensureSingleSpace(Tokens $tokens, int $index, int $offset): int return 1; } - if (' ' !== $tokens[$index]->getContent() && 1 !== Preg::match('/\R/', $tokens[$index]->getContent())) { + if (' ' !== $tokens[$index]->getContent() && !Preg::match('/\R/', $tokens[$index]->getContent())) { $tokens[$index] = new Token([T_WHITESPACE, ' ']); } @@ -149,7 +149,7 @@ private function ensureSingleSpace(Tokens $tokens, int $index, int $offset): int private function ensureNoSpace(Tokens $tokens, int $index): void { - if ($tokens[$index]->isWhitespace() && 1 !== Preg::match('/\R/', $tokens[$index]->getContent())) { + if ($tokens[$index]->isWhitespace() && !Preg::match('/\R/', $tokens[$index]->getContent())) { $tokens->clearAt($index); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/FixerDefinition/FixerDefinition.php b/vendor/friendsofphp/php-cs-fixer/src/FixerDefinition/FixerDefinition.php index cd1e47797..f4ae91597 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/FixerDefinition/FixerDefinition.php +++ b/vendor/friendsofphp/php-cs-fixer/src/FixerDefinition/FixerDefinition.php @@ -26,8 +26,14 @@ final class FixerDefinition implements FixerDefinitionInterface */ private array $codeSamples; + /** + * Description of Fixer and benefit of using it. + */ private ?string $description; + /** + * Description why Fixer is risky. + */ private ?string $riskyDescription; /** diff --git a/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php b/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php index ecbc464de..fea453472 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php +++ b/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php @@ -88,7 +88,7 @@ public function registerBuiltInFixers(): self /** @var SplFileInfo $file */ foreach (SymfonyFinder::create()->files()->in(__DIR__.'/Fixer')->name('*Fixer.php')->depth(1) as $file) { $relativeNamespace = $file->getRelativePath(); - $fixerClass = 'PhpCsFixer\\Fixer\\'.($relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php'); + $fixerClass = 'PhpCsFixer\\Fixer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php'); $builtInFixers[] = $fixerClass; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/FixerNameValidator.php b/vendor/friendsofphp/php-cs-fixer/src/FixerNameValidator.php index ce2697d3e..8f19cb06c 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/FixerNameValidator.php +++ b/vendor/friendsofphp/php-cs-fixer/src/FixerNameValidator.php @@ -24,9 +24,9 @@ final class FixerNameValidator public function isValid(string $name, bool $isCustom): bool { if (!$isCustom) { - return 1 === Preg::match('/^[a-z][a-z0-9_]*$/', $name); + return Preg::match('/^[a-z][a-z0-9_]*$/', $name); } - return 1 === Preg::match('/^[A-Z][a-zA-Z0-9]*\/[a-z][a-z0-9_]*$/', $name); + return Preg::match('/^[A-Z][a-zA-Z0-9]*\/[a-z][a-z0-9_]*$/', $name); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php b/vendor/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php index 543bbf1b9..b4942d93d 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Indicator/PhpUnitTestCaseIndicator.php @@ -40,7 +40,7 @@ public function isPhpUnitClass(Tokens $tokens, int $index): bool return false; } - if (0 !== Preg::match('/(?:Test|TestCase)$/', $tokens[$index]->getContent())) { + if (Preg::match('/(?:Test|TestCase)$/', $tokens[$index]->getContent())) { return true; } @@ -53,7 +53,7 @@ public function isPhpUnitClass(Tokens $tokens, int $index): bool continue; // not part of extends nor part of implements; so continue } - if (0 !== Preg::match('/(?:Test|TestCase)(?:Interface)?$/', $tokens[$index]->getContent())) { + if (Preg::match('/(?:Test|TestCase)(?:Interface)?$/', $tokens[$index]->getContent())) { return true; } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Preg.php b/vendor/friendsofphp/php-cs-fixer/src/Preg.php index 42456035c..1dadb476f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Preg.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Preg.php @@ -30,16 +30,16 @@ final class Preg * * @throws PregException */ - public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool { $result = @preg_match(self::addUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && PREG_NO_ERROR === preg_last_error()) { - return $result; + return 1 === $result; } $result = @preg_match(self::removeUtf8Modifier($pattern), $subject, $matches, $flags, $offset); if (false !== $result && PREG_NO_ERROR === preg_last_error()) { - return $result; + return 1 === $result; } throw self::newPregException(preg_last_error(), __METHOD__, (array) $pattern); diff --git a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/AbstractMigrationSetDescription.php b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/AbstractMigrationSetDescription.php index 02138fe0d..57e1911ba 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/AbstractMigrationSetDescription.php +++ b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/AbstractMigrationSetDescription.php @@ -25,11 +25,11 @@ public function getDescription(): string { $name = $this->getName(); - if (0 !== Preg::match('#^@PHPUnit(\d+)(\d)Migration.*$#', $name, $matches)) { + if (Preg::match('#^@PHPUnit(\d+)(\d)Migration.*$#', $name, $matches)) { return sprintf('Rules to improve tests code for PHPUnit %d.%d compatibility.', $matches[1], $matches[2]); } - if (0 !== Preg::match('#^@PHP([\d]{2})Migration.*$#', $name, $matches)) { + if (Preg::match('#^@PHP([\d]{2})Migration.*$#', $name, $matches)) { return sprintf('Rules to improve code for PHP %d.%d compatibility.', $matches[1][0], $matches[1][1]); } diff --git a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/PhpCsFixerRiskySet.php b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/PhpCsFixerRiskySet.php index 7a1350c58..7ed53fe30 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/PhpCsFixerRiskySet.php +++ b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/PhpCsFixerRiskySet.php @@ -50,6 +50,7 @@ public function getRules(): array 'no_unreachable_default_argument_value' => true, 'no_unset_on_property' => true, 'php_unit_data_provider_name' => true, + 'php_unit_data_provider_return_type' => true, 'php_unit_strict' => true, 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], 'strict_comparison' => true, diff --git a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/SymfonySet.php b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/SymfonySet.php index 577079522..38e82a618 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/SymfonySet.php +++ b/vendor/friendsofphp/php-cs-fixer/src/RuleSet/Sets/SymfonySet.php @@ -55,7 +55,6 @@ public function getRules(): array 'empty_loop_body' => ['style' => 'braces'], 'empty_loop_condition' => true, 'fully_qualified_strict_types' => true, - 'function_typehint_space' => true, 'general_phpdoc_tag_rename' => [ 'replacements' => [ 'inheritDocs' => 'inheritDoc', @@ -204,6 +203,7 @@ public function getRules(): array '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, diff --git a/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php b/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php index b8133c941..ca2083a8f 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Runner/Runner.php @@ -195,7 +195,7 @@ private function fixFile(\SplFileInfo $file, LintingResultInterface $lintingResu $fixInfo = null; - if (!empty($appliedFixers)) { + if ([] !== $appliedFixers) { $new = $tokens->generateCode(); $newHash = $tokens->getCodeHash(); } @@ -257,7 +257,7 @@ private function fixFile(\SplFileInfo $file, LintingResultInterface $lintingResu $error = error_get_last(); throw new IOException( - sprintf('Failed to write file "%s", "%s".', $fileName, $error ? $error['message'] : 'no reason available'), + sprintf('Failed to write file "%s", "%s".', $fileName, null !== $error ? $error['message'] : 'no reason available'), 0, null, $fileName @@ -270,7 +270,7 @@ private function fixFile(\SplFileInfo $file, LintingResultInterface $lintingResu $this->dispatchEvent( FixerFileProcessedEvent::NAME, - new FixerFileProcessedEvent($fixInfo ? FixerFileProcessedEvent::STATUS_FIXED : FixerFileProcessedEvent::STATUS_NO_CHANGES) + new FixerFileProcessedEvent(null !== $fixInfo ? FixerFileProcessedEvent::STATUS_FIXED : FixerFileProcessedEvent::STATUS_NO_CHANGES) ); return $fixInfo; diff --git a/vendor/friendsofphp/php-cs-fixer/src/StdinFileInfo.php b/vendor/friendsofphp/php-cs-fixer/src/StdinFileInfo.php index bbb66acf3..4649a6ca4 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/StdinFileInfo.php +++ b/vendor/friendsofphp/php-cs-fixer/src/StdinFileInfo.php @@ -23,6 +23,7 @@ final class StdinFileInfo extends \SplFileInfo { public function __construct() { + parent::__construct(__FILE__); } public function __toString(): string diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/AbstractTypeTransformer.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/AbstractTypeTransformer.php index 7ee8a9c2d..8c5476b42 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/AbstractTypeTransformer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/AbstractTypeTransformer.php @@ -52,7 +52,7 @@ private function isPartOfType(Tokens $tokens, int $index): bool { // return types and non-capturing catches $typeColonIndex = $tokens->getTokenNotOfKindSibling($index, -1, self::TYPE_TOKENS); - if ($tokens[$typeColonIndex]->isGivenKind([T_CATCH, CT::T_TYPE_COLON])) { + if ($tokens[$typeColonIndex]->isGivenKind([T_CATCH, CT::T_TYPE_COLON, T_CONST])) { return true; } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php index 7fe14158c..7cd8771b1 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/Analysis/TypeAnalysis.php @@ -63,6 +63,8 @@ public function __construct(string $name, int $startIndex, int $endIndex) if (str_starts_with($name, '?')) { $this->name = substr($name, 1); $this->nullable = true; + } elseif (\PHP_VERSION_ID >= 8_00_00) { + $this->nullable = \in_array('null', array_map('trim', explode('|', strtolower($name))), true); } $this->startIndex = $startIndex; diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php index 85b4c8679..94322071e 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/ArgumentsAnalyzer.php @@ -155,7 +155,7 @@ public function getArgumentInfo(Tokens $tokens, int $argumentStart, int $argumen $info['name'], $info['name_index'], $info['default'], - $info['type'] ? new TypeAnalysis($info['type'], $info['type_index_start'], $info['type_index_end']) : null + null !== $info['type'] ? new TypeAnalysis($info['type'], $info['type_index_start'], $info['type_index_end']) : null ); } } diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Token.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Token.php index a8cd3efb3..58399d805 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Token.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Token.php @@ -186,7 +186,7 @@ public function equals($other, bool $caseSensitive = true): bool // detect unknown keys unset($otherPrototype[0], $otherPrototype[1]); - return empty($otherPrototype); + return [] === $otherPrototype; } /** diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php index 3a72a6d38..ccd98d332 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Tokens.php @@ -297,7 +297,9 @@ public function offsetUnset($index): void { $this->changed = true; $this->namespaceDeclarations = null; - $this->unregisterFoundToken($this[$index]); + if (isset($this[$index])) { + $this->unregisterFoundToken($this[$index]); + } parent::offsetUnset($index); } @@ -322,7 +324,6 @@ public function offsetSet($index, $newval): void if (isset($this[$index])) { $this->unregisterFoundToken($this[$index]); } - $this->registerFoundToken($newval); } @@ -1048,7 +1049,7 @@ public function toJson(): string public function isAllTokenKindsFound(array $tokenKinds): bool { foreach ($tokenKinds as $tokenKind) { - if (empty($this->foundTokenKinds[$tokenKind])) { + if (!isset($this->foundTokenKinds[$tokenKind])) { return false; } } @@ -1064,7 +1065,7 @@ public function isAllTokenKindsFound(array $tokenKinds): bool public function isAnyTokenKindsFound(array $tokenKinds): bool { foreach ($tokenKinds as $tokenKind) { - if (!empty($this->foundTokenKinds[$tokenKind])) { + if (isset($this->foundTokenKinds[$tokenKind])) { return true; } } @@ -1079,7 +1080,7 @@ public function isAnyTokenKindsFound(array $tokenKinds): bool */ public function isTokenKindFound($tokenKind): bool { - return !empty($this->foundTokenKinds[$tokenKind]); + return isset($this->foundTokenKinds[$tokenKind]); } /** @@ -1117,7 +1118,7 @@ public function isMonolithicPhp(): bool } if (1 === $this->countTokenKind(T_INLINE_HTML)) { - return 1 === Preg::match('/^#!.+$/', $this[0]->getContent()); + return Preg::match('/^#!.+$/', $this[0]->getContent()); } return 1 === ($this->countTokenKind(T_OPEN_TAG) + $this->countTokenKind(T_OPEN_TAG_WITH_ECHO)); @@ -1381,7 +1382,7 @@ private function registerFoundToken($token): void } /** - * Register token as found. + * Unregister token as not found. * * @param array{int}|string|Token $token token prototype */ @@ -1392,11 +1393,11 @@ private function unregisterFoundToken($token): void ? ($token->isArray() ? $token->getId() : $token->getContent()) : (\is_array($token) ? $token[0] : $token); - if (!isset($this->foundTokenKinds[$tokenKind])) { - return; + if (1 === $this->foundTokenKinds[$tokenKind]) { + unset($this->foundTokenKinds[$tokenKind]); + } else { + --$this->foundTokenKinds[$tokenKind]; } - - --$this->foundTokenKinds[$tokenKind]; } /** diff --git a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Transformers.php b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Transformers.php index 7cec5a061..c506b31b0 100644 --- a/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Transformers.php +++ b/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Transformers.php @@ -103,7 +103,7 @@ private function findBuiltInTransformers(): iterable /** @var SplFileInfo $file */ foreach (Finder::create()->files()->in(__DIR__.'/Transformer') as $file) { $relativeNamespace = $file->getRelativePath(); - $class = __NAMESPACE__.'\\Transformer\\'.($relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php'); + $class = __NAMESPACE__.'\\Transformer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php'); yield new $class(); }