diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index 5867996af2..e43b964d59 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -36,6 +36,10 @@ jobs: name: 'Check Active Classes' run: vendor/bin/class-leak check bin src --ansi + - + name: 'Run StructArmed' + run: vendor/bin/structarmed analyze + name: ${{ matrix.actions.name }} runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index cfba02408c..5d908bc102 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "webmozart/assert": "^2.3" }, "require-dev": { + "boundwize/structarmed": "^0.9.1", "phpstan/extension-installer": "^1.4.3", "phpstan/phpstan": "^2.1.54", "phpstan/phpstan-phpunit": "^2.0.16", diff --git a/src/Configuration/ECSConfigBuilder.php b/src/Configuration/ECSConfigBuilder.php index e866df6d14..2be27f2ffc 100644 --- a/src/Configuration/ECSConfigBuilder.php +++ b/src/Configuration/ECSConfigBuilder.php @@ -891,17 +891,17 @@ private function applyEditorConfigSettings(): void if ($editorConfig->indentStyle !== null) { $this->indentation = match ($editorConfig->indentStyle) { - IndentStyle::Space => Option::INDENTATION_SPACES, - IndentStyle::Tab => Option::INDENTATION_TAB, + IndentStyle::SPACE => Option::INDENTATION_SPACES, + IndentStyle::TAB => Option::INDENTATION_TAB, default => Option::INDENTATION_SPACES, }; } if ($editorConfig->endOfLine !== null) { $this->lineEnding = match ($editorConfig->endOfLine) { - EndOfLine::Posix => "\n", - EndOfLine::Legacy => "\r", - EndOfLine::Windows => "\r\n", + EndOfLine::POSIX => "\n", + EndOfLine::LEGACY => "\r", + EndOfLine::WINDOWS => "\r\n", default => "\n", }; } @@ -930,13 +930,13 @@ private function applyEditorConfigSettings(): void ]; } - if ($editorConfig->quoteType === QuoteType::Auto) { + if ($editorConfig->quoteType === QuoteType::AUTO) { $this->rules[] = SingleQuoteFixer::class; - } elseif ($editorConfig->quoteType === QuoteType::Single) { + } elseif ($editorConfig->quoteType === QuoteType::SINGLE) { $this->rulesWithConfiguration[SingleQuoteFixer::class] = [ 'strings_containing_single_quote_chars' => true, ]; - } elseif ($editorConfig->quoteType === QuoteType::Double) { + } elseif ($editorConfig->quoteType === QuoteType::DOUBLE) { $this->skip = [...$this->skip, SingleQuoteFixer::class, DoubleQuoteUsageSniff::class]; } } diff --git a/src/Configuration/EditorConfig/EndOfLine.php b/src/Configuration/EditorConfig/EndOfLine.php index 6e65fecd77..bb08ebe619 100644 --- a/src/Configuration/EditorConfig/EndOfLine.php +++ b/src/Configuration/EditorConfig/EndOfLine.php @@ -6,9 +6,9 @@ final class EndOfLine { - public const string Posix = 'lf'; + public const string POSIX = 'lf'; - public const string Legacy = 'cr'; + public const string LEGACY = 'cr'; - public const string Windows = 'crlf'; + public const string WINDOWS = 'crlf'; } diff --git a/src/Configuration/EditorConfig/IndentStyle.php b/src/Configuration/EditorConfig/IndentStyle.php index 43dbf79904..9917f5d126 100644 --- a/src/Configuration/EditorConfig/IndentStyle.php +++ b/src/Configuration/EditorConfig/IndentStyle.php @@ -6,7 +6,7 @@ final class IndentStyle { - public const string Space = 'space'; + public const string SPACE = 'space'; - public const string Tab = 'tab'; + public const string TAB = 'tab'; } diff --git a/src/Configuration/EditorConfig/QuoteType.php b/src/Configuration/EditorConfig/QuoteType.php index b06d847a4d..2425c39a1a 100644 --- a/src/Configuration/EditorConfig/QuoteType.php +++ b/src/Configuration/EditorConfig/QuoteType.php @@ -9,9 +9,9 @@ */ final class QuoteType { - public const string Single = 'single'; + public const string SINGLE = 'single'; - public const string Double = 'double'; + public const string DOUBLE = 'double'; - public const string Auto = 'auto'; + public const string AUTO = 'auto'; } diff --git a/structarmed.php b/structarmed.php new file mode 100644 index 0000000000..edcef4209f --- /dev/null +++ b/structarmed.php @@ -0,0 +1,16 @@ +skip([ + __DIR__ . '/tests/Console/Output/Source', + Psr1Preset::FILES_SHOULD_DECLARE_SYMBOLS_OR_SIDE_EFFECTS => [ + __DIR__ . '/src/Testing/PHPUnit/AbstractCheckerTestCase.php', + ], + ]) + ->withPresets(Preset::PSR4(), Preset::PSR1()); diff --git a/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php b/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php index 03939edc2d..eb8fd7c590 100644 --- a/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php +++ b/tests/Configuration/EditorConfig/EditorConfigFactoryTest.php @@ -22,8 +22,8 @@ public function testLoadingFromProjectRoot(): void $editorConfig = $editorConfigFactory->load(); $this->assertEquals($editorConfig, new EditorConfig( - indentStyle: IndentStyle::Space, - endOfLine: EndOfLine::Posix, + indentStyle: IndentStyle::SPACE, + endOfLine: EndOfLine::POSIX, trimTrailingWhitespace: true, insertFinalNewline: true, maxLineLength: null, @@ -68,8 +68,8 @@ public function testLoadsExpectedSections(): void INI ), new EditorConfig( - indentStyle: IndentStyle::Tab, - endOfLine: EndOfLine::Posix, + indentStyle: IndentStyle::TAB, + endOfLine: EndOfLine::POSIX, trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: 100, @@ -103,7 +103,7 @@ public function testIndentStyleSpaces(): void INI ), new EditorConfig( - indentStyle: IndentStyle::Space, + indentStyle: IndentStyle::SPACE, endOfLine: null, trimTrailingWhitespace: null, insertFinalNewline: null, @@ -123,7 +123,7 @@ public function testIndentStyleTabs(): void INI ), new EditorConfig( - indentStyle: IndentStyle::Tab, + indentStyle: IndentStyle::TAB, endOfLine: null, trimTrailingWhitespace: null, insertFinalNewline: null, @@ -144,7 +144,7 @@ public function testEndOfLinePosix(): void ), new EditorConfig( indentStyle: null, - endOfLine: EndOfLine::Posix, + endOfLine: EndOfLine::POSIX, trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, @@ -164,7 +164,7 @@ public function testEndOfLineLegacy(): void ), new EditorConfig( indentStyle: null, - endOfLine: EndOfLine::Legacy, + endOfLine: EndOfLine::LEGACY, trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, @@ -184,7 +184,7 @@ public function testEndOfLineWindows(): void ), new EditorConfig( indentStyle: null, - endOfLine: EndOfLine::Windows, + endOfLine: EndOfLine::WINDOWS, trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, @@ -308,7 +308,7 @@ public function quoteTypeAuto(): void trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, - quoteType: QuoteType::Auto + quoteType: QuoteType::AUTO ) ); } @@ -328,7 +328,7 @@ public function quoteTypeSingle(): void trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, - quoteType: QuoteType::Single + quoteType: QuoteType::SINGLE ) ); } @@ -348,7 +348,7 @@ public function quoteTypeDouble(): void trimTrailingWhitespace: null, insertFinalNewline: null, maxLineLength: null, - quoteType: QuoteType::Double + quoteType: QuoteType::DOUBLE ) ); }