Fix 'function declaration in loop' scrutinizer errors.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Update PHPDoc and remove useless variables and methods to fix scrutinizer errors.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Merge pull request #1240 from Tithugues/scrutinizer

Fix some Scrutinizer issues