<commit_before><?php

namespace League\Container;

use League\Container\Argument\ArgumentResolverInterface;
use League\Container\Argument\ArgumentResolverTrait;
use ReflectionClass;
use ReflectionException;
use ReflectionFunction;
use ReflectionMethod;

class ReflectionContainer implements
    ArgumentResolverInterface,
    ImmutableContainerInterface
{
    use ArgumentResolverTrait;
    use ImmutableContainerAwareTrait;

    /**
     * {@inheritdoc}
     */
    public function get($alias, array $args = [])
    {
        try {
            $reflector = new ReflectionClass($alias);
            $construct = $reflector->getConstructor();
        } catch (ReflectionException $e) {
            return new $alias;
        }

        return $reflector->newInstanceArgs(
            $this->reflectArguments($construct, $args)
        );
    }

    /**
     * {@inheritdoc}
     */
    public function has($alias)
    {
        return class_exists($alias);
    }

    /**
     * Invoke a callable via the container.
     *
     * @param  callable $callable
     * @param  array    $args<commit_msg>Fix: Instantiate class if it doesn't have a constructor<commit_after><?php

namespace League\Container;

use League\Container\Argument\ArgumentResolverInterface;
use League\Container\Argument\ArgumentResolverTrait;
use ReflectionClass;
use ReflectionException;
use ReflectionFunction;
use ReflectionMethod;

class ReflectionContainer implements
    ArgumentResolverInterface,
    ImmutableContainerInterface
{
    use ArgumentResolverTrait;
    use ImmutableContainerAwareTrait;

    /**
     * {@inheritdoc}
     */
    public function get($alias, array $args = [])
    {
        try {
            $reflector = new ReflectionClass($alias);
            $construct = $reflector->getConstructor();
        } catch (ReflectionException $e) {
            return new $alias;
        }

        if ($construct === null) {
            return new $alias;
        }

        return $reflector->newInstanceArgs(
            $this->reflectArguments($construct, $args)
        );
    }

    /**
     * {@inheritdoc}
     */
    public function has($alias)
    {
        return class_exists($alias);
    }

    /**
     * Invoke a callable via the container.
     *
     * @param  callable $callable
     * @param  array    $args
{'fraction_non_alphanumeric': 0.09943795936013834, 'fraction_numerical': 0.0, 'mean_word_length': 2.532824427480916, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6245859', 'n_tokens_mistral': 624, 'n_tokens_neox': 614, 'n_words': 141}