Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/console/Question/Question.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
115 } | 115 } |
116 | 116 |
117 /** | 117 /** |
118 * Gets values for the autocompleter. | 118 * Gets values for the autocompleter. |
119 * | 119 * |
120 * @return null|iterable | 120 * @return iterable|null |
121 */ | 121 */ |
122 public function getAutocompleterValues() | 122 public function getAutocompleterValues() |
123 { | 123 { |
124 return $this->autocompleterValues; | 124 return $this->autocompleterValues; |
125 } | 125 } |
126 | 126 |
127 /** | 127 /** |
128 * Sets values for the autocompleter. | 128 * Sets values for the autocompleter. |
129 * | 129 * |
130 * @param null|iterable $values | 130 * @param iterable|null $values |
131 * | 131 * |
132 * @return $this | 132 * @return $this |
133 * | 133 * |
134 * @throws InvalidArgumentException | 134 * @throws InvalidArgumentException |
135 * @throws LogicException | 135 * @throws LogicException |
136 */ | 136 */ |
137 public function setAutocompleterValues($values) | 137 public function setAutocompleterValues($values) |
138 { | 138 { |
139 if (is_array($values)) { | 139 if (\is_array($values)) { |
140 $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values); | 140 $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values); |
141 } | 141 } |
142 | 142 |
143 if (null !== $values && !is_array($values) && !$values instanceof \Traversable) { | 143 if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) { |
144 throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.'); | 144 throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.'); |
145 } | 145 } |
146 | 146 |
147 if ($this->hidden) { | 147 if ($this->hidden) { |
148 throw new LogicException('A hidden question cannot use the autocompleter.'); | 148 throw new LogicException('A hidden question cannot use the autocompleter.'); |
154 } | 154 } |
155 | 155 |
156 /** | 156 /** |
157 * Sets a validator for the question. | 157 * Sets a validator for the question. |
158 * | 158 * |
159 * @param null|callable $validator | 159 * @param callable|null $validator |
160 * | 160 * |
161 * @return $this | 161 * @return $this |
162 */ | 162 */ |
163 public function setValidator(callable $validator = null) | 163 public function setValidator(callable $validator = null) |
164 { | 164 { |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
171 * Gets the validator for the question. | 171 * Gets the validator for the question. |
172 * | 172 * |
173 * @return null|callable | 173 * @return callable|null |
174 */ | 174 */ |
175 public function getValidator() | 175 public function getValidator() |
176 { | 176 { |
177 return $this->validator; | 177 return $this->validator; |
178 } | 178 } |
180 /** | 180 /** |
181 * Sets the maximum number of attempts. | 181 * Sets the maximum number of attempts. |
182 * | 182 * |
183 * Null means an unlimited number of attempts. | 183 * Null means an unlimited number of attempts. |
184 * | 184 * |
185 * @param null|int $attempts | 185 * @param int|null $attempts |
186 * | 186 * |
187 * @return $this | 187 * @return $this |
188 * | 188 * |
189 * @throws InvalidArgumentException in case the number of attempts is invalid | 189 * @throws InvalidArgumentException in case the number of attempts is invalid |
190 */ | 190 */ |
202 /** | 202 /** |
203 * Gets the maximum number of attempts. | 203 * Gets the maximum number of attempts. |
204 * | 204 * |
205 * Null means an unlimited number of attempts. | 205 * Null means an unlimited number of attempts. |
206 * | 206 * |
207 * @return null|int | 207 * @return int|null |
208 */ | 208 */ |
209 public function getMaxAttempts() | 209 public function getMaxAttempts() |
210 { | 210 { |
211 return $this->attempts; | 211 return $this->attempts; |
212 } | 212 } |
239 return $this->normalizer; | 239 return $this->normalizer; |
240 } | 240 } |
241 | 241 |
242 protected function isAssoc($array) | 242 protected function isAssoc($array) |
243 { | 243 { |
244 return (bool) count(array_filter(array_keys($array), 'is_string')); | 244 return (bool) \count(array_filter(array_keys($array), 'is_string')); |
245 } | 245 } |
246 } | 246 } |