<commit_before><?php

namespace Encore\Kernel;

use Encore\Console\Command;
use Encore\Container\Container;
use Symfony\Component\Debug\Debug;
use Encore\Container\ServiceProvider;
use Encore\Config\ServiceProvider as ConfigServiceProvider;

class Application extends Container
{
    const VERSION = '0.1';

    const OS_OSX = 'osx';
    const OS_WIN = 'win';
    const OS_LINUX = 'linux';
    const OS_OTHER = 'other';

    private $appPath;
    private $resourcesPath;
    private $vendorPath;

    private $booted = false;
    private $os;

    protected $mode = 'dev';
    protected $serviceProviders = array();
    protected $loadedProviders = array();

    public function __construct($appPath, $resourcesPath, $vendorPath)
    {
        $this->appPath = $appPath;
        $this->resourcesPath = $resourcesPath;
        $this->vendorPath = $vendorPath;

        // First things first... Register this as the app
        $this->bind('app', $this);
    }

    public static function fromCwd()
    {
        $cwd = getcwd();

        return new static("{$cwd}/app", "{$cwd}/resources", "{$cwd}/vendor");
    }

    public function launching(callable $callback)
    {
        $this['events']->listen('app.launching', $callback);
    }

    public function quitting(callable $callback)
    {
        $this['events']->listen('app.quitting', $callback);
    }

    public function mode()
    {
        return $this->mode;
    }

    public function setMode($mode)
    {
        $this->mode = $mode;
    }

    public function boot()
    {
        if ($this->booted) return;

        // Use proper error handling
        ini_set('display_errors', $this->mode === 'dev');
        error_reporting($this->mode === 'dev' ? -1 : 0);

        $this->addProvider(new ConfigServiceProvider($this));

        // Register service providers
        foreach ($this['config']->get('app.providers') as $provider) {
            $this->addProvider($provider);
        }

        // Register aliases
        foreach ($this['config']->get('app.aliases') as $alias => $class) {
            class_alias($class, $alias);
        }

        // Now run boot events on service providers
        array_walk($this->registered, function($p) {
            if (method_exists($p, 'boot')) $p->boot();

            if ($this->mode == 'dev' and method_exists($p, 'commands')) {
                $this->registerCommands($p->commands());
            }
        });

        if (file_exists($bootstrap = $this->appPath."/bootstrap/{$this->mode}.php")) {
            require $bootstrap;
        }

        require $this->appPath.'/start.php';

        $this->booted = true;
    }

    public function launch()
    {
        $this['events']->fire('app.launching', [$this]);
    }

    public function quit()
    {
        $this['events']->fire('app.quitting', [$this]);

        exit;
    }

    public function get()
    {
        return $this;
    }

    public function appPath()
    {
        return $this->appPath;
    }

    public function resourcesPath()
    {
        return $this->resourcesPath;
    }

    public function vendorPath()
    {
        return $this->vendorPath;
    }

    public function os()
    {
        return isset($this->os) ? $this->os : $this->findOS();
    }<commit_msg>Removing exit from quit event<commit_after><?php

namespace Encore\Kernel;

use Encore\Console\Command;
use Encore\Container\Container;
use Symfony\Component\Debug\Debug;
use Encore\Container\ServiceProvider;
use Encore\Config\ServiceProvider as ConfigServiceProvider;

class Application extends Container
{
    const VERSION = '0.1';

    const OS_OSX = 'osx';
    const OS_WIN = 'win';
    const OS_LINUX = 'linux';
    const OS_OTHER = 'other';

    private $appPath;
    private $resourcesPath;
    private $vendorPath;

    private $booted = false;
    private $os;

    protected $mode = 'dev';
    protected $serviceProviders = array();
    protected $loadedProviders = array();

    public function __construct($appPath, $resourcesPath, $vendorPath)
    {
        $this->appPath = $appPath;
        $this->resourcesPath = $resourcesPath;
        $this->vendorPath = $vendorPath;

        // First things first... Register this as the app
        $this->bind('app', $this);
    }

    public static function fromCwd()
    {
        $cwd = getcwd();

        return new static("{$cwd}/app", "{$cwd}/resources", "{$cwd}/vendor");
    }

    public function launching(callable $callback)
    {
        $this['events']->listen('app.launching', $callback);
    }

    public function quitting(callable $callback)
    {
        $this['events']->listen('app.quitting', $callback);
    }

    public function mode()
    {
        return $this->mode;
    }

    public function setMode($mode)
    {
        $this->mode = $mode;
    }

    public function boot()
    {
        if ($this->booted) return;

        // Use proper error handling
        ini_set('display_errors', $this->mode === 'dev');
        error_reporting($this->mode === 'dev' ? -1 : 0);

        $this->addProvider(new ConfigServiceProvider($this));

        // Register service providers
        foreach ($this['config']->get('app.providers') as $provider) {
            $this->addProvider($provider);
        }

        // Register aliases
        foreach ($this['config']->get('app.aliases') as $alias => $class) {
            class_alias($class, $alias);
        }

        // Now run boot events on service providers
        array_walk($this->registered, function($p) {
            if (method_exists($p, 'boot')) $p->boot();

            if ($this->mode == 'dev' and method_exists($p, 'commands')) {
                $this->registerCommands($p->commands());
            }
        });

        if (file_exists($bootstrap = $this->appPath."/bootstrap/{$this->mode}.php")) {
            require $bootstrap;
        }

        require $this->appPath.'/start.php';

        $this->booted = true;
    }

    public function launch()
    {
        $this['events']->fire('app.launching', [$this]);
    }

    public function quit()
    {
        $this['events']->fire('app.quitting', [$this]);
    }

    public function get()
    {
        return $this;
    }

    public function appPath()
    {
        return $this->appPath;
    }

    public function resourcesPath()
    {
        return $this->resourcesPath;
    }

    public function vendorPath()
    {
        return $this->vendorPath;
    }

    public function os()
    {
        return isset($this->os) ? $this->os : $this->findOS();
    }
{'fraction_non_alphanumeric': 0.15121801746591082, 'fraction_numerical': 0.0012256779531178183, 'mean_word_length': 2.3053164556962025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '328860', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1886, 'n_words': 425}