-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates coding standard to something PSR-12-ish #7886
Merged
Sesquipedalian
merged 7 commits into
SimpleMachines:release-3.0
from
Sesquipedalian:psr-12-ish
Nov 21, 2023
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d02e6d2
Adds PHP-CS-Fixer ruleset
Sesquipedalian a86ccb8
Updates coding style
Sesquipedalian 56093d5
Merge remote-tracking branch 'upstream/release-3.0' into psr-12-ish
Sesquipedalian a5c8003
Tweaks formatting of db query strings
Sesquipedalian e8489b7
Removes PHP-CS-Fixer rule to insert blank line before break statements
Sesquipedalian 8f94ae6
Makes Unicode data files compliant with our coding standard
Sesquipedalian a01f66c
Makes root directory files compliant with our coding standard
Sesquipedalian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<?php | ||
|
||
/** | ||
* Simple Machines Forum (SMF) | ||
* | ||
* @package SMF | ||
* @author Simple Machines https://www.simplemachines.org | ||
* @copyright 2023 Simple Machines and individual contributors | ||
* @license https://www.simplemachines.org/about/smf/license.php BSD | ||
* | ||
* @version 3.0 Alpha 1 | ||
*/ | ||
|
||
$finder = (new PhpCsFixer\Finder()) | ||
->in(__DIR__ . '/Sources') | ||
// Don't touch libraries. | ||
->exclude([ | ||
'minify', | ||
'random_compat', | ||
'ReCaptcha', | ||
]) | ||
// Work with PHP files. | ||
->name('*.php') | ||
// Skip all index.php files. | ||
->notName('index.php') | ||
// Skip Unicode data files, but not Utf8String.php. | ||
->notPath('/Unicode\/(?!Utf8String).*\.php/') | ||
// Skip anything being ignored in .gitignore. | ||
->ignoreVCSIgnored(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
'no_closing_tag' => false, | ||
'concat_space' => ['spacing' => 'one'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'ordered_imports' => [ | ||
'imports_order' => [ | ||
'class', | ||
'function', | ||
'const', | ||
], | ||
'sort_algorithm' => 'alpha', | ||
], | ||
'no_leading_namespace_whitespace' => true, | ||
'no_trailing_comma_in_singleline' => true, | ||
'normalize_index_brace' => true, | ||
'whitespace_after_comma_in_array' => true, | ||
'class_reference_name_casing' => true, | ||
'cast_spaces' => ['space' => 'single'], | ||
'single_line_comment_spacing' => true, | ||
'include' => true, | ||
'no_superfluous_elseif' => true, | ||
'no_useless_else' => true, | ||
'simplified_if_return' => true, | ||
'trailing_comma_in_multiline' => [ | ||
'after_heredoc' => true, | ||
'elements' => [ | ||
'arguments', | ||
'arrays', | ||
'match', | ||
'parameters', | ||
], | ||
], | ||
'lambda_not_used_import' => true, | ||
'nullable_type_declaration_for_default_null_value' => true, | ||
'nullable_type_declaration' => ['syntax' => 'question_mark'], | ||
'no_unused_imports' => true, | ||
'combine_consecutive_issets' => true, | ||
'combine_consecutive_unsets' => true, | ||
'operator_linebreak' => [ | ||
'only_booleans' => true, | ||
'position' => 'beginning', | ||
], | ||
'standardize_not_equals' => true, | ||
'ternary_to_null_coalescing' => true, | ||
'phpdoc_indent' => true, | ||
'phpdoc_line_span' => [ | ||
'const' => 'multi', | ||
'property' => 'multi', | ||
'method' => 'multi', | ||
], | ||
'phpdoc_no_access' => true, | ||
'phpdoc_no_useless_inheritdoc' => true, | ||
'phpdoc_order' => [ | ||
'order' => [ | ||
'param', | ||
'throws', | ||
'return', | ||
], | ||
], | ||
'phpdoc_no_empty_return' => true, | ||
'phpdoc_param_order' => true, | ||
'phpdoc_scalar' => [ | ||
'types' => [ | ||
'boolean', | ||
'callback', | ||
'double', | ||
'integer', | ||
'real', | ||
'str', | ||
], | ||
], | ||
'phpdoc_to_comment' => [ | ||
'ignored_tags' => ['todo'], | ||
], | ||
'phpdoc_trim_consecutive_blank_line_separation' => true, | ||
'phpdoc_types' => [ | ||
'groups' => ['alias', 'meta', 'simple'], | ||
], | ||
'phpdoc_var_without_name' => true, | ||
'no_useless_return' => true, | ||
'simplified_null_return' => true, | ||
'no_empty_statement' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'escape_implicit_backslashes' => [ | ||
'double_quoted' => true, | ||
'heredoc_syntax' => true, | ||
'single_quoted' => true, | ||
], | ||
'explicit_string_variable' => true, | ||
'simple_to_complex_string_variable' => true, | ||
'single_quote' => true, | ||
'array_indentation' => true, | ||
'blank_line_before_statement' => [ | ||
'statements' => [ | ||
'break', | ||
'case', | ||
'continue', | ||
'declare', | ||
'default', | ||
'do', | ||
'exit', | ||
'for', | ||
'foreach', | ||
'goto', | ||
'if', | ||
'include', | ||
'include_once', | ||
'require', | ||
'require_once', | ||
'return', | ||
'switch', | ||
'throw', | ||
'try', | ||
'while', | ||
'yield', | ||
'yield_from', | ||
], | ||
], | ||
'heredoc_indentation' => ['indentation' => 'start_plus_one'], | ||
'method_chaining_indentation' => true, | ||
'no_spaces_around_offset' => [ | ||
'positions' => ['inside', 'outside'], | ||
], | ||
'type_declaration_spaces' => [ | ||
'elements' => ['function', 'property'], | ||
], | ||
]) | ||
->setIndent("\t") | ||
->setFinder($finder); | ||
|
||
?> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, blank line before "break" looks weird. But if that is in PSR-12 let's go with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required by PSR-12. I've tweaked the rules now to change that bit.