diff --git a/.github/workflows/workflows.yml b/.github/workflows/workflows.yml index b1fe286..6250e2e 100644 --- a/.github/workflows/workflows.yml +++ b/.github/workflows/workflows.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.2', '8.3', '8.4'] + php-versions: ['8.2', '8.3', '8.4', '8.5'] steps: - uses: actions/checkout@v4 - uses: "shivammathur/setup-php@v2" @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.2', '8.3', '8.4'] + php-versions: ['8.2', '8.3', '8.4', '8.5'] steps: - uses: actions/checkout@v4 - uses: "shivammathur/setup-php@v2" @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.2', '8.3', '8.4'] + php-versions: ['8.2', '8.3', '8.4', '8.5'] dependency-versions: ['highest', 'lowest'] steps: - uses: actions/checkout@v4 diff --git a/composer.json b/composer.json index 7ad7a2c..a5a0da9 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "require": { "php": "^8.2", "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "drupal/coder": "^8.3.26", - "slevomat/coding-standard": "^8.16.0", - "squizlabs/php_codesniffer": "^3.11.1" + "drupal/coder": "^8.3.26 || ^9.0", + "slevomat/coding-standard": "^8.11", + "squizlabs/php_codesniffer": "^3.9.1 || ^4.0.1" }, "require-dev": { "phpstan/extension-installer": "^1.4.3", diff --git a/tests/Sniffs/AlphabeticallySortedUsesTest.php b/tests/Sniffs/AlphabeticallySortedUsesTest.php index bf74e0c..f1fc3a1 100644 --- a/tests/Sniffs/AlphabeticallySortedUsesTest.php +++ b/tests/Sniffs/AlphabeticallySortedUsesTest.php @@ -21,8 +21,8 @@ public function testError(): void { self::assertSniffError($report, 8, AlphabeticallySortedUsesSniff::CODE_INCORRECT_ORDER); } - protected static function getSniffName(): string { - return 'SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses'; + protected static function getSniffClassName(): string { + return AlphabeticallySortedUsesSniff::class; } } diff --git a/tests/Sniffs/Base.php b/tests/Sniffs/Base.php index a57f093..e28d35f 100644 --- a/tests/Sniffs/Base.php +++ b/tests/Sniffs/Base.php @@ -1,8 +1,7 @@ init(); - if (count($sniffProperties) > 0) { - $codeSniffer->ruleset->ruleset[self::getSniffName()]['properties'] = $sniffProperties; + $sniffName = self::getSniffName(); + if (count($sniffProperties) > 0 && $sniffName !== null) { + $codeSniffer->ruleset->ruleset[$sniffName]['properties'] = $sniffProperties; } $sniffClassName = static::getSniffClassName(); diff --git a/tests/Sniffs/DrupalRulesetTest.php b/tests/Sniffs/DrupalRulesetTest.php index 67e64e3..0779581 100644 --- a/tests/Sniffs/DrupalRulesetTest.php +++ b/tests/Sniffs/DrupalRulesetTest.php @@ -4,6 +4,8 @@ namespace PreviousNext\CodingStandard\Tests\Sniffs; +use Drupal\Sniffs\ControlStructures\InlineControlStructureSniff; + /** * Tests inherits from Drupal ruleset. */ @@ -17,7 +19,11 @@ public function testNoError(): void { public function testMissing(): void { $report = self::checkFile(__DIR__ . '/fixtures/DrupalRulesetError.php'); self::assertSame(2, $report->getErrorCount()); - self::assertSniffError($report, 5, sniffName: 'Drupal.ControlStructures.InlineControlStructure', code: 'NotAllowed'); + // Sniff removed in drupal/coder 9.x. + $inlineControlSniff = \class_exists(InlineControlStructureSniff::class) + ? 'Drupal.ControlStructures.InlineControlStructure' + : 'Generic.ControlStructures.InlineControlStructure'; + self::assertSniffError($report, 5, sniffName: $inlineControlSniff, code: 'NotAllowed'); self::assertSniffError($report, 5, sniffName: 'Generic.PHP.UpperCaseConstant', code: 'Found'); }