Skip to content

Instantly share code, notes, and snippets.

@connorhu
Last active March 2, 2024 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connorhu/7d6690cc57b9d54cd224038ad0c5bc1c to your computer and use it in GitHub Desktop.
Save connorhu/7d6690cc57b9d54cd224038ad0c5bc1c to your computer and use it in GitHub Desktop.
generate rector rule to rename google api client alias
#!/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
<?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