public function toPhpCode(string $containerVariable, array $usedVariables = array()): InlineEntryInterface
    {
        // TODO: not optimal compared to previous interface!!!
        $analyzer = new TokenAnalyzer();
        $analysis = $analyzer->analyze($this->closure);

        if ($analysis['hasThis']) {
            throw new DefinitionException('Your closure cannot call the $this keyword.');
        }
        if (!empty($analysis['context'])) {
            throw new DefinitionException('Your closure cannot have a context (i.e. cannot have a "use" keyword).');
        }
        $code = $analysis['code'];
        $variableName = VariableUtils::getNextAvailableVariableName("\$closure", $usedVariables);
        $usedVariables[] = $variableName;
        $assignClosure = sprintf('%s = %s;', $variableName, $code);

        return new InlineEntry($variableName.'('.$containerVariable.')', $assignClosure, $usedVariables);
    }
public function toPhpCode(string $containerVariable, array $usedVariables = array()): InlineEntryInterface
    {
        // TODO: not optimal compared to previous interface!!!
        $analyzer = new TokenAnalyzer();
        $analysis = $analyzer->analyze($this->closure);

        if ($analysis['hasThis']) {
            throw new DefinitionException('Your closure cannot call the $this keyword.');
        }
        if (!empty($analysis['context'])) {
            throw new DefinitionException('Your closure cannot have a context (i.e. cannot have a "use" keyword).');
        }
        $code = $analysis['code'];
        $variableName = VariableUtils::getNextAvailableVariableName("\$closure", $usedVariables);
        $usedVariables[] = $variableName;
        $assignClosure = sprintf('%s = %s;', $variableName, $code);

        return new InlineEntry($variableName.'('.$containerVariable.')', $assignClosure, $usedVariables);
    }
Returns an InlineEntryInterface object representing the PHP code necessary to generate
the container entry.

@param string $containerVariable The name of the variable that allows access to the container instance. For instance: "$container", or "$this->container"
@param array  $usedVariables     An array of variables that are already used and that should not be used when generating this code.

@return InlineEntryInterface

@throws DefinitionException