Fix phpdoc and function scope