Scripts: add instanceof syntax for import linter

This commit is contained in:
Franco Fichtner 2026-04-08 08:34:44 +02:00
parent 7cfb03be5d
commit 4f7fccd93e

View file

@ -34,7 +34,10 @@ fi
for FILE in $(find src -name "*.php"); do
for IMPORT in $(grep -iE 'use [a-z0-9_\\]+\\[^;\\]+;' ${FILE} | awk '{ print $2 }' | tr -d ';'); do
CLASS=${IMPORT##*\\}
if [ "$(grep -c -e "new ${CLASS}" -e "${CLASS}::" -e "extends ${CLASS}" ${FILE})" = "0" ]; then
if [ "$(grep -c -e "instanceof ${CLASS}" \
-e "new ${CLASS}" \
-e "${CLASS}::" \
-e "extends ${CLASS}" ${FILE})" = "0" ]; then
echo "${FILE}: warning: stale import \`${IMPORT}'"
fi
done