optimize some unneeded casts (esp. when casting something to string for array access)
fix phpdoc and add typehints to private methods
merged branch Tobion/cast-optimization (PR #8201)

This PR was submitted for the 2.3 branch but it was merged into the master branch instead (closes #8201).

Discussion
----------

Cast optimization

bc break: no
test pass: yes

I searched for some unneeded casts esp. for `$array[(string) $stringOrInteger]`. But found only a few. When doing so I mainly fixed some phpdocs.

Commits
-------

2c41a31 [Serializer] fix phpdoc and add typehints to private methods
ebe7015 optimize some unneeded casts (esp. when casting something to string for array access)