Merge branch 'ticket/16748' into ticket/16748-master

This commit is contained in:
Marc Alexander 2021-04-03 22:44:04 +02:00
commit 8518393c46
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 7 additions and 7 deletions

View file

@ -42,16 +42,16 @@ class phpbb_Sniffs_ControlStructures_StaticKeywordSniff implements Sniff
{ {
$tokens = $phpcsFile->getTokens(); $tokens = $phpcsFile->getTokens();
$disallowed_before_tokens = [ $disallowed_after_tokens = [
T_PUBLIC, T_PUBLIC,
T_PROTECTED, T_PROTECTED,
T_PRIVATE, 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'; $error = 'Access specifier (e.g. public) should not follow static scope attribute. Encountered "' . $tokens[$stackPtr + 2]['content'] . '" after static';
$phpcsFile->addError($error, $stackPtr, 'InvalidStaticFunctionDeclaration'); $phpcsFile->addWarning($error, $stackPtr, 'InvalidStaticFunctionDeclaration', [], 1);
} }
} }
} }

View file

@ -717,18 +717,18 @@ switch ($mode)
<h4>Class Members</h4> <h4>Class Members</h4>
<p>Use the explicit visibility qualifiers <code>public</code>, <code>private</code> and <code>protected</code> for all properties instead of <code>var</code>. <p>Use the explicit visibility qualifiers <code>public</code>, <code>private</code> and <code>protected</code> for all properties instead of <code>var</code>.
<p>Place the <code>static</code> qualifier before the visibility qualifiers.</p> <p>Place the <code>static</code> qualifier after the visibility qualifiers.</p>
<p class="bad">//Wrong </p> <p class="bad">//Wrong </p>
<div class="codebox"><pre> <div class="codebox"><pre>
var $x; var $x;
private static function f()</pre> static private function f()</pre>
</div> </div>
<p class="good">// Right </p> <p class="good">// Right </p>
<div class="codebox"><pre> <div class="codebox"><pre>
public $x; public $x;
static private function f()</pre> private static function f()</pre>
</div> </div>
<h4>Constants</h4> <h4>Constants</h4>