-
-
Notifications
You must be signed in to change notification settings - Fork 407
[Core] Add Option::ALLOW_BC_BREAK option via --allow-bc-break #1744
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
Conversation
implemented 🎉 applied the example use case to |
All checks have passed 🎉 @TomasVotruba it is ready for review. |
I'm not sure about usefulness of this change, as any rule can be potentially BC break. Just 99.99 % cases isn't. We would have to introduce huge level of complexity to maintain it to be reliable enough to be true. Otherwise it will loose trust and make it irrelevant. Same thing happened to PHP CS Fixer, where not-risky rules are breaking code and are not reliable. İt should bee solved on rule level. |
The BC-Break only applied when using I add its check https://github.com/rectorphp/rector-src/pull/1744/files#diff-cbdd57028cbf699819fb6adde8248728f712c6e75d0640239e089b5a1b73b8e8 before last checking for private and protected property only. Other previously skipped check verify still apply, eg: on interface, modified by trait, etc. I think it is usefull for an application/library that requires a BC break major change, eg from version 1 to version 2. Do you think the alternative is create a separate namespace like in original issue, eg: |
I understand the feature. Yet which is the complete list that are enabled/disabled by this flag, that is the hard question. The BC breaks should be avoided unless intentional on package upgrade. Maybe this can be resolved on already existing level without marking each of ~600 rules as BC break/non BC break. As for the typed property example, what change in code is needed? |
Previously, before rector 0.12.9, eg on rector 0.12.8, there are 2 options: rector-src/rules/Php74/Rector/Property/TypedPropertyRector.php Lines 65 to 71 in 528d6dd
which when user want to only update the code to update private property only, they can enable it via set in rector.php: $services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class)
->call('configure', [[
TypedPropertyRector::PRIVATE_PROPERTY_ONLY => true,
]]); Start from 0.12.9, – private property which make user that want to upgrade the code for other modifiers except above is not possible. |
Closing as separate rule is a better way: #1745 (comment) |
Fixes rectorphp/rector#6872
So it can be used in the rules to be used to upgrade application, eg: on
TypedPropertyRector
, using:to update non-private property as well.