Skip to content

Conversation

@mmetayer
Copy link
Contributor

Fixes #24

$issues [] = $issue;
$matches = [];
$pattern = '/^& (?<original>[^\s]+) \d+ (?<offset>\d+): (?<suggestions>.*)$/';
if (1 === preg_match($pattern, $line, $matches)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do if it doesn't match the pattern 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not matching, previously we wouldn't have anything in $parts. So that would be an empty array.
I would say the line is simply ignored.

But you could write a test for that where the Ispell output doesn't match. And see if it breaks :)

Copy link
Collaborator

@icanhazstring icanhazstring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create fix. Thank you!
What you could add is a test to be expected to fail if the "return" value from ispell output does not match your regex.

Other than that. Create PR!

$issues [] = $issue;
$matches = [];
$pattern = '/^& (?<original>[^\s]+) \d+ (?<offset>\d+): (?<suggestions>.*)$/';
if (1 === preg_match($pattern, $line, $matches)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not matching, previously we wouldn't have anything in $parts. So that would be an empty array.
I would say the line is simply ignored.

But you could write a test for that where the Ispell output doesn't match. And see if it breaks :)

public function testCheckTestWithColon(): void
{
$source = $this->prophesize(EncodingAwareSource::class);
$source->getEncoding()->shouldBeCalled()->willReturn('UTF-8');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add shouldBeCalled() to every method your are mocking.
It is not necessary here because the only thing you want to provide is the string value.

What you could have also done is using a instance of StringSource
E.g.

$source = new StringSource('S:t Petersburg är i Ryssland');

Because this is simply a "DataObject" which doesn't need mocking.

@icanhazstring
Copy link
Collaborator

Nice. Thanks for the fix 👍

@icanhazstring icanhazstring merged commit a358650 into mekras:master Jun 18, 2020
@mmetayer mmetayer deleted the fix-24 branch June 18, 2020 08:26
@icanhazstring
Copy link
Collaborator

Tagged with 2.1.1. Thanks again 👏
https://github.com/mekras/php-speller/releases/tag/2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspell output parsing for Swedish

2 participants