Nest files section inside file template

Since this all refers to a hook in the backend, how can I even debug this? The only thing that comes to mind is to write some values into custom debugging fields. Are there any better strategies? Sorry, still a noob when it comes to PHP development.