-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
rector: automatic code refactoring (part 1) #2879
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
Component: Api
PageRelates to Mage_Api
Component: Catalog
Relates to Mage_Catalog
Component: Core
Relates to Mage_Core
Component: lib/Mage
Relates to lib/Mage
Component: lib/*
Relates to lib/*
Component: Oauth
Relates to Mage_Oauth
phpstan
labels
Jan 1, 2023
github-actions
bot
added
Component: ImportExport
Relates to Mage_ImportExport
Component: PayPal
Relates to Mage_Paypal
labels
Jan 1, 2023
github-actions
bot
added
Component: Adminhtml
Relates to Mage_Adminhtml
Component: Sales
Relates to Mage_Sales
labels
Jan 1, 2023
github-actions
bot
added
the
Component: CatalogInventory
Relates to Mage_CatalogInventory
label
Jan 2, 2023
sreichel
changed the title
[wip] automatic code refactoring
rector: automatic code refactoring (part 1)
Jan 2, 2023
This error goes and comes ...
Cool stuff. But why are certain CI workflows being skipped? |
fballiano
approved these changes
Jan 2, 2023
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.
beautiful
Some checks run on schedule at the moment ... https://github.com/OpenMage/magento-lts/actions?query=event%3Aschedule |
elidrissidev
approved these changes
Jan 2, 2023
tmotyl
reviewed
Jan 2, 2023
app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Startdate.php
Show resolved
Hide resolved
fballiano
pushed a commit
that referenced
this pull request
Jan 3, 2023
* Add "never" return-type for methods that never return anything - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#returnnevertyperector * Updated phpstan.dist.baseline.neon * Added ddev rector command shortcut * Change array_push() to direct variable assign - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#changearraypushtoarrayassignrector * Replace array_keys() and in_array() to array_key_exists() - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#arraykeysandinarraytoarraykeyexistsrector * Use common != instead of less known <> with same meaning - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#commonnotequalrector * Issue in rector found ...reverted - see rectorphp/rector#7699 * Updated phpstan.dist.baseline.neon * Change compact() call to own array - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#compacttovariablesrector * Change OR, AND to ||, && with more common understanding - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#logicaltobooleanrector * Replace the Double not operator (!!) by type-casting to boolean - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#replacemultiplebooleannotrector * Simplify array_search to in_array - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#simplifyarraysearchrector * Changes compared to value and return of expr to direct return - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#simplifyifexactvaluereturnvaluerector * Updated phpstan.dist.baseline.neon This error goes and comes ... * Changes strlen comparison to 0 to direct empty string compare - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#strlenzerotoidenticalemptystringrector * Simplify conditions - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#simplifyconditionsrector * Simplify tautology ternary to value - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#simplifytautologyternaryrector * Splits [$a, $b] = [5, 10] scalar assign to standalone lines - see https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#splitlistassigntoseparatelinerector
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: Adminhtml
Relates to Mage_Adminhtml
Component: Api
PageRelates to Mage_Api
Component: Catalog
Relates to Mage_Catalog
Component: CatalogInventory
Relates to Mage_CatalogInventory
Component: Core
Relates to Mage_Core
Component: Dataflow
Relates to Mage_Dataflow
Component: Downloadable
Relates to Mage_Downloadable
Component: Eav
Relates to Mage_Eav
Component: ImportExport
Relates to Mage_ImportExport
Component: lib/Mage
Relates to lib/Mage
Component: lib/Varien
Relates to lib/Varien
Component: lib/*
Relates to lib/*
Component: Oauth
Relates to Mage_Oauth
Component: PayPal
Relates to Mage_Paypal
Component: Sales
Relates to Mage_Sales
phpstan
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
We had a lot of code-style improvements made manually (or with help of phpstorm in my case). E.g. Tenery operators. A lot of changes were only made when the file has been touched for some other reason.
Why not automate this and fix all occourences?
I had time to test rector and i am positively surprised!
I tried ~50 rules step by step and ... there is not soo much to change. (stopped with ~500 changed files ... incl. lib)
Manual testing scenarios (*)
composer require --dev sreichel/openmage-rector
cp -n vendor/sreichel/openmage-rector/rector.php rector.php
php vendor/bin/rector process <path-to-files> --dry-run
Note: running w/o path (whole project) takes some memory.
Questions or comments
Contribution checklist (*)