Skip to content

Commit

Permalink
Fix: Add a stub for Event class if it's not loaded (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage authored May 16, 2022
1 parent ac7ac1e commit bdb6b39
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Event/FeatureToggleDisabledEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

namespace Unleash\Client\Event;

use Symfony\Contracts\EventDispatcher\Event;
use Unleash\Client\Configuration\Context;
use Unleash\Client\DTO\Feature;

final class FeatureToggleDisabledEvent
if (!class_exists(Event::class)) {
require __DIR__ . '/../../stubs/event-dispatcher/Event.php';
}

final class FeatureToggleDisabledEvent extends Event
{
/**
* @internal
Expand Down
7 changes: 6 additions & 1 deletion src/Event/FeatureToggleMissingStrategyHandlerEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

namespace Unleash\Client\Event;

use Symfony\Contracts\EventDispatcher\Event;
use Unleash\Client\Configuration\Context;
use Unleash\Client\DTO\Feature;

final class FeatureToggleMissingStrategyHandlerEvent
if (!class_exists(Event::class)) {
require __DIR__ . '/../../stubs/event-dispatcher/Event.php';
}

final class FeatureToggleMissingStrategyHandlerEvent extends Event
{
/**
* @internal
Expand Down
4 changes: 4 additions & 0 deletions src/Event/FeatureToggleNotFoundEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Symfony\Contracts\EventDispatcher\Event;
use Unleash\Client\Configuration\Context;

if (!class_exists(Event::class)) {
require __DIR__ . '/../../stubs/event-dispatcher/Event.php';
}

final class FeatureToggleNotFoundEvent extends Event
{
/**
Expand Down
9 changes: 9 additions & 0 deletions stubs/event-dispatcher/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Symfony\Contracts\EventDispatcher;

if (!class_exists(Event::class)) {
class Event
{
}
}

0 comments on commit bdb6b39

Please sign in to comment.