LimeParser.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. abstract class LimeParser implements LimeParserInterface
  3. {
  4. public
  5. $buffer = '',
  6. $output = null;
  7. public function __construct(LimeOutputInterface $output)
  8. {
  9. $this->output = $output;
  10. }
  11. protected function clearErrors()
  12. {
  13. while (!empty($this->buffer))
  14. {
  15. if (preg_match('/^\s*([\w\s]+): (.+) in (.+) on line (\d+)/', $this->buffer, $matches))
  16. {
  17. $this->buffer = trim(substr($this->buffer, strlen($matches[0])));
  18. if ($matches[1] == 'Warning')
  19. {
  20. $this->output->warning($matches[1].': '.$matches[2], $matches[3], $matches[4]);
  21. }
  22. else
  23. {
  24. $this->output->error(new LimeError($matches[2], $matches[3], $matches[4], $matches[1]));
  25. }
  26. // consume Xdebug call stack
  27. while (preg_match('/^(Call Stack:|\d\.\d+\s+\d+\s+\d+\.\s+.+:\d+)/', $this->buffer, $matches))
  28. {
  29. $this->buffer = trim(substr($this->buffer, strlen($matches[0])));
  30. }
  31. }
  32. else
  33. {
  34. break;
  35. }
  36. }
  37. }
  38. }