public function toPhpValue($type = null, $serviceLocator = null)
    {
        if (!$type) {
            $type = $this->getName();
        }

        switch ($type) {
            case 'array':
                $value = array();
                if (!isset($this->item)) {
                    return $value;
                }

                foreach ($this->item as $item) {
                    if (!($type = (string)$item['type'])) {
                        $type = 'string';
                    }

                    // Instance must be defined in subtag
                    if (($type == 'instance') && !$item->{$type}) {
                        $current = null;
                    } else {
                        $current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator);
                    }

                    if (!isset($item['key']) && !isset($item['index'])) {
                        $value[] = $current;
                        continue;
                    }

                    $key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']);
                    $value[$key] = $current;
                }

                break;

            case 'null':
                $value = null;
                break;

            case 'instance':
                $class = (string)$this['class'];
                $value = null;

                if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) {
                    $value = $serviceLocator->get($class);
                    break;
                }

                if ($serviceLocator instanceof DependencyInjectionInterface) {
                    $options = array();
                    if (isset($this->options)) {
                        $options = $this->options->toPhpValue('array', $serviceLocator);
                    }

                    $value = $serviceLocator->newInstance($class, $options);
                    break;
                }

                break;

            default:
                $value = $this->toValue($type);
                break;
        }

        return $value;
    }