We use globals a lot inside [[ https://phabricator.wikimedia.org/diffusion/EMFR/browse/master/includes/MobileFrontend.hooks.php | MobileFrontend.hooks.php ]] but sometimes we use the global keyword and sometimes we use getMFConfig. We want to encourage use of ConfigRegistry via getMFConfig and discourage use of globals.
Acceptance criteria
- PHPCodeSniffer, in short phpcs, helps us stick to same coding standards across MediaWiki and its extensions. phpcs should complain when global keyword is used in our PHP codebase using GlobalKeywordSniff.php. It should be enabled with low severity.
- Where we need to access globals add an inline comment documenting why and disable the phpcs sniff using // @codingStandardsIgnoreLine
- If inappropriate usages of globals are found e.g. https://phabricator.wikimedia.org/T146312#3188363 document them so whoever signs off the ticket can create a follow up card
Examples:
- https://phabricator.wikimedia.org/diffusion/EMFR/browse/master/includes/MobileFrontend.hooks.php;02946c7face0f9eefe739f708408efdd9bfd3c65$74
- https://phabricator.wikimedia.org/diffusion/EMFR/browse/master/includes/MobileFrontend.hooks.php;02946c7face0f9eefe739f708408efdd9bfd3c65$665
Sign off checklist
- If any globals need fixing, please create a follow up task.
Timebox: 4hrs