Skip to content

Allow extending a class without calling parent::__construct #257

@GromNaN

Description

@GromNaN

Feature request

Some classes may have an optional constructor, but the strict rules requires the parent constructor to be called (RequireParentConstructCallRule)

We want to make it easy to extend the Symfony\Componant\Console\Command class, having dependencies injected in the constructor, without requiring a call to the parent constructor. We need to keep the Command::__constructor method for backward compatibility for setting the $name property (see symfony/symfony#59564)

Example: https://phpstan.org/r/9c33c972-d1c6-4608-80b7-990cbbfcc0f8

Ideally, a phpdoc annotation on Command::__constructor method would indicate that calling the constructor in child classes is optional.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions