Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions src/Configuration/ECSConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
}
Expand Down Expand Up @@ -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];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration/EditorConfig/EndOfLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
4 changes: 2 additions & 2 deletions src/Configuration/EditorConfig/IndentStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
6 changes: 3 additions & 3 deletions src/Configuration/EditorConfig/QuoteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
16 changes: 16 additions & 0 deletions structarmed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use Boundwize\StructArmed\Architecture;
use Boundwize\StructArmed\Preset\Preset;
use Boundwize\StructArmed\Preset\Presets\Psr1Preset;

return Architecture::define()
->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());
24 changes: 12 additions & 12 deletions tests/Configuration/EditorConfig/EditorConfigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -103,7 +103,7 @@ public function testIndentStyleSpaces(): void
INI
),
new EditorConfig(
indentStyle: IndentStyle::Space,
indentStyle: IndentStyle::SPACE,
endOfLine: null,
trimTrailingWhitespace: null,
insertFinalNewline: null,
Expand All @@ -123,7 +123,7 @@ public function testIndentStyleTabs(): void
INI
),
new EditorConfig(
indentStyle: IndentStyle::Tab,
indentStyle: IndentStyle::TAB,
endOfLine: null,
trimTrailingWhitespace: null,
insertFinalNewline: null,
Expand All @@ -144,7 +144,7 @@ public function testEndOfLinePosix(): void
),
new EditorConfig(
indentStyle: null,
endOfLine: EndOfLine::Posix,
endOfLine: EndOfLine::POSIX,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These would be BC breaks, I prefer to keep it as it is.

trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
Expand All @@ -164,7 +164,7 @@ public function testEndOfLineLegacy(): void
),
new EditorConfig(
indentStyle: null,
endOfLine: EndOfLine::Legacy,
endOfLine: EndOfLine::LEGACY,
trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
Expand All @@ -184,7 +184,7 @@ public function testEndOfLineWindows(): void
),
new EditorConfig(
indentStyle: null,
endOfLine: EndOfLine::Windows,
endOfLine: EndOfLine::WINDOWS,
trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
Expand Down Expand Up @@ -308,7 +308,7 @@ public function quoteTypeAuto(): void
trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
quoteType: QuoteType::Auto
quoteType: QuoteType::AUTO
)
);
}
Expand All @@ -328,7 +328,7 @@ public function quoteTypeSingle(): void
trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
quoteType: QuoteType::Single
quoteType: QuoteType::SINGLE
)
);
}
Expand All @@ -348,7 +348,7 @@ public function quoteTypeDouble(): void
trimTrailingWhitespace: null,
insertFinalNewline: null,
maxLineLength: null,
quoteType: QuoteType::Double
quoteType: QuoteType::DOUBLE
)
);
}
Expand Down
Loading