<commit_before><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Zend\Config\Writer;

class PhpArray extends AbstractWriter
{
    /**
     * processConfig(): defined by AbstractWriter.
     *
     * @param  array $config
     * @return string
     */
    public function processConfig(array $config)
    {
        $arrayString = "<?php\n\n"
                     . "return";
        $indentLevel = 0;

        foreach (explode("\n", var_export($config, true)) as $line) {
            $line = trim($line);

            if ($line === '),' || $line === ')') {
                $indentLevel--;
            } else if (preg_match('/^\s*array \(/', $line)) {
                $line = 'array(';
                $indentLevel++;
                $arrayString .= ' ' . $line;
                continue;
            }

            $arrayString .= "\n" . str_repeat('    ', $indentLevel) . $line;
        }

        return $arrayString . ";\n";
    }
}
<commit_msg>Modified to build out formatted PHP code by hand for greater speed<commit_after><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Zend\Config\Writer;

class PhpArray extends AbstractWriter
{
    /**
     * processConfig(): defined by AbstractWriter.
     *
     * @param  array $config
     * @return string
     */
    public function processConfig(array $config)
    {
        return "<?php\n\n" .
               "return array(\n" . $this->processIndented($config) . ");\n";
    }

    protected function processIndented(array $config, &$indentLevel = 1)
    {
        $arrayString = "";

        foreach ($config as $key => $value) {
            $arrayString .= str_repeat('    ', $indentLevel);
            $arrayString .= (is_numeric($key) ? $key : "'" . addslashes($key) . "'") . ' => ';

            if (is_array($value)) {
                if ($value === array()) {
                    $arrayString .= "array(),\n";
                } else {
                    $indentLevel++;
                    $arrayString .= "array(\n" . $this->processIndented($value, $indentLevel)
                                  . str_repeat('    ', --$indentLevel) . "),\n";
                }
            } elseif (is_object($value)) {
                $arrayString .= var_export($value, true) . ",\n";
            } else {
                $arrayString .= "'" . addslashes($value) . "',\n";
            }
        }

        return $arrayString;
    }
}

{'fraction_non_alphanumeric': 0.15942524803284297, 'fraction_numerical': 0.006842285323297981, 'mean_word_length': 1.7874165872259296, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3855528', 'n_tokens_mistral': 880, 'n_tokens_neox': 828, 'n_words': 187}