src/Compiler.php
public function compile($className)
    {
        // FIXME: 2 successive calls to compile will yield invalid results as the state is modified by "compile".

        // Let's fill the definitions from service providers:
        $serviceProviderLoader = new ServiceProviderLoader($this, $this->converter);
        $serviceProviderLoader->loadFromRegistry($this->registry);

        $classCode = <<<EOF
<?php
%s

use Mouf\Picotainer\Picotainer;
use TheCodingMachine\ServiceProvider\Registry;

class %s extends Picotainer
{
    /**
     * The registry containing service providers.
     * @var Registry
     */
    protected \$registry;

    public function __construct(Registry \$registry = null, ContainerInterface \$delegateLookupContainer = null) {
        parent::__construct([
%s        ], \$delegateLookupContainer);
        \$this->objects = [
%s        ];
        if (\$registry === null) {
            \$registry = new Registry();
        }
        \$this->registry = \$registry;
    }
}

EOF;

        list($shortClassName, $namespaceLine) = $this->splitFQCN($className);

        $closuresCode = '';
        $parametersCode = '';

        $convertedDefinitions = [];
        // Let's merge dumpable definitions with standard definitions.
        foreach ($this->definitions as $identifier => $definition) {
            $convertedDefinitions[$identifier] = $this->converter->convert($identifier, $definition);
        }

        $allDefinitions = $convertedDefinitions + $this->dumpableDefinitions;

        foreach ($allDefinitions as $identifier => $definition) {
            $inlineEntry = $definition->toPhpCode('$container', ['$container']);

            if ($inlineEntry->isLazilyEvaluated()) {
                $closuresCode .= '            '.var_export($identifier, true).' => '.$this->getClosureCode($inlineEntry).",\n";
            } else {
                $parametersCode .= '            '.var_export($identifier, true).' => '.$this->getParametersCode($inlineEntry).",\n";
            }
        }

        return sprintf($classCode, $namespaceLine, $shortClassName, $closuresCode, $parametersCode);
    }
public function compile($className)
    {
        // FIXME: 2 successive calls to compile will yield invalid results as the state is modified by "compile".

        // Let's fill the definitions from service providers:
        $serviceProviderLoader = new ServiceProviderLoader($this, $this->converter);
        $serviceProviderLoader->loadFromRegistry($this->registry);

        $classCode = <<<EOF
<?php
%s

use Mouf\Picotainer\Picotainer;
use TheCodingMachine\ServiceProvider\Registry;

class %s extends Picotainer
{
    /**
     * The registry containing service providers.
     * @var Registry
     */
    protected \$registry;

    public function __construct(Registry \$registry = null, ContainerInterface \$delegateLookupContainer = null) {
        parent::__construct([
%s        ], \$delegateLookupContainer);
        \$this->objects = [
%s        ];
        if (\$registry === null) {
            \$registry = new Registry();
        }
        \$this->registry = \$registry;
    }
}

EOF;

        list($shortClassName, $namespaceLine) = $this->splitFQCN($className);

        $closuresCode = '';
        $parametersCode = '';

        $convertedDefinitions = [];
        // Let's merge dumpable definitions with standard definitions.
        foreach ($this->definitions as $identifier => $definition) {
            $convertedDefinitions[$identifier] = $this->converter->convert($identifier, $definition);
        }

        $allDefinitions = $convertedDefinitions + $this->dumpableDefinitions;

        foreach ($allDefinitions as $identifier => $definition) {
            $inlineEntry = $definition->toPhpCode('$container', ['$container']);

            if ($inlineEntry->isLazilyEvaluated()) {
                $closuresCode .= '            '.var_export($identifier, true).' => '.$this->getClosureCode($inlineEntry).",\n";
            } else {
                $parametersCode .= '            '.var_export($identifier, true).' => '.$this->getParametersCode($inlineEntry).",\n";
            }
        }

        return sprintf($classCode, $namespaceLine, $shortClassName, $closuresCode, $parametersCode);
    }
@param string $className

@return string