Skip to content

Commit 7b2ec87

Browse files
committed
Fix description when construction Regex scalars
1 parent ee23c04 commit 7b2ec87

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

tests/Foo.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
class Foo extends Regex
1010
{
11+
public $description = 'Bar';
12+
1113
/**
1214
* Return the Regex that the values are validated against.
1315
*

tests/RegexTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public function regexClassProvider()
1919
[
2020
new class() extends Regex {
2121
public $name = 'Foo';
22+
23+
public $description = 'Bar';
2224

2325
/**
2426
* Return the Regex that the values are validated against.
@@ -33,11 +35,29 @@ protected function regex(): string
3335
}
3436
},
3537
],
38+
[
39+
new class([
40+
'name' => 'Foo',
41+
'description' => 'Bar',
42+
]) extends Regex {
43+
/**
44+
* Return the Regex that the values are validated against.
45+
*
46+
* Must be a valid
47+
*
48+
* @return string
49+
*/
50+
protected function regex(): string
51+
{
52+
return '/foo/';
53+
}
54+
},
55+
],
3656
[
3757
new Foo(),
3858
],
3959
[
40-
Regex::make('Foo', '/foo/'),
60+
Regex::make('Foo', 'Bar', '/foo/'),
4161
],
4262
];
4363
}
@@ -48,6 +68,7 @@ protected function regex(): string
4868
public function testCreateNamedRegexClass(Regex $regex)
4969
{
5070
$this->assertSame('Foo', $regex->name);
71+
$this->assertSame('Bar', $regex->description);
5172
}
5273

5374
/**

0 commit comments

Comments
 (0)