Skip to content

Commit

Permalink
feature #440 [PHP 8.3] Add Exception/Error classes for Date/Time ex…
Browse files Browse the repository at this point in the history
…tension (Ayesh)

This PR was merged into the 1.x branch.

Discussion
----------

[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)

Commits
-------

010788c [PHP 8.3] Add Exception/Error classes for `Date/Time` extension
  • Loading branch information
nicolas-grekas committed Aug 16, 2023
2 parents 2b18ad0 + 010788c commit 174a51b
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateError extends Error
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateException extends Exception
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateInvalidOperationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateInvalidOperationException extends DateException
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateInvalidTimeZoneException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateInvalidTimeZoneException extends DateException
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateMalformedIntervalStringException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateMalformedIntervalStringException extends DateException
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateMalformedPeriodStringException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateMalformedPeriodStringException extends DateException
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateMalformedStringException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateMalformedStringException extends DateException
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateObjectError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateObjectError extends DateError
{
}
}
16 changes: 16 additions & 0 deletions src/Php83/Resources/stubs/DateRangeError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if (\PHP_VERSION_ID < 80300) {
class DateRangeError extends DateError
{
}
}
13 changes: 13 additions & 0 deletions tests/Php83/Php83Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,17 @@ public function testStreamContextSetOptions()
$this->assertTrue(stream_context_set_options($context, ['http' => ['method' => 'POST']]));
$this->assertSame(['http' => ['method' => 'POST']], stream_context_get_options($context));
}

public function testDateTimeExceptionClassesExist()
{
$this->assertTrue(class_exists('\DateError'));
$this->assertTrue(class_exists('\DateObjectError'));
$this->assertTrue(class_exists('\DateRangeError'));
$this->assertTrue(class_exists('\DateException'));
$this->assertTrue(class_exists('\DateInvalidTimeZoneException'));
$this->assertTrue(class_exists('\DateInvalidOperationException'));
$this->assertTrue(class_exists('\DateMalformedStringException'));
$this->assertTrue(class_exists('\DateMalformedIntervalStringException'));
$this->assertTrue(class_exists('\DateMalformedPeriodStringException'));
}
}

0 comments on commit 174a51b

Please sign in to comment.