stable

Clone or download

Read-only

chore: Convert SvnPlugin to attribute based hook listening

This contribution introduce the usage of rector[0] to automate refactorings. Instead of doing the tedious and error prone job of doing the conversion of addHook() calls to attributes, a rector rule does the transformation on our behalf. The transformation itself can be reviewed with the provided test file for the rule. SvnPlugin was bit tied up after the automated transformation because there are some changes that seemed a bit to hard to automate but easily done in IDE (like removing the comments after the method call or dealing with uses). Rector command can be run this way: ```bash ./src/vendor/bin/rector --config=tools/utils/rector.php process --clear-cache -- plugins/svn/include/svnPlugin.php ``` Not all transformations are covered yet (it only take hooks in __construct right now). Future contributions will improve the process. [0]: https://github.com/rectorphp/rector Part of: request #31113 Simplify hook listening for plugins Change-Id: I7e63e4d335386350d45c9c54a5b20fd579bccfb6

Modified Files

Name
M plugins/svn/include/svnPlugin.php +65 −96 Go to diff View file
M src/composer.json +3 −1 Go to diff View file
M src/composer.lock +121 −1 Go to diff View file
A tests/unit/TuleapDev/Rector/ConvertAddHookToAttributesRuleTest.php +66 −0 Go to diff View file
A tests/unit/TuleapDev/Rector/_fixtures/plugin-with-add-hook-calls.php.inc +138 −0 Go to diff View file
A tests/unit/TuleapDev/Rector/config/configured_rule.php +29 −0 Go to diff View file
A tools/utils/Rector/CallbackAndAttribute.php +52 −0 Go to diff View file
A tools/utils/Rector/CallbackAndAttributeClass.php +38 −0 Go to diff View file
A tools/utils/Rector/CallbackAndAttributeName.php +48 −0 Go to diff View file
A tools/utils/Rector/ConvertAddHookToAttributesRule.php +215 −0 Go to diff View file
A tools/utils/rector.php +29 −0 Go to diff View file