[TASK] Check lightweight cases before class_exists if possible

If other checks like "in_array" can be done first that are more
lightweight than calling class_exists and potentially causing
(multiple) autoloaders (without success) to search for files.

Resolves: #50494
Releases 6.2

Change-Id: I9b2010c09591fd02eefdc57f869edd80d4106e14
Reviewed-on: https://review.typo3.org/22627
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters