<commit_before><?php

namespace Symfony\Components\DependencyInjection\Dumper;

use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Container;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\Reference;
use Symfony\Components\DependencyInjection\Parameter;

/*
 * This file is part of the Symfony framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

/**
 * PhpDumper dumps a service container as a PHP class.
 *
 * @package    Symfony
 * @subpackage Components_DependencyInjection
 * @author     <NAME> <<EMAIL>>
 */
class PhpDumper extends Dumper
{
    /**
     * Dumps the service container as a PHP class.
     *
     * Available options:
     *
     *  * class:      The class name
     *  * base_class: The base class name
     *
     * @param  array  $options An array of options
     *
     * @return string A PHP class representing of the service container
     */
    public function dump(array $options = array())
    {
        $options = array_merge(array(
            'class'      => 'ProjectServiceContainer',
            'base_class' => 'Container',
        ), $options);

        return
            $this->startClass($options['class'], $options['base_class']).
            $this->addConstructor().
            $this->addServices().
            $this->addAnnotations().
            $this->addDefaultParametersMethod().
            $this->endClass()
        ;
    }

    protected function addServiceInclude($id, $definition)
    {
        if (null !== $definition->getFile()) {
            return sprintf("        require_once %s;\n\n", $this->dumpValue($definition->getFile()));
        }
    }

    protected function addServiceShared($id, $definition)
    {
        if ($definition->isShared()) {
            return <<<EOF
        if (isset(\$this->shared['$id'])) return \$this->shared['$id'];


EOF;
        }
    }

    protected function addServiceReturn($id, $definition)
    {
        return <<<EOF

        return \$instance;
    }

EOF;
    }

    protected function addServiceInstance($id, $definition)
    {
        $class = $this->dumpValue($definition->getClass());

        if (0 === strpos($class, "'") && !preg_match('/^\'[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\'$/', $class)) {<commit_msg>[DependencyInjection] added a check for the class name when dumping a container to PHP<commit_after><?php

namespace Symfony\Components\DependencyInjection\Dumper;

use Symfony\Components\DependencyInjection\ContainerBuilder;
use Symfony\Components\DependencyInjection\Container;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\Reference;
use Symfony\Components\DependencyInjection\Parameter;

/*
 * This file is part of the Symfony framework.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

/**
 * PhpDumper dumps a service container as a PHP class.
 *
 * @package    Symfony
 * @subpackage Components_DependencyInjection
 * @author     <NAME> <<EMAIL>>
 */
class PhpDumper extends Dumper
{
    /**
     * Dumps the service container as a PHP class.
     *
     * Available options:
     *
     *  * class:      The class name
     *  * base_class: The base class name
     *
     * @param  array  $options An array of options
     *
     * @return string A PHP class representing of the service container
     */
    public function dump(array $options = array())
    {
        $options = array_merge(array(
            'class'      => 'ProjectServiceContainer',
            'base_class' => 'Container',
        ), $options);

        return
            $this->startClass($options['class'], $options['base_class']).
            $this->addConstructor().
            $this->addServices().
            $this->addAnnotations().
            $this->addDefaultParametersMethod().
            $this->endClass()
        ;
    }

    protected function addServiceInclude($id, $definition)
    {
        if (null !== $definition->getFile()) {
            return sprintf("        require_once %s;\n\n", $this->dumpValue($definition->getFile()));
        }
    }

    protected function addServiceShared($id, $definition)
    {
        if ($definition->isShared()) {
            return <<<EOF
        if (isset(\$this->shared['$id'])) return \$this->shared['$id'];


EOF;
        }
    }

    protected function addServiceReturn($id, $definition)
    {
        return <<<EOF

        return \$instance;
    }

EOF;
    }

    protected function addServiceInstance($id, $definition)
    {
        $class = $this->dumpValue($definition->getClass());

        if (0 === strpos($class, "'") && !preg_match('/^\'[\\a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\'$/', $class)) {
{'fraction_non_alphanumeric': 0.13578500707213578, 'fraction_numerical': 0.002020610224287735, 'mean_word_length': 2.5714285714285716, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 47, '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': '5043437', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1389, 'n_words': 343}