Skip to content

Pattern matching with wildcards doesn't work for all cases #457

@hgraca

Description

@hgraca

Bug Report

Q A
BC Break no
Library Version 0.4.0
PHP version 7.4

Summary

Pattern matching with wildcards doesn't work as it should, which impacts the expressions selectors.

Current behavior

The pattern *This will match with the expression SoThisIsAnExample

    public function test_wildcard_is_for_alphanumeric(): void
    {
        $pattern = new PatternString('SoThisIsAnExample');
        $this->assertTrue($pattern->matches('*This*'));
        $this->assertFalse($pattern->matches('This*')); // this passes
        $this->assertFalse($pattern->matches('*This')); // this fails but it should pass because the given string doesn't end with `This`
    }

How to reproduce

Add this line to the test \Arkitect\Tests\Unit\Analyzer\PatternStringTest::test_wildcard_is_for_alphanumeric()

    $this->assertFalse($pattern->matches('*This'));

Expected behavior

The test with the extra line should pass

    public function test_wildcard_is_for_alphanumeric(): void
    {
        $pattern = new PatternString('SoThisIsAnExample');
        $this->assertTrue($pattern->matches('*This*'));
        $this->assertFalse($pattern->matches('This*')); // this passes
        $this->assertFalse($pattern->matches('*This')); // this should pass
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions