Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce0feb3

Browse filesBrowse files
committed
remove exception properties
1 parent 60b8ba7 commit ce0feb3
Copy full SHA for ce0feb3

File tree

6 files changed

+25
-44
lines changed
Filter options

6 files changed

+25
-44
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Exception/ExpiredSignedUriException.php
+6-5
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Exception/SignedUriException.php
-6
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Exception/UnsignedUriException.php
+5-2
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Exception/UnverifiedSignedUriException.php
+5-2
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/UriSignerTest.php
+6-22
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/UriSigner.php
+3-7
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.