Skip to content
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

PHP 8.1 | PSR12/ConstantVisibility: allow for class constants to be final #3527

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
$ignore = Tokens::$emptyTokens;
$ignore[] = T_FINAL;

$prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
if (isset(Tokens::$scopeModifiers[$tokens[$prev]['code']]) === true) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ class Foo {
}

const APPLICATION_ENV = 'development';

// Issue 3526, PHP 8.1 final constants.
class SampleEnum
{
final const FOO = 'SAMPLE';

public final const BAR = 'SAMPLE';

final private const BAZ = 'SAMPLE';
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public function getErrorList()
*/
public function getWarningList()
{
return [4 => 1];
return [
4 => 1,
12 => 1,
];

}//end getWarningList()

Expand Down