Fix notices and using not-defined variables

i will plug php-cs-fixer in another PR then