[5.0] Use Contracts As Typehints

Wherever possible, we should use the 

This is still work in progress. Some components (database, foundation, queue, routing) have not yet been reviewed. And some questions came up, which I'll have to tackle later.

I also want to see whether tests are now failing in some places.