Fix EZP-22143: Fix dead code and type hinting issues reported by SensioLabs Insight

https://jira.ez.no/browse/EZP-22143

See [report from SensioLabs Insight](https://insight.sensiolabs.com/projects/0885c0ce-4b9f-4b89-aa9c-e8f9f7a315e0/analyses/17)

## TODO
* [x] Fix dead code
* [ ] Fix object parameters type hint