Skip to content

Commit ce0feb3

Browse files
committed
remove exception properties
1 parent 60b8ba7 commit ce0feb3

File tree

6 files changed

+25
-44
lines changed

6 files changed

+25
-44
lines changed

src/Symfony/Component/HttpFoundation/Exception/ExpiredSignedUriException.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
*/
1717
final class ExpiredSignedUriException extends SignedUriException
1818
{
19-
public function __construct(
20-
public readonly \DateTimeImmutable $expiredAt,
21-
string $uri,
22-
) {
23-
parent::__construct($uri, 'The URI has expired.');
19+
/**
20+
* @internal
21+
*/
22+
public function __construct()
23+
{
24+
parent::__construct('The URI has expired.');
2425
}
2526
}

src/Symfony/Component/HttpFoundation/Exception/SignedUriException.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,4 @@
1616
*/
1717
abstract class SignedUriException extends \RuntimeException implements ExceptionInterface
1818
{
19-
public function __construct(
20-
public readonly string $uri,
21-
string $message,
22-
) {
23-
parent::__construct($message);
24-
}
2519
}

src/Symfony/Component/HttpFoundation/Exception/UnsignedUriException.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
*/
1717
final class UnsignedUriException extends SignedUriException
1818
{
19-
public function __construct(string $uri)
19+
/**
20+
* @internal
21+
*/
22+
public function __construct()
2023
{
21-
parent::__construct($uri, 'The URI is not signed.');
24+
parent::__construct('The URI is not signed.');
2225
}
2326
}

src/Symfony/Component/HttpFoundation/Exception/UnverifiedSignedUriException.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
*/
1717
final class UnverifiedSignedUriException extends SignedUriException
1818
{
19-
public function __construct(string $uri)
19+
/**
20+
* @internal
21+
*/
22+
public function __construct()
2023
{
21-
parent::__construct($uri, 'The URI signature is invalid.');
24+
parent::__construct('The URI signature is invalid.');
2225
}
2326
}

src/Symfony/Component/HttpFoundation/Tests/UriSignerTest.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,44 +237,28 @@ public function testVerifyUnSignedUri()
237237
$signer = new UriSigner('foobar');
238238
$uri = 'http://example.com/foo';
239239

240-
try {
241-
$signer->verify($uri);
240+
$this->expectException(UnsignedUriException::class);
242241

243-
$this->fail('Exception not thrown.');
244-
} catch (UnsignedUriException $e) {
245-
$this->assertSame('The URI is not signed.', $e->getMessage());
246-
$this->assertSame($uri, $e->uri);
247-
}
242+
$signer->verify($uri);
248243
}
249244

250245
public function testVerifyUnverifiedUri()
251246
{
252247
$signer = new UriSigner('foobar');
253248
$uri = 'http://example.com/foo?_hash=invalid';
254249

255-
try {
256-
$signer->verify($uri);
250+
$this->expectException(UnverifiedSignedUriException::class);
257251

258-
$this->fail('Exception not thrown.');
259-
} catch (UnverifiedSignedUriException $e) {
260-
$this->assertSame('The URI signature is invalid.', $e->getMessage());
261-
$this->assertSame($uri, $e->uri);
262-
}
252+
$signer->verify($uri);
263253
}
264254

265255
public function testVerifyExpiredUri()
266256
{
267257
$signer = new UriSigner('foobar');
268258
$uri = $signer->sign('http://example.com/foo', 123456);
269259

270-
try {
271-
$signer->verify($uri);
260+
$this->expectException(ExpiredSignedUriException::class);
272261

273-
$this->fail('Exception not thrown.');
274-
} catch (ExpiredSignedUriException $e) {
275-
$this->assertSame('The URI has expired.', $e->getMessage());
276-
$this->assertSame($uri, $e->uri);
277-
$this->assertSame(123456, $e->expiredAt->getTimestamp());
278-
}
262+
$signer->verify($uri);
279263
}
280264
}

src/Symfony/Component/HttpFoundation/UriSigner.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,14 @@ public function verify(Request|string $uri): void
126126
}
127127

128128
if (self::STATUS_MISSING === $status) {
129-
throw new UnsignedUriException($uri);
129+
throw new UnsignedUriException();
130130
}
131131

132132
if (self::STATUS_INVALID === $status) {
133-
throw new UnverifiedSignedUriException($uri);
133+
throw new UnverifiedSignedUriException();
134134
}
135135

136-
$url = parse_url($uri);
137-
parse_str($url['query'], $params);
138-
$expiration = $params[$this->expirationParameter];
139-
140-
throw new ExpiredSignedUriException(\DateTimeImmutable::createFromFormat('U', $expiration), $uri);
136+
throw new ExpiredSignedUriException();
141137
}
142138

143139
private function computeHash(string $uri): string

0 commit comments

Comments
 (0)