corvée(outils) importe divers configurations

- phpactor
- php cs fixer
- phpstan
This commit is contained in:
gcch 2025-12-15 15:34:50 +01:00
commit 4720c46ff8
5 changed files with 316 additions and 28 deletions

View file

@ -2,6 +2,7 @@
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner;
$finder = new Finder()->in(__DIR__)->exclude([
'vendor',
@ -12,4 +13,249 @@ $finder = new Finder()->in(__DIR__)->exclude([
'web/app/mu-plugins',
]);
return new Config()->setRules(['@PhpCsFixer' => true])->setFinder($finder);
return new Config()
->setRiskyAllowed(true)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'assign_null_coalescing_to_coalesce_equal' => true,
'attribute_empty_parentheses' => ['use_parentheses' => true],
'blank_line_after_namespace' => true,
'blank_lines_before_namespace' => ['min_line_breaks' => 1, 'max_line_breaks' => 2],
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => [
'case' => 'none',
'const' => 'none',
'method' => 'one',
'property' => 'one',
'trait_import' => 'none',
]],
'class_reference_name_casing' => true,
'clean_namespace' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'comment_to_phpdoc' => true,
'constant_case' => true,
'date_time_immutable' => true,
'declare_equal_normalize' => true,
'declare_parentheses' => true,
'declare_strict_types' => true,
'dir_constant' => true,
'echo_tag_syntax' => true,
'encoding' => true,
'ereg_to_preg' => true,
'error_suppression' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'final_class' => true,
'final_internal_class' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => ['import_symbols' => true],
'function_to_constant' => true,
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'heredoc_to_nowdoc' => true,
'integer_literal_case' => true,
'lambda_not_used_import' => true,
'list_syntax' => true,
'logical_operators' => true,
'long_to_shorthand_operator' => true,
'lowercase_cast' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_constant_casing' => true,
'magic_method_casing' => true,
'mb_str_functions' => true,
'modernize_strpos' => ['modernize_stripos' => true],
'modernize_types_casting' => true,
'modifier_keywords' => true,
'multiline_comment_opening_closing' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => [
'include' => ['@compiler_optimized'],
'scope' => 'namespaced',
'strict' => true,
],
'native_type_declaration_casing' => true,
'new_expression_parentheses' => true,
'no_alias_functions' => ['sets' => ['@all']],
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => true,
'no_binary_string' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
'no_homoglyph_names' => true,
'no_leading_import_slash' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiple_statements_per_line' => true,
'no_null_property_initialization' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_trailing_comma_in_singleline' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_braces' => ['namespaces' => true],
'no_unneeded_control_parentheses' => ['statements' => [
'break',
'clone',
'continue',
'echo_print',
'negative_instanceof',
'others',
'return',
'switch_case',
'yield',
'yield_from',
]],
'no_unneeded_final_method' => true,
'no_unneeded_import_alias' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
'no_unset_on_property' => true,
'no_unused_imports' => true,
'no_useless_concat_operator' => true,
'no_useless_nullsafe_operator' => true,
'no_useless_printf' => true,
'no_useless_return' => true,
'no_useless_sprintf' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'non_printable_character' => true,
'normalize_index_brace' => true,
'nullable_type_declaration' => ['syntax' => 'union'],
'nullable_type_declaration_for_default_null_value' => true,
'numeric_literal_separator' => ['override_existing' => true, 'strategy' => 'use_separator'],
'ordered_attributes' => true,
'ordered_class_elements' => ['case_sensitive' => false, 'sort_algorithm' => 'alpha'],
'ordered_imports' => ['case_sensitive' => true],
'ordered_interfaces' => true,
'ordered_traits' => true,
'ordered_types' => ['null_adjustment' => 'always_last'],
'phpdoc_readonly_class_comment_to_keyword' => true,
'phpdoc_to_param_type' => true,
'phpdoc_to_property_type' => true,
'phpdoc_to_return_type' => true,
'pow_to_exponentiation' => true,
'protected_to_private' => true,
'psr_autoloading' => true,
'random_api_migration' => ['replacements' => [
'getrandmax' => 'mt_getrandmax',
'rand' => 'mt_rand',
'srand' => 'mt_srand',
]],
'return_assignment' => true,
'self_accessor' => true,
'self_static_accessor' => true,
'set_type_to_cast' => true,
'short_scalar_cast' => true,
'simple_to_complex_string_variable' => true,
'simplified_null_return' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_spacing' => true,
'single_line_comment_style' => true,
'single_line_empty_body' => true,
'single_trait_insert_per_statement' => true,
'standardize_not_equals' => true,
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'string_implicit_backslashes' => true,
'string_length_to_empty' => true,
'switch_continue_to_break' => true,
'ternary_to_null_coalescing' => true,
'trim_array_spaces' => true,
'use_arrow_functions' => true,
'void_return' => true,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
// ---
// Each line of multi-line DocComments must have an asterisk [PSR-5] and must be aligned with the first one.
'align_multiline_comment' => ['comment_type' => 'all_multiline'],
// There should not be blank lines between docblock and the documented element.
'no_blank_lines_after_phpdoc' => true,
// There should not be empty PHPDoc blocks.
'no_empty_phpdoc' => true,
// Removes @param, @return and @var tags that don't provide any useful information.
'no_superfluous_phpdoc_tags' => [
'allow_hidden_params' => false,
'allow_mixed' => false,
'allow_unused_params' => false,
],
// PHPDoc should contain @param for all params.
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
// All items of the given PHPDoc tags must be either left-aligned or (by default) aligned vertically.
'phpdoc_align' => true,
// PHPDoc annotation descriptions should not be a sentence.
'phpdoc_annotation_without_dot' => true,
// PHPDoc array<T> type must be used instead of T[].
'phpdoc_array_type' => true,
// Docblocks should have the same indentation as the documented subject.
'phpdoc_indent' => true,
// Fixes PHPDoc inline tags.
'phpdoc_inline_tag_normalizer' => true,
// Changes doc blocks from single to multi line, or reversed. Works for class constants, properties and methods only.
'phpdoc_line_span' => ['const' => 'single', 'method' => 'multi', 'property' => 'single'],
// PHPDoc list type must be used instead of array without a key.
'phpdoc_list_type' => false,
// @access annotations must be removed from PHPDoc.
'phpdoc_no_access' => true,
// No alias PHPDoc tags should be used.
'phpdoc_no_alias_tag' => true,
// @return void and @return null annotations must be removed from PHPDoc.
'phpdoc_no_empty_return' => false,
// @package and @subpackage annotations must be removed from PHPDoc.
'phpdoc_no_package' => true,
// Classy that does not inherit must not have @inheritdoc tags.
'phpdoc_no_useless_inheritdoc' => true,
// Annotations in PHPDoc should be ordered in defined sequence.
'phpdoc_order' => true,
// Order PHPDoc tags by value.
'phpdoc_order_by_value' => true,
// Orders all @param annotations in DocBlocks according to method signature.
'phpdoc_param_order' => true,
// The type of @return annotations of methods returning a reference to itself must the configured one.
'phpdoc_return_self_reference' => true,
// Scalar types should always be written in the same form. int not integer, bool not boolean, float not real or double.
'phpdoc_scalar' => ['types' => [
'boolean',
'callback',
'double',
'integer',
'never-return',
'never-returns',
'no-return',
'real',
'str',
]],
// Annotations in PHPDoc should be grouped together so that annotations of the same type immediately follow each other. Annotations of a different type are separated by a single blank line.
'phpdoc_separation' => [
'groups' => [
['Annotation', 'NamedArgumentConstructor', 'Target'],
['author', 'copyright', 'license'],
['category', 'package', 'subpackage'],
['property', 'property-read', 'property-write'],
['deprecated', 'link', 'see', 'since'],
],
'skip_unlisted_annotations' => false,
],
// Single line @var PHPDoc should have proper spacing.
'phpdoc_single_line_var_spacing' => true,
// PHPDoc summary should end in either a full stop, exclamation mark, or question mark.
'phpdoc_summary' => true,
// Docblocks should only be used on structural elements.
'phpdoc_to_comment' => false,
// PHPDoc should start and end with content, excluding the very first and last line of the docblocks.
'phpdoc_trim' => true,
// Removes extra blank lines after summary and after description in PHPDoc.
'phpdoc_trim_consecutive_blank_line_separation' => true,
// The correct case must be used for standard PHP types in PHPDoc.
'phpdoc_types' => true,
// Sorts PHPDoc types.
'phpdoc_types_order' => ['null_adjustment' => 'always_last'],
// @var and @type annotations must have type and name in the correct order.
'phpdoc_var_annotation_correct_order' => true,
// @var and @type annotations of classy properties should not contain the name.
'phpdoc_var_without_name' => true,
])
->setFinder($finder)
->setParallelConfig(Runner\Parallel\ParallelConfigFactory::detect());

View file

@ -1,10 +1,19 @@
{
"$schema": "/opt/phpactor/phpactor.schema.json",
"language_server.diagnostic_outsource_timeout": 1,
"language_server_php_cs_fixer.enabled": false,
"$schema": "/phpactor.schema.json",
"indexer.exclude_patterns": [
"/vendor/**/Tests/**/*",
"/vendor/**/tests/**/*",
"/var/cache/**/*",
"/vendor/composer/**/*"
],
"language_server.diagnostic_outsource_timeout": 5,
"language_server.diagnostics_on_update": true,
"language_server.diagnostics_on_save": true,
"language_server_highlight.enabled": true,
"language_server_php_cs_fixer.enabled": true,
"language_server_phpstan.config": "phpstan.neon",
"language_server_phpstan.enabled": true,
"language_server_psalm.enabled": false,
"language_server_reference_finder.soft_timeout": 10,
"language_server_reference_reference_finder.reference_timeout": 10,
"php_code_sniffer.enabled": false
"language_server_reference_reference_finder.reference_timeout": 10
}

View file

@ -33,6 +33,8 @@ format:
-vendor/bin/twig-cs-fixer fix web/app/themes/haiku-atelier-2024/
# Mago
mago fmt
# PhpCsFixer
-vendor/bin/php-cs-fixer fix --allow-risky yes
fish scripts/format-sort-files.fish
# Compile, minifie et optimise Sass vers CSS.

View file

@ -1,10 +1,12 @@
php-version = "8.4.0"
php-version = "8.5"
stack-size = 8388608
threads = 8
[source]
excludes = ["web/wp/wp-admin/includes/noop.php"]
extensions = ["php"]
includes = ["config", "vendor", "web/app/plugins", "web/vendor", "web/wp"]
paths = ["web/app/themes/haiku-atelier-2024/"]
paths = ["web/app/themes/haiku-atelier-2024"]
[formatter]
# Brace style for classes, traits, etc.

View file

@ -1,22 +1,51 @@
parameters:
parallel:
maximumNumberOfProcesses: 8
level: 6
paths:
- web/app/themes/haiku-atelier-2024
scanDirectories:
- vendor
- web/app
- web/vendor
- web/wp
scanFiles:
- .php-cs-fixer.dist.php
- web/index.php
- web/wp-config.php
# Utilise la version de développement de PHPStan
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
excludePaths:
analyse:
- web/app/themes/la-fille-davril/vendor
analyseAndScan:
- web/app/themes/twentytwentyfour
parameters:
# When set to true, it reports use of dynamic properties as undefined.
checkDynamicProperties: true
checkExplicitMixedMissingReturn: true
# When set to true, it reports function and method calls with incorrect name case.
checkFunctionNameCase: true
# When set to true, it reports references to built-in classes with incorrect name case.
checkInternalClassCaseSensitivity: true
# When set to true, it reports return typehints that could be narrowed down because some of the listed types are never returned from a public or protected method.
checkTooWideReturnTypesInProtectedAndPublicMethods: true
# When set to true, it reports properties with native types that werent initialized in the class constructor.
checkUninitializedProperties: false
reportUnmatchedIgnoredErrors: false
# When set to true, it reports violations of parameter type contravariance and return type covariance.
reportMaybesInMethodSignatures: true
# By default PHPStan reports wrong type in @var tag only for native types on the right side of =. With reportWrongPhpDocTypeInVarTag set to true it will consider PHPDoc types too.
reportWrongPhpDocTypeInVarTag: true
# Setting treatPhpDocTypesAsCertain to false relaxes some of the rules around type-checking.
treatPhpDocTypesAsCertain: true
parallel:
jobSize: 20
maximumNumberOfProcesses: 32
minimumNumberOfJobsPerProcess: 2
level: max
scanDirectories:
- config
- vendor
- web/app
- web/vendor
- web/wp
scanFiles:
- .php-cs-fixer.dist.php
- web/index.php
- web/wp-config.php
paths:
- web/app/themes/haiku-atelier-2024
excludePaths:
analyseAndScan:
- web/app/db.php (?)
- web/app/languages
- web/app/themes/twentytwentyfour