NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist · #1423 most downloaded on Packagist
Moodle Coding Sniffer rules
Last release 10 months ago
02 Dec 2025
Ships unpredictably
gaps range from 9 days to 12 months
Most releases are documented
notes for 34 of 39 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
40 releases · first in 2022
One column per quarter.
Support for PHPCompatibility until moodle-cs is upgraded to support PHP_CodeSniffer version 4.
Take a look at the CHANGELOG for details about other releases.
Take a look at the CHANGELOG for details about other releases.
Take a look at the CHANGELOG for details about other releases.
moodle.NamingConventions.ValidFunctionNamemoodle.NamingConventions.ValidVariableNameSquiz.Classes.DuplicateProperty - JS onlyGeneric.Functions.CallTimePassByReference - PHP support dropped in PHP 5.4The branch detector was not able to detect the Moodle version following MDL-83424.
moodle.PHPUnit.TestCaseProvider sniff can now detect fully-qualified class names.NamespaceScopeUtil helper was added with methods to help qualify names within a file.Take a look at the CHANGELOG for details about other releases.
The moodle.Commenting.VariableComment sniff now accepts the following tags as valid on a @var :
moodle.Commenting.VariableComment sniff now accepts the following tags as valid on a @var:
@since@link@deprecatedTake a look at the CHANGELOG for details about other releases.
squizlabs/php_codesniffer to 3.13.2
squizlabs/php_codesniffer to 3.13.2phpcsstandards/phpcsextra to 1.4.0dealerdirect/phpcodesniffer-composer-installer to 1.1.1Generic.Arrays.DisallowLongArraySyntax rule has been changed to an error as planned in #58.Take a look at the CHANGELOG for details about other releases.
The moodle.Commenting.InlineComment sniff will now accept a full-stop inside a closing parentheses as valid English.
moodle.Commenting.InlineComment sniff will now accept a full-stop inside a closing parentheses as valid English.@Transform tag is now an accepted tag for Behat testsmoodle.Commenting.InlineComment sniff is now aware of PHP enum types.Take a look at the CHANGELOG for details about other releases.
The moodle.NamingConventions.ValidFunctionName sniff will now ignore errors on methods employing the #[\Override] attribute.
moodle.NamingConventions.ValidFunctionName sniff will now ignore errors on methods employing the #[\Override] attribute.moodle.Commenting.MissingDocblock sniff no longer warns about missing docs on non-global anonymous classes, for example those written as an instance class in a unit test.moodle.Files.BoilerplateComment related to empty comment lines and to comments in the <?php open tag line.Take a look at the CHANGELOG for details about other releases.
Fixed a recent regression by allowing to the moodle.Files.BoilerplateComment sniff to contain "extra" consecutive comment lines immediately after the
moodle.Files.BoilerplateComment sniff to contain "extra" consecutive comment lines immediately after the official boilerplate ends.Take a look at the CHANGELOG for details about other releases.
The existing moodle.PHPUnit.TestCaseCovers sniff now detects multiple uses of the @coversDefaultClass annotation. Only one is allowed by class.
moodle.PHPUnit.TestCaseCovers sniff now detects multiple uses of the @coversDefaultClass annotation. Only one is allowed by class.moodle.Files.BoilerplateComment sniff now performs more checks (spacing, placement, blank lines, ...) and is able to fix many of them.moodle.Commenting.MissingDocblock more specific to the scenario (Fixes #154).Take a look at the CHANGELOG for details about other releases.
Add new moodle.PHPUnit.ParentSetUpTearDown sniff to verify, among other things, that all the setUp() , tearDown() , setUpBeforeClass() and tearDownAft
moodle.PHPUnit.ParentSetUpTearDown sniff to verify, among other things, that all the setUp(), tearDown(), setUpBeforeClass() and tearDownAfterClass() methods in unit tests are properly calling to their parent counterparts. Applies to Moodle 4.5 and up.moodle.Commenting.ConstructorReturn sniff to check that constructors do not document a return value.PHP_CodeSniffer (3.10.1) and PHPCompatibility (96072c30).moodle.Commenting.MissingDocblock sniff will now detect use of the Override attribute (Fixes #155).Take a look at the CHANGELOG for details about other releases.
Solved a problem where Windows file paths were not normalised leading to false positive results on some path-based sniffs.
Solved a problem when checking constructor's promoted properties that was leading to some false positives.
The @deprecated tag is allowed to be alone within PHPDoc blocks.
moodle.Util.Docblocks helpers and uses.@deprecated tag is allowed to be alone within PHPDoc blocks.Add new moodle.Commenting.DocblockDescription sniff to check that all the artifacts (classes, interfaces, traits, ...) and functions PHPDoc blocks hav
moodle.Commenting.DocblockDescription sniff to check that all the artifacts (classes, interfaces, traits, ...) and functions PHPDoc blocks have some description.moodle.Commenting.MissingDocBlock sniff now also checks that constants are documented.You can find more information about the deprecation of the former and links to track the progress in the announcement in General developer forum.
Add new moodle.Files.LangFilesOrdering sniff to check that lang files are sorted by key.
Add new moodle.Commenting.MissingDocBlock sniff to check that all the artifacts (classes, interfaces, traits, ...) and functions are documented.
Add new moodle.Commenting.VariableComment sniff to check that the @var tag and its types are used correctly.
Add new moodle.Commenting.ValidTag sniff to check that only allowed tags are used.
Add new moodle.Commenting.FileExpectedTags sniff to check that files or classes have the correct PHPDoc block with both @copyright and @license information.
The expected contents of the @license tag can be controlled both by the preferredLicenseRegex property in ruleset files or by the moodleLicenseRegex configuration option in phpcs.xml files and CLI invocations. Setting them to empty string disables the Sniff completely. By default, the "https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later" content is checked.
Note that all the moodle.Commenting sniffs above are part of the migration from moodle-local_moodlecheck to moodle-cs. You can find more information about the deprecation of the former and links to track the progress in the announcement in General developer forum.
Solved a problem with the moodle.Commenting.Package sniff when running against arbitrary (not Moodle based) directories.
moodle.Commenting.Package sniff when running against arbitrary (not Moodle based) directories.As part of the move to be PSR12 compliant, all the methods used for testing have been converted, without deprecation, to camel case (setStandard(), se…
moodle.PHPUnit.TestCasesAbstract sniff to check that testcase classes are declared abstract.moodle.PHPUnit.TestClassesFinal sniff to check that test classes are declared final.moodle.Commenting.Package sniff to replace those present in moodle-local_moodlecheck.moodle.Commenting.Category sniffs to replace those present in moodle-local_moodlecheck.phpcs.xml.dist to enforce the coding style to follow by moodle-cs itself. Basically, PSR12 ruled. CI verified from now on.PHP_CodeSniffer (3.9.0) and PHPCompatibility (e5cd2e24).setStandard(), setSniff(), ...).moodle-cs and having own tests will need to adapt them to the new method names.Function declaration lines are verified to have correct whitespace separation (1 space or 0 spaces) between all their parts.
enum uses are not considered side-effects by some sniffs.dataProvider sniff now reports the problematic lines properly.\$) contents within double quoted strings and they aren't considered - for validation - anymore.Modified internal CI scripts towards better Codecov future support.
moodle.PHPUnit Sniffs running an endless loop when processing abstract test methods.Applied various internal, coding and CI improvements:
nikic/php-parser to v4 to avoid jumping to v5 yet (PHP compatibility).PHP_CodeSniffer (3.8.1).New moodle.Commenting.TodoComment Sniff will be in charge to control that all the todo comments in core (both // TODO and @todo ones) always come with a link to the MDL project in the Tracker.
Its behaviour can be controlled both by the commentRequiredRegex property in ruleset files or by the moodleTodoCommentRegex configuration option in phpcs.xml files and CLI invocations. Setting them to empty string disables the Sniff completely.
Moved PHP_CodeSniffer from squizlabs (being abandoned) to PHPCSStandars (new repository). Everybody is welcome to contribute or help sponsoring the pr
PHP_CodeSniffer from squizlabs (being abandoned) to PHPCSStandars (new repository). Everybody is welcome to contribute or help sponsoring the project!PHP_CodeSniffer (3.8.0) and PHPCompatibility (306cd263).Amended the installation instructions to be able to use some dev dependencies.
CommaAfterLast Sniff that was causing some valid multi-line arrays to be identified as invalid, missing commas.Detected various duplicate array keys cases (code smell).
: void).Defined (via .gitattributes) which files must not be part of distribution (generated .zip & .gz in GitHub, --prefer-dist in Composer, ...) packages. T
.gitattributes) which files must not be part of distribution (generated .zip & .gz in GitHub, --prefer-dist in Composer, ...) packages. This includes docs, ci files, tests... Note that it's still possible to download the complete packages (using git clone, --prefer-source with Composer, ...).PSR1.Classes.ClassDeclaration.MissingNamespace sniff from the moodle-extra standard because it was reporting some (for Moodle) false positives.Detect PHPUnit data provider (@dataProvider) declarations using () after the function name.
@dataProvider) declarations using () after the function name.coverage.php, ...) being managed as such.Require trailing commas in multi-line arrays.
namespace and use (class import) declarations don't use leading slashes (\).A new moodle-extra coding standard which moves towards a more PSR-12 compliant coding style.
moodle-extra coding standard which moves towards a more PSR-12 compliant coding style.[]), warning about the long alternative (array()): Generic.Arrays.DisallowLongArraySyntax. This will be raised from warning to error in 1 year.Update composer dependencies to current versions, notably PHPCompatibility (0a17f9ed).
&& and || logical operators, now erroring (after a grace period of 1 year) with and and or uses: Squiz.Operators.ValidLogicalOperatorsUpdate composer dependencies to current versions, notably PHPCompatibility (70e4ca24).
Revert the check for the only one-space rule before the assignment operator @ Squiz.WhiteSpace.OperatorSpacing as an interim solution while we revisit
Squiz.WhiteSpace.OperatorSpacing as an interim solution while we revisit MDLSITE-6594.Check for one (and only one) space before assignment operator @ Squiz.WhiteSpace.OperatorSpacing
Squiz.WhiteSpace.OperatorSpacingUpdated the outdated list of valid magic methods.
Enforce the use of && and || logical operators, warning about and and or: Squiz.Operators.ValidLogicalOperators
&& and || logical operators, warning about and and or: Squiz.Operators.ValidLogicalOperatorsclass_alias like a side effect.Squiz.Arrays.ArrayBracketSpacing sniff.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
This release is the first release of the new moodlehq/moodle-cs packages.
This release is the first release of the new moodlehq/moodle-cs packages.
These rules, in an identical form, were previously available as a part of the local_codechecker Moodle plugin but are being moved to their own repository to make installation friendlier for developers.
All features are maintained and no new features have been introduced to either the rules, or the sniffs.
All the details about previous releases can be found in local_codechecker own change log.
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →