Skip to content
Merged
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
121 changes: 82 additions & 39 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<<<EOM
This file is part of the TYPO3 project.

(c) 2019-2024 Benni Mack
(c) 2019-2026 Benni Mack
Simon Gilli

For the full copyright and license information, please view
Expand All @@ -17,55 +17,98 @@
true
)
->addRules([
'@PER:risky' => true,
'@PHP80Migration:risky' => true,
'@PHP81Migration' => true,
'declare_strict_types' => true,
'fully_qualified_strict_types' => true,
'@DoctrineAnnotation' => true,
'@PER-CS3x0' => true,
// Override PER-CS3x0 default (single) to keep no space after cast operators
'cast_spaces' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
'function_to_constant' => [
'functions' => [
'get_called_class',
'get_class',
'get_class_this',
'php_sapi_name',
'phpversion',
'pi',
],
],
'type_declaration_spaces' => true,
'global_namespace_import' => [
'import_classes' => true,
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
'no_unneeded_import_alias' => true,
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
'sort_algorithm' => 'alpha',
'list_syntax' => ['syntax' => 'short'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'native_function_invocation' => [
'include' => [],
'scope' => 'all',
'strict' => true,
],
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => true,
'phpdoc_line_span' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_order_by_value' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_tag_casing' => true,
'phpdoc_tag_type' => true,
'phpdoc_to_comment' => [
'ignored_tags' => [
'phpstan-ignore-line',
'phpstan-ignore-next-line',
'todo',
],
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
// Override PER-CS3x0 default (union) to keep ?Type shorthand syntax
'nullable_type_declaration' => [
'syntax' => 'question_mark',
],
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'alpha',
'nullable_type_declaration_for_default_null_value' => true,
'ordered_class_elements' => ['order' => ['use_trait', 'case', 'constant', 'property']],
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'self',
'methods' => [
'any' => 'this',
'atLeast' => 'this',
'atLeastOnce' => 'this',
'atMost' => 'this',
'exactly' => 'this',
'never' => 'this',
'onConsecutiveCalls' => 'this',
'once' => 'this',
'returnArgument' => 'this',
'returnCallback' => 'this',
'returnSelf' => 'this',
'returnValue' => 'this',
'returnValueMap' => 'this',
'throwException' => 'this',
],
],
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'self_accessor' => true,
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'protected_to_private' => true,
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
->getFinder()
->exclude('templates')
->exclude('tests/Unit/Fixtures')
->in(__DIR__)
->append(['typo3-coding-standards'])
;
->append(['typo3-coding-standards']);

return $config;
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"friendsofphp/php-cs-fixer": "^3.88.2",
"friendsofphp/php-cs-fixer": "^3.95.1",
"symfony/console": "^6.4 || ^7.4 || ^8.0",
"symfony/filesystem": "^6.4 || ^7.4 || ^8.0"
},
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand Down
11 changes: 5 additions & 6 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand All @@ -16,7 +16,6 @@

namespace TYPO3\CodingStandards\Console;

use RuntimeException;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -38,7 +37,7 @@ final class Application extends BaseApplication
/**
* getcwd() equivalent which always returns a string.
*
* @throws RuntimeException
* @throws \RuntimeException
*/
private static function getCwd(bool $allowEmpty = false): string
{
Expand All @@ -57,7 +56,7 @@ private static function getCwd(bool $allowEmpty = false): string
return '';
}

throw new RuntimeException('Could not determine the current working directory');
throw new \RuntimeException('Could not determine the current working directory');
}

// @codeCoverageIgnoreEnd
Expand All @@ -71,7 +70,7 @@ public static function getProjectDir(): string
}

/**
* @throws RuntimeException
* @throws \RuntimeException
*/
public static function getTargetDir(InputInterface $input): string
{
Expand All @@ -87,7 +86,7 @@ public static function getTargetDir(InputInterface $input): string
}

if (!is_dir($targetDir)) {
throw new RuntimeException(\sprintf('Invalid target directory specified, %s does not exist.', $targetDir));
throw new \RuntimeException(sprintf('Invalid target directory specified, %s does not exist.', $targetDir));
}

return $targetDir;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand Down
23 changes: 11 additions & 12 deletions src/Console/Command/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand All @@ -16,7 +16,6 @@

namespace TYPO3\CodingStandards\Console\Command;

use RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -73,7 +72,7 @@ private function getRuleSets(InputInterface $input): array
}

/**
* @throws RuntimeException
* @throws \RuntimeException
*/
private function getType(InputInterface $input): string
{
Expand All @@ -84,22 +83,22 @@ private function getType(InputInterface $input): string

$composerManifest = $this->getProjectDir() . '/composer.json';
if (!file_exists($composerManifest)) {
throw new RuntimeException(sprintf($composerManifestError, 'found'));
throw new \RuntimeException(sprintf($composerManifestError, 'found'));
}

$composerManifest = \file_get_contents($composerManifest);
$composerManifest = file_get_contents($composerManifest);
if ($composerManifest === false) {
throw new RuntimeException(sprintf($composerManifestError, 'read')); // @codeCoverageIgnore
throw new \RuntimeException(sprintf($composerManifestError, 'read')); // @codeCoverageIgnore
}

$composerManifest = \json_decode($composerManifest, true);
$composerManifest = json_decode($composerManifest, true);
if ($composerManifest === false || !is_array($composerManifest)) {
throw new RuntimeException(sprintf($composerManifestError, 'decoded'));
throw new \RuntimeException(sprintf($composerManifestError, 'decoded'));
}

if (
($composerManifest['type'] ?? '') === 'typo3-cms-extension' ||
($composerManifest['extra']['typo3/cms']['extension-key'] ?? '') !== ''
($composerManifest['type'] ?? '') === 'typo3-cms-extension'
|| ($composerManifest['extra']['typo3/cms']['extension-key'] ?? '') !== ''
) {
$type = Setup::EXTENSION;
} else {
Expand All @@ -120,11 +119,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$result = true;

if (\in_array(Setup::RULE_SET_EDITORCONFIG, $ruleSets, true)) {
if (in_array(Setup::RULE_SET_EDITORCONFIG, $ruleSets, true)) {
$result = $setup->copyEditorConfig($force);
}

if (\in_array(Setup::RULE_SET_PHP_CS_FIXER, $ruleSets, true)) {
if (in_array(Setup::RULE_SET_PHP_CS_FIXER, $ruleSets, true)) {
$result = $setup->copyPhpCsFixerConfig($force, $type) && $result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand Down
22 changes: 4 additions & 18 deletions src/CsFixerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand Down Expand Up @@ -41,20 +41,11 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface
*/
protected static $typo3Rules = [
'@DoctrineAnnotation' => true,
// @todo: Switch to @PER-CS2x0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
'@PER-CS1x0' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'@PER-CS3x0' => true,
// Override PER-CS3x0 default (single) to keep no space after cast operators
'cast_spaces' => ['space' => 'none'],
// @todo: Can be dropped once we enable @PER-CS2x0
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
// @todo: Can be dropped once we enable @PER-CS2x0
'function_declaration' => [
'closure_fn_spacing' => 'none',
],
'function_to_constant' => [
'functions' => [
'get_called_class',
Expand All @@ -72,8 +63,6 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface
'import_functions' => false,
],
'list_syntax' => ['syntax' => 'short'],
// @todo: Can be dropped once we enable @PER-CS2x0
'method_argument_space' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
Expand All @@ -97,6 +86,7 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
// Override PER-CS3x0 default (union) to keep ?Type shorthand syntax
'nullable_type_declaration' => [
'syntax' => 'question_mark',
],
Expand Down Expand Up @@ -132,12 +122,8 @@ class CsFixerConfig extends Config implements CsFixerConfigInterface
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'protected_to_private' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_space_around_construct' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
// @todo: Can be dropped once we enable @PER-CS2x0
'single_line_empty_body' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
Expand Down
2 changes: 1 addition & 1 deletion src/CsFixerConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* This file is part of the TYPO3 project.
*
* (c) 2019-2024 Benni Mack
* (c) 2019-2026 Benni Mack
* Simon Gilli
*
* For the full copyright and license information, please view
Expand Down
Loading
Loading