Best Atoum code snippet using extension.getChildren
XmlFileLoader.php
Source:XmlFileLoader.php
...58 * @param \DOMDocument $xml59 */60 private function parseParameters(\DOMDocument $xml)61 {62 if ($parameters = $this->getChildren($xml->documentElement, 'parameters')) {63 $this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter'));64 }65 }66 /**67 * Parses imports.68 *69 * @param \DOMDocument $xml70 * @param string $file71 */72 private function parseImports(\DOMDocument $xml, $file)73 {74 $xpath = new \DOMXPath($xml);75 $xpath->registerNamespace('container', self::NS);76 if (false === $imports = $xpath->query('//container:imports/container:import')) {77 return;78 }79 $defaultDirectory = dirname($file);80 foreach ($imports as $import) {81 $this->setCurrentDir($defaultDirectory);82 $this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);83 }84 }85 /**86 * Parses multiple definitions.87 *88 * @param \DOMDocument $xml89 * @param string $file90 */91 private function parseDefinitions(\DOMDocument $xml, $file)92 {93 $xpath = new \DOMXPath($xml);94 $xpath->registerNamespace('container', self::NS);95 if (false === $services = $xpath->query('//container:services/container:service')) {96 return;97 }98 foreach ($services as $service) {99 if (null !== $definition = $this->parseDefinition($service, $file)) {100 $this->container->setDefinition((string) $service->getAttribute('id'), $definition);101 }102 }103 }104 /**105 * Parses an individual Definition.106 *107 * @param \DOMElement $service108 * @param string $file109 *110 * @return Definition|null111 */112 private function parseDefinition(\DOMElement $service, $file)113 {114 if ($alias = $service->getAttribute('alias')) {115 $public = true;116 if ($publicAttr = $service->getAttribute('public')) {117 $public = XmlUtils::phpize($publicAttr);118 }119 $this->container->setAlias((string) $service->getAttribute('id'), new Alias($alias, $public));120 return;121 }122 if ($parent = $service->getAttribute('parent')) {123 $definition = new DefinitionDecorator($parent);124 } else {125 $definition = new Definition();126 }127 foreach (array('class', 'shared', 'public', 'factory-class', 'factory-method', 'factory-service', 'synthetic', 'lazy', 'abstract') as $key) {128 if ($value = $service->getAttribute($key)) {129 if (in_array($key, array('factory-class', 'factory-method', 'factory-service'))) {130 @trigger_error(sprintf('The "%s" attribute of service "%s" in file "%s" is deprecated since version 2.6 and will be removed in 3.0. Use the "factory" element instead.', $key, (string) $service->getAttribute('id'), $file), E_USER_DEPRECATED);131 }132 $method = 'set'.str_replace('-', '', $key);133 $definition->$method(XmlUtils::phpize($value));134 }135 }136 if ($value = $service->getAttribute('autowire')) {137 $definition->setAutowired(XmlUtils::phpize($value));138 }139 if ($value = $service->getAttribute('scope')) {140 $triggerDeprecation = 'request' !== (string) $service->getAttribute('id');141 if ($triggerDeprecation) {142 @trigger_error(sprintf('The "scope" attribute of service "%s" in file "%s" is deprecated since version 2.8 and will be removed in 3.0.', (string) $service->getAttribute('id'), $file), E_USER_DEPRECATED);143 }144 $definition->setScope(XmlUtils::phpize($value), false);145 }146 if ($value = $service->getAttribute('synchronized')) {147 $triggerDeprecation = 'request' !== (string) $service->getAttribute('id');148 if ($triggerDeprecation) {149 @trigger_error(sprintf('The "synchronized" attribute of service "%s" in file "%s" is deprecated since version 2.7 and will be removed in 3.0.', (string) $service->getAttribute('id'), $file), E_USER_DEPRECATED);150 }151 $definition->setSynchronized(XmlUtils::phpize($value), $triggerDeprecation);152 }153 if ($files = $this->getChildren($service, 'file')) {154 $definition->setFile($files[0]->nodeValue);155 }156 if ($deprecated = $this->getChildren($service, 'deprecated')) {157 $definition->setDeprecated(true, $deprecated[0]->nodeValue);158 }159 $definition->setArguments($this->getArgumentsAsPhp($service, 'argument'));160 $definition->setProperties($this->getArgumentsAsPhp($service, 'property'));161 if ($factories = $this->getChildren($service, 'factory')) {162 $factory = $factories[0];163 if ($function = $factory->getAttribute('function')) {164 $definition->setFactory($function);165 } else {166 $factoryService = $this->getChildren($factory, 'service');167 if (isset($factoryService[0])) {168 $class = $this->parseDefinition($factoryService[0], $file);169 } elseif ($childService = $factory->getAttribute('service')) {170 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);171 } else {172 $class = $factory->getAttribute('class');173 }174 $definition->setFactory(array($class, $factory->getAttribute('method')));175 }176 }177 if ($configurators = $this->getChildren($service, 'configurator')) {178 $configurator = $configurators[0];179 if ($function = $configurator->getAttribute('function')) {180 $definition->setConfigurator($function);181 } else {182 $configuratorService = $this->getChildren($configurator, 'service');183 if (isset($configuratorService[0])) {184 $class = $this->parseDefinition($configuratorService[0], $file);185 } elseif ($childService = $configurator->getAttribute('service')) {186 $class = new Reference($childService, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false);187 } else {188 $class = $configurator->getAttribute('class');189 }190 $definition->setConfigurator(array($class, $configurator->getAttribute('method')));191 }192 }193 foreach ($this->getChildren($service, 'call') as $call) {194 $definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument'));195 }196 foreach ($this->getChildren($service, 'tag') as $tag) {197 $parameters = array();198 foreach ($tag->attributes as $name => $node) {199 if ('name' === $name) {200 continue;201 }202 if (false !== strpos($name, '-') && false === strpos($name, '_') && !array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) {203 $parameters[$normalizedName] = XmlUtils::phpize($node->nodeValue);204 }205 // keep not normalized key for BC too206 $parameters[$name] = XmlUtils::phpize($node->nodeValue);207 }208 if ('' === $tag->getAttribute('name')) {209 throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', (string) $service->getAttribute('id'), $file));210 }211 $definition->addTag($tag->getAttribute('name'), $parameters);212 }213 foreach ($this->getChildren($service, 'autowiring-type') as $type) {214 $definition->addAutowiringType($type->textContent);215 }216 if ($value = $service->getAttribute('decorates')) {217 $renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null;218 $priority = $service->hasAttribute('decoration-priority') ? $service->getAttribute('decoration-priority') : 0;219 $definition->setDecoratedService($value, $renameId, $priority);220 }221 return $definition;222 }223 /**224 * Parses a XML file to a \DOMDocument.225 *226 * @param string $file Path to a file227 *228 * @return \DOMDocument229 *230 * @throws InvalidArgumentException When loading of XML file returns error231 */232 private function parseFileToDOM($file)233 {234 try {235 $dom = XmlUtils::loadFile($file, array($this, 'validateSchema'));236 } catch (\InvalidArgumentException $e) {237 throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);238 }239 $this->validateExtensions($dom, $file);240 return $dom;241 }242 /**243 * Processes anonymous services.244 *245 * @param \DOMDocument $xml246 * @param string $file247 */248 private function processAnonymousServices(\DOMDocument $xml, $file)249 {250 $definitions = array();251 $count = 0;252 $xpath = new \DOMXPath($xml);253 $xpath->registerNamespace('container', self::NS);254 // anonymous services as arguments/properties255 if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]')) {256 foreach ($nodes as $node) {257 // give it a unique name258 $id = sprintf('%s_%d', hash('sha256', $file), ++$count);259 $node->setAttribute('id', $id);260 if ($services = $this->getChildren($node, 'service')) {261 $definitions[$id] = array($services[0], $file, false);262 $services[0]->setAttribute('id', $id);263 }264 }265 }266 // anonymous services "in the wild"267 if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {268 foreach ($nodes as $node) {269 // give it a unique name270 $id = sprintf('%s_%d', hash('sha256', $file), ++$count);271 $node->setAttribute('id', $id);272 if ($services = $this->getChildren($node, 'service')) {273 $definitions[$id] = array($node, $file, true);274 $services[0]->setAttribute('id', $id);275 }276 }277 }278 // resolve definitions279 krsort($definitions);280 foreach ($definitions as $id => $def) {281 list($domElement, $file, $wild) = $def;282 // anonymous services are always private283 // we could not use the constant false here, because of XML parsing284 $domElement->setAttribute('public', 'false');285 if (null !== $definition = $this->parseDefinition($domElement, $file)) {286 $this->container->setDefinition($id, $definition);287 }288 if (true === $wild) {289 $tmpDomElement = new \DOMElement('_services', null, self::NS);290 $domElement->parentNode->replaceChild($tmpDomElement, $domElement);291 $tmpDomElement->setAttribute('id', $id);292 } else {293 $domElement->parentNode->removeChild($domElement);294 }295 }296 }297 /**298 * Returns arguments as valid php types.299 *300 * @param \DOMElement $node301 * @param string $name302 * @param bool $lowercase303 *304 * @return mixed305 */306 private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true)307 {308 $arguments = array();309 foreach ($this->getChildren($node, $name) as $arg) {310 if ($arg->hasAttribute('name')) {311 $arg->setAttribute('key', $arg->getAttribute('name'));312 }313 if (!$arg->hasAttribute('key')) {314 $key = !$arguments ? 0 : max(array_keys($arguments)) + 1;315 } else {316 $key = $arg->getAttribute('key');317 }318 // parameter keys are case insensitive319 if ('parameter' == $name && $lowercase) {320 $key = strtolower($key);321 }322 // this is used by DefinitionDecorator to overwrite a specific323 // argument of the parent definition324 if ($arg->hasAttribute('index')) {325 $key = 'index_'.$arg->getAttribute('index');326 }327 switch ($arg->getAttribute('type')) {328 case 'service':329 $onInvalid = $arg->getAttribute('on-invalid');330 $invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;331 if ('ignore' == $onInvalid) {332 $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;333 } elseif ('null' == $onInvalid) {334 $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;335 }336 if ($strict = $arg->getAttribute('strict')) {337 $strict = XmlUtils::phpize($strict);338 } else {339 $strict = true;340 }341 $arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior, $strict);342 break;343 case 'expression':344 $arguments[$key] = new Expression($arg->nodeValue);345 break;346 case 'collection':347 $arguments[$key] = $this->getArgumentsAsPhp($arg, $name, false);348 break;349 case 'string':350 $arguments[$key] = $arg->nodeValue;351 break;352 case 'constant':353 $arguments[$key] = constant($arg->nodeValue);354 break;355 default:356 $arguments[$key] = XmlUtils::phpize($arg->nodeValue);357 }358 }359 return $arguments;360 }361 /**362 * Get child elements by name.363 *364 * @param \DOMNode $node365 * @param mixed $name366 *367 * @return array368 */369 private function getChildren(\DOMNode $node, $name)370 {371 $children = array();372 foreach ($node->childNodes as $child) {373 if ($child instanceof \DOMElement && $child->localName === $name && $child->namespaceURI === self::NS) {374 $children[] = $child;375 }376 }377 return $children;378 }379 /**380 * Validates a documents XML schema.381 *382 * @param \DOMDocument $dom383 *...
getChildren
Using AI Code Generation
1$ext = new Extension();2$ext->getChildren();3$ext = new Extension();4$ext->getChildren();5$ext = new Extension();6$ext->getChildren();7$ext = new Extension();8$ext->getChildren();9$ext = new Extension();10$ext->getChildren();11$ext = new Extension();12$ext->getChildren();13$ext = new Extension();14$ext->getChildren();15$ext = new Extension();16$ext->getChildren();17$ext = new Extension();18$ext->getChildren();19$ext = new Extension();20$ext->getChildren();21$ext = new Extension();22$ext->getChildren();23$ext = new Extension();24$ext->getChildren();25$ext = new Extension();26$ext->getChildren();27$ext = new Extension();28$ext->getChildren();29$ext = new Extension();30$ext->getChildren();31$ext = new Extension();32$ext->getChildren();33$ext = new Extension();34$ext->getChildren();
getChildren
Using AI Code Generation
1$children = $this->getChildren();2$children = $this->getChildren();3$children = $this->getChildren();4$children = $this->getChildren();5$children = $this->getChildren();6$children = $this->getChildren();7$children = $this->getChildren();8$children = $this->getChildren();9$children = $this->getChildren();10$children = $this->getChildren();11$children = $this->getChildren();12$children = $this->getChildren();13$children = $this->getChildren();14$children = $this->getChildren();15$children = $this->getChildren();16$children = $this->getChildren();17$children = $this->getChildren();18$children = $this->getChildren();19$children = $this->getChildren();
getChildren
Using AI Code Generation
1$extension = new Extension();2$extension->getChildren();3$extension = new Extension();4$extension->getChildren();5$extension = new Extension();6$extension->getChildren();7$extension = new Extension();8$extension->getChildren();9$extension = new Extension();10$extension->getChildren();11$extension = new Extension();12$extension->getChildren();13$extension = new Extension();14$extension->getChildren();15$extension = new Extension();16$extension->getChildren();17$extension = new Extension();18$extension->getChildren();19$extension = new Extension();20$extension->getChildren();21$extension = new Extension();22$extension->getChildren();23$extension = new Extension();24$extension->getChildren();25$extension = new Extension();26$extension->getChildren();27$extension = new Extension();28$extension->getChildren();29$extension = new Extension();30$extension->getChildren();31$extension = new Extension();32$extension->getChildren();33$extension = new Extension();34$extension->getChildren();
getChildren
Using AI Code Generation
1$ext = new Extension();2$ext->getChildren();3$ext = new Extension();4$ext->getChildren();5require_once("extension.php");6$ext = new Extension();7$ext->getChildren();8require_once("extension.php");9$ext = new Extension();10$ext->getChildren();
getChildren
Using AI Code Generation
1$extension = new Extension();2$extension->getChildren($id);3$extension = new Extension();4$extension->getChildren($id);5class Extension {6 private static $instance;7 public static function getInstance() {8 if (self::$instance === null) {9 self::$instance = new Extension();10 }11 return self::$instance;12 }13 private function __construct() {}14 private function __clone() {}15 private function __wakeup() {}16}17Fatal error: Call to private Extension::__construct() from invalid context in D:\xampp\htdocs\test\2.php on line 418class Extension {19 private static $instance;20 public static function getInstance() {21 if (self::$instance === null) {22 self::$instance = new Extension();23 }24 return self::$instance;25 }26 private function __construct() {}27 private function __clone() {}28 private function __wakeup() {}29}30Fatal error: Call to private Extension::__construct() from invalid context in D:\xampp\htdocs\test\2.php on line 431class Extension {32 private static $instance;33 public static function getInstance() {34 if (self::$instance === null) {35 self::$instance = new Extension();36 }37 return self::$instance;38 }39 private function __construct() {}40 private function __clone() {}
getChildren
Using AI Code Generation
1$extension = new Extension();2$extension->getChildren();3 (4 (5 (6 (7 (8 (9 (10 (
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with getChildren on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!