Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index b3993e8..ca4e8b0 100644
- --- a/moodle/Sniffs/Files/MoodleInternalSniff.php
- +++ b/moodle/Sniffs/Files/MoodleInternalSniff.php
- @@ -30,6 +30,7 @@ namespace MoodleCodeSniffer\moodle\Sniffs\Files;
- use PHP_CodeSniffer\Sniffs\Sniff;
- use PHP_CodeSniffer\Files\File;
- use PHP_CodeSniffer\Util\Tokens;
- +use MoodleCodeSniffer\moodle\Util\MoodleUtil;
- class MoodleInternalSniff implements Sniff {
- /**
- @@ -47,14 +48,29 @@ class MoodleInternalSniff implements Sniff {
- * @param int $pointer The position in the stack.
- */
- public function process(File $file, $pointer) {
- - // Special dispensation for behat files.
- - if (basename(dirname($file->getFilename())) === 'behat') {
- - return;
- - }
- + // Guess moodle root, so we can do better dispensations below.
- + $moodleRoot = MoodleUtil::getMoodleRoot($file);
- + if ($moodleRoot) {
- + $relPath = str_replace('\\', '/', substr($file->path, strlen($moodleRoot)));
- + // Special dispensation for behat dirs at any level.
- + if (strpos($relPath, '/behat/') !== false) {
- + return;
- + }
- + // Special dispensation for lang dirs at any level.
- + if (strpos($relPath, '/lang/') !== false) {
- + return;
- + }
- + } else {
- + // Falback to simpler dispensations, only looking 1 level.
- + // Special dispensation for behat files.
- + if (basename(dirname($file->getFilename())) === 'behat') {
- + return;
- + }
- - // Special dispensation for lang files.
- - if (basename(dirname(dirname($file->getFilename()))) === 'lang') {
- - return;
- + // Special dispensation for lang files.
- + if (basename(dirname(dirname($file->getFilename()))) === 'lang') {
- + return;
- + }
- }
- // We only want to do this once per file.
Add Comment
Please, Sign In to add comment