Problem/Motivation
\Drupal\Tests\PhpUnitCompatibilityTrait doesn't quite work the way it should on the latest PHPStan and PHPStan-Drupal. We get:
------ -----------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php
------ -----------------------------------------------------------------------------
11 Class Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\BuildTests\Framework\BuildTestBase)
------ -----------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\KernelTests\KernelTestBase)
------ -----------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\BrowserTestBase)
------ -----------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------------------------------------------------------
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Component\Annotation\Plugin\Discovery\AnnotationBridgeDecoratorTest)
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ --------------------------------------------------------------------------------------------------------------------------------------------------------------
------ --------------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Component\DependencyInjection\ContainerTest)
------ --------------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ --------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumperTest)
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Component\Gettext\PoStreamWriterTest)
------ -------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -------------------------------------------------------------------------------------------------------------------------------
------ ---------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Component\Plugin\PluginManagerBaseTest)
------ ---------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ---------------------------------------------------------------------------------------------------------------------------------
------ ----------------------------------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest)
------ ----------------------------------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ----------------------------------------------------------------------------------------------------------------------------------------------------
------ -----------------------------------------------------------------------------------------------------------------------------
Line core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php (in context of class Drupal\Tests\UnitTestCase)
------ -----------------------------------------------------------------------------------------------------------------------------
19 Trait Drupal\Tests\PhpUnitCompatibilityTrait uses unknown trait Drupal\Tests\PhpUnitVersionDependentTestCompatibilityTrait.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ -----------------------------------------------------------------------------------------------------------------------------
This is already happening on a DrupalCI that does updates - see https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/55836/...
Steps to reproduce
Checkout core 10.0.x
Run composer update
Run PHPStan
Proposed resolution
Use the same solution as vendor/symfony/phpunit-bridge/SymfonyTestsListener.php to trick PHPStan into finding the trait.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
alexpottComment #3
alexpottLol fixed coding standards.
Comment #4
alexpottThe
errors on the composer update build are interesting. I do not get them locally and they are incorrect.... for some reason on DrupalCI PHPStan is missing the use of REQUEST_TIME in the define() calls at the top of comment.module and history.module.
Hmmm....
Comment #5
mondrakeDuplicate of #3282315: Update phpstan/phpstan and mglaman/phpstan-drupal to latest versions, kinda
Comment #6
alexpott@mondrake this is a better fix for part of #3282315: Update phpstan/phpstan and mglaman/phpstan-drupal to latest versions. We could land this and then solve the REQUEST_TIME stuff and actually do the update in the other issue.
Comment #7
mallezieThis looks good to me. Simple trick, and bot agrees. And this unblocks the upgrade (which improves the performance of running phpstan)
Comment #10
catchCommitted/pushed to 10.0.x, cherry-picked to 9.5.x and 9.4.x, thanks!