[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/ -> SimpleXMLElement.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\DependencyInjection;
  13  
  14  @trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  15  
  16  use Symfony\Component\Config\Util\XmlUtils;
  17  use Symfony\Component\ExpressionLanguage\Expression;
  18  
  19  /**
  20   * SimpleXMLElement class.
  21   *
  22   * @author Fabien Potencier <fabien@symfony.com>
  23   *
  24   * @deprecated since version 2.5, to be removed in 3.0.
  25   */
  26  class SimpleXMLElement extends \SimpleXMLElement
  27  {
  28      /**
  29       * Converts an attribute as a PHP type.
  30       *
  31       * @param string $name
  32       *
  33       * @return mixed
  34       */
  35      public function getAttributeAsPhp($name)
  36      {
  37          return self::phpize($this[$name]);
  38      }
  39  
  40      /**
  41       * Returns arguments as valid PHP types.
  42       *
  43       * @param string $name
  44       * @param bool   $lowercase
  45       *
  46       * @return mixed
  47       */
  48      public function getArgumentsAsPhp($name, $lowercase = true)
  49      {
  50          $arguments = array();
  51          foreach ($this->$name as $arg) {
  52              if (isset($arg['name'])) {
  53                  $arg['key'] = (string) $arg['name'];
  54              }
  55              $key = isset($arg['key']) ? (string) $arg['key'] : (!$arguments ? 0 : max(array_keys($arguments)) + 1);
  56  
  57              // parameter keys are case insensitive
  58              if ('parameter' == $name && $lowercase) {
  59                  $key = strtolower($key);
  60              }
  61  
  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'];
  66              }
  67  
  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;
  75                      }
  76  
  77                      if (isset($arg['strict'])) {
  78                          $strict = self::phpize($arg['strict']);
  79                      } else {
  80                          $strict = true;
  81                      }
  82  
  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);
  99              }
 100          }
 101  
 102          return $arguments;
 103      }
 104  
 105      /**
 106       * Converts an xml value to a PHP type.
 107       *
 108       * @param mixed $value
 109       *
 110       * @return mixed
 111       */
 112      public static function phpize($value)
 113      {
 114          return XmlUtils::phpize($value);
 115      }
 116  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1