Skip to content

Documented the support of iterators in write() and writeln() #9776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ messages to the console)::
'',
]);

// the value returned by someMethod() can be an iterator (https://secure.php.net/iterator)
// that generates and returns the messages with the 'yield' PHP keyword
$output->writeln($this->someMethod());

// outputs a message followed by a "\n"
$output->writeln('Whoa!');

Expand All @@ -109,6 +113,10 @@ messages to the console)::
$output->write('create a user.');
}

.. versionadded:: 4.1
The support of PHP iterators in the ``write()`` and ``writeln()`` methods
was introduced in Symfony 4.1.

Now, try executing the command:

.. code-block:: terminal
Expand Down