Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ArgumentMetadata.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\HttpKernel\ControllerMetadata;
013
014 /**
015 * Responsible for storing metadata of an argument.
016 *
017 * @author Iltar van der Berg <kjarli@gmail.com>
018 */
019 class ArgumentMetadata
020 {
021 private $name;
022 private $type;
023 private $isVariadic;
024 private $hasDefaultValue;
025 private $defaultValue;
026 private $isNullable;
027
028 /**
029 * @param string $name
030 * @param string $type
031 * @param bool $isVariadic
032 * @param bool $hasDefaultValue
033 * @param mixed $defaultValue
034 * @param bool $isNullable
035 */
036 public function __construct($name, $type, $isVariadic, $hasDefaultValue, $defaultValue, $isNullable = false)
037 {
038 $this->name = $name;
039 $this->type = $type;
040 $this->isVariadic = $isVariadic;
041 $this->hasDefaultValue = $hasDefaultValue;
042 $this->defaultValue = $defaultValue;
043 $this->isNullable = $isNullable || null === $type || ($hasDefaultValue && null === $defaultValue);
044 }
045
046 /**
047 * Returns the name as given in PHP, $foo would yield "foo".
048 *
049 * @return string
050 */
051 public function getName()
052 {
053 return $this->name;
054 }
055
056 /**
057 * Returns the type of the argument.
058 *
059 * The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
060 *
061 * @return string|null
062 */
063 public function getType()
064 {
065 return $this->type;
066 }
067
068 /**
069 * Returns whether the argument is defined as "...$variadic".
070 *
071 * @return bool
072 */
073 public function isVariadic()
074 {
075 return $this->isVariadic;
076 }
077
078 /**
079 * Returns whether the argument has a default value.
080 *
081 * Implies whether an argument is optional.
082 *
083 * @return bool
084 */
085 public function hasDefaultValue()
086 {
087 return $this->hasDefaultValue;
088 }
089
090 /**
091 * Returns whether the argument accepts null values.
092 *
093 * @return bool
094 */
095 public function isNullable()
096 {
097 return $this->isNullable;
098 }
099
100 /**
101 * Returns the default value of the argument.
102 *
103 * @throws \LogicException if no default value is present; {@see self::hasDefaultValue()}
104 *
105 * @return mixed
106 */
107 public function getDefaultValue()
108 {
109 if (!$this->hasDefaultValue) {
110 throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__));
111 }
112
113 return $this->defaultValue;
114 }
115 }
116