Skip to content

Rector\SOLID\Rector\Class_\FinalizeClassesWithoutChildrenRector doesn't understands correctly classes hierarchy #2695

@Aerendir

Description

@Aerendir
Subject Details
Rector version 0.6.10
PHP version PHP 7.2

Current Behaviour

  *
  * @ORM\Embeddable
  */
-class Address implements AddressInterface
+final class Address implements AddressInterface
 {
     use ComplexValueObjectTrait {
         __construct as traitConstruct;
    ----------- end diff -----------

Applied rules:

 * Rector\SOLID\Rector\Class_\FinalizeClassesWithoutChildrenRector
 * Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector

Rector makes the class final also if it shouldn't.

I have no idea of how to create a test case about this as it seems it is covered by https://github.com/rectorphp/rector/blob/master/packages/SOLID/tests/Rector/Class_/FinalizeClassesWithoutChildrenRector/Fixture/fixture.php.inc

But actually it doesn't work.

How to reproduce the issue

As I'm not able to create a failing test case, to verify the bug it way simpler use the source code that cause the issue.

  1. Clone the repo https://github.com/Aerendir/PHPValueObjects
  2. composer install
  3. Open the file `rector.yaml``
  4. Uncomment the line 65 (the one that excludes the rector Rector\SOLID\Rector\Class_\FinalizeClassesWithoutChildrenRector)
  5. Run the command vendor/bin/rector process src/Address/Address.php

The bug appears.

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