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

Appearance settings

Commit 1c22d72

Browse filesBrowse files
committed
minor #12703 [WIP][Console] Fix missing return in console documentation on execute function (JeremieSamson)
This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead (closes #12703). Discussion ---------- [WIP][Console] Fix missing return in console documentation on execute function Since Symfony 5.0, we have an error if we don't return an int on the `execute` function, I added it in the doc so there will not be an `TypeError` when trying this. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- e2d1c06 Update console.rst
2 parents 214ffe2 + e2d1c06 commit 1c22d72
Copy full SHA for 1c22d72

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎console.rst

Copy file name to clipboardExpand all lines: console.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ the console::
146146
// outputs a message without adding a "\n" at the end of the line
147147
$output->write('You are about to ');
148148
$output->write('create a user.');
149+
150+
return 0;
149151
}
150152

151153
Now, try executing the command:
@@ -195,6 +197,8 @@ which returns an instance of
195197
// (this example deletes the last two lines of the section)
196198
$section1->clear(2);
197199
// Output is now completely empty!
200+
201+
return 0;
198202
}
199203
}
200204

@@ -235,6 +239,8 @@ Use input options or arguments to pass information to the command::
235239

236240
// retrieve the argument value using getArgument()
237241
$output->writeln('Username: '.$input->getArgument('username'));
242+
243+
return 0;
238244
}
239245

240246
Now, you can pass the username to the command:
@@ -284,6 +290,8 @@ as a service, you can use normal dependency injection. Imagine you have a
284290
$this->userManager->create($input->getArgument('username'));
285291

286292
$output->writeln('User successfully generated!');
293+
294+
return 0;
287295
}
288296
}
289297

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.