public function warmUp(): void
    {
        $options = $this->aspectKernel->getOptions();

        if (empty($options['cacheDir'])) {
            throw new InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
        }

        $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
        $iterator   = $enumerator->enumerate();
        $total      = iterator_count($iterator);

        $this->output->writeln(sprintf('Total <info>%s</info> files to process.', $total));
        $this->output->writeln('');
        $iterator->rewind();

        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
            throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
        });

        $errors = [];

        $displayException = function (Throwable $exception, string $path) use (&$errors) {
            $this->output->writeln(sprintf('<fg=white;bg=red;options=bold>[ERR]</>: %s', $path));
            $errors[$path] = $exception->getMessage();
        };

        foreach ($iterator as $file) {
            $path = $file->getRealPath();

            try {
                // This will trigger creation of cache
                file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ .
                    SourceTransformingLoader::FILTER_IDENTIFIER .
                    '/resource=' . $path
                );

                $this->output->writeln(sprintf('<fg=green;options=bold>[OK]</>: <comment>%s</comment>', $path));
            } catch (Throwable $e) {
                $displayException($e, $path);
            }
        }

        restore_error_handler();

        if ($this->output->isVerbose()) {
            foreach ($errors as $path => $error) {
                $this->output->writeln(sprintf('<fg=white;bg=red;options=bold>[ERR]</>: File "%s" is not processed correctly due to exception: "%s".', $path, $error));
            }
        }

        $this->output->writeln('');
        $this->output->writeln(sprintf('<fg=green;>[DONE]</>: Total processed %s, %s errors.', $total, count($errors)));
    }
public function warmUp(): void
    {
        $options = $this->aspectKernel->getOptions();

        if (empty($options['cacheDir'])) {
            throw new InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
        }

        $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
        $iterator   = $enumerator->enumerate();
        $total      = iterator_count($iterator);

        $this->output->writeln(sprintf('Total <info>%s</info> files to process.', $total));
        $this->output->writeln('');
        $iterator->rewind();

        set_error_handler(function ($errno, $errstr, $errfile, $errline) {
            throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
        });

        $errors = [];

        $displayException = function (Throwable $exception, string $path) use (&$errors) {
            $this->output->writeln(sprintf('<fg=white;bg=red;options=bold>[ERR]</>: %s', $path));
            $errors[$path] = $exception->getMessage();
        };

        foreach ($iterator as $file) {
            $path = $file->getRealPath();

            try {
                // This will trigger creation of cache
                file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ .
                    SourceTransformingLoader::FILTER_IDENTIFIER .
                    '/resource=' . $path
                );

                $this->output->writeln(sprintf('<fg=green;options=bold>[OK]</>: <comment>%s</comment>', $path));
            } catch (Throwable $e) {
                $displayException($e, $path);
            }
        }

        restore_error_handler();

        if ($this->output->isVerbose()) {
            foreach ($errors as $path => $error) {
                $this->output->writeln(sprintf('<fg=white;bg=red;options=bold>[ERR]</>: File "%s" is not processed correctly due to exception: "%s".', $path, $error));
            }
        }

        $this->output->writeln('');
        $this->output->writeln(sprintf('<fg=green;>[DONE]</>: Total processed %s, %s errors.', $total, count($errors)));
    }
public function warmUp ( ) : void { $ options = $ this -> aspectKernel -> getOptions ( ) ; if ( empty ( $ options [ 'cacheDir' ] ) ) { throw new InvalidArgumentException ( 'Cache warmer require the `cacheDir` options to be configured' ) ; } $ enumerator = new Enumerator ( $ options [ 'appDir' ] , $ options [ 'includePaths' ] , $ options [ 'excludePaths' ] ) ; $ iterator = $ enumerator -> enumerate ( ) ; $ total = iterator_count ( $ iterator ) ; $ this -> output -> writeln ( sprintf ( 'Total <info>%s</info> files to process.' , $ total ) ) ; $ this -> output -> writeln ( '' ) ; $ iterator -> rewind ( ) ; set_error_handler ( function ( $ errno , $ errstr , $ errfile , $ errline ) { throw new ErrorException ( $ errstr , $ errno , 0 , $ errfile , $ errline ) ; } ) ; $ errors = [ ] ; $ displayException = function ( Throwable $ exception , string $ path ) use ( & $ errors ) { $ this -> output -> writeln ( sprintf ( '<fg=white;bg=red;options=bold>[ERR]</>: %s' , $ path ) ) ; $ errors [ $ path ] = $ exception -> getMessage ( ) ; } ; foreach ( $ iterator as $ file ) { $ path = $ file -> getRealPath ( ) ; try { // This will trigger creation of cache file_get_contents ( FilterInjectorTransformer :: PHP_FILTER_READ . SourceTransformingLoader :: FILTER_IDENTIFIER . '/resource=' . $ path ) ; $ this -> output -> writeln ( sprintf ( '<fg=green;options=bold>[OK]</>: <comment>%s</comment>' , $ path ) ) ; } catch ( Throwable $ e ) { $ displayException ( $ e , $ path ) ; } } restore_error_handler ( ) ; if ( $ this -> output -> isVerbose ( ) ) { foreach ( $ errors as $ path => $ error ) { $ this -> output -> writeln ( sprintf ( '<fg=white;bg=red;options=bold>[ERR]</>: File "%s" is not processed correctly due to exception: "%s".' , $ path , $ error ) ) ; } } $ this -> output -> writeln ( '' ) ; $ this -> output -> writeln ( sprintf ( '<fg=green;>[DONE]</>: Total processed %s, %s errors.' , $ total , count ( $ errors ) ) ) ; }
Warms up cache
Warms up cache