Skip to content

Commit

Permalink
Bump all dependencies to current ones
Browse files Browse the repository at this point in the history
Explicit:
- Moodle CS v3.4.10

Implicit:
- None
  • Loading branch information
stronk7 committed Jul 5, 2024
1 parent b49b907 commit 997ded6
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-3.0-or-later",
"require": {
"php": ">=7.4",
"moodlehq/moodle-cs": "^v3.4.8",
"moodlehq/moodle-cs": "^v3.4.10",
"phpcompatibility/php-compatibility": "dev-develop#96072c30"
},
"config": {
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitbd0a96a20590db32325fc04f2993298a::getLoader();
return ComposerAutoloaderInitf911c1a21380142d6ee33490dc0eee6a::getLoader();
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitbd0a96a20590db32325fc04f2993298a
class ComposerAutoloaderInitf911c1a21380142d6ee33490dc0eee6a
{
private static $loader;

Expand All @@ -24,12 +24,12 @@ public static function getLoader()

require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInitbd0a96a20590db32325fc04f2993298a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf911c1a21380142d6ee33490dc0eee6a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitbd0a96a20590db32325fc04f2993298a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf911c1a21380142d6ee33490dc0eee6a', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbd0a96a20590db32325fc04f2993298a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf911c1a21380142d6ee33490dc0eee6a::getInitializer($loader));

$loader->register(true);

Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitbd0a96a20590db32325fc04f2993298a
class ComposerStaticInitf911c1a21380142d6ee33490dc0eee6a
{
public static $prefixLengthsPsr4 = array (
'P' =>
Expand Down Expand Up @@ -72,9 +72,9 @@ class ComposerStaticInitbd0a96a20590db32325fc04f2993298a
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbd0a96a20590db32325fc04f2993298a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbd0a96a20590db32325fc04f2993298a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbd0a96a20590db32325fc04f2993298a::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf911c1a21380142d6ee33490dc0eee6a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf911c1a21380142d6ee33490dc0eee6a::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf911c1a21380142d6ee33490dc0eee6a::$classMap;

}, null, ClassLoader::class);
}
Expand Down
12 changes: 6 additions & 6 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@
},
{
"name": "moodlehq/moodle-cs",
"version": "v3.4.8",
"version_normalized": "3.4.8.0",
"version": "v3.4.10",
"version_normalized": "3.4.10.0",
"source": {
"type": "git",
"url": "https://github.com/moodlehq/moodle-cs.git",
"reference": "91661a17a23ed17e7ae4276f8c19df789b8882c2"
"reference": "89ff0acd727f8611cbafe5aea524614090b24ad9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/91661a17a23ed17e7ae4276f8c19df789b8882c2",
"reference": "91661a17a23ed17e7ae4276f8c19df789b8882c2",
"url": "https://api.github.com/repos/moodlehq/moodle-cs/zipball/89ff0acd727f8611cbafe5aea524614090b24ad9",
"reference": "89ff0acd727f8611cbafe5aea524614090b24ad9",
"shasum": ""
},
"require": {
Expand All @@ -116,7 +116,7 @@
"sebastian/phpcpd": "^6.0",
"thor-juhasz/phpunit-coverage-check": "^0.3.0"
},
"time": "2024-06-14T14:47:25+00:00",
"time": "2024-07-04T16:34:56+00:00",
"type": "phpcodesniffer-standard",
"installation-source": "dist",
"autoload": {
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'moodlehq/local_codechecker',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '3ec6941b73874fb0bc33ded196e8a5c6fe80be6f',
'reference' => 'b49b9077544290509a775bff341b74ec26e75c8c',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -22,16 +22,16 @@
'moodlehq/local_codechecker' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '3ec6941b73874fb0bc33ded196e8a5c6fe80be6f',
'reference' => 'b49b9077544290509a775bff341b74ec26e75c8c',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'moodlehq/moodle-cs' => array(
'pretty_version' => 'v3.4.8',
'version' => '3.4.8.0',
'reference' => '91661a17a23ed17e7ae4276f8c19df789b8882c2',
'pretty_version' => 'v3.4.10',
'version' => '3.4.10.0',
'reference' => '89ff0acd727f8611cbafe5aea524614090b24ad9',
'type' => 'phpcodesniffer-standard',
'install_path' => __DIR__ . '/../moodlehq/moodle-cs',
'aliases' => array(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ protected function processScopes(File $phpcsFile, int $stackPtr): void {
// Skip methods of classes, traits and interfaces.
continue;
}
if ($token['code'] === T_ANON_CLASS && !empty($token['conditions'])) {
// Skip anonymous classes.
continue;
}

$artifactCount++;

if ($token['code'] === T_FUNCTION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,22 @@ public function process(File $phpcsFile, $stackPtr): void
return;
}

$tokenptr++;
// Let's jump over all the extra (allowed) consecutive comments to find the first non-comment token.
$lastComment = $tokenptr;
$nextComment = $tokenptr;
while (($nextComment = $phpcsFile->findNext(T_COMMENT, ($nextComment + 1), null, false)) !== false) {
// Only \n is allowed as spacing since the previous comment line.
if (strpos($tokens[$nextComment - 1]['content'], "\n") === false) {
// Stop looking for consecutive comments, some spacing broke the sequence.
break;
}
if ($tokens[$nextComment]['line'] !== ($tokens[$lastComment]['line'] + 1)) {
// Stop looking for comments, the lines are not consecutive.
break;
}
$lastComment = $nextComment;
}
$tokenptr = $lastComment + 1; // Move to the last found comment + 1.

$nextnonwhitespace = $phpcsFile->findNext(T_WHITESPACE, $tokenptr, null, true);

Expand Down Expand Up @@ -218,8 +233,16 @@ private function fullComment(): array

private function insertBoilerplate(File $file, int $stackptr): void
{
$prefix = substr($file->getTokens()[$stackptr]['content'], -1) === "\n" ? '' : "\n";
$file->fixer->addContent($stackptr, $prefix . implode("\n", $this->fullComment()) . "\n");
$token = $file->getTokens()[$stackptr];
$paddedComment = implode("\n", $this->fullComment()) . "\n";

if ($token['code'] === T_OPEN_TAG) {
$replacement = trim($token['content']) . "\n" . $paddedComment;
$file->fixer->replaceToken($stackptr, $replacement);
} else {
$prefix = substr($token['content'], -1) === "\n" ? '' : "\n";
$file->fixer->addContent($stackptr, $prefix . $paddedComment);
}
}

private function moveBoilerplate(File $file, int $start, int $target): void
Expand Down Expand Up @@ -265,6 +288,11 @@ private function completeBoilerplate(File $file, $stackptr, int $lineindex): voi
*/
private function regexForLine(string $line): string
{
// We need to match the blank lines in their entirety.
if ($line === '//') {
return '/^\/\/$/';
}

return str_replace(
['Moodle', 'https\\:'],
['.*', 'https?\\:'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

namespace MoodleHQ\MoodleCS\moodle\Sniffs\NamingConventions;

use MoodleHQ\MoodleCS\moodle\Util\Attributes;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractScopeSniff;
use PHP_CodeSniffer\Util\Tokens;
Expand Down Expand Up @@ -108,6 +109,11 @@ protected function processTokenWithinScope(File $phpcsfile, $stackptr, $currscop
$scope = $methodprops['scope'];
$scopespecified = $methodprops['scope_specified'];

if (Attributes::hasOverrideAttribute($phpcsfile, $stackptr)) {
// This method has an `#[\Override]` attribute, so it is allowed to have a different name.
return;
}

// Only lower-case accepted.
if (
preg_match('/[A-Z]+/', $methodname) &&
Expand Down
62 changes: 62 additions & 0 deletions vendor/moodlehq/moodle-cs/moodle/Util/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use PHP_CodeSniffer\Files\File;
use PHPCSUtils\Utils\Context;
use PHPCSUtils\Utils\Namespaces;
use PHPCSUtils\Utils\ObjectDeclarations;

/**
* Utilities related to PHP Attributes.
Expand Down Expand Up @@ -108,4 +109,65 @@ public static function getAttributeProperties(

return $properties;
}

/**
* Check if a function has an \Override Attribute.
*
* Note: Override attributes can only be valid on methods of classes which extend or implement another class.
*
* @param File $phpcsFile
* @param int $stackPtr
* @return bool
*/
public static function hasOverrideAttribute(
File $phpcsFile,
int $stackPtr
): bool {
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
if ($token['code'] !== T_FUNCTION) {
// Not a function so can't have an Override Attribute.
return false;
}

if (empty($token['conditions'])) {
// Not in a class or interface.
return false;
}

$extendsOrImplements = false;
foreach ($token['conditions'] as $condition => $conditionCode) {
$extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findExtendedClassName(
$phpcsFile,
$condition
);
$extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findImplementedInterfaceNames(
$phpcsFile,
$condition
);
$extendsOrImplements = $extendsOrImplements || ObjectDeclarations::findExtendedInterfaceNames(
$phpcsFile,
$condition
);

if ($extendsOrImplements) {
break;
}
}

if (!$extendsOrImplements) {
// The OVerride attrinbute can only apply to a class which has a parent.
return false;
}

$attributes = self::getAttributePointers($phpcsFile, $stackPtr);
foreach ($attributes as $attributePtr) {
$attribute = self::getAttributeProperties($phpcsFile, $attributePtr);
if ($attribute['attribute_name'] === '\Override') {
return true;
}
}

return false;
}
}
5 changes: 5 additions & 0 deletions vendor/moodlehq/moodle-cs/moodle/Util/Docblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ protected static function getDocTagFromOpenTag(
];

while ($stackPtr = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true)) {
// If we have arrived to a stop token, and haven't found the file docblock yet, then there isn't one.
if (in_array($tokens[$stackPtr]['code'], $stopAtTypes)) {
return null;
}

if ($tokens[$stackPtr]['code'] === T_NAMESPACE || $tokens[$stackPtr]['code'] === T_USE) {
$stackPtr = $phpcsFile->findNext(T_SEMICOLON, $stackPtr + 1);
continue;
Expand Down

0 comments on commit 997ded6

Please sign in to comment.