Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression with pattern validation #359

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Analyzer/FullyQualifiedClassName.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public static function fromString(string $fqcn): self

public function isNotAValidPattern(string $pattern): bool
{
return 0 === preg_match('/^([A-Za-z]|\\\\|\*|\?)*$/', $pattern);
return 0 === preg_match('/^([A-Za-z0-9]|\\\\|\*|\?)*$/', $pattern);
}
}
15 changes: 15 additions & 0 deletions tests/Unit/Expressions/ForClasses/ExtendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ public function test_it_should_return_no_violation_on_success(): void
self::assertEquals(0, $violations->count());
}

public function test_it_should_work_with_wildcards(): void
{
$extend = new Extend('My\B14*');

$classDescription = (new ClassDescriptionBuilder())
->setClassName('My\Class')
->setExtends('My\B14Class', 10)
->build();

$violations = new Violations();
$extend->evaluate($classDescription, $violations, 'because');

self::assertEquals(0, $violations->count());
}

public function test_it_should_return_violation_error_when_argument_is_a_regex(): void
{
$extend = new Extend('App\Providers\(Auth|Event|Route|Horizon)ServiceProvider');
Expand Down