This complies with coding standards and best practices for security.
Note that this change is also covered in #3350588, which still needs work but deals with a number of other issues flagged by PHPCS.
Closes #3124353.