From 6172485b44629de7a0e302c5af4bd8aa082d3f88 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Apr 2017 13:28:52 +0200 Subject: [PATCH 1/2] Documented the getIterator() method --- components/process.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/process.rst b/components/process.rst index 2b9f0b2adf2..a81c4a233a7 100644 --- a/components/process.rst +++ b/components/process.rst @@ -69,6 +69,22 @@ for new output before going to the next iteration:: } } +.. tip:: + + The Process component uses internally a PHP iterator to get the the output + while it is generated. That iterator is exposed via the ``getIterator()`` + method to allow customizing its behavior:: + + $process = new Process('ls -lsa'); + $process->start(); + $iterator = $process->getIterator($process::ITER_SKIP_ERR | $process::ITER_KEEP_OUTPUT); + foreach ($iterator as $data) { + echo $data."\n"; + } + + .. versionadded:: 3.2 + The ``getIterator()`` method was introduced in Symfony 3.2. + The ``mustRun()`` method is identical to ``run()``, except that it will throw a :class:`Symfony\\Component\\Process\\Exception\\ProcessFailedException` if the process couldn't be executed successfully (i.e. the process exited From 15c5471dc3bd34d26a61d7bb4095b4dea3d73643 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 3 May 2017 09:13:55 +0200 Subject: [PATCH 2/2] Fixes --- components/process.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/process.rst b/components/process.rst index a81c4a233a7..b66274c5290 100644 --- a/components/process.rst +++ b/components/process.rst @@ -71,9 +71,9 @@ for new output before going to the next iteration:: .. tip:: - The Process component uses internally a PHP iterator to get the the output - while it is generated. That iterator is exposed via the ``getIterator()`` - method to allow customizing its behavior:: + The Process component internally uses a PHP iterator to get the output while + it is generated. That iterator is exposed via the ``getIterator()`` method + to allow customizing its behavior:: $process = new Process('ls -lsa'); $process->start();