File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,11 @@ public function register(): void
1616 }
1717
1818 /** Injects assets inside every full-page response */
19- public function handle (RequestHandled $ handled )
19+ public function handle (RequestHandled $ handled ): void
2020 {
2121 $ identifier = 'NativePHP Livewire Dispatcher ' ;
2222 $ html = $ handled ->response ->getContent ();
23- $ originalContent = $ handled ->response ->original ;
23+ $ originalContent = $ handled ->response ->original ?? null ;
2424
2525 if (! $ handled ->response ->isSuccessful ()) {
2626 return ;
@@ -50,7 +50,13 @@ public function handle(RequestHandled $handled)
5050 HTML )
5151 );
5252
53- $ handled ->response ->original = $ originalContent ;
53+ // Laravel dispatches the ResponseHandled event even for response
54+ // objects that don't include the `original` property.
55+ // The typehint in Laravel core is wrong, so we ignore
56+ /* @phpstan-ignore function.alreadyNarrowedType */
57+ if (property_exists ($ handled ->response , 'original ' )) {
58+ $ handled ->response ->original = $ originalContent ;
59+ }
5460 }
5561
5662 /** Injects assets into given html string (taken from Livewire's injection mechanism) */
You can’t perform that action at this time.
0 commit comments