Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event dispatch inconsistency #52521

Closed
Pr3d4dor opened this issue Aug 19, 2024 · 1 comment · May be fixed by #52522
Closed

Event dispatch inconsistency #52521

Pr3d4dor opened this issue Aug 19, 2024 · 1 comment · May be fixed by #52522

Comments

@Pr3d4dor
Copy link

Pr3d4dor commented Aug 19, 2024

Laravel Version

11.20.0

PHP Version

8.3.7

Database Driver & Version

No response

Description

There is a inconsistency when dispatching events.

Given the classes:

class TestEvent
{
    public function __construct(
        public string $test
    ) {}
}

And

class TestListener
{
    public function handle(TestEvent $exampleEvent)
    {
        // Some code
    }
}

Those snippets dont produce the same behavior:

// Does not work, throws a error in the listener class (listener excepts the TestEvent class, but is given a string)
Event::dispatch(TestEvent::class, ['hello']);
// Works as expected
Event::dispatch(new TestEvent('hello'));

I dont know if this is the intended behavior or not.

Links to #owen-it/laravel-auditing#963

Steps To Reproduce

The steps do reproduce are in the description above.

@driesvints
Copy link
Member

I don't think we document the former?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants