detection for internal PHP classes fails for traits. This fixes it.

(cherry picked from commit c18eb4528b94f8a9ad265edfd122238e07091749)