Skip to content

Instantly share code, notes, and snippets.

@chx
Last active January 1, 2016 21:49
Show Gist options
  • Save chx/8206137 to your computer and use it in GitHub Desktop.
Save chx/8206137 to your computer and use it in GitHub Desktop.
How to find non-PSR0 classes
find path/to/dir -type f -name \*.php -exec awk -F ' ' '$1=="namespace" {namespace=substr($2, 1, length($2)-1); gsub("\\\\", "/", namespace);} /^(abstract|final)? *class/ {for (i=1;i<=NF;i++) if ($(i)=="class") namespaced=namespace "/" $(i+1) ; n = length(namespaced); if (namespaced != substr(FILENAME,length(FILENAME)-3-n,n)) print FILENAME " contains " namespaced } ' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment