Last active
March 2, 2024 21:50
-
-
Save connorhu/7d6690cc57b9d54cd224038ad0c5bc1c to your computer and use it in GitHub Desktop.
generate rector rule to rename google api client alias
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
#!/bin/sh | |
echo "<?php" > rector_rule.php | |
echo "return [" >> rector_rule.php | |
for file in $(grep ^class_alias vendor/google/ -R | cut -d: -f1); | |
do | |
echo " '$(cat $file | grep ^class_alias | cut -d\' -f2)' => '$(cat $file | grep ^namespace | cut -d" " -f2 | cut -d\; -f1)\\$(cat $file | grep ^class\ | cut -d" " -f2)',"; | |
done >> rector_rule.php | |
echo "];" >> rector_rule.php |
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
<?php | |
use Rector\Config\RectorConfig; | |
use Rector\Renaming\Rector\Name\RenameClassRector; | |
return function (RectorConfig $rectorConfig) { | |
$rectorConfig->ruleWithConfiguration(RenameClassRector::class, require_once "rector_rule.php"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment