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

Fix undefined array key "type" on empty array dump #413

Merged
merged 3 commits into from
Nov 1, 2021

Conversation

nicoorfi
Copy link
Contributor

@nicoorfi nicoorfi commented Nov 1, 2021

This PR fixes an edge case where the stream type is undefined when using the dump function, with an empty array.

For example

This works without problems

    public function foo()
    {
       // ...do something

        dump(['foo'=>'bar']);
    }

But this crashed the swoole server

    public function foo()
    {
       // ...do something

        dump([]);
    }

With the followring error:


   ErrorException 

  Undefined array key "type"

  at vendor/laravel/octane/src/Commands/Concerns/InteractsWithIO.php:231
    227▕     public function handleStream($stream, $verbosity = null)
    228▕     {
    229▕       
    230▕ 
  ➜ 231▕         match ($stream['type']) {
    232▕             'request' => $this->requestInfo($stream, $verbosity),
    233▕             'throwable' => $this->throwableInfo($stream, $verbosity),
    234▕             'shutdown' => $this->shutdownInfo($stream, $verbosity),
    235▕             default => $this->info(json_encode($stream, $verbosity))

      +31 vendor frames 
  32  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
  • PHP Version: 8.1
  • Laravel Framework v8.68.1
  • Octane v1.0.16

@driesvints driesvints changed the title FIX: Undefined array key "type" on empty array dump Undefined array key "type" on empty array dump Nov 1, 2021
@driesvints driesvints changed the title Undefined array key "type" on empty array dump Fix undefined array key "type" on empty array dump Nov 1, 2021
@taylorotwell taylorotwell merged commit 07b55bf into laravel:1.x Nov 1, 2021
@nicoorfi
Copy link
Contributor Author

nicoorfi commented Nov 2, 2021

Just want to say a big thank you for this awsome package 🥇

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 this pull request may close these issues.

3 participants