Skip to content

Commit

Permalink
coding standards related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsizemore committed Apr 27, 2024
1 parent 29df4b4 commit b6e888c
Show file tree
Hide file tree
Showing 21 changed files with 678 additions and 684 deletions.
110 changes: 82 additions & 28 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,90 @@

declare(strict_types=1);

$header = <<<'EOF'
This file is part of the Numverify API Client for PHP.
(c) 2024 Eric Sizemore <admin@secondversion.com>
(c) 2018-2021 Mark Rogoyski <mark@rogoyski.com>
This source file is subject to the MIT license. For the full copyright,
license information, and credits/acknowledgements, please view the LICENSE
and README files that were distributed with this source code.
EOF;

$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'@PER-CS' => true,
'@PSR12' => true,
'@PHP82Migration' => true,
'array_syntax' => ['syntax' => 'short'],
'php_unit_internal_class' => ['types' => ['normal', 'final']],
'php_unit_namespaced' => true,
'php_unit_expectation' => true,
'php_unit_strict' => ['assertions' => ['assertAttributeEquals', 'assertAttributeNotEquals', 'assertEquals', 'assertNotEquals']],
'php_unit_set_up_tear_down_visibility' => true,
'@PER-CS' => true,
'@PSR12' => true,
'@PHP82Migration' => true,
'align_multiline_comment' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'operators' => [
'*=' => 'align_single_space_minimal',
'+=' => 'align_single_space_minimal',
'-=' => 'align_single_space_minimal',
'/=' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
'fully_qualified_strict_types' => true,
'header_comment' => ['comment_type' => 'PHPDoc', 'header' => $header, 'separate' => 'top'],
'heredoc_to_nowdoc' => true,
//'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced', 'strict' => true],
'native_constant_invocation' => ['fix_built_in' => false, 'include' => ['DIRECTORY_SEPARATOR', 'PHP_INT_SIZE', 'PHP_SAPI', 'PHP_VERSION_ID'], 'scope' => 'namespaced', 'strict' => true],
'no_leading_import_slash' => true,
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'case',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_public_static',
'property_protected',
'property_protected_static',
'property_private',
'property_private_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_public_static',
'method_protected',
'method_protected_static',
'method_private',
'method_private_static',
],
'sort_algorithm' => 'alpha',
],
'ordered_imports' => ['imports_order' => ['class', 'function', 'const', ]],
'ordered_interfaces' => [
'direction' => 'ascend',
'order' => 'alpha',
],
'ordered_traits' => true,
'ordered_types' => true,
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag_normalizer' => 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' => true,
'phpdoc_param_order' => true,
'phpdoc_return_self_reference' => true,
'phpdoc_scalar' => true,
Expand All @@ -33,26 +97,16 @@
'phpdoc_to_comment' => false,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'phpdoc_no_useless_inheritdoc' => true,
'align_multiline_comment' => true,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'binary_operator_spaces' => [
'operators' => [
'*=' => 'align_single_space_minimal',
'+=' => 'align_single_space_minimal',
'-=' => 'align_single_space_minimal',
'/=' => 'align_single_space_minimal',
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
],
'heredoc_to_nowdoc' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const',]],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'declare_strict_types' => true,
//'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
'php_unit_internal_class' => ['types' => ['normal', 'final']],
'php_unit_expectation' => true,
'single_import_per_statement' => true,
'static_lambda' => true,
'strict_param' => true,
'use_arrow_functions' => true,
'whitespace_after_comma_in_array' => true,
])
->setLineEnding("\n")
->setFinder(
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"symfony/cache": "^7.0"
},
"require-dev": {
"esi/phpunit-coverage-check": "^1.0",
"friendsofphp/php-cs-fixer": "dev-master",
"esi/phpunit-coverage-check": "^2.0",
"friendsofphp/php-cs-fixer": "^3.54",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "^11.0",
"phpunit/phpunit": "^11.1",
"psalm/plugin-phpunit": "^0.19.0",
"vimeo/psalm": "dev-master"
},
Expand All @@ -71,7 +71,7 @@
}
},
"scripts": {
"coverage": "vendor/bin/coverage-check coverage:check build/logs/clover.xml 100 --ansi",
"coverage": "vendor/bin/coverage-check build/logs/clover.xml 100",
"cs:check": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run --diff",
"cs:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php",
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
Expand Down

0 comments on commit b6e888c

Please sign in to comment.