Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/moodle-plugin-ci
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (file_exists(__DIR__ . '/../../../autoload.php')) {
}

// Current version. Keep it updated on releases.
define('MOODLE_PLUGIN_CI_VERSION', '4.5.9');
define('MOODLE_PLUGIN_CI_VERSION', '4.5.10');

define('MOODLE_PLUGIN_CI_BOXED', '@is_boxed@');

Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
],
"require": {
"php": ">=7.4",
"moodlehq/moodle-cs": "^3.6.0",
"moodlehq/moodle-local_ci": "^1.1.3",
"moodlehq/moodle-cs": "^3.7.0",
"moodlehq/moodle-local_ci": "^1.1.4",
"moodlehq/moodle-local_moodlecheck": "^1.3.2",
"sebastian/phpcpd": "^6.0.3",
"sebastian/version": "^3.0.2",
Expand All @@ -73,7 +73,6 @@
"psr/log": "^1.1.4",
"nikic/php-parser": "^4.14",
"marcj/topsort": "^2.0.0",
"phpcompatibility/php-compatibility": "dev-develop#96072c30",
"laravel-zero/phar-updater": "^1.0.0"
},
"require-dev": {
Expand Down
414 changes: 155 additions & 259 deletions composer.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ This project adheres to [Semantic Versioning](https://semver.org/).
The format of this change log follows the advice given at [Keep a CHANGELOG](https://keepachangelog.com).

## [Unreleased]

## [4.5.10] - 2026-02-09
### Changed
- Updated project dependencies to current PHP and Moodle versions
- Updated project dependencies to current [moodle-cs v3.7.0](https://github.com/moodlehq/moodle-cs) and [moodle-local_ci v1.1.4](https://github.com/moodlehq/moodle-local_ci) releases. The project now targets the current Moodle version.
- ACTION SUGGESTED: bump workflows to postgres 16, which is a requirement for Moodle 5.2
- Linting for mobile app templates is disabled to avoid throwing warnings with Angular, Ionic or Moodle app custom directives.
- ACTION SUGGESTED: move mobile app templates to a `templates/mobileapp/` folder.

### Added
- Support Moodle cloning from local repo. Installation command `--repo` params support `file://` and `./moodle` making it similar to `git clone` behaviour.
Expand Down Expand Up @@ -786,7 +790,8 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
- `moodle-plugin-ci shifter` command. Run YUI Shifter on plugin YUI modules.
- `moodle-plugin-ci csslint` command. Lints the CSS files in the plugin.

[Unreleased]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.9...main
[Unreleased]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.10...main
[4.5.10]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.9...4.5.10
[4.5.9]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.8...4.5.9
[4.5.8]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.7...4.5.8
[4.5.7]: https://github.com/moodlehq/moodle-plugin-ci/compare/4.5.6...4.5.7
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Vendors.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getRelativeVendorPaths()
{
$base = dirname($this->path) . '/';

return array_map(function ($path) use ($base) {
return array_map(static function ($path) use ($base) {
return str_replace($base, '', $path);
}, $this->getVendorPaths());
}
Expand Down
6 changes: 3 additions & 3 deletions src/Parser/StatementFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StatementFilter
*/
public function filterFunctions(array $statements): array
{
return array_filter($statements, function ($statement) {
return array_filter($statements, static function ($statement) {
return $statement instanceof Function_;
});
}
Expand All @@ -52,7 +52,7 @@ public function filterFunctions(array $statements): array
*/
public function filterClasses(array $statements): array
{
return array_filter($statements, function ($statement) {
return array_filter($statements, static function ($statement) {
return $statement instanceof Class_;
});
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public function filterClassNames(array $statements): array
*/
public function filterNamespaces(array $statements): array
{
return array_filter($statements, function ($statement) {
return array_filter($statements, static function ($statement) {
return $statement instanceof Namespace_;
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Process/Execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function setNodeEnv(Process $process): Process
*/
public function run($cmd, ?string $error = null): Process
{
if (!($cmd instanceof Process)) {
if (!$cmd instanceof Process) {
$cmd = new Process($cmd);
}
$this->setNodeEnv($cmd);
Expand All @@ -124,7 +124,7 @@ public function run($cmd, ?string $error = null): Process
*/
public function mustRun($cmd, ?string $error = null): Process
{
if (!($cmd instanceof Process)) {
if (!$cmd instanceof Process) {
$cmd = new Process($cmd);
}
$this->setNodeEnv($cmd);
Expand Down
63 changes: 1 addition & 62 deletions tests/Command/CodeCheckerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ abstract private function somefunc() { // To verify PHPCompatibility sniff.
$output = $commandTester->getDisplay();
$this->assertMatchesRegularExpression('/E\.* 10\.* \/ 10 \(100%\)/', $output); // Progress.
$this->assertMatchesRegularExpression('/\/fixable.php/', $output); // File.
$this->assertMatchesRegularExpression('/ 13 ERRORS AND 1 WARNING AFFECTING 8 /', $output); // Summary.
$this->assertMatchesRegularExpression('/ 12 ERRORS AND 1 WARNING AFFECTING 8 /', $output); // Summary.
$this->assertMatchesRegularExpression('/BoilerplateComment\.NoBoilerplateComment/', $output); // Moodle sniff.
$this->assertMatchesRegularExpression('/Expected MOODLE_INTERNAL check/', $output); // Moodle sniff.
$this->assertMatchesRegularExpression('/print_error\(\) has been deprecated/', $output); // Moodle sniff.
Expand All @@ -106,7 +106,6 @@ abstract private function somefunc() { // To verify PHPCompatibility sniff.
$this->assertMatchesRegularExpression('/Missing @copyright tag/', $output); // Moodle sniff.
$this->assertMatchesRegularExpression('/Missing @license tag/', $output); // Moodle sniff.
$this->assertMatchesRegularExpression('/Missing docblock for function somefunc/', $output); // Moodle sniff.
$this->assertMatchesRegularExpression('/AbstractPrivateMethods\.Found/', $output); // PHPCompatibility sniff.
$this->assertMatchesRegularExpression('/Opening brace must be the last content/', $output); // Generic sniff.
$this->assertMatchesRegularExpression('/Closing brace must not be followed by/', $output); // PSR12 sniff.
$this->assertMatchesRegularExpression('/Files\.EndFileNewline\.NoneFound/', $output); // Generic of file.
Expand Down Expand Up @@ -150,66 +149,6 @@ public function testExecuteWithWarningsAndThreshold()
$this->assertSame(0, $commandTester->getStatusCode());
}

public function testExecuteWithTestVersion()
{
// Let's add a file with some new and deprecated stuff, and verify that the test-version option affects to the outcome.
$content = <<<'EOT'
<?php // phpcs:disable moodle
mb_str_split(); // New in PHP 7.4.
ini_get('allow_url_include'); // Deprecated in PHP 7.4.
ldap_count_references(); // New in PHP 8.0.
pg_errormessage(); // Deprecated in PHP 8.0.
$fb = new ReflectionFiber(); // New in PHP 8.1.
ini_get('auto_detect_line_endings'); // Deprecated in PHP 8.1.
openssl_cipher_key_length(); // New in PHP 8.2.
utf8_encode(); // Deprecated in PHP 8.2.

EOT;
$this->fs->dumpFile($this->pluginDir . '/test_versions.php', $content);

// By default, without specify test-version, only reports deprecation warnings and returns 0.
$commandTester = $this->executeCommand($this->pluginDir);
$output = $commandTester->getDisplay();
$this->assertSame(0, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES/', $output);

// With test-version 7.4, reports 3 new errors and <= 7.4 specific warnings and returns 1.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '7.4']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES/', $output);

// With test-version 8.0, reports 2 new errors and <= 8.0 specific warnings and returns 1.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '8.0']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES/', $output);

// With test-version 8.1, reports 1 new errors and <= 8.1 specific warnings and returns 0.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '8.1']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES/', $output);

// With test-version 7.4-8.0, reports 3 new errors and <= 8.0 specific warnings and returns 1.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '7.4-8.0']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES/', $output);

// With test-version 7.4-8.1, reports 3 new errors and <= 8.1 specific warnings and returns 1.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '7.4-8.1']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 6 LINES/', $output);

// With test-version 7.4- (open range), reports 3 new errors and <= 8.2 specific warnings and returns 1.
$commandTester = $this->executeCommand($this->pluginDir, ['--test-version' => '7.4-']);
$output = $commandTester->getDisplay();
$this->assertSame(1, $commandTester->getStatusCode());
$this->assertMatchesRegularExpression('/FOUND 3 ERRORS AND 4 WARNINGS AFFECTING 7 LINES/', $output);
}

public function testExecuteWithExclusions()
{
// Add a file with errors and warnings, and verify that they are suppressed with the exclusions.
Expand Down
Loading