From 2408bf1165144493523a6f6d69be517b8a4ee3e2 Mon Sep 17 00:00:00 2001 From: Jonathan Champ Date: Thu, 29 Aug 2024 16:48:04 -0400 Subject: [PATCH] ValidVariableNameSniff: freshen allowed globals - Group by global type with comment. - Add comment to removed globals. - Add missing FULLSCRIPT literal. - Add missing XMLDB object. --- .../ValidVariableNameSniff.php | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php b/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php index 5655766..115e1fd 100644 --- a/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/moodle/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -29,12 +29,47 @@ class ValidVariableNameSniff extends AbstractVariableSniff { - public static $allowedglobals = ['ADMIN', 'CFG', 'COURSE', 'DB', 'FULLME', - 'OUTPUT', 'PAGE', 'PERF', 'SESSION', 'SITE', 'THEME', 'USER', - '_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', - '_COOKIE', '_HTTP_RAW_POST_DATA', 'ACCESSLIB_PRIVATE', 'ME', - 'CONDITIONLIB_PRIVATE', 'FILTERLIB_PRIVATE', 'SCRIPT', 'MNET_REMOTE_CLIENT', - 'http_response_header']; + public static $allowedglobals = [ + // PHP Superglobals. + '_COOKIE', + '_ENV', + '_FILES', + '_GET', + '_POST', + '_REQUEST', + '_SERVER', + '_SESSION', + + // PHP Predefined variables. + 'http_response_header', + '_HTTP_RAW_POST_DATA', // Removed in PHP 7.0. + + // Moodle global objects. + 'ADMIN', + 'CFG', + 'COURSE', + 'DB', + 'OUTPUT', + 'PAGE', + 'PERF', + 'SESSION', + 'SITE', + 'THEME', + 'USER', + 'XMLDB', + + // Moodle global literals. + 'FULLME', + 'FULLSCRIPT', + 'ME', + 'SCRIPT', + + // Moodle private objects. + 'ACCESSLIB_PRIVATE', + 'CONDITIONLIB_PRIVATE', // Removed in Moodle 2.7. + 'FILTERLIB_PRIVATE', + 'MNET_REMOTE_CLIENT', + ]; /** * Processes class member variables.