<commit_before><?php

namespace Scientist;

use Scientist\Matchers\Matcher;

/**
 * Class Intern
 *
 * Interns do all the hard work, naturally. They'll execute an experiment within
 * the Laboratory, and record the results.
 *
 * @package \Scientist
 */
class Intern
{
    /**
     * Run an experiment, and retrieve the result.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return \Scientist\Report
     */
    public function run(Experiment $experiment)
    {
        $control = $this->runControl($experiment);
        $trials  = $this->runTrials($experiment);

        $this->determineMatches($experiment->getMatcher(), $control, $trials);

        return new Report($experiment->getName(), $control, $trials);
    }

    /**
     * Run the control callback, and record its execution state.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return \Scientist\Result
     */
    protected function runControl(Experiment $experiment)
    {
        return (new Machine($experiment->getControl(), $experiment->getParams()))->execute();
    }

    /**
     * Run trial callbacks and record their execution state.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return array
     */
    protected function runTrials(Experiment $experiment)
    {
        $executions = [];

        foreach ($experiment->getTrials() as $name => $trial) {
            $executions[$name] = (new Machine(
                $trial,
                $experiment->getParams(),
                true
            ))->execute();
        }

        return $executions;
    }

    /**
     * Determine whether trial results match the control.
     *
     * @param \Scientist\Matchers\Matcher $matcher
     * @param \Scientist\Result           $control
     * @param array                       $trials
     */
    protected function determineMatches(Matcher $matcher, Result $control, array $trials = [])
    {
        foreach ($trials as $trial) {
            if ($matcher->match($control->getValue(), $trial->getValue())) {
                $trial->setMatch(true);
            }
        }
    }
}<commit_msg>swap some array typehints for Result[] typehints<commit_after><?php

namespace Scientist;

use Scientist\Matchers\Matcher;

/**
 * Class Intern
 *
 * Interns do all the hard work, naturally. They'll execute an experiment within
 * the Laboratory, and record the results.
 *
 * @package \Scientist
 */
class Intern
{
    /**
     * Run an experiment, and retrieve the result.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return \Scientist\Report
     */
    public function run(Experiment $experiment)
    {
        $control = $this->runControl($experiment);
        $trials  = $this->runTrials($experiment);

        $this->determineMatches($experiment->getMatcher(), $control, $trials);

        return new Report($experiment->getName(), $control, $trials);
    }

    /**
     * Run the control callback, and record its execution state.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return \Scientist\Result
     */
    protected function runControl(Experiment $experiment)
    {
        return (new Machine($experiment->getControl(), $experiment->getParams()))->execute();
    }

    /**
     * Run trial callbacks and record their execution state.
     *
     * @param \Scientist\Experiment $experiment
     *
     * @return \Scientist\Result[]
     */
    protected function runTrials(Experiment $experiment)
    {
        $executions = [];

        foreach ($experiment->getTrials() as $name => $trial) {
            $executions[$name] = (new Machine(
                $trial,
                $experiment->getParams(),
                true
            ))->execute();
        }

        return $executions;
    }

    /**
     * Determine whether trial results match the control.
     *
     * @param \Scientist\Matchers\Matcher $matcher
     * @param \Scientist\Result           $control
     * @param \Scientist\Result[]         $trials
     */
    protected function determineMatches(Matcher $matcher, Result $control, array $trials = [])
    {
        foreach ($trials as $trial) {
            if ($matcher->match($control->getValue(), $trial->getValue())) {
                $trial->setMatch(true);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.1276300578034682, 'fraction_numerical': 0.0, 'mean_word_length': 2.164594001463058, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2704342', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1188, 'n_words': 292}