Skip to content

Reflection error: Drupal\Tests\PhpunitCompatibilityTrait not found #143

@MPParsley

Description

@MPParsley

How is drupal-check installed?

drupal-check is installed as a dependency to my project

Environment:

  • OS: macOS
  • PHP Version: 7.3
  • Drupal core: 9.0.x

Describe the bug
Reflection error occurs when using multiple arguments to test different files.
$ vendor/bin/drupal-check --deprecations --no-progress --drupal-root=../drupal --exclude-dir=vendor cookiebot_consent.module src/Event/LibrariesEvent.php

This issue was partially fixed in phpstan/phpstan#3522 but still occurs when using different files as arguments.

cookiebot_consent.module

  $event = new LibrariesEvent($extension);

src/Event/LibrariesEvent.php

use Symfony\Contracts\EventDispatcher\Event;

class LibrariesEvent extends Event {

Symfony\Contracts\EventDispatcher\Event

namespace Symfony\Contracts\EventDispatcher;

use Psr\EventDispatcher\StoppableEventInterface;

if (interface_exists(StoppableEventInterface::class)) {
    class Event implements StoppableEventInterface
    {
    }
} else {
    class Event
    {
    }
}

Console output

 ------ -------------------------------------------------------------------- 
  Line   cookiebot_consent.module                                            
 ------ -------------------------------------------------------------------- 
         Reflection error: Psr\EventDispatcher\StoppableEventInterface not   
         found.                                                              
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ -------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------- 
  Line   src/Event/LibrariesEvent.php                                        
 ------ -------------------------------------------------------------------- 
         Reflection error: Psr\EventDispatcher\StoppableEventInterface not   
         found.                                                              
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
  52     Reflection error: Psr\EventDispatcher\StoppableEventInterface not   
         found.                                                              
         💡 Learn more at https://phpstan.org/user-guide/discovering-symbols  
 ------ -------------------------------------------------------------------- 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions