~~~
if (class_exists($className, false) || interface_exists($className, false) ||
   function_exists('trait_exists') && trait_exists($className, false)) {
~~~

Remove the static variable as the check will affect ALL autoloading. 
Putting the check as above, it only affects trait autoloading.