somehwat working schema generator

This still needs load of work, for the time being we will probably hack
the schema after it is generated.

To get this down to something sane I might end up not generating the
json with twig. I still need to find a sane pretty printer to i can write it
in a commitable fashion though.
php-cs fixes
code hinting fixes
duplication refactor