Add PHP coding standard
This commit is contained in:
parent
46775a8ae6
commit
c5f0fc164a
15 changed files with 2689 additions and 0 deletions
15
2023/php-coding-standard/.editorconfig
Normal file
15
2023/php-coding-standard/.editorconfig
Normal file
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = LF
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
max_line_length = 80
|
||||
|
||||
[*.php]
|
||||
# settings required by PSR-12 standard
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
4
2023/php-coding-standard/.gitignore
vendored
Normal file
4
2023/php-coding-standard/.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
/.php-cs-fixer.cache
|
||||
/.php-cs-fixer.php
|
||||
/composer.lock
|
||||
/vendor/
|
43
2023/php-coding-standard/.php-cs-fixer.dist.php
Normal file
43
2023/php-coding-standard/.php-cs-fixer.dist.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* My personal coding standard
|
||||
*
|
||||
* @author Krzysztof Sikorski
|
||||
* @copyright 2023 Krzysztof Sikorski
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use KrzysztofSikorski\CodingStandard\PhpCsFixerRulesFactory;
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
require_once __DIR__ . '/tools/php-cs-fixer/vendor/autoload.php';
|
||||
|
||||
$configName = 'My personal coding standard';
|
||||
|
||||
$header = <<<'HEADER'
|
||||
My personal coding standard
|
||||
|
||||
@author Krzysztof Sikorski
|
||||
@copyright 2023 Krzysztof Sikorski
|
||||
HEADER;
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files();
|
||||
$finder->in(dirs: __DIR__);
|
||||
$finder->ignoreDotFiles(ignoreDotFiles: false);
|
||||
$finder->ignoreVCSIgnored(ignoreVCSIgnored: true);
|
||||
|
||||
$finder->append(iterator: [__FILE__]);
|
||||
|
||||
$rules = PhpCsFixerRulesFactory::create(header: $header);
|
||||
|
||||
$config = new Config(name: $configName);
|
||||
$config->setFinder(finder: $finder);
|
||||
$config->setRiskyAllowed(isRiskyAllowed: true);
|
||||
$config->setRules(rules: $rules);
|
||||
|
||||
return $config;
|
38
2023/php-coding-standard/CHANGELOG.md
Normal file
38
2023/php-coding-standard/CHANGELOG.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Version 4.0.0
|
||||
|
||||
Released: 2023-09-22
|
||||
|
||||
- Bump required PHP version to **8.2**
|
||||
- Remove dependencies on dev tools
|
||||
- Simplify package: remove all classes except rules generator
|
||||
|
||||
# Version 3.1.0
|
||||
|
||||
Released: 2023-09-22
|
||||
|
||||
- Added deprecation messages to prepare users for v4.0
|
||||
|
||||
# Version 3.0.0
|
||||
|
||||
Released: 2023-08-06
|
||||
|
||||
- Redesigned API: split rules generation into separate class `RulesFactory`.
|
||||
|
||||
# Version 2.0.0
|
||||
|
||||
Released: 2023-08-06
|
||||
|
||||
- Redesigned API: split Finder generation into separate class `FinderFactory`.
|
||||
|
||||
# Version 1.0.1
|
||||
|
||||
Released: 2023-07-30
|
||||
|
||||
- Documentation updates.
|
||||
|
||||
# Version 1.0.0
|
||||
|
||||
Released: 2023-07-30
|
||||
|
||||
- Created `ConfigFactory` class for generating config objects for PHP Coding
|
||||
Standards Fixer.
|
21
2023/php-coding-standard/LICENCE.txt
Normal file
21
2023/php-coding-standard/LICENCE.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Krzysztof Sikorski
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
52
2023/php-coding-standard/Makefile
Normal file
52
2023/php-coding-standard/Makefile
Normal file
|
@ -0,0 +1,52 @@
|
|||
SHELL := /bin/sh
|
||||
.POSIX: # enable POSIX compatibility
|
||||
.SUFFIXES: # no special suffixes
|
||||
.DEFAULT_GOAL := default
|
||||
|
||||
default:
|
||||
@echo "Please choose target explicitly."
|
||||
|
||||
.PHONY: git_push_all
|
||||
git_push_all:
|
||||
git remote | xargs -L1 git push --verbose --all
|
||||
git remote | xargs -L1 git push --verbose --tags
|
||||
|
||||
.PHONY: clean_all
|
||||
clean_all: clean_cache clean_packages
|
||||
|
||||
.PHONY: clean_cache
|
||||
clean_cache:
|
||||
rm --force --verbose .php-cs-fixer.cache
|
||||
|
||||
.PHONY: clean_packages
|
||||
clean_packages:
|
||||
rm --force --recursive --verbose vendor
|
||||
rm --force --recursive --verbose tools/parallel-lint/vendor
|
||||
rm --force --recursive --verbose tools/php-cs-fixer/vendor
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
composer install
|
||||
composer --working-dir=tools/parallel-lint install
|
||||
composer --working-dir=tools/php-cs-fixer install
|
||||
|
||||
.PHONY: check_requirements
|
||||
check_requirements:
|
||||
composer check-platform-reqs
|
||||
composer --working-dir=tools/parallel-lint check-platform-reqs
|
||||
composer --working-dir=tools/php-cs-fixer check-platform-reqs
|
||||
|
||||
.PHONY: lint_all
|
||||
lint_all: lint_php_syntax lint_coding_style
|
||||
|
||||
.PHONY: lint_php_syntax
|
||||
lint_php_syntax:
|
||||
tools/parallel-lint/vendor/bin/parallel-lint --show-deprecated src
|
||||
|
||||
.PHONY: lint_coding_style
|
||||
lint_coding_style:
|
||||
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -vvv --dry-run
|
||||
|
||||
.PHONY: fix_coding_style
|
||||
fix_coding_style:
|
||||
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -vvv
|
64
2023/php-coding-standard/README.md
Normal file
64
2023/php-coding-standard/README.md
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Coding standard
|
||||
|
||||
Helper classes for enforcing my personal coding standard in PHP code.
|
||||
|
||||
## Licence
|
||||
|
||||
This mini-library is licensed under [MIT License][MIT].
|
||||
|
||||
Full text of the licence is attached in [LICENSE.txt](./LICENSE.txt) file.
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
composer require --dev krzysztof-sikorski/coding-standard
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create or update a configuration file `.php-cs-fixer.dist.php`
|
||||
in the root of your project:
|
||||
|
||||
```php
|
||||
use KrzysztofSikorski\CodingStandard\PhpCsFixer\RulesFactory;
|
||||
use PhpCsFixer\Config;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
$configName = 'My personal coding standard';
|
||||
|
||||
$header = <<<'HEADER'
|
||||
My personal coding standard
|
||||
|
||||
@author Krzysztof Sikorski
|
||||
@copyright 2023 Krzysztof Sikorski
|
||||
HEADER;
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files();
|
||||
$finder->in(dirs: __DIR__);
|
||||
$finder->ignoreDotFiles(ignoreDotFiles: false);
|
||||
$finder->ignoreVCSIgnored(ignoreVCSIgnored: true);
|
||||
|
||||
$finder->append(iterator: [__FILE__]);
|
||||
|
||||
$rules = PhpCsFixerRulesFactory::create(header: $header);
|
||||
|
||||
$config = new Config(name: $configName);
|
||||
$config->setFinder(finder: $finder);
|
||||
$config->setRiskyAllowed(isRiskyAllowed: true);
|
||||
$config->setRules(rules: $rules);
|
||||
|
||||
return $config;
|
||||
```
|
||||
|
||||
## Source code
|
||||
|
||||
This repository is mirrored to multiple services for redundancy:
|
||||
|
||||
- <https://codeberg.org/krzysztof-sikorski/php-coding-standard>
|
||||
- <https://git.disroot.org/krzysztof-sikorski/php-coding-standard>
|
||||
- <https://gitlab.com/krzysztof-sikorski/php-coding-standard>
|
||||
- <https://github.com/krzysztof-sikorski/php-coding-standard>
|
||||
|
||||
[MIT]:
|
||||
https://spdx.org/licenses/MIT.html
|
37
2023/php-coding-standard/composer.json
Normal file
37
2023/php-coding-standard/composer.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "krzysztof-sikorski/coding-standard",
|
||||
"description": "Helper classes for enforcing my personal coding standard",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"php-cs-fixer"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Krzysztof Sikorski",
|
||||
"homepage": "https://zerozero.pl/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"chat": "https://discord.gg/RZ69vTMzEp",
|
||||
"source": "https://gitlab.com/krzysztof-sikorski/php-coding-standard"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"KrzysztofSikorski\\CodingStandard\\": "src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"notify-on-install": false,
|
||||
"platform-check": true
|
||||
}
|
||||
}
|
361
2023/php-coding-standard/src/PhpCsFixerRulesFactory.php
Normal file
361
2023/php-coding-standard/src/PhpCsFixerRulesFactory.php
Normal file
|
@ -0,0 +1,361 @@
|
|||
<?php
|
||||
/**
|
||||
* My personal coding standard
|
||||
*
|
||||
* @author Krzysztof Sikorski
|
||||
* @copyright 2023 Krzysztof Sikorski
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KrzysztofSikorski\CodingStandard;
|
||||
|
||||
final class PhpCsFixerRulesFactory
|
||||
{
|
||||
private const DEFAULT_RULES = [
|
||||
// rule sets
|
||||
'@PER-CS1.0' => true,
|
||||
'@PER-CS1.0:risky' => true,
|
||||
'@PHP82Migration' => true,
|
||||
'@PHP80Migration:risky' => true,
|
||||
'@PHPUnit100Migration:risky' => true,
|
||||
|
||||
// "Alias" rules
|
||||
'array_push' => true,
|
||||
'backtick_to_shell_exec' => true,
|
||||
'ereg_to_preg' => true,
|
||||
'mb_str_functions' => true,
|
||||
'no_alias_language_construct_call' => true,
|
||||
'no_mixed_echo_print' => true,
|
||||
'set_type_to_cast' => true,
|
||||
|
||||
// "Array Notation" rules
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
|
||||
'yield_from_array_to_yields' => true,
|
||||
|
||||
// "Basic" rules
|
||||
'curly_braces_position' => [
|
||||
'allow_single_line_empty_anonymous_classes' => true,
|
||||
'allow_single_line_anonymous_functions' => true,
|
||||
],
|
||||
'no_trailing_comma_in_singleline' => true,
|
||||
'psr_autoloading' => true,
|
||||
'single_line_empty_body' => true,
|
||||
|
||||
// "Casing" rules
|
||||
'class_reference_name_casing' => true,
|
||||
'integer_literal_case' => true,
|
||||
'magic_constant_casing' => true,
|
||||
'magic_method_casing' => true,
|
||||
'native_function_casing' => true,
|
||||
'native_function_type_declaration_casing' => true,
|
||||
|
||||
// "Cast Notation" rules
|
||||
'cast_spaces' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
|
||||
// "Class Notation" rules
|
||||
'class_attributes_separation' => [
|
||||
'elements' => [
|
||||
'const' => 'only_if_meta',
|
||||
'method' => 'one',
|
||||
'property' => 'only_if_meta',
|
||||
'trait_import' => 'none',
|
||||
'case' => 'none',
|
||||
],
|
||||
],
|
||||
'final_class' => true,
|
||||
'final_internal_class' => false,
|
||||
'final_public_method_for_abstract_class' => true,
|
||||
'no_null_property_initialization' => true,
|
||||
'ordered_class_elements' => [
|
||||
'order' => [
|
||||
'use_trait',
|
||||
'case',
|
||||
'constant',
|
||||
'property',
|
||||
'construct',
|
||||
'destruct',
|
||||
'magic',
|
||||
'phpunit',
|
||||
'method_abstract',
|
||||
'method',
|
||||
],
|
||||
],
|
||||
'ordered_interfaces' => true,
|
||||
'ordered_traits' => true,
|
||||
'ordered_types' => true,
|
||||
'protected_to_private' => true,
|
||||
'self_accessor' => true,
|
||||
'self_static_accessor' => true,
|
||||
'single_class_element_per_statement' => true,
|
||||
|
||||
// "Class Usage" rules
|
||||
'date_time_immutable' => true,
|
||||
|
||||
// "Comment" rules
|
||||
'comment_to_phpdoc' => true,
|
||||
'header_comment' => false,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'no_empty_comment' => true,
|
||||
'single_line_comment_spacing' => true,
|
||||
'single_line_comment_style' => true,
|
||||
|
||||
// "Constant Notation" rules
|
||||
'native_constant_invocation' => true,
|
||||
|
||||
// "Control Structure" rules
|
||||
'empty_loop_body' => ['style' => 'braces'],
|
||||
'empty_loop_condition' => true,
|
||||
'include' => true,
|
||||
'no_alternative_syntax' => true,
|
||||
'no_superfluous_elseif' => true,
|
||||
'no_unneeded_control_parentheses' => [
|
||||
'statements' => [
|
||||
'break',
|
||||
'clone',
|
||||
'continue',
|
||||
'echo_print',
|
||||
'negative_instanceof',
|
||||
'others',
|
||||
'return',
|
||||
'switch_case',
|
||||
'yield',
|
||||
'yield_from',
|
||||
],
|
||||
],
|
||||
'no_unneeded_curly_braces' => ['namespaces' => true],
|
||||
'no_useless_else' => true,
|
||||
'simplified_if_return' => true,
|
||||
'switch_continue_to_break' => true,
|
||||
'trailing_comma_in_multiline' => [
|
||||
'after_heredoc' => true,
|
||||
'elements' => ['arguments', 'arrays', 'match', 'parameters'],
|
||||
],
|
||||
'yoda_style' => ['always_move_variable' => true],
|
||||
|
||||
// "Function Notation" rules
|
||||
'date_time_create_from_format_call' => true,
|
||||
'fopen_flag_order' => true,
|
||||
'fopen_flags' => true,
|
||||
'lambda_not_used_import' => true,
|
||||
'native_function_invocation' => ['include' => ['@all']],
|
||||
'no_useless_sprintf' => true,
|
||||
'nullable_type_declaration_for_default_null_value' => true,
|
||||
'regular_callable_call' => true,
|
||||
'single_line_throw' => false,
|
||||
'static_lambda' => true,
|
||||
|
||||
// "Import" rules
|
||||
'fully_qualified_strict_types' => true,
|
||||
'global_namespace_import' => ['import_constants' => true, 'import_functions' => true, 'import_classes' => true],
|
||||
'group_import' => false,
|
||||
'no_unneeded_import_alias' => true,
|
||||
'no_unused_imports' => true,
|
||||
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
|
||||
'single_import_per_statement' => true,
|
||||
|
||||
// "Language Construct" rules
|
||||
'combine_consecutive_issets' => true,
|
||||
'combine_consecutive_unsets' => true,
|
||||
'declare_parentheses' => true,
|
||||
'dir_constant' => true,
|
||||
'error_suppression' => ['mute_deprecation_error' => false, 'noise_remaining_usages' => true],
|
||||
'explicit_indirect_variable' => true,
|
||||
'function_to_constant' => true,
|
||||
'is_null' => true,
|
||||
'no_unset_on_property' => true,
|
||||
'nullable_type_declaration' => ['syntax' => 'union'],
|
||||
'single_space_around_construct' => true,
|
||||
|
||||
// "Namespace Notation" rules
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
|
||||
// "Naming" rules
|
||||
'no_homoglyph_names' => true,
|
||||
|
||||
// "Operator" rules
|
||||
'binary_operator_spaces' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'increment_style' => true,
|
||||
'logical_operators' => true,
|
||||
'no_useless_concat_operator' => ['juggle_simple_strings' => true],
|
||||
'no_useless_nullsafe_operator' => true,
|
||||
'not_operator_with_space' => false,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'operator_linebreak' => true,
|
||||
'standardize_increment' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_to_elvis_operator' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
|
||||
// "PHP Tag" rules
|
||||
'echo_tag_syntax' => true,
|
||||
'linebreak_after_opening_tag' => true,
|
||||
|
||||
// "PHPUnit" rules
|
||||
'php_unit_construct' => true,
|
||||
'php_unit_data_provider_name' => false,
|
||||
'php_unit_data_provider_return_type' => true,
|
||||
'php_unit_fqcn_annotation' => true,
|
||||
'php_unit_internal_class' => false,
|
||||
'php_unit_method_casing' => true,
|
||||
'php_unit_mock_short_will_return' => true,
|
||||
'php_unit_set_up_tear_down_visibility' => true,
|
||||
'php_unit_size_class' => false,
|
||||
'php_unit_strict' => true,
|
||||
'php_unit_test_annotation' => false,
|
||||
'php_unit_test_case_static_method_calls' => true,
|
||||
'php_unit_test_class_requires_covers' => true,
|
||||
|
||||
// "PHPDoc" rules
|
||||
'align_multiline_comment' => true,
|
||||
'general_phpdoc_annotation_remove' => false,
|
||||
'general_phpdoc_tag_rename' => false,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_superfluous_phpdoc_tags' => true,
|
||||
'phpdoc_add_missing_param_annotation' => false,
|
||||
'phpdoc_align' => ['align' => 'left'],
|
||||
'phpdoc_annotation_without_dot' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_inline_tag_normalizer' => true,
|
||||
'phpdoc_line_span' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_alias_tag' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_no_useless_inheritdoc' => true,
|
||||
'phpdoc_order_by_value' => [
|
||||
'annotations' => [
|
||||
'author',
|
||||
'covers',
|
||||
'coversNothing',
|
||||
'dataProvider',
|
||||
'depends',
|
||||
'group',
|
||||
'internal',
|
||||
'method',
|
||||
'mixin',
|
||||
'property',
|
||||
'property-read',
|
||||
'property-write',
|
||||
'requires',
|
||||
'throws',
|
||||
'uses',
|
||||
],
|
||||
],
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_param_order' => true,
|
||||
'phpdoc_return_self_reference' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_summary' => true,
|
||||
'phpdoc_tag_casing' => true,
|
||||
'phpdoc_tag_type' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_types_order' => true,
|
||||
'phpdoc_var_annotation_correct_order' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
|
||||
// "Return Notation" rules
|
||||
'no_useless_return' => true,
|
||||
'return_assignment' => true,
|
||||
'simplified_null_return' => true,
|
||||
|
||||
// "Semicolon" rules
|
||||
'multiline_whitespace_before_semicolons' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'semicolon_after_instruction' => true,
|
||||
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
|
||||
|
||||
// "Strict" rules
|
||||
'strict_comparison' => true,
|
||||
'strict_param' => true,
|
||||
|
||||
// "String Notation" rules
|
||||
'escape_implicit_backslashes' => true,
|
||||
'explicit_string_variable' => true,
|
||||
'heredoc_to_nowdoc' => true,
|
||||
'no_binary_string' => true,
|
||||
'single_quote' => true,
|
||||
'string_length_to_empty' => true,
|
||||
'string_line_ending' => true,
|
||||
|
||||
// "Whitespace" rules
|
||||
'array_indentation' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'break',
|
||||
'case',
|
||||
'continue',
|
||||
'declare',
|
||||
'default',
|
||||
'do',
|
||||
'exit',
|
||||
'for',
|
||||
'foreach',
|
||||
'goto',
|
||||
'if',
|
||||
'include',
|
||||
'include_once',
|
||||
'phpdoc',
|
||||
'require',
|
||||
'require_once',
|
||||
'return',
|
||||
'switch',
|
||||
'throw',
|
||||
'try',
|
||||
'while',
|
||||
'yield',
|
||||
'yield_from',
|
||||
],
|
||||
],
|
||||
'method_chaining_indentation' => true,
|
||||
'no_extra_blank_lines' => [
|
||||
'tokens' => [
|
||||
'attribute',
|
||||
'break',
|
||||
'case',
|
||||
'continue',
|
||||
'curly_brace_block',
|
||||
'default',
|
||||
'extra',
|
||||
'parenthesis_brace_block',
|
||||
'return',
|
||||
'square_brace_block',
|
||||
'switch',
|
||||
'throw',
|
||||
'use',
|
||||
],
|
||||
],
|
||||
'no_spaces_around_offset' => true,
|
||||
'type_declaration_spaces' => true,
|
||||
'types_spaces' => ['space' => 'single'],
|
||||
];
|
||||
|
||||
public static function create(null | string $header): array
|
||||
{
|
||||
$rules = self::DEFAULT_RULES;
|
||||
|
||||
if (null !== $header) {
|
||||
$rules['header_comment'] = [
|
||||
'header' => $header,
|
||||
'comment_type' => 'PHPDoc',
|
||||
'location' => 'after_open',
|
||||
'separate' => 'bottom',
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
1
2023/php-coding-standard/tools/parallel-lint/.gitignore
vendored
Normal file
1
2023/php-coding-standard/tools/parallel-lint/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/vendor
|
17
2023/php-coding-standard/tools/parallel-lint/composer.json
Normal file
17
2023/php-coding-standard/tools/parallel-lint/composer.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"description": "Dummy project to load parallel-lint package.",
|
||||
"type": "project",
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-console-highlighter": "^1.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.3"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"notify-on-install": false,
|
||||
"platform-check": true
|
||||
}
|
||||
}
|
177
2023/php-coding-standard/tools/parallel-lint/composer.lock
generated
Normal file
177
2023/php-coding-standard/tools/parallel-lint/composer.lock
generated
Normal file
|
@ -0,0 +1,177 @@
|
|||
{
|
||||
"_readme": [
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "657cc2e983e81eaa3e81f1696cc80c2c",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "php-parallel-lint/php-console-color",
|
||||
"version": "v1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-parallel-lint/PHP-Console-Color.git",
|
||||
"reference": "7adfefd530aa2d7570ba87100a99e2483a543b88"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Color/zipball/7adfefd530aa2d7570ba87100a99e2483a543b88",
|
||||
"reference": "7adfefd530aa2d7570ba87100a99e2483a543b88",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"replace": {
|
||||
"jakub-onderka/php-console-color": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-code-style": "^2.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.0",
|
||||
"php-parallel-lint/php-var-dump-check": "0.*",
|
||||
"phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHP_Parallel_Lint\\PhpConsoleColor\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jakub Onderka",
|
||||
"email": "jakub.onderka@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Simple library for creating colored console ouput.",
|
||||
"support": {
|
||||
"issues": "https://github.com/php-parallel-lint/PHP-Console-Color/issues",
|
||||
"source": "https://github.com/php-parallel-lint/PHP-Console-Color/tree/v1.0.1"
|
||||
},
|
||||
"time": "2021-12-25T06:49:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-parallel-lint/php-console-highlighter",
|
||||
"version": "v1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-parallel-lint/PHP-Console-Highlighter.git",
|
||||
"reference": "5b4803384d3303cf8e84141039ef56c8a123138d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-parallel-lint/PHP-Console-Highlighter/zipball/5b4803384d3303cf8e84141039ef56c8a123138d",
|
||||
"reference": "5b4803384d3303cf8e84141039ef56c8a123138d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.2",
|
||||
"php-parallel-lint/php-console-color": "^1.0.1"
|
||||
},
|
||||
"replace": {
|
||||
"jakub-onderka/php-console-highlighter": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-parallel-lint/php-code-style": "^2.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.0",
|
||||
"php-parallel-lint/php-var-dump-check": "0.*",
|
||||
"phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PHP_Parallel_Lint\\PhpConsoleHighlighter\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jakub Onderka",
|
||||
"email": "acci@acci.cz",
|
||||
"homepage": "http://www.acci.cz/"
|
||||
}
|
||||
],
|
||||
"description": "Highlight PHP code in terminal",
|
||||
"support": {
|
||||
"issues": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/issues",
|
||||
"source": "https://github.com/php-parallel-lint/PHP-Console-Highlighter/tree/v1.0.0"
|
||||
},
|
||||
"time": "2022-02-18T08:23:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-parallel-lint/php-parallel-lint",
|
||||
"version": "v1.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git",
|
||||
"reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6483c9832e71973ed29cf71bd6b3f4fde438a9de",
|
||||
"reference": "6483c9832e71973ed29cf71bd6b3f4fde438a9de",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"replace": {
|
||||
"grogy/php-parallel-lint": "*",
|
||||
"jakub-onderka/php-parallel-lint": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette/tester": "^1.3 || ^2.0",
|
||||
"php-parallel-lint/php-console-highlighter": "0.* || ^1.0",
|
||||
"squizlabs/php_codesniffer": "^3.6"
|
||||
},
|
||||
"suggest": {
|
||||
"php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet"
|
||||
},
|
||||
"bin": [
|
||||
"parallel-lint"
|
||||
],
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"./src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-2-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jakub Onderka",
|
||||
"email": "ahoj@jakubonderka.cz"
|
||||
}
|
||||
],
|
||||
"description": "This tool check syntax of PHP files about 20x faster than serial check.",
|
||||
"homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint",
|
||||
"support": {
|
||||
"issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues",
|
||||
"source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.3.2"
|
||||
},
|
||||
"time": "2022-02-21T12:50:22+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
1
2023/php-coding-standard/tools/php-cs-fixer/.gitignore
vendored
Normal file
1
2023/php-coding-standard/tools/php-cs-fixer/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/vendor
|
16
2023/php-coding-standard/tools/php-cs-fixer/composer.json
Normal file
16
2023/php-coding-standard/tools/php-cs-fixer/composer.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"description": "Dummy project to load php-cs-fixer package.",
|
||||
"type": "project",
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.27"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"notify-on-install": false,
|
||||
"platform-check": true
|
||||
}
|
||||
}
|
1842
2023/php-coding-standard/tools/php-cs-fixer/composer.lock
generated
Normal file
1842
2023/php-coding-standard/tools/php-cs-fixer/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue