From 95496ebd38ae6812b66a1c6ddf6cb6a653fa3570 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 3 Apr 2021 22:41:58 +0200 Subject: [PATCH] [ticket/16748] Adjust coding guidelines to put static after visibility PHPBB3-16748 --- .../phpbb/Sniffs/ControlStructures/StaticKeywordSniff.php | 8 ++++---- phpBB/docs/coding-guidelines.html | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/code_sniffer/phpbb/Sniffs/ControlStructures/StaticKeywordSniff.php b/build/code_sniffer/phpbb/Sniffs/ControlStructures/StaticKeywordSniff.php index 1dabe82235..a9d52432d1 100644 --- a/build/code_sniffer/phpbb/Sniffs/ControlStructures/StaticKeywordSniff.php +++ b/build/code_sniffer/phpbb/Sniffs/ControlStructures/StaticKeywordSniff.php @@ -42,16 +42,16 @@ class phpbb_Sniffs_ControlStructures_StaticKeywordSniff implements Sniff { $tokens = $phpcsFile->getTokens(); - $disallowed_before_tokens = [ + $disallowed_after_tokens = [ T_PUBLIC, T_PROTECTED, T_PRIVATE, ]; - if (in_array($tokens[$stackPtr - 2]['code'], $disallowed_before_tokens)) + if (in_array($tokens[$stackPtr + 2]['code'], $disallowed_after_tokens)) { - $error = 'Access specifier (e.g. public) should follow static scope attribute. Encountered "' . $tokens[$stackPtr - 2]['content'] . '" before static'; - $phpcsFile->addError($error, $stackPtr, 'InvalidStaticFunctionDeclaration'); + $error = 'Access specifier (e.g. public) should not follow static scope attribute. Encountered "' . $tokens[$stackPtr + 2]['content'] . '" after static'; + $phpcsFile->addWarning($error, $stackPtr, 'InvalidStaticFunctionDeclaration', [], 1); } } } diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 218d65afeb..7843702659 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -718,18 +718,18 @@ switch ($mode)

Class Members

Use the explicit visibility qualifiers public, private and protected for all properties instead of var. -

Place the static qualifier before the visibility qualifiers.

+

Place the static qualifier after the visibility qualifiers.

//Wrong

 var $x;
-private static function f()
+static private function f()

// Right

 public $x;
-static private function f()
+private static function f()

Constants