Skip to content
Open
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
10 changes: 10 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ jobs:
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/install.php --debug
- name: "Test legacy hook attribute stubs"
run: |
cp $GITHUB_WORKSPACE/tests/fixtures/integration/legacy-hook-attributes.php ~/drupal/legacy-hook-attributes.php
cd ~/drupal
./vendor/bin/phpstan analyze legacy-hook-attributes.php --no-progress
- name: "Test BrowserTestBase is autoloaded"
run: |
cd ~/drupal
Expand Down Expand Up @@ -200,6 +205,11 @@ jobs:
run: |
cd ~/drupal
./vendor/bin/phpstan analyze web/core/install.php --debug
- name: "Test legacy hook attribute stubs"
run: |
cp $GITHUB_WORKSPACE/tests/fixtures/integration/legacy-hook-attributes.php ~/drupal/legacy-hook-attributes.php
cd ~/drupal
./vendor/bin/phpstan analyze legacy-hook-attributes.php --no-progress
- name: "Test no crash"
run: |
cd ~/drupal
Expand Down
10 changes: 10 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
parameters:
bootstrapFiles:
- drupal-autoloader.php
ignoreErrors:
-
message: '#^Attribute class Drupal\\Core\\Hook\\Attribute\\LegacyHook does not exist\.$#'
reportUnmatched: false
-
message: '#^Attribute class Drupal\\Core\\Hook\\Attribute\\LegacyRequirementsHook does not exist\.$#'
reportUnmatched: false
-
message: '#^Attribute class Drupal\\Core\\Hook\\Attribute\\LegacyModuleImplementsAlter does not exist\.$#'
reportUnmatched: false
excludePaths:
- '*.api.php'
- '*/tests/fixtures/*.php'
Expand Down
28 changes: 28 additions & 0 deletions tests/fixtures/integration/legacy-hook-attributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

/**
* Fixture for verifying LegacyHook, LegacyRequirementsHook, and
* LegacyModuleImplementsAlter attribute stubs are available regardless of
* installed Drupal version.
*
* These attributes were added at different minor versions and LegacyHook is
* being removed in Drupal 12. PHPStan should not report "class not found"
* errors when these attributes are used.
*/

use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\Core\Hook\Attribute\LegacyModuleImplementsAlter;
use Drupal\Core\Hook\Attribute\LegacyRequirementsHook;

#[LegacyHook]
function phpstan_drupal_test_node_presave(): void {}

#[LegacyRequirementsHook]
function phpstan_drupal_test_requirements(string $phase): array {
return [];
}

#[LegacyModuleImplementsAlter]
function phpstan_drupal_test_module_implements_alter(array &$implementations, string $hook): void {}
Loading