PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
true
or false
; or contained true
or false
as part of a union type.
Generic.Debug.ESLint
sniff only supports the "old" configuration file formats and when using the sniff to run ESLint, the ESLINT_USE_FLAT_CONFIG=false
environment variable will need to be set when using ESLint >= 9.0.
For more information, see #436.Closed: 0 issues Merged: 22 pull requests
If you like to stay informed about releases and more, follow @phpcs on Mastodon or @PHP_CodeSniffer on X.
If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
The PHP_CodeSniffer project is happy to welcome the following new contributors: @jaymcp @jpoliveira08
Closed: 2 issues Merged: 52 pull requests
If you like to stay informed about releases and more, follow @phpcs on Mastodon or @PHP_CodeSniffer on X.
PHP_CodeSniffer\Sniffs\DeprecatedSniff
interface to allow for marking a sniff as deprecated. #281
-q
(quiet) mode, the deprecation notices will be hidden.-e
) an asterix *
will show next to deprecated sniffs.Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence
sniff. #197
ShortOpenEchoNoSemicolon
errorcode to allow for selectively ignoring missing semicolons in single line embedded PHP snippets within short open echo tags.phpcbf
run. #308
AbstractSniffUnitTest
class will now show a (non-build-breaking) warning when test case files contain fixable errors/warnings, but there is no corresponding .fixed
file available in the test suite to verify the fixes against. #336
PHP_CodeSniffer\Filters\ExactMatch::getBlacklist()
and PHP_CodeSniffer\Filters\ExactMatch::getWhitelist()
methods are deprecated and will be removed in the 4.0 release. See #198.
ExactMatch::getDisallowedFiles()
and ExactMatch::getAllowedFiles()
methodsExactMatch
cross-version compatible with both PHP_CodeSniffer 3.9.0+ as well as 4.0+, implement the new getDisallowedFiles()
and getAllowedFiles()
methods.
getDisallowedFiles()
and getAllowedFiles()
methods as well as the getBlacklist()
and getWhitelist()
are available, the new methods will take precedence over the old methods.Zend.Debug.CodeAnalyzer
sniff. See #277.
MissingParamType
error code will now be used instead of MissingParamName
when a parameter name is provided, but not its type. Additionally, invalid type hint suggestions will no longer be provided in these cases.
switch
case
.
class
keyword was not checked when the space included a new line or comment.
.github
folder.The PHP_CodeSniffer project is happy to welcome the following new contributors: @joachim-n, @remicollet, @TimWolla
Closed: 8 issues Merged: 77 pull requests
💸 If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
-s
is used
-s
is used and messages wraps
true
/false
/null
type declarations
parent
, self
or a namespace relative class name type declaration
The PHP_CodeSniffer project is happy to welcome the following new contributors: @anomiex, @dingo-d, @fcool, @lucc, @rodrigoprimo
Closed: 4 issues Merged: 63 pull requests
If you like what you see, please consider funding the PHP_CodeSniffer project. If you already do so: thank you!
Squizlabs/PHP_CodeSniffer is dead. Long live PHPCSStandards/PHP_CodeSniffer!
squizlabs/PHP_CodeSniffer
repository has been abandoned. The PHPCSStandards/PHP_CodeSniffer
repository will serve as the continuation of the project. For more information about this change, please read the announcement.
squizlabs/php_codesniffer
package now points to the new repository and everything will continue to work as before.
https://squizlabs.github.io/PHP_CodeSniffer/phars/
to https://phars.phpcodesniffer.com/phars/
.https://squizlabs.github.io/PHP_CodeSniffer/[phpcs|phpcbf].phar
or https://github.com/squizlabs/PHP_CodeSnifffer/releases/latest/download/[phpcs|phpcbf].phar
to https://phars.phpcodesniffer.com/[phpcs|phpcbf].phar
.[email protected]:squizlabs/PHP_CodeSniffer.git
to [email protected]:PHPCSStandards/PHP_CodeSniffer.git
.
squizlabs/PHP_CodeSniffer
repository are invited to resubmit these to the PHPCSStandards/PHP_CodeSniffer
repository.true
as a stand-alone type declaration
File::getMethodProperties()
, File::getMethodParameters()
and File::getMemberProperties()
methods now all support the true
typetrue
as a stand-alone type to a number of sniffs
Generic.PHP.RequireStrictTypes.Disabled
error codeParamNameUnexpectedAmpersandPrefix
error for parameters annotated as passed by reference while the parameter is not passed by reference
setUp()
/tearDown()
methods or overload the setUp()
in the AbstractSniffUnitTest
test case, they will need to be adjusted. See the PR details for further information
Internal.PropertyDoesNotExist
errror on line 1 of the scanned file, but will not halt the execution of PHPCSauto
report width (the default) a value of 80 columns will be used if the width cannot be determined
InvalidNoReturn
when type is never
match
inside of it
--basepath
and running from project subdirectory
use
keyword
use
keyword for multi-line trait use statements
$unknown
property
Thanks go to Dan Wallis (@fredden) and Danny van der Sluijs (@DannyvdSluijs) for reviewing quite a few of the PRs for this release. Additionally, thanks to Alexander Turek (@derrabus) for consulting on the repo change over.
PHP_CodeSniffer has run correctly under PHP 8.1 since PHP 8 support was added, but it has not supported new 8.1 language features until this release. Version 3.7.0 adds support for the following PHP 8.1 language features:
never
typeNote: Standards and sniffs included with PHP_CodeSniffer have been updated to support these language features, but external standards and sniffs may need updating before they are able to detect them correctly.
T_ENUM_CASE
token to represent the case statements inside an enumT_TYPE_INTERSECTION
token to represent the ampersand character inside intersection typesFile::getMethodParameters
now supports the new PHP 8.1 readonly token
property_readonly
array index is included in the return value
readonly_token
array index is included in the return value
Generic.PHP.LowerCaseKeyword
PSR2.Classes.PropertyDeclaration
Squiz.Commenting.BlockComment
Squiz.Commenting.DocCommentAlignment
Squiz.Commenting.VariableComment
Squiz.WhiteSpace.ScopeKeywordSpacing
Generic.PHP.UpperCaseConstant
and Generic.PHP.LowerCaseConstant
now ignore type declarations
true
/false
/null
when used as valuesGeneric.PHP.LowerCaseType
now supports the PHP 8.1 never
type
@throw
T_GOTO_LABEL
${
Generic.Files.ExecutableFile
Generic.Files.LowercasedFilename
Generic.Files.LineEndings
Generic.Files.EndFileNewline
Generic.Files.EndFileNoNewline
Generic.PHP.ClosingPHPTag
Generic.PHP.Syntax
Generic.VersionControl.GitMergeConflict
Generic.WhiteSpace.DisallowSpaceIndent
Generic.WhiteSpace.DisallowTabIndent
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
and T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG
are unsuedT_BITWISE_AND
for all PHP versionsFile::getMethodParameters()
no longer incorrectly returns argument attributes in the type hint array index
has_attributes
array index is available and set to TRUE
if the argument has attributes definedGeneric.NamingConventions.ConstructorName
no longer throws deprecation notices on PHP 8.1
Squiz.Commenting.BlockComment
now correctly applies rules for block comments after a short echo tag
PEAR.Commenting.FunctionComment
Squiz.Commenting.InlineComment
Squiz.Commenting.BlockComment
Squiz.Commenting.VariableComment
Squiz.WhiteSpace.MemberVarSpacing