title: PHP PSR1 echo side effects
body: <p>I was working on a command line application and I have this class that handles the business logic. This class has some method that loops all data from a <code>\Generator</code> and echo out some values. </p>
  
  <p>I use <code>\Generator</code> because this command line application will loop a hundred of thousand of datum. and I need it to be print/echo in the command line the output on the fly</p>
  
  <pre class="lang-php prettyprint-override"><code>// SomeClass.php
  class SomeClass {
      //... some code here
      public function someMethod($someArgs) { 
          foreach ($this-&gt;isFromAGenerator() as $data) {
              // the data above from `isFromAGenerator` 
              // is a data that is being yield
              echo $this-&gt;isAnotherMethod($data);
          }
      }
  }
  
  // index.php
  $someClass = new SomeClass();
  $someClass-&gt;someMethod(); 
  
  </code></pre>
  
  <p>This works fine and running smoothly but this is directly violates PSR1 2.3 Side Effects <a href="https://www.php-fig.org/psr/psr-1/#23-side-effects" rel="nofollow noreferrer">https://www.php-fig.org/psr/psr-1/#23-side-effects</a></p>
  
  <p>How can I approach this solution without violation PSR1 side effects?</p>