-
-
Notifications
You must be signed in to change notification settings - Fork 407
[Renaming] Add RenameCastRector
#7117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Renaming] Add RenameCastRector
#7117
Conversation
Background: PHP 8.5 will most likely deprecate further non-standard casts, see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_non-standard_cast_names. In preparation, I already submitted a patch to Additional side information: I have already prepared locally quite a few branches for other changes from this deprecation RFC that are likely to pass. Please inform me whether I could already open PRs for them to signal to other contributors that they were already implemented and you can merge then whenever you want or do you want me to wait until a future point in time to open them? |
Why not rename that rule and make it configurable then? |
@calebdw Good question, that is a point I wanted to ask, too, but forgot. I do not know how rector handles BC with rector rules. Renaming the real cast rector could break existing code. It could be deprecated and the PHP 7.4 set could use this rector instead, I guess. |
final readonly class RenameCast | ||
{ | ||
public function __construct( | ||
/** @var class-string<Cast> */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether this is okay, to directly expose PHP parser class names in value objects. This avoids having to add a mapping layer between the value passed here and the cast class.
While there is already `RealToFloatTypeCastRector` to handle the deprecation of the `(real)` cast, this generalized rector rule will allow to configure the cast renaming and thus also support other types of cast renamings.
d0f9def
to
16b0c9d
Compare
Great idea, thank you 👍 Could you replace |
@TomasVotruba Yes, see #7136 |
While there is already
RealToFloatTypeCastRector
to handle the deprecation of the(real)
cast, this generalized rector rule will allow to configure the cast renaming and thus also support other types of cast renamings.