Skip to content

Instantly share code, notes, and snippets.

@jnduli
Created September 23, 2019 12:11
Show Gist options
  • Select an option

  • Save jnduli/b8d76fd0f976cd686eb719f4f6e3b1b5 to your computer and use it in GitHub Desktop.

Select an option

Save jnduli/b8d76fd0f976cd686eb719f4f6e3b1b5 to your computer and use it in GitHub Desktop.
This helps find unused or rarely used functions in a php project
## This script is used to check for unused or rarely used function in php
## It has been tested on a laravel project
## It outputs a list containing all functions plus number of occurences in the project
## It can be used together with sort e.g. php_unused_functions.sh | sort -h
for f in $(grep --exclude-dir=tests -rho -P '^.*public .*function .*(?=\()'| awk -F' ' '{print $NF}'); do
echo $(grep -ro $f * | wc -l) $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment