/**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     $name = strtr($class, '.', '\\');
     if (isset(\xp::$cl[$class])) {
         return $name;
     }
     // Load class
     \xp::$cl[$class] = nameof($this) . '://' . $this->path;
     \xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         unset(\xp::$cl[$class]);
         \xp::$cll--;
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($name, false) || interface_exists($name, false) || trait_exists($name, false)) {
             throw new ClassDependencyException($class, [$this], $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         throw new ClassLinkageException($class, [$this], $e);
     }
     \xp::$cll--;
     if (false === $r) {
         unset(\xp::$cl[$class]);
         $e = new ClassNotFoundException($class, [$this]);
         \xp::gc(__FILE__);
         throw $e;
     } else {
         if (!class_exists($name, false) && !interface_exists($name, false) && !trait_exists($name, false)) {
             $details = XPClass::detailsForClass($class);
             $uri = $this->classUri($class);
             unset(\xp::$cl[$class]);
             if (isset($details['class'])) {
                 $reflect = new \ReflectionClass($details['class'][DETAIL_ARGUMENTS]);
                 \xp::$errors[$uri][$reflect->getStartLine()] = ['' => 1];
                 $e = new ClassFormatException('File does not declare type `' . $class . '`, but `' . strtr($reflect->getName(), '\\', '.') . '`');
                 \xp::gc($uri);
                 throw $e;
             } else {
                 throw new ClassFormatException('Loading `' . $class . '`: No types declared in ' . $this->classUri($class));
             }
         }
     }
     method_exists($name, '__static') && (\xp::$cli[] = [$name, '__static']);
     if (0 === \xp::$cll) {
         $invocations = \xp::$cli;
         \xp::$cli = [];
         foreach ($invocations as $inv) {
             $inv($name);
         }
     }
     return $name;
 }
 public function canBeCachedViaXpRegistry()
 {
     with(xp::$registry['details.' . ($fixture = 'DummyDetails')] = $details = $this->dummyDetails());
     $actual = XPClass::detailsForClass($fixture);
     unset(xp::$registry['details.' . $fixture]);
     $this->assertEquals($details, $actual);
 }