Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb24c8a4

Browse files
committed
minor#16870 [Console] Update questionhelper.rst (issamkhadiri1989)
This PR was submitted for the 6.0 branch but it was merged into the 4.4 branch instead.Discussion----------[Console] Update questionhelper.rsthello,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<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/releases for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `6.x` for features of unreleased versions).-->Commits-------bf9e245 Update questionhelper.rst
2 parentsf065b76 +bf9e245 commitb24c8a4

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
@@ -384,6 +384,9 @@ You can also use a validator with a hidden question::
384384
$helper = $this->getHelper('question');
385385

386386
$question = new Question('Please enter your password');
387+
$question->setNormalizer(function ($value) {
388+
return null === $value ? '' : $value;
389+
});
387390
$question->setValidator(function ($value) {
388391
if (trim($value) == '') {
389392
throw new \Exception('The password cannot be empty');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp