Moved the deprecate checks to the php functions file. This file should do all checks with the PHP parser to prevent things being looped twice.

Cleaned up some of the code, splitted up functions into a few ones.