src/ContainerParser/ContainerInterpreter.php
public function handleServiceDefinition(ServiceDefinitionNode $definition) 
    {
        if ($this->namespace->hasService($definition->getName()) && $definition->isOverride() === false)
        {
            throw new ContainerInterpreterException("A service named \"{$definition->getName()}\" is already defined, you can prefix the definition with \"override\" to get around this error.");
        }

        // create a service definition from the node
        $service = new ServiceDefinition($definition->getClassName());

        if ($definition->hasArguments()) 
        {
            $arguments = $definition
                ->getArguments() // get the definitions arguments
                ->getArguments(); // and the argument array from the object

            foreach($arguments as $argument)
            {
                if ($argument instanceof ServiceReferenceNode)
                {
                    $service->addDependencyArgument($argument->getName());
                }
                elseif ($argument instanceof ParameterReferenceNode)
                {
                    $service->addParameterArgument($argument->getName());
                }
                elseif ($argument instanceof ArrayNode)
                {
                    $service->addRawArgument($argument->convertToNativeArray());
                }
                elseif ($argument instanceof ValueNode)
                {
                    $service->addRawArgument($argument->getRawValue());
                }
                else 
                {
                    throw new ContainerInterpreterException("Unable to handle argument node of type \"" . get_class($argument) . "\".");
                }
            }
        }

        // handle construction actions
        foreach($definition->getConstructionActions() as $action)
        {
            if ($action instanceof ServiceMethodCallNode)
            {
                if ($action->hasArguments()) 
                {
                    $service->addMethodCall($action->getName(), $this->createServiceArgumentsFromNode($action->getArguments()));
                } else {
                    $service->calls($action->getName());
                }
            }
            else 
            {
                throw new ContainerInterpreterException("Invalid construction action of type \"" . get_class($action) . "\" given.");
            }
        }

        // handle meta data
        foreach($definition->getMetaDataAssignemnts() as $meta)
        {
            if ($meta instanceof MetaDataAssignmentNode)
            {
                if ($meta->hasData()) 
                {
                    $service->addMetaData($meta->getKey(), $meta->getData()->convertToNativeArray());
                } else {
                    $service->addMetaData($meta->getKey(), []);
                }
            }
            else 
            {
                throw new ContainerInterpreterException("Invalid meta data assignment \"" . get_class($meta) . "\" given.");
            }
        }

        // add the node to the namespace
        $this->namespace->setService($definition->getName(), $service);
    }
public function handleServiceDefinition(ServiceDefinitionNode $definition) 
    {
        if ($this->namespace->hasService($definition->getName()) && $definition->isOverride() === false)
        {
            throw new ContainerInterpreterException("A service named \"{$definition->getName()}\" is already defined, you can prefix the definition with \"override\" to get around this error.");
        }

        // create a service definition from the node
        $service = new ServiceDefinition($definition->getClassName());

        if ($definition->hasArguments()) 
        {
            $arguments = $definition
                ->getArguments() // get the definitions arguments
                ->getArguments(); // and the argument array from the object

            foreach($arguments as $argument)
            {
                if ($argument instanceof ServiceReferenceNode)
                {
                    $service->addDependencyArgument($argument->getName());
                }
                elseif ($argument instanceof ParameterReferenceNode)
                {
                    $service->addParameterArgument($argument->getName());
                }
                elseif ($argument instanceof ArrayNode)
                {
                    $service->addRawArgument($argument->convertToNativeArray());
                }
                elseif ($argument instanceof ValueNode)
                {
                    $service->addRawArgument($argument->getRawValue());
                }
                else 
                {
                    throw new ContainerInterpreterException("Unable to handle argument node of type \"" . get_class($argument) . "\".");
                }
            }
        }

        // handle construction actions
        foreach($definition->getConstructionActions() as $action)
        {
            if ($action instanceof ServiceMethodCallNode)
            {
                if ($action->hasArguments()) 
                {
                    $service->addMethodCall($action->getName(), $this->createServiceArgumentsFromNode($action->getArguments()));
                } else {
                    $service->calls($action->getName());
                }
            }
            else 
            {
                throw new ContainerInterpreterException("Invalid construction action of type \"" . get_class($action) . "\" given.");
            }
        }

        // handle meta data
        foreach($definition->getMetaDataAssignemnts() as $meta)
        {
            if ($meta instanceof MetaDataAssignmentNode)
            {
                if ($meta->hasData()) 
                {
                    $service->addMetaData($meta->getKey(), $meta->getData()->convertToNativeArray());
                } else {
                    $service->addMetaData($meta->getKey(), []);
                }
            }
            else 
            {
                throw new ContainerInterpreterException("Invalid meta data assignment \"" . get_class($meta) . "\" given.");
            }
        }

        // add the node to the namespace
        $this->namespace->setService($definition->getName(), $service);
    }
Handle a service definition

@param ParameterDefinitionNode           $definition
@return void