Code cleanup from PHPStan report

Problem/Motivation

Our tests with code sniffer and phpunit helped us a lot to get to a high quality code base. However, static code analysis uncovers another range of potential or real code issues, that should also be resolved and tested in both a PHP 7.4 and 8.1 environment.

Proposed resolution

Work through the attached report and clean everything up.

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information