rectorphp / swiss-knife

Swiss knife in pocket of every upgrade architect!
https://getrector.com
MIT License
72 stars 8 forks source link

[Question] Finalise only classes that have implements/extends? #10

Closed deoomen closed 5 months ago

deoomen commented 5 months ago

Hi!

Is there an option to only finalise classes that implement an interface or extend another class?

Like in FinalizeClassesWithoutChildrenRector.

-class FirstClass extends SecondClass
+final class FirstClass extends SecondClass
 {
 }

 class SecondClass
 {
 }

class ThirdClass
{
}

I don't want to change classes without extends/implements (ThirdClass).

TomasVotruba commented 5 months ago

Hi,

not at the moment. It could be an option --require-interface. Could you add it to the command to handle it?

deoomen commented 5 months ago

I tried:

vendor/bin/swiss-knife finalize-classes src --require-interface

but:

The "--require-interface" option does not exist.
TomasVotruba commented 5 months ago

We don't have that option.

Would you add it via PR?

deoomen commented 5 months ago

Oh, I misunderstood you, sorry.

I could try, but at the moment I have very little time after hours, so I don't know when it could be done.

Could you briefly describe what should be changed?

TomasVotruba commented 5 months ago

The option must be added in the configure() method, then processed in execute() method: https://github.com/rectorphp/swiss-knife/blob/main/src/Command/FinalizeClassesCommand.php#L38-L56

Feel free to send PR when your free :+1: Thank you

Closing as idea moved to PR phase