Skip to content

[DX] Split up typed property/method/param inferrer God classes  #6762

@TomasVotruba

Description

@TomasVotruba

Rules like TypedPropertyRector and PropertyTypeDeclarationRector do way too much. Also, the name is super unclear and overlapping.

Infering from 7 different places with different priorities, this result is often "not the best":

+/**
+ * @var DateTime|null
+ */
 public $dateTime;

 public fuction getDateTime(): DateTime|null
 {
     return $this->dateTime;
 }

This is technically correct, but based on strict return type, the property cannot be anything else than DateTime|null strict type.

Saying that, these should be separated to own rules, so developer can add them one by one. Also, we'll be able to control them without deep nesting. This already started with:

  • ParamTypeByParentCallTypeRector
  • ParamTypeFromStrictTypedPropertyRector
  • ReturnTypeFromReturnNewRector

etc.

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