for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace PhpSpellcheck\Utils;
use PhpSpellcheck\Misspelling;
class IspellOutputParser
{
/**
* @return Misspelling[]
*/
public static function parseMisspellings(string $output, array $context): iterable
$lines = explode(PHP_EOL, $output);
$lineNumber = 1;
foreach ($lines as $line) {
$line = trim($line);
if ('' === $line) {
$lineNumber++;
// Go to the next line
continue;
}
switch ($line[0]) {
case '#':
list(, $word, $offset) = explode(' ', $line);
yield new Misspelling(
yield new PhpSpellcheck\...ber, array(), $context)
Generator
PhpSpellcheck\Misspelling[]
$word,
(int) trim($offset),
$lineNumber,
[],
$context
);
break;
case '&':
$parts = explode(':', $line);
list(, $word, , $offset) = explode(' ', $parts[0]);
explode(', ', trim($parts[1])),