<commit_before><?php

/*
 * This file is part of Psy Shell
 *
 * (c) 2013 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Psy;

use Psy\Configuration;
use Psy\Exception\BreakException;
use Psy\Exception\ErrorException;
use Psy\Exception\Exception as PsyException;
use Psy\Formatter\ArrayFormatter;
use Psy\Formatter\ObjectFormatter;
use Psy\Output\ShellOutput;
use Psy\Readline;
use Psy\Command\ShellAware;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * The Psy Shell application
 *
 * Usage:
 *
 *     $shell = new Shell;
 *     $shell->run();
 *
 * @author <NAME> <<EMAIL>>
 */
class Shell extends Application
{
    const VERSION = 'v0.1.0-dev';

    const PROMPT      = '>>> ';
    const BUFF_PROMPT = '... ';
    const REPLAY      = '--> ';
    const RETVAL      = '=> ';

    private $config;
    private $cleaner;
    private $output;
    private $readline;
    private $inputBuffer;
    private $code;
    private $codeBuffer;
    private $scopeVariables;
    private $includes;
    private $exceptions;

    /**
     * Create a new Psy Shell.
     *
     * @param Configuration $config (default: null)
     */
    public function __construct(Configuration $config = null)
    {
        $this->config         = $config ?: new Configuration;
        $this->cleaner        = $this->config->getCodeCleaner();
        $this->loop           = $this->config->getLoop();
        $this->scopeVariables = array();
        $this->includes       = $this->config->getDefaultIncludes();
        $this->readline       = $this->config->getReadline();

        parent::__construct('Psy Shell', self::VERSION);

        $this->config->setShell($this);
    }

    /**
     * Invoke a Psy Shell from the current context.
     *
     * For example:
     *
     *     foreach ($items as $item) {
     *         \Psy\Shell::debug(get_defined_vars());
     *     }
     *
     * If you would like your shell interaction to affect the state of the
     * current context, you can export() the values returned from this call:
     *
     *     foreach ($items as $item) {
     *         export(\Psy\Shell::debug(get_defined_vars()));
     *         var_dump($item); // will be whatever you set $item to in Psy Shell
     *     }
     *
     * @param array $vars Scope variables from the calling context (default: array())
     *
     * @return array Scope variables from the debugger session.
     */
    public static function debug(array $vars = array())
    {
        echo PHP_EOL;

        $sh = new \Psy\Shell;
        $sh->setScopeVariables($vars);<commit_msg>Fix doc comment (export -> extract)<commit_after><?php

/*
 * This file is part of Psy Shell
 *
 * (c) 2013 <NAME>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Psy;

use Psy\Configuration;
use Psy\Exception\BreakException;
use Psy\Exception\ErrorException;
use Psy\Exception\Exception as PsyException;
use Psy\Formatter\ArrayFormatter;
use Psy\Formatter\ObjectFormatter;
use Psy\Output\ShellOutput;
use Psy\Readline;
use Psy\Command\ShellAware;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * The Psy Shell application
 *
 * Usage:
 *
 *     $shell = new Shell;
 *     $shell->run();
 *
 * @author <NAME> <<EMAIL>>
 */
class Shell extends Application
{
    const VERSION = 'v0.1.0-dev';

    const PROMPT      = '>>> ';
    const BUFF_PROMPT = '... ';
    const REPLAY      = '--> ';
    const RETVAL      = '=> ';

    private $config;
    private $cleaner;
    private $output;
    private $readline;
    private $inputBuffer;
    private $code;
    private $codeBuffer;
    private $scopeVariables;
    private $includes;
    private $exceptions;

    /**
     * Create a new Psy Shell.
     *
     * @param Configuration $config (default: null)
     */
    public function __construct(Configuration $config = null)
    {
        $this->config         = $config ?: new Configuration;
        $this->cleaner        = $this->config->getCodeCleaner();
        $this->loop           = $this->config->getLoop();
        $this->scopeVariables = array();
        $this->includes       = $this->config->getDefaultIncludes();
        $this->readline       = $this->config->getReadline();

        parent::__construct('Psy Shell', self::VERSION);

        $this->config->setShell($this);
    }

    /**
     * Invoke a Psy Shell from the current context.
     *
     * For example:
     *
     *     foreach ($items as $item) {
     *         \Psy\Shell::debug(get_defined_vars());
     *     }
     *
     * If you would like your shell interaction to affect the state of the
     * current context, you can extract() the values returned from this call:
     *
     *     foreach ($items as $item) {
     *         extract(\Psy\Shell::debug(get_defined_vars()));
     *         var_dump($item); // will be whatever you set $item to in Psy Shell
     *     }
     *
     * @param array $vars Scope variables from the calling context (default: array())
     *
     * @return array Scope variables from the debugger session.
     */
    public static function debug(array $vars = array())
    {
        echo PHP_EOL;

        $sh = new \Psy\Shell;
        $sh->setScopeVariables($vars);
{'fraction_non_alphanumeric': 0.12365591397849462, 'fraction_numerical': 0.0023521505376344087, 'mean_word_length': 2.6144505160898603, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 58, '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': '6841395', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1742, 'n_words': 467}