File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ parameters:
1010 - ./tests
1111 excludePaths :
1212 - var/
13- - templates/
14- - translations/
1513
1614 ignoreErrors :
17- - ' #Attribute class Symfony\\Contracts\\Service\\Attribute\\Required does not exist #' # Not required
15+ # Not required
16+ - ' #Attribute class Symfony\\Contracts\\Service\\Attribute\\Required does not exist #'
17+
18+ # Always set, as it's only NULL after zeroing, which happens later
19+ - '#Parameter \#1 \$verifier of method Rollerworks\\Component\\SplitToken\\SplitToken\:\:hashVerifier\ (\ ) expects string , string\|null given #'
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ abstract class SplitToken
9494 protected array $ config = [];
9595 private HiddenString $ token ;
9696 private string $ selector ;
97- private string $ verifier ;
97+ private ? string $ verifier ;
9898 private ?string $ verifierHash = null ;
9999 private ?\DateTimeImmutable $ expiresAt = null ;
100100
@@ -203,6 +203,10 @@ final public function matches(?SplitTokenValueHolder $token): bool
203203 return false ;
204204 }
205205
206+ if ($ this ->verifier === null ) {
207+ throw new \RuntimeException ('matches() does not work with a SplitToken object when created with create(), use fromString() instead. ' );
208+ }
209+
206210 return $ this ->verifyHash ($ token ->verifierHash (), $ this ->verifier );
207211 }
208212
Original file line number Diff line number Diff line change @@ -166,6 +166,17 @@ public function it_fails_when_creating_holder_with_string_constructed(): void
166166 SplitToken::fromString (self ::FULL_TOKEN )->toValueHolder ();
167167 }
168168
169+ #[Test]
170+ public function it_fails_matches_when_just_created (): void
171+ {
172+ $ splitToken = SplitToken::create (self ::$ randValue );
173+
174+ $ this ->expectException (\RuntimeException::class);
175+ $ this ->expectExceptionMessage ('matches() does not work with a SplitToken object when created with create(), use fromString() instead. ' );
176+
177+ $ splitToken ->matches ($ splitToken ->toValueHolder ());
178+ }
179+
169180 #[Test]
170181 public function it_verifies_split_token (): void
171182 {
You can’t perform that action at this time.
0 commit comments