Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. # For those who has big projects with many classes named as "Object"
  2. # migration to PHP 7.2 or above may be very painful. This script for the rescue
  3.  
  4. # Author: Denis Boulas
  5.  
  6. # Path to your repository
  7. BASEDIR=/path/to/codebase
  8.  
  9.  
  10. # Rename files in batch
  11. find $BASEDIR -type f -name 'Object.php' |
  12. while IFS= read file_name; do
  13. DIR=$(dirname $file_name)
  14. mv "$file_name" "${DIR}/BaseObject.php"
  15. done
  16.  
  17. # Rewrite contents
  18. find $BASEDIR -type f -name '*.php' |
  19. while IFS= read file_name; do
  20. sed -i \
  21. -e 's;class[[:blank:]]*Object\([[:blank:]]*\|$\);class BaseObject\1;g' \
  22. -e 's;\/Object.php;/BaseObject.php;g' \
  23. -e 's;\(\/\|\\\)Object\(\\\|[[:blank:]]*\|$\);\1BaseObject\2;g' \
  24. -e 's;BaseBaseObject;BaseObject;g' \
  25. "$file_name"
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement