From ff3e52d9904314f5cc76e1bbfb23837c857aa300 Mon Sep 17 00:00:00 2001 From: Angela Kuznetsova Date: Fri, 10 Apr 2026 14:21:46 +1200 Subject: [PATCH 1/4] Update codesniffer package to work with Modern Totara --- README.md | 8 +- composer.json | 8 +- composer.lock | 240 +++++++++++++++++++++++-------- src/Standards/Totara/ruleset.xml | 3 +- 4 files changed, 191 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 8610677..04512b6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project contains a Code Sniffer Standard for Totara Learn. ## Prerequisites - * PHP 7.4 or higher + * PHP 7.4 or higher (including PHP 8.4 and 8.5) * Composer (https://getcomposer.org/) *** @@ -118,8 +118,8 @@ The Totara standard does include the PHPCompatibility standard as well to check By default the PHPCompatibility rules will check only the PHP version you are running the phpcs command on. To choose a specific version to check either set the version on the console ``` -# to run all the checks for PHP 7.1, PHP 7.2 and PHP 7.3 -/path/to/phpcs --runtime-set testVersion 7.1-7.3 ... +# to run all the checks for PHP 8.4 and PHP 8.5 +/path/to/phpcs --runtime-set testVersion 8.4-8.5 ... ``` or have a "testVersion" configuration option in your phpcs.xml file. @@ -151,4 +151,4 @@ vendor/bin/phpunit There is also a pre-commit hook for git to run Code Sniffer on commit. -Check out the [instructions](git-hook) on how to use it. \ No newline at end of file +Check out the [instructions](git-hook) on how to use it. diff --git a/composer.json b/composer.json index 45add6f..441cb4b 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,10 @@ ], "prefer-stable" : true, "require": { - "squizlabs/php_codesniffer": "3.*", - "exussum12/coverage-checker": "*", - "phpcompatibility/php-compatibility": "*", - "php": ">=5.6.0", + "squizlabs/php_codesniffer": "^4.0.1", + "exussum12/coverage-checker": "1.1.1", + "phpcompatibility/php-compatibility": "10.0.0-alpha2", + "php": ">=7.4", "dealerdirect/phpcodesniffer-composer-installer": "^1.1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 2c902b2..3487997 100644 --- a/composer.lock +++ b/composer.lock @@ -4,33 +4,33 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "89c1cf241e3b7399ad8da6825c2a33d0", + "content-hash": "d6ce493f4b557d246031172f22a23858", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.1.2", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1" + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1", - "reference": "e9cf5e4bbf7eeaf9ef5db34938942602838fc2b1", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1", + "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1", "shasum": "" }, "require": { "composer-plugin-api": "^2.2", "php": ">=5.4", - "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "^2.2", "ext-json": "*", "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.4.0", - "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", @@ -100,30 +100,30 @@ "type": "thanks_dev" } ], - "time": "2025-07-17T20:45:56+00:00" + "time": "2025-11-11T04:32:07+00:00" }, { "name": "exussum12/coverage-checker", - "version": "1.0.2", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/exussum12/coverageChecker.git", - "reference": "544984601cf563003b36c8ed9a5a61a40daafa93" + "reference": "0a0350772ca3077d18e87118ffb1d9338b10c63c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/exussum12/coverageChecker/zipball/544984601cf563003b36c8ed9a5a61a40daafa93", - "reference": "544984601cf563003b36c8ed9a5a61a40daafa93", + "url": "https://api.github.com/repos/exussum12/coverageChecker/zipball/0a0350772ca3077d18e87118ffb1d9338b10c63c", + "reference": "0a0350772ca3077d18e87118ffb1d9338b10c63c", "shasum": "" }, "require": { "ext-json": "*", "ext-xmlreader": "*", - "nikic/php-parser": "^3.1||^4.0", - "php": ">=7.0" + "nikic/php-parser": "^3.1||^4.0||^5.0", + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0" }, "bin": [ "bin/diffFilter" @@ -148,31 +148,33 @@ "description": "Allows checking the code coverage of a single pull request", "support": { "issues": "https://github.com/exussum12/coverageChecker/issues", - "source": "https://github.com/exussum12/coverageChecker/tree/1.0.2" + "source": "https://github.com/exussum12/coverageChecker/tree/1.1.1" }, - "time": "2022-01-19T14:42:51+00:00" + "time": "2024-06-25T15:05:17+00:00" }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v5.7.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82", + "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -180,7 +182,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.x-dev" } }, "autoload": { @@ -204,39 +206,47 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2025-12-06T11:56:16+00:00" }, { "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", + "version": "10.0.0-alpha2", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + "reference": "e0f0e5a3dc819a4a0f8d679a0f2453d941976e18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/e0f0e5a3dc819a4a0f8d679a0f2453d941976e18", + "reference": "e0f0e5a3dc819a4a0f8d679a0f2453d941976e18", "shasum": "" }, "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.1.2", + "squizlabs/php_codesniffer": "^3.13.3 || ^4.0" }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "replace": { + "wimg/php-compatibility": "*" }, "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "phpcsstandards/phpcsdevtools": "^1.2.3", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4 || ^10.5.32 || ^11.3.3", + "yoast/phpunit-polyfills": "^1.1.5 || ^2.0.5 || ^3.1.0" }, "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev", + "dev-develop": "10.x-dev" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ "LGPL-3.0-or-later" @@ -258,51 +268,159 @@ } ], "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "homepage": "https://techblog.wimgodden.be/tag/codesniffer/", "keywords": [ "compatibility", "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "security": "https://github.com/PHPCompatibility/PHPCompatibility/security/policy", "source": "https://github.com/PHPCompatibility/PHPCompatibility" }, - "time": "2019-12-27T09:44:58+00:00" + "funding": [ + { + "url": "https://github.com/PHPCompatibility", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcompatibility", + "type": "thanks_dev" + } + ], + "time": "2025-11-28T11:36:33+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "reference": "c216317e96c8b3f5932808f9b0f1f7a14e3bbf55", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-12-08T14:27:58+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "reference": "0525c73950de35ded110cffafb9892946d7771b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0525c73950de35ded110cffafb9892946d7771b5", + "reference": "0525c73950de35ded110cffafb9892946d7771b5", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.4.0" + "php": ">=7.2.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + "phpunit/phpunit": "^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31" }, "bin": [ "bin/phpcbf", "bin/phpcs" ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -321,7 +439,7 @@ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.", "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", @@ -346,9 +464,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2025-11-10T16:43:36+00:00" } ], "packages-dev": [ @@ -1769,12 +1891,14 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "phpcompatibility/php-compatibility": 15 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=5.6.0" + "php": ">=7.4" }, "platform-dev": {}, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/src/Standards/Totara/ruleset.xml b/src/Standards/Totara/ruleset.xml index 74d730f..14f9e23 100644 --- a/src/Standards/Totara/ruleset.xml +++ b/src/Standards/Totara/ruleset.xml @@ -68,8 +68,7 @@ - - + From ff6eec531164d92ad1d525db4209251cf4dc5202 Mon Sep 17 00:00:00 2001 From: Angela Kuznetsova Date: Fri, 10 Apr 2026 16:35:05 +1200 Subject: [PATCH 2/4] Update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 42cd73d..cac762f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/vendor/ \ No newline at end of file +/vendor/ +/.idea/ From 8bf7ead8ee755e361ea06df0c6468ae3648b61f3 Mon Sep 17 00:00:00 2001 From: Angela Kuznetsova Date: Fri, 10 Apr 2026 16:08:46 +1200 Subject: [PATCH 3/4] Update codesniffer package to work with SonarQube --- src/Standards/Totara/ruleset.xml | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/Standards/Totara/ruleset.xml b/src/Standards/Totara/ruleset.xml index 14f9e23..ea30b54 100644 --- a/src/Standards/Totara/ruleset.xml +++ b/src/Standards/Totara/ruleset.xml @@ -189,4 +189,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 30d06846b86188d722d15c2bb6e774d2aa594523 Mon Sep 17 00:00:00 2001 From: Angela Kuznetsova Date: Mon, 20 Apr 2026 13:13:47 +1200 Subject: [PATCH 4/4] Update codesniffer ruleset --- src/Standards/Totara/ruleset.xml | 70 ++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/Standards/Totara/ruleset.xml b/src/Standards/Totara/ruleset.xml index ea30b54..f27bee7 100644 --- a/src/Standards/Totara/ruleset.xml +++ b/src/Standards/Totara/ruleset.xml @@ -68,8 +68,6 @@ - - @@ -87,7 +85,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + @@ -197,51 +231,34 @@ - - - - - - - - - - - - - - - - - @@ -249,39 +266,30 @@ - - - - - - + - - - + - -