[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <[email protected]> 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\OptionsResolver\Debug; 13 14 use Symfony\Component\OptionsResolver\Exception\NoConfigurationException; 15 use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; 16 use Symfony\Component\OptionsResolver\OptionsResolver; 17 18 /** 19 * @author Maxime Steinhausser <[email protected]> 20 * 21 * @final 22 */ 23 class OptionsResolverIntrospector 24 { 25 private $get; 26 27 public function __construct(OptionsResolver $optionsResolver) 28 { 29 $this->get = \Closure::bind(function ($property, $option, $message) { 30 /** @var OptionsResolver $this */ 31 if (!$this->isDefined($option)) { 32 throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); 33 } 34 35 if (!\array_key_exists($option, $this->{$property})) { 36 throw new NoConfigurationException($message); 37 } 38 39 return $this->{$property}[$option]; 40 }, $optionsResolver, $optionsResolver); 41 } 42 43 /** 44 * @return mixed 45 * 46 * @throws NoConfigurationException on no configured value 47 */ 48 public function getDefault(string $option) 49 { 50 return ($this->get)('defaults', $option, sprintf('No default value was set for the "%s" option.', $option)); 51 } 52 53 /** 54 * @return \Closure[] 55 * 56 * @throws NoConfigurationException on no configured closures 57 */ 58 public function getLazyClosures(string $option): array 59 { 60 return ($this->get)('lazy', $option, sprintf('No lazy closures were set for the "%s" option.', $option)); 61 } 62 63 /** 64 * @return string[] 65 * 66 * @throws NoConfigurationException on no configured types 67 */ 68 public function getAllowedTypes(string $option): array 69 { 70 return ($this->get)('allowedTypes', $option, sprintf('No allowed types were set for the "%s" option.', $option)); 71 } 72 73 /** 74 * @return mixed[] 75 * 76 * @throws NoConfigurationException on no configured values 77 */ 78 public function getAllowedValues(string $option): array 79 { 80 return ($this->get)('allowedValues', $option, sprintf('No allowed values were set for the "%s" option.', $option)); 81 } 82 83 /** 84 * @throws NoConfigurationException on no configured normalizer 85 */ 86 public function getNormalizer(string $option): \Closure 87 { 88 return current($this->getNormalizers($option)); 89 } 90 91 /** 92 * @throws NoConfigurationException when no normalizer is configured 93 */ 94 public function getNormalizers(string $option): array 95 { 96 return ($this->get)('normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option)); 97 } 98 99 /** 100 * @return string|\Closure 101 * 102 * @throws NoConfigurationException on no configured deprecation 103 * 104 * @deprecated since Symfony 5.1, use "getDeprecation()" instead. 105 */ 106 public function getDeprecationMessage(string $option) 107 { 108 trigger_deprecation('symfony/options-resolver', '5.1', 'The "%s()" method is deprecated, use "getDeprecation()" instead.', __METHOD__); 109 110 return $this->getDeprecation($option)['message']; 111 } 112 113 /** 114 * @throws NoConfigurationException on no configured deprecation 115 */ 116 public function getDeprecation(string $option): array 117 { 118 return ($this->get)('deprecated', $option, sprintf('No deprecation was set for the "%s" option.', $option)); 119 } 120 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |