Add return typehints to protected test helper methods

Created on 18 June 2024, 12 days ago
Updated 24 June 2024, 6 days ago

Problem/Motivation

While reviewing 📌 Add void return typehints to all test methods Active , we noticed a number of protected helper methods that are not receiving return typehints as part of the scope of the issue.

Proposed resolution

  • Add return typehints to all protected helper methods, starting with those that return void. Needs child issue.
  • Add additional child issues as appropriate.
  • As a possible followup, also consider renaming those that are named testSomethingSomething() to a less-confusing naming pattern, like the more common assertSomethingSomething() (since they aren't actually test methods, just helpers).

Child issues:

Remaining tasks

Use particular attention/care when addressing UpdatePathTestBase:: testDatabaseLoaded() since it's a part of a very important and highly structured test base class.

API changes

Protected test helper methods get return typehints.

Release notes snippet

TBD

🌱 Plan
Status

Active

Version

11.0 🔥

Component
PHPUnit  →

Last updated about 18 hours ago

Created by

🇺🇸United States xjm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @xjm
  • 🇺🇸United States xjm
  • 🇦🇺Australia mstrelan

    We could simplify this by using existing rector rules and create child issues that target one or more of these per issue. The relevant rules are listed in \Rector\Config\Level\TypeDeclarationLevel::RULES and I've identified the following as possibly relevant.

    void:

    • AddVoidReturnTypeWhereNoReturnRector

    bool:

    • ReturnTypeFromStrictBoolReturnExprRector
    • BoolReturnTypeFromStrictScalarReturnsRector

    array:

    • ReturnTypeFromStrictNewArrayRector
    • ReturnTypeFromReturnDirectArrayRector

    The downfall is where rector determines the return type based on Other Things, one rule may end up with multiple return types.

    • NumericReturnTypeFromStrictScalarReturnsRector
    • ReturnTypeFromStrictConstantReturnRector
    • ReturnTypeFromStrictTernaryRector
    • ReturnTypeFromStrictScalarReturnExprRector
    • ReturnTypeFromReturnNewRector
    • ReturnTypeFromReturnCastRector
    • ReturnTypeFromSymfonySerializerRector
    • ReturnTypeFromStrictTypedPropertyRector
    • AddReturnTypeDeclarationFromYieldsRector
    • ReturnTypeFromStrictNativeCallRector
    • ReturnTypeFromStrictTypedCallRector
    • ReturnUnionTypeRector
    • ReturnTypeFromStrictParamRector
    • AddReturnTypeDeclarationBasedOnParentClassMethodRector
    • ReturnTypeFromStrictFluentReturnRector
    • ReturnNeverTypeRector
  • 🇦🇺Australia mstrelan
  • 🇦🇺Australia mstrelan
Production build 0.69.0 2024