Error: Call to a member function init() on null: Using $this when not in object context