/** * Try to load a class. * * @param string $className The class name. * * @param string $file The file where the class should be contained. * * @return bool */ private function tryLoadClass($className, $file) { if ($this->isLoaded($className)) { return true; } $this->logger->debug('Trying to load {class} (should be located in file {file}).', array('class' => $className, 'file' => $file)); try { $this->loader->loadClass($className); if (!$this->loader->isClassFromFile($className, $file)) { $this->logger->warning('{class} was loaded from {realFile} (should be located in file {file}).', array('class' => $className, 'file' => $file, 'realFile' => $this->loader->getFileDeclaringClass($className))); } return true; } catch (ClassNotFoundException $exception) { $this->logger->error('The autoloader could not load {class} (should be located in file {file}).', array('class' => $className, 'file' => $file)); } catch (\ErrorException $exception) { $this->logger->error('Loading class {class} failed with reason: {error}.', array('class' => $className, 'error' => $exception->getMessage())); } return false; }