Skip to content

Instantly share code, notes, and snippets.

@edmondscommerce
Created August 29, 2017 10:12
Show Gist options
  • Save edmondscommerce/5ea9a3d87e757574243509c628a0f584 to your computer and use it in GitHub Desktop.
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
#!/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