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

[BUG] Cant install in Laravel v11.33.0 #81

Open
ayrtonandino opened this issue Nov 19, 2024 · 2 comments
Open

[BUG] Cant install in Laravel v11.33.0 #81

ayrtonandino opened this issue Nov 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ayrtonandino
Copy link
Contributor

What happened?

After composer update to Laravel v11.33.0 i got this error

@php artisan package:discover --ansi

  Symfony\Component\ErrorHandler\Error\FatalError

 Declaration of FumeApp\ModelTyper\Commands\ShowModelCommand::handle() must be compatible with Illuminate\Database\Console\ShowModelCommand::handle(Illuminate\Database\Eloquent\ModelInspector $modelInspector) at vendor\fumeapp\modeltyper\src\Commands\ShowModelCommand.php:31
    27▕
    28▕     /**
    29▕      * @override
    30▕      */
 ➜  31▕     public function handle()
    32▕     {
    33▕         // Override default console component factory to force parent command to return failed exit code on error.
    34▕         $this->components = new ErrorEmittingConsoleComponentFactory($this->components, $this->option('throw-exceptions')); // @phpstan-ignore-line
    35▕

looks like Laravel upgrade Illuminate\Database\Console\ShowModelCommand to extract its functionality to separate class in #53541

for now adding Illuminate\Database\Eloquent\ModelInspector to the handle method works just fine for install, command runs ok, dont know if this works ErrorEmittingConsoleComponentFactory

use Illuminate\Database\Eloquent\ModelInspector;


     /**
     * @override
     */
    public function handle(ModelInspector $modelInspector)
    {
        // Override default console component factory to force parent command to return failed exit code on error.
        $this->components = new ErrorEmittingConsoleComponentFactory($this->components, $this->option('throw-exceptions')); // @phpstan-ignore-line

        if ($this->option('custom-relationships')) {
            $customRelationships = collect(explode(',', $this->option('custom-relationships')))->map(fn($method) => trim($method));
            $this->relationMethods = array_merge($this->relationMethods, $customRelationships->toArray());
        }

        return parent::handle($modelInspector);
    }

Expected Behavior

No response

Steps To Reproduce

init new laravel >=11.33 project
install modeltyper
get composer error

@ayrtonandino ayrtonandino added the bug Something isn't working label Nov 19, 2024
@ayrtonandino
Copy link
Contributor Author

I think a new version V3 would be good, drop the old ModelInterface::class, drop laravel < 11.33, upgrade larastan@v3/phpstan@v2 and implement the new ModelInspector::class instead off overriding the base ShowModelCommand::class

@tcampbPPU
Copy link
Member

Thanks for reporting @ayrtonandino
I like the v3 idea! but its not something I can promise to get too soon, but feel free to PR something and I can review it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants