<commit_before><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfContext provides information about the current application context, such as
 * the module and action names and the module directory. References to the
 * main symfony instances are also provided.
 *
 * @package    symfony
 * @subpackage util
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfContext
{
  protected
    $factories = array();

  protected static
    $instances = array(),
    $current   = 'default';

  /**
   * Initializes the current sfContext instance.
   */
  public function initialize()
  {
    $this->factories['logger'] = sfLogger::getInstance();
    if (sfConfig::get('sf_logging_enabled'))
    {
      $this->factories['logger']->info('{sfContext} initialization');
    }

    if (sfConfig::get('sf_use_database'))
    {
      // setup our database connections
      $this->factories['databaseManager'] = new sfDatabaseManager();
      $this->factories['databaseManager']->initialize();
    }

    // create a new action stack
    $this->factories['actionStack'] = new sfActionStack();

    // include the factories configuration
    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml'));

    // register our shutdown function
    register_shutdown_function(array($this, 'shutdown'));
  }

  /**
   * Retrieves the singleton instance of this class.
   *
   * @param  string    The name of the sfContext to retrieve.
   *
   * @return sfContext A sfContext implementation instance.
   */
  public static function getInstance($name = null, $class = null)
  {
    if (is_null($name))
    {
      $name = self::$current;
    }

    if (!isset(self::$instances[$name]))
    {
      if (is_null($class))
      {
        $class = __CLASS__;
      }

      self::$instances[$name] = new $class();

      if (!self::$instances[$name] instanceof sfContext)
      {
        throw new sfFactoryException(sprintf('Class "%s" is not of the type sfContext.', $class));
      }

      self::$instances[$name]->initialize();
    }

    return self::$instances[$name];
  }

  public static function hasInstance($name = null)
  {<commit_msg>changed the default __CLASS__ as the default sfContext class in getInstance() method<commit_after><?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 <NAME> <<EMAIL>>
 * (c) 2004-2006 <NAME>.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfContext provides information about the current application context, such as
 * the module and action names and the module directory. References to the
 * main symfony instances are also provided.
 *
 * @package    symfony
 * @subpackage util
 * @author     <NAME> <<EMAIL>>
 * @author     <NAME> <<EMAIL>>
 * @version    SVN: $Id$
 */
class sfContext
{
  protected
    $factories = array();

  protected static
    $instances = array(),
    $current   = 'default';

  /**
   * Initializes the current sfContext instance.
   */
  public function initialize()
  {
    $this->factories['logger'] = sfLogger::getInstance();
    if (sfConfig::get('sf_logging_enabled'))
    {
      $this->factories['logger']->info('{sfContext} initialization');
    }

    if (sfConfig::get('sf_use_database'))
    {
      // setup our database connections
      $this->factories['databaseManager'] = new sfDatabaseManager();
      $this->factories['databaseManager']->initialize();
    }

    // create a new action stack
    $this->factories['actionStack'] = new sfActionStack();

    // include the factories configuration
    require(sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name').'/factories.yml'));

    // register our shutdown function
    register_shutdown_function(array($this, 'shutdown'));
  }

  /**
   * Retrieves the singleton instance of this class.
   *
   * @param  string    The name of the sfContext to retrieve.
   *
   * @return sfContext A sfContext implementation instance.
   */
  public static function getInstance($name = null, $class = __CLASS__)
  {
    if (is_null($name))
    {
      $name = self::$current;
    }

    if (!isset(self::$instances[$name]))
    {
      self::$instances[$name] = new $class();

      if (!self::$instances[$name] instanceof sfContext)
      {
        throw new sfFactoryException(sprintf('Class "%s" is not of the type sfContext.', $class));
      }

      self::$instances[$name]->initialize();
    }

    return self::$instances[$name];
  }

  public static function hasInstance($name = null)
  {
{'fraction_non_alphanumeric': 0.1371499176276771, 'fraction_numerical': 0.006589785831960461, 'mean_word_length': 3.245629370629371, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 41, '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': '4376373', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1384, 'n_words': 397}