Apply PSR-12 code style (#9)
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 18 Jan 2021 11:46:02 +0000 (12:46 +0100)
committerGitHub <noreply@github.com>
Mon, 18 Jan 2021 11:46:02 +0000 (12:46 +0100)
Co-authored-by: Alexander Ebert <ebert@woltlab.com>
.github/diff.json [new file with mode: 0644]
.github/typescript-tsc.json [new file with mode: 0644]
.github/workflows/codestyle.yml
.php_cs.dist [new file with mode: 0644]
.phpcs.xml
constants.php
files/lib/page/LegalNoticePage.class.php

diff --git a/.github/diff.json b/.github/diff.json
new file mode 100644 (file)
index 0000000..73a3348
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "problemMatcher": [
+    {
+      "owner": "diff",
+      "pattern": [
+        {
+          "regexp": "--- a/(.*)",
+          "file": 1,
+          "message": 1
+        }
+      ]
+    }
+  ]
+}
diff --git a/.github/typescript-tsc.json b/.github/typescript-tsc.json
new file mode 100644 (file)
index 0000000..6985bec
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "problemMatcher": [
+    {
+      "owner": "tsc",
+      "pattern": [
+        {
+          "source": "MIT License - Copyright (c) 2015 - present Microsoft Corporation - https://github.com/microsoft/vscode/blob/8d0ca78841d41bfbae9119879a742ad546491af0/extensions/typescript-language-features/package.json#L1006-L1017",
+          "regexp": "^([^\\s].*)[\\(:](\\d+)[,:](\\d+)(?:\\):\\s+|\\s+-\\s+)(error|warning|info)\\s+TS(\\d+)\\s*:\\s*(.*)$",
+          "file": 1,
+          "line": 2,
+          "column": 3,
+          "severity": 4,
+          "code": 5,
+          "message": 6
+        }
+      ]
+    }
+  ]
+}
index 964e5360c29b460d4a20ce3767f4b9bd078d4d05..5ae031c2b3df11c447a8f0ed91666e56d5794d2a 100644 (file)
@@ -10,9 +10,13 @@ on:
 
 jobs:
   php:
-    name: PHP CodeSniffer
+    name: PHP
     runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v2
-    - run: git clone --branch=master --depth=1 --quiet git://github.com/WoltLab/WCF.git WCF
-    - uses: chekalsky/phpcs-action@e269c2f264f400adcda7c6b24c8550302350d495
+    - name: phpcs
+      uses: chekalsky/phpcs-action@e269c2f264f400adcda7c6b24c8550302350d495
+    - name: php-cs-fixer
+      uses: docker://oskarstark/php-cs-fixer-ga
+      with:
+        args: --dry-run --diff-format udiff
diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644 (file)
index 0000000..adcc3be
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+$finder = PhpCsFixer\Finder::create()
+    ->exclude('*/vendor/*')
+    ->in(__DIR__.'/files/');
+
+return (new PhpCsFixer\Config())
+    ->setRiskyAllowed(true)
+    ->setRules([
+        '@PSR1' => true,
+        '@PSR2' => true,
+
+        'array_push' => true,
+        'backtick_to_shell_exec' => true,
+        'no_alias_language_construct_call' => true,
+        'no_mixed_echo_print' => true,
+        'pow_to_exponentiation' => true,
+        'random_api_migration' => true,
+
+        'array_syntax' => ['syntax' => 'short'],
+        'no_multiline_whitespace_around_double_arrow' => true,
+        'no_trailing_comma_in_singleline_array' => true,
+        'no_whitespace_before_comma_in_array' => true,
+        'normalize_index_brace' => true,
+        'trailing_comma_in_multiline_array' => true,
+        'whitespace_after_comma_in_array' => true,
+
+        'non_printable_character' => ['use_escape_sequences_in_strings' => true],
+
+        'lowercase_static_reference' => true,
+        'magic_constant_casing' => true,
+        'magic_method_casing' => true,
+        'native_function_casing' => true,
+        'native_function_type_declaration_casing' => true,
+
+        'cast_spaces' => ['space' => 'none'],
+        'lowercase_cast' => true,
+        'no_unset_cast' => true,
+        'short_scalar_cast' => true,
+
+        'class_attributes_separation' => true,
+        'no_blank_lines_after_class_opening' => true,
+        'no_null_property_initialization' => true,
+        'self_accessor' => true,
+        'single_class_element_per_statement' => true,
+        'single_trait_insert_per_statement' => true,
+
+        'no_empty_comment' => true,
+        'single_line_comment_style' => ['comment_types' => ['hash']],
+
+        'native_constant_invocation' => true,
+
+        'no_alternative_syntax' => true,
+        'no_trailing_comma_in_list_call' => true,
+        'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield', 'yield_from']],
+        'no_unneeded_curly_braces' => ['namespaces' => true],
+        'switch_continue_to_break' => true,
+
+        'function_typehint_space' => true,
+        'lambda_not_used_import' => true,
+        'native_function_invocation' => true,
+        'no_unreachable_default_argument_value' => true,
+        'nullable_type_declaration_for_default_null_value' => true,
+        'return_type_declaration' => true,
+        'static_lambda' => true,
+
+        'fully_qualified_strict_types' => true,
+        'no_leading_import_slash' => true,
+        'no_unused_imports' => true,
+        'ordered_imports' => true,
+
+        'declare_equal_normalize' => true,
+        'dir_constant' => true,
+        'explicit_indirect_variable' => true,
+        'function_to_constant' => true,
+        'is_null' => true,
+        'no_unset_on_property' => true,
+
+        'list_syntax' => ['syntax' => 'short'],
+
+        'clean_namespace' => true,
+        'no_leading_namespace_whitespace' => true,
+        'single_blank_line_before_namespace' => true,
+
+        'no_homoglyph_names' => true,
+
+        'binary_operator_spaces' => true,
+        'concat_space' => ['spacing' => 'one'],
+        'increment_style' => ['style' => 'post'],
+        'logical_operators' => true,
+        'object_operator_without_whitespace' => true,
+        'operator_linebreak' => true,
+        'standardize_increment' => true,
+        'standardize_not_equals' => true,
+        'ternary_operator_spaces' => true,
+        'ternary_to_elvis_operator' => true,
+        'ternary_to_null_coalescing' => true,
+        'unary_operator_spaces' => true,
+
+        'no_useless_return' => true,
+        'return_assignment' => true,
+        'simplified_null_return' => true,
+
+        'multiline_whitespace_before_semicolons' => true,
+        'no_empty_statement' => true,
+        'no_singleline_whitespace_before_semicolons' => true,
+        'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
+
+        'escape_implicit_backslashes' => true,
+        'explicit_string_variable' => true,
+        'heredoc_to_nowdoc' => true,
+        'no_binary_string' => true,
+        'simple_to_complex_string_variable' => true,
+
+        'array_indentation' => true,
+        'blank_line_before_statement' => ['statements' => ['return', 'exit']],
+        'compact_nullable_typehint' => true,
+        'method_chaining_indentation' => true,
+        'no_extra_blank_lines' => ['tokens' => ['case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait']],
+        'no_spaces_around_offset' => true,
+    ])
+    ->setFinder($finder);
index 57a48ad9db2aadc3d523af2b93b5a5c35957291e..52e8202fe279642a7decddde57d3f349c11ecd47 100644 (file)
@@ -1,9 +1,10 @@
 <?xml version="1.0"?>
 <ruleset>
        <file>files/</file>
+       <exclude-pattern>*/vendor/*</exclude-pattern>
        <arg name="extensions" value="php" />
        <arg value="p"/>
        <arg name="basepath" value="."/>
 
-       <rule ref="./WCF/CodeSniff/WCF/ruleset.xml"/>
+       <rule ref="PSR12"/>
 </ruleset>
index 7415e63d85a3fb1d06be57ddce7d7f9008f29837..4ba97fc977bc974ba63617ca6bd4912b140e9fe8 100644 (file)
@@ -2,10 +2,10 @@
 /**
  * Defines constants for autocompletion in IDEs. This file is not meant to be actively used anywhere!
  *
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core
+ * @author    Matthias Schmidt
+ * @copyright    2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core
  */
 
 // option constants
index e872eb2c1fc770426cc9b3aee2c59b41f2f0c620..237bccd5219aecf9f16e7e172516d8335c96d55e 100644 (file)
@@ -1,38 +1,43 @@
 <?php
+
 namespace wcf\page;
+
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
 /**
  * Shows the legal notice page.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Page
+ *
+ * @author  Marcel Werk
+ * @copyright   2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Page
  */
-class LegalNoticePage extends AbstractPage {
-       const AVAILABLE_DURING_OFFLINE_MODE = true;
-       
-       /**
-        * @inheritDoc
-        */
-       public function readParameters() {
-               parent::readParameters();
-               
-               $this->canonicalURL = LinkHandler::getInstance()->getLink('LegalNotice');
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign([
-                       'encodedEmailAddress' => StringUtil::encodeAllChars(LEGAL_NOTICE_EMAIL_ADDRESS),
-                       'encodedUriEmailAddress' => StringUtil::encodeAllChars(rawurlencode(LEGAL_NOTICE_EMAIL_ADDRESS)),
-               ]);
-       }
+class LegalNoticePage extends AbstractPage
+{
+    const AVAILABLE_DURING_OFFLINE_MODE = true;
+
+    /**
+     * @inheritDoc
+     */
+    public function readParameters()
+    {
+        parent::readParameters();
+
+        $this->canonicalURL = LinkHandler::getInstance()->getLink('LegalNotice');
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function assignVariables()
+    {
+        parent::assignVariables();
+
+        WCF::getTPL()->assign([
+            'encodedEmailAddress' => StringUtil::encodeAllChars(LEGAL_NOTICE_EMAIL_ADDRESS),
+            'encodedUriEmailAddress' => StringUtil::encodeAllChars(\rawurlencode(LEGAL_NOTICE_EMAIL_ADDRESS)),
+        ]);
+    }
 }