Skip to content

Commit 010788c

Browse files
committed
[PHP 8.3] Add Exception/Error classes for Date/Time extension
Adds nine classes for the new exceptions/errors declared in ext-date. - [RFC: PHP RFC: More Appropriate Date/Time Exceptions](https://wiki.php.net/rfc/datetime-exceptions) - [PHP.Watch: DateTime Exception Class Polyfill](https://php.watch/versions/8.3/datetime-exceptions#polyfill)
1 parent 2b18ad0 commit 010788c

10 files changed

+157
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateError extends Error
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateException extends Exception
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateInvalidOperationException extends DateException
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateInvalidTimeZoneException extends DateException
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateMalformedIntervalStringException extends DateException
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateMalformedPeriodStringException extends DateException
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateMalformedStringException extends DateException
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateObjectError extends DateError
14+
{
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (\PHP_VERSION_ID < 80300) {
13+
class DateRangeError extends DateError
14+
{
15+
}
16+
}

tests/Php83/Php83Test.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,17 @@ public function testStreamContextSetOptions()
189189
$this->assertTrue(stream_context_set_options($context, ['http' => ['method' => 'POST']]));
190190
$this->assertSame(['http' => ['method' => 'POST']], stream_context_get_options($context));
191191
}
192+
193+
public function testDateTimeExceptionClassesExist()
194+
{
195+
$this->assertTrue(class_exists('\DateError'));
196+
$this->assertTrue(class_exists('\DateObjectError'));
197+
$this->assertTrue(class_exists('\DateRangeError'));
198+
$this->assertTrue(class_exists('\DateException'));
199+
$this->assertTrue(class_exists('\DateInvalidTimeZoneException'));
200+
$this->assertTrue(class_exists('\DateInvalidOperationException'));
201+
$this->assertTrue(class_exists('\DateMalformedStringException'));
202+
$this->assertTrue(class_exists('\DateMalformedIntervalStringException'));
203+
$this->assertTrue(class_exists('\DateMalformedPeriodStringException'));
204+
}
192205
}

0 commit comments

Comments
 (0)