Skip to content

Commit 7b998f1

Browse files
issamkhadiri1989Spomky
authored andcommitted
Update questionhelper.rst
hello, when running the example as it is, a deprecation message is shown (i'm on PHP 8.1.6). the deprecation message says that ``trim(): Passing null to parameter #1 ($string) of type string is deprecated``. what if we add a normalizer that returns an empty string when the entered value is `null` otherwise returns the user's intial input. with this suggestion, the example works great
1 parent 63db952 commit 7b998f1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

components/console/helpers/questionhelper.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ You can also use a validator with a hidden question::
420420
$helper = $this->getHelper('question');
421421

422422
$question = new Question('Please enter your password');
423+
$question->setNormalizer(function ($value) {
424+
return null === $value ? '' : $value;
425+
});
423426
$question->setValidator(function ($value) {
424427
if (trim($value) == '') {
425428
throw new \Exception('The password cannot be empty');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy