mekras/php-speller

"$speller->checkText($source, $languages)" will cache "$languages" for all subsequent requests

Closed this issue · 3 comments

Hi, I found the following error:

$speller =  new ExternalSpeller(...); // In the example I use an abstract class because the error is here
$speller->checkText($source, ['en']);
// the command "hunspell -i UTF-8 -a -d en_US" will be generated
$speller->checkText($source, ['uk']);
// "hunspell -i UTF-8 -a -d en_US" will also be generated and hunspell will ignore the language change

The problem exist in: mekras/php-speller/src/ExternalSpeller.php method "composeProcess":

    private function composeProcess(array $command): Process
    {
        if ($this->process === null) {
            $this->process = new Process($command);
        }

        $this->process->setTimeout($this->timeout);

        return $this->process;
    }

because it caches the "process" and does not use the existing "resetProcess" method to clear them.

Good catch :)
Will take care of that 👍

Fixed with 2.3.0

thank you!