Skip to content

Undefined variable $result in Container.php #58065

@frkcn

Description

@frkcn

Laravel Version

12.42.0

PHP Version

8.5.0

Database Driver & Version

MySQL 8.0.42

Description

When running php artisan schedule:run, an ErrorException: Undefined variable $result is thrown in Container.php.
The error occurs in the following code path:

if ($this->resolved($abstract)) {
    $this->rebound($abstract);
}

return $result;  // <-- $result is undefined

It appears that $result is being returned without being defined in certain code paths within the Container class.

Image

Steps To Reproduce

Run php artisan schedule:run (the exact trigger may vary)
The error is thrown from Illuminate\Container\Container.php

Stack Trace:
ErrorException: Undefined variable $result

vendor/laravel/framework/src/Illuminate/Container/Container.php
  in Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
Environment

Expected Behavior
The container method should properly initialize and return $result in all code paths without throwing an undefined variable error.
Additional Context
This error was captured in production via error monitoring. The breadcrumbs show:

artisan.command → Finished artisan command: schedule:run
The error triggers during the command execution lifecycle

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions