예제 #1
0
 /**
  * Remove blank lines.
  *
  * @param string   $source
  * @param Isolator $isolator
  * @return string
  */
 protected function normalizeEndings($source, Isolator $isolator)
 {
     //Step #1, \n only
     $source = $isolator->isolatePHP(Strings::normalizeEndings($source));
     //Step #2, chunk by lines
     $sourceLines = explode("\n", $source);
     //Step #3, no blank lines and html comments (will keep conditional commends)
     $sourceLines = array_filter($sourceLines, function ($line) {
         return trim($line);
     });
     $source = $isolator->repairPHP(join("\n", $sourceLines));
     $isolator->reset();
     return $source;
 }
예제 #2
0
파일: Source.php 프로젝트: vvval/spiral
 /**
  * Converts input string into set of lines.
  *
  * @param string $string
  * @param bool   $cutIndents
  * @return array
  */
 public function fetchLines($string, $cutIndents)
 {
     if ($cutIndents) {
         $string = Strings::normalizeEndings($string, false);
     }
     $lines = explode("\n", Strings::normalizeEndings($string, false));
     //Pre-processing
     return array_map([$this, 'prepareLine'], $lines);
 }