Skip to content

StaticCallToMethodCallRector generates fatal PHP when parent declares final __construct #9766

Description

@maks-oleksyuk

Bug Report

StaticCallToMethodCallRector converts App::make() to constructor injection, but does not check whether the parent class has a final constructor. The with a fatal error:

Caution

Cannot override final method ParentClass::__construct()

Subject Details
Rector version 2.4.4

Minimal PHP Code Causing Issue

https://getrector.com/demo/39a9f663-825e-4594-a8f4-332655d63f16

Expected Behaviour

Rector should detect that the parent constructor is final and skip the transformation, leaving App::make() as-is (or reporting a notice that the rule cannot be applied).

Real-world Case

Filament v5 (https://github.com/filamentphp/filament) custom fields extend Filament\Forms\Components\Hidden (→ Field), which declares __construct as final. Any App::make() call inside such a field triggers this bug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions