Build a metric calculator with a sub-set of mutators

@param MutantProcessInterface[] $mutantProcesses

@return MetricsCalculator
334340
public static function createFromArray(array $mutantProcesses): self
    {
        $self = new self();

        foreach ($mutantProcesses as $process) {
            $self->collect($process);
        }

        return $self;
    }
57562
private function createRuler($methods, $paths): RulerInterface
    {
        if (!is_array($methods)) {
            $methods = [$methods];
        }
        if (!is_array($paths)) {
            $paths = [$paths];
        }
        return new Ruler($paths, null, $methods);
    }
1109727
public function usingPaginatorIfPaged(): TransformationFactory
	{
		if ($this->resource instanceof Collection && $this->entity instanceof LengthAwarePaginator) {
			return $this->usingPaginator();
		}

		return $this;
	}
1316115
public function setProcessorParameters(TransformationObject $transformation, $proc)
    {
        foreach ($this->xsl_variables as $key => $variable) {
            // XSL does not allow both single and double quotes in a string
            if ((strpos($variable, '"') !== false)
                && ((strpos($variable, "'") !== false))
            ) {
                $this->logger->warning(
                    'XSLT does not allow both double and single quotes in '
                    . 'a variable; transforming single quotes to a character '
                    . 'encoded version in variable: ' . $key
                );
                $variable = str_replace("'", '&#39;', $variable);
            }

            $proc->setParameter('', $key, $variable);
        }

        // add / overwrite the parameters with those defined in the
        // transformation entry
        $parameters = $transformation->getParameters();
        if (isset($parameters['variables'])) {
            /** @var \DOMElement $variable */
            foreach ($parameters['variables'] as $key => $value) {
                $proc->setParameter('', $key, $value);
            }
        }
    }
251768
protected function _methodMetrics($node, $metrics)
    {
        if ($node->type !== 'function' || $node->isClosure) {
            return $metrics;
        }
        $metrics['methods'] = 1;
        if ($metrics['cloc']) {
            $metrics['cmethods'] = 1;
        }

        $metrics['line']['start'] = $node->lines['start'];
        $metrics['line']['stop'] = $node->lines['stop'];
        return $metrics;
    }
893688
public static function get()
    {
        $cache = Cache::getTransientCache();
        $cacheKey = CacheId::siteAware('MetricsList');

        if ($cache->contains($cacheKey)) {
            return $cache->fetch($cacheKey);
        }

        $list = new static;

        /**
         * Triggered to add new metrics that cannot be picked up automatically by the platform.
         * This is useful if the plugin allows a user to create metrics dynamically. For example
         * CustomDimensions or CustomVariables.
         *
         * **Example**
         *
         *     public function addMetric(&$list)
         *     {
         *         $list->addMetric(new MyCustomMetric());
         *     }
         *
         * @param MetricsList $list An instance of the MetricsList. You can add metrics to the list this way.
         */
        Piwik::postEvent('Metric.addMetrics', array($list));

        $dimensions = Dimension::getAllDimensions();
        foreach ($dimensions as $dimension) {
            $factory = new DimensionMetricFactory($dimension);
            $dimension->configureMetrics($list, $factory);
        }

        $computedFactory = new ComputedMetricFactory($list);

        /**
         * Triggered to add new metrics that cannot be picked up automatically by the platform.
         * This is useful if the plugin allows a user to create metrics dynamically. For example
         * CustomDimensions or CustomVariables.
         *
         * **Example**
         *
         *     public function addMetric(&$list)
         *     {
         *         $list->addMetric(new MyCustomMetric());
         *     }
         *
         * @param MetricsList $list An instance of the MetricsList. You can add metrics to the list this way.
         */
        Piwik::postEvent('Metric.addComputedMetrics', array($list, $computedFactory));

        /**
         * Triggered to filter metrics.
         *
         * **Example**
         *
         *     public function removeMetrics(Piwik\Columns\MetricsList $list)
         *     {
         *         $list->remove($category='General_Visits'); // remove all metrics having this category
         *     }
         *
         * @param MetricsList $list An instance of the MetricsList. You can change the list of metrics this way.
         */
        Piwik::postEvent('Metric.filterMetrics', array($list));

        $availableMetrics = array();
        foreach ($list->getMetrics() as $metric) {
            $availableMetrics[] = $metric->getName();
        }

        foreach ($list->metrics as $index => $metric) {
            if ($metric instanceof ProcessedMetric) {
                $depMetrics = $metric->getDependentMetrics();
                if (is_array($depMetrics)) {
                    foreach ($depMetrics as $depMetric) {
                        if (!in_array($depMetric, $availableMetrics, $strict = true)) {
                            unset($list->metrics[$index]); // not resolvable metric
                        }
                    }
                }
            }
        }

        $cache->save($cacheKey, $list);

        return $list;
    }
65349
protected function buildProcessHandlers($processReferences, $container, $processHandlerClass)
    {
        foreach ($processReferences as $processName => $processReference) {
            $definition = new Definition($processHandlerClass, array(
                new Reference(sprintf('lexik_workflow.process.%s', $processName)),
                new Reference('lexik_workflow.model_storage'),
                new Reference('event_dispatcher'),
            ));

            $definition->addMethodCall('setAuthorizationChecker', array(new Reference('security.authorization_checker')));

            $container->setDefinition(sprintf('lexik_workflow.handler.%s', $processName), $definition);
        }
    }
1251021
public function createProcess(ProcessFactoryInterface $processFactory): Process
    {
        return $processFactory->createProcess($this->name, $this->arguments);
    }
120350
public function CloneInstance()
	{
		$result = new InstanceFactsIterator( $this->context );
		$result->nonNilOnly = $this->nonNilOnly;
		$result->iterator = $this->iterator->CloneInstance();
		$result->substitutionGroups = $this->substitutionGroups;
		$result->Reset();
		return $result;
	}
1134232
public function probePhpCsFixer()
    {
        $execFinder = new ExecutableFinder();
        $execFinder->setSuffixes(['.bat', '.cmd', '.sh', '']);

        $fixer = $execFinder->find('php-cs-fixer', 'php-cs-fixer');

        $builder = new ProcessBuilder([$fixer, '--version']);
        $builder
            ->setWorkingDirectory(getcwd())
            ->setTimeout(3600)
        ;

        $process = $builder->getProcess();
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException('Please install php-cs-fixer');
        }

        return $fixer;
    }
366933
def _psutil_config_to_stats(self, instance):
        
        process_metrics = instance.get('process_metrics', self.init_config.get('process_metrics', None))
        if not process_metrics:
            self.log.error('No metrics configured for AgentMetrics check!')
            return {}

        methods, metric_types = zip(
            *[(p['name'], p.get('type', GAUGE))
                for p in process_metrics if _is_affirmative(p.get('active'))]
        )

        names_to_metric_types = {}
        for i, m in enumerate(methods):
            names_to_metric_types[AgentMetrics._get_statistic_name_from_method(m)] = metric_types[i]

        stats = AgentMetrics._collect_internal_stats(methods)
        return stats, names_to_metric_types
985460
public function buildRuntimeSequence(): Sequence
    {
        $sequence = $this->buildEssentialsSequence('runtime');
        $sequence->addStep(new Step('neos.flow:objectmanagement:proxyclasses', [Scripts::class, 'initializeProxyClasses']), 'neos.flow:systemlogger');
        $sequence->addStep(new Step('neos.flow:classloader:cache', [Scripts::class, 'initializeClassLoaderClassesCache']), 'neos.flow:objectmanagement:proxyclasses');
        $sequence->addStep(new Step('neos.flow:objectmanagement:runtime', [Scripts::class, 'initializeObjectManager']), 'neos.flow:classloader:cache');

        if (!$this->context->isProduction()) {
            $sequence->addStep(new Step('neos.flow:systemfilemonitor', [Scripts::class, 'initializeSystemFileMonitor']), 'neos.flow:objectmanagement:runtime');
            $sequence->addStep(new Step('neos.flow:objectmanagement:recompile', [Scripts::class, 'recompileClasses']), 'neos.flow:systemfilemonitor');
        }

        $sequence->addStep(new Step('neos.flow:reflectionservice:factory', [Scripts::class, 'initializeReflectionServiceFactory']), 'neos.flow:objectmanagement:runtime');
        $sequence->addStep(new Step('neos.flow:resources', [Scripts::class, 'initializeResources']), 'neos.flow:reflectionservice:factory');
        return $sequence;
    }
814787
public function generateProcessProxy($arguments = array())
    {
        if (!$this->isProxyLoaded()) {
            $this->loadProxyClass();
        }

        $reflect = new ReflectionClass($this->proxyClass);

        return $reflect->newInstanceArgs($arguments);
    }
805292
public function getProcess()
    {
        $parentClass = get_parent_class($this);
        $this_prefix = \Closure::bind(function(ProcessBuilder $builder){return $builder->prefix;}, null, $parentClass);
        $this_prefix = $this_prefix($this);
        $this_arguments = \Closure::bind(function(ProcessBuilder $builder){return $builder->arguments;}, null, $parentClass);
        $this_arguments = $this_arguments($this);
        $this_options = \Closure::bind(function(ProcessBuilder $builder){return $builder->options;}, null, $parentClass);
        $this_options = $this_options($this);
        $this_inheritEnv = \Closure::bind(function(ProcessBuilder $builder){return $builder->inheritEnv;}, null, $parentClass);
        $this_inheritEnv = $this_inheritEnv($this);
        $this_env = \Closure::bind(function(ProcessBuilder $builder){return $builder->env;}, null, $parentClass);
        $this_env = $this_env($this);
        $this_cwd = \Closure::bind(function(ProcessBuilder $builder){return $builder->cwd;}, null, $parentClass);
        $this_cwd = $this_cwd($this);
        $this_input = \Closure::bind(function(ProcessBuilder $builder){return $builder->input;}, null, $parentClass);
        $this_input = $this_input($this);
        $this_timeout = \Closure::bind(function(ProcessBuilder $builder){return $builder->timeout;}, null, $parentClass);
        $this_timeout = $this_timeout($this);
        $this_outputDisabled = \Closure::bind(function(ProcessBuilder $builder){return $builder->outputDisabled;}, null, $parentClass);
        $this_outputDisabled = $this_outputDisabled($this);

        if (0 === count($this_prefix) && 0 === count($this_arguments)) {
            throw new LogicException('You must add() command arguments before calling getProcess().');
        }

        $options = $this_options;

        $arguments = array_merge($this_prefix, $this_arguments);
        $script = implode(' ', array_map(array('Symfony\\Component\\Process\\ProcessUtils', 'escapeArgument'), $arguments));

        if ($this_inheritEnv) {
            // include $_ENV for BC purposes
            $env = array_replace($_ENV, $_SERVER, $this_env);
        } else {
            $env = $this_env;
        }

        $process = new Process($script, $this_cwd, $env, $this_input, $this_timeout, $options);

        if ($this_outputDisabled) {
            $process->disableOutput();
        }

        return $process;
    }
969478
protected function prepareProcessors()
    {
        usort($this->processors, function (ProcessorInterface $one, ProcessorInterface $two) {
            if ($one->getPriority() == $two->getPriority()) {
                return 0;
            }

            return $one->getPriority() < $two->getPriority() ? 1 : -1;
        });
    }
52101
private function generateVariablesByProdutosIterator(Iterator $iterator, $quantidadeColunas = 3)
    {
        $retorno = array();
        $coluna = 1;
        foreach ($iterator as $produto) {
            $retorno['coluna'.$coluna][] = $produto->toArray();
            $coluna++;
            if ($coluna > $quantidadeColunas) {
                $coluna = 1;
            }
        }
        $this->variables['produtos'] = $retorno;
    }
654197
private static function addCompilerPasses(ContainerBuilder $container, array $passes)
    {
        foreach ($passes as $passClass => $options) {
            if (!class_exists($passClass)) {
                throw new RuntimeException("Symfony DI CompilerPass not found: \"${passClass}\"");
            }

            $pass = new $passClass;
            $type = $options['type'] ?? PassConfig::TYPE_BEFORE_OPTIMIZATION;
            $priority = $options['priority'] ?? 1000;

            $container->addCompilerPass($pass, $type, $priority);
        }
    }