ClassNotFoundErrorEnhancer example

/** * Override this method if you want to define more error enhancers. * * @return ErrorEnhancerInterface[] */
    protected function getErrorEnhancers(): iterable
    {
        return [
            new UndefinedFunctionErrorEnhancer(),
            new UndefinedMethodErrorEnhancer(),
            new ClassNotFoundErrorEnhancer(),
        ];
    }

    /** * Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader. */
    private function cleanTrace(array $backtrace, int $type, string &$file, int &$line, bool $throw): array
    {
        $lightTrace = $backtrace;

        for ($i = 0; isset($backtrace[$i]); ++$i) {
            

        try {
            if ($autoloader) {
                // Unregister all autoloaders to ensure the custom provided                 // autoloader is the only one to be used during the test run.                 $autoloaders = spl_autoload_functions();
                array_map('spl_autoload_unregister', $autoloaders);
                spl_autoload_register($autoloader);
            }

            $expectedLine = __LINE__ + 1;
            $error = (new ClassNotFoundErrorEnhancer())->enhance(new \Error($originalMessage));
        } finally {
            if ($autoloader) {
                spl_autoload_unregister($autoloader);
                array_map('spl_autoload_register', $autoloaders);
            }
        }

        $this->assertInstanceOf(ClassNotFoundError::class$error);
        $this->assertSame($enhancedMessage$error->getMessage());
        $this->assertSame(realpath(__FILE__)$error->getFile());
        $this->assertSame($expectedLine$error->getLine());
    }
/** * Override this method if you want to define more error enhancers. * * @return ErrorEnhancerInterface[] */
    protected function getErrorEnhancers(): iterable
    {
        return [
            new UndefinedFunctionErrorEnhancer(),
            new UndefinedMethodErrorEnhancer(),
            new ClassNotFoundErrorEnhancer(),
        ];
    }

    /** * Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader. */
    private function cleanTrace(array $backtrace, int $type, string &$file, int &$line, bool $throw): array
    {
        $lightTrace = $backtrace;

        for ($i = 0; isset($backtrace[$i]); ++$i) {
            
Home | Imprint | This part of the site doesn't use cookies.