Created
August 29, 2017 10:12
-
-
Save edmondscommerce/5ea9a3d87e757574243509c628a0f584 to your computer and use it in GitHub Desktop.
A bash script to allow you to easily set any missing declare(strict_types) in PHP files
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
#!/usr/bin/env bash | |
echo " | |
Setting Strict Types If It's Missing | |
------------------------------------- | |
" | |
for f in $(grep -r -L 'strict_types' $projectRoot/src); | |
do | |
echo "Found file with no strict types:" | |
echo $f; | |
echo | |
read -p "Would you like to fix? " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
sed -i 's/<?php/<\?php declare(strict_types=1);/g' $f; | |
echo "fixed $f" | |
else | |
echo "skipped $f" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment