mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-17 14:18:24 +01:00
Merge branch 'ticket/16748' into ticket/16748-master
This commit is contained in:
commit
8518393c46
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -717,18 +717,18 @@ switch ($mode)
|
||||
<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>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>
|
||||
<div class="codebox"><pre>
|
||||
var $x;
|
||||
private static function f()</pre>
|
||||
static private function f()</pre>
|
||||
</div>
|
||||
|
||||
<p class="good">// Right </p>
|
||||
<div class="codebox"><pre>
|
||||
public $x;
|
||||
static private function f()</pre>
|
||||
private static function f()</pre>
|
||||
</div>
|
||||
|
||||
<h4>Constants</h4>
|
||||
|
Loading…
x
Reference in New Issue
Block a user