composer package updates
[openemr.git] / vendor / symfony / dependency-injection / SimpleXMLElement.php
blob8f300e09e5a27c6f8692a072c7f6d06e75d28354
1 <?php
3 /*
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection;
14 @trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
16 use Symfony\Component\Config\Util\XmlUtils;
17 use Symfony\Component\ExpressionLanguage\Expression;
19 /**
20 * SimpleXMLElement class.
22 * @author Fabien Potencier <fabien@symfony.com>
24 * @deprecated since version 2.5, to be removed in 3.0.
26 class SimpleXMLElement extends \SimpleXMLElement
28 /**
29 * Converts an attribute as a PHP type.
31 * @param string $name
33 * @return mixed
35 public function getAttributeAsPhp($name)
37 return self::phpize($this[$name]);
40 /**
41 * Returns arguments as valid PHP types.
43 * @param string $name
44 * @param bool $lowercase
46 * @return mixed
48 public function getArgumentsAsPhp($name, $lowercase = true)
50 $arguments = array();
51 foreach ($this->$name as $arg) {
52 if (isset($arg['name'])) {
53 $arg['key'] = (string) $arg['name'];
55 $key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
57 // parameter keys are case insensitive
58 if ('parameter' == $name && $lowercase) {
59 $key = strtolower($key);
62 // this is used by DefinitionDecorator to overwrite a specific
63 // argument of the parent definition
64 if (isset($arg['index'])) {
65 $key = 'index_'.$arg['index'];
68 switch ($arg['type']) {
69 case 'service':
70 $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
71 if (isset($arg['on-invalid']) && 'ignore' == $arg['on-invalid']) {
72 $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
73 } elseif (isset($arg['on-invalid']) && 'null' == $arg['on-invalid']) {
74 $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
77 if (isset($arg['strict'])) {
78 $strict = self::phpize($arg['strict']);
79 } else {
80 $strict = true;
83 $arguments[$key] = new Reference((string) $arg['id'], $invalidBehavior, $strict);
84 break;
85 case 'expression':
86 $arguments[$key] = new Expression((string) $arg);
87 break;
88 case 'collection':
89 $arguments[$key] = $arg->getArgumentsAsPhp($name, false);
90 break;
91 case 'string':
92 $arguments[$key] = (string) $arg;
93 break;
94 case 'constant':
95 $arguments[$key] = constant((string) $arg);
96 break;
97 default:
98 $arguments[$key] = self::phpize($arg);
102 return $arguments;
106 * Converts an xml value to a PHP type.
108 * @param mixed $value
110 * @return mixed
112 public static function phpize($value)
114 return XmlUtils::phpize($value);