Code Monkey home page Code Monkey logo

Comments (3)

scheb avatar scheb commented on June 12, 2024

Feature released with v1.2.0

from tombstone.

0nedark avatar 0nedark commented on June 12, 2024

@scheb I've tried to use this the other day and I found an issue that makes this unusable. The custom analyzer is initialised through the constructor $logReader = $reflectionClass->newInstance(); instead of static create function that is used to initialise built in AnalyzerLogProvider. The issue is that this way the custom analyzer does not have access to the output writer or the config, making it, I think, impossible to create any reports. I suggest the following change to resolve this issue.

    private function createLogCollector(array $config, VampireIndex $vampireIndex): LogCollector
    {
        $logProviders = [];
        if (isset($config['logs']['directory'])) {
            $logProviders[] = AnalyzerLogProvider::create($config, $this->output);
        }
        if (isset($config['logs']['custom'])) {
            if (isset($config['logs']['custom']['file'])) {
                /** @psalm-suppress UnresolvableInclude */
                require_once $config['logs']['custom']['file'];
            }

            $className = $config['logs']['custom']['class'];
            $reflectionClass = new \ReflectionClass($className);
            if (!$reflectionClass->implementsInterface(LogProviderInterface::class)) {
                throw new \Exception(sprintf('Class %s must implement %s', $className, LogProviderInterface::class));
            }

            /** @var LogProviderInterface $logReader */
            $logReader = $className::create($config, $this->output);

            $logProviders[] = $logReader;
        }

        return new LogCollector($logProviders, $vampireIndex);
    }

from tombstone.

scheb avatar scheb commented on June 12, 2024

My bad, I reused some older code and didn't realize the class was instantiated differently. Fix released as v1.2.1.

from tombstone.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.