-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
I'm trying to write a class that supports both Symfony Contracts event and legacy event from Syfmony 3.x. PHPStan reports the following error when running on Symfony 5 where Symfony\Component\EventDispatcher\Event is not present:
------ ----------------------------------------------------------------------
Line MyEvent.php
------ ----------------------------------------------------------------------
Reflection error: Symfony\Component\EventDispatcher\Event not found.
22 Reflection error: Symfony\Component\EventDispatcher\Event not found.
22 Reflection error: Symfony\Component\EventDispatcher\Event not found.
22 Reflection error: Symfony\Component\EventDispatcher\Event not found.
29 Reflection error: Symfony\Component\EventDispatcher\Event not found.
29 Reflection error: Symfony\Component\EventDispatcher\Event not found.
29 Reflection error: Symfony\Component\EventDispatcher\Event not found.
29 Reflection error: Symfony\Component\EventDispatcher\Event not found.
31 Reflection error: Symfony\Component\EventDispatcher\Event not found.
31 Reflection error: Symfony\Component\EventDispatcher\Event not found.
31 Reflection error: Symfony\Component\EventDispatcher\Event not found.
31 Reflection error: Symfony\Component\EventDispatcher\Event not found.
31 Reflection error: Symfony\Component\EventDispatcher\Event not found.
------ ----------------------------------------------------------------------
Code snippet that reproduces the problem
<?php
declare(strict_types=1);
namespace App;
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;
if (class_exists(ContractsEvent::class)) {
abstract class Event extends ContractsEvent
{
}
} elseif (class_exists(LegacyEvent::class)) {
abstract class Event extends LegacyEvent
{
}
}
final class MyEvent extends Event
{
// ...
}However, I can't seem to reproduce this in the playground: https://phpstan.org/r/e812ed4d-2759-46d0-bee1-c589d7c4fca2
Expected output
No errors should be reported as in 0.12.25
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels