Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Polyfills are provided for:
- the `NoDiscard` attribute introduced in PHP 8.5;
- the `array_first` and `array_last` functions introduced in PHP 8.5;
- the `DelayedTargetValidation` attribute introduced in PHP 8.5;
- the `Filter\FilterException` class introduced in PHP 8.5;
- the `Filter\FilterFailedException` class introduced in PHP 8.5;

It is strongly recommended to upgrade your PHP version and/or install the missing
extensions whenever possible. This polyfill should be used only when there is no
Expand Down
2 changes: 2 additions & 0 deletions src/Php85/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This component provides features added to PHP 8.5 core:
- [`NoDiscard`](https://wiki.php.net/rfc/marking_return_value_as_important)
- [`array_first` and `array_last`](https://wiki.php.net/rfc/array_first_last)
- [`DelayedTargetValidation`](https://wiki.php.net/rfc/delayedtargetvalidation_attribute)
- [`Filter\FilterException class`](https://wiki.php.net/rfc/filter_throw_on_failure)
- [`Filter\FilterFailedException class`](https://wiki.php.net/rfc/filter_throw_on_failure)

More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
Expand Down
18 changes: 18 additions & 0 deletions src/Php85/Resources/stubs/Filter/FilterException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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.
*/

namespace Filter;

if (\PHP_VERSION_ID < 80500) {
class FilterException extends \Exception
{
}
}
18 changes: 18 additions & 0 deletions src/Php85/Resources/stubs/Filter/FilterFailedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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.
*/

namespace Filter;

if (\PHP_VERSION_ID < 80500) {
class FilterFailedException extends FilterException
{
}
}
6 changes: 6 additions & 0 deletions tests/Php85/Php85Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public function testArrayFirstArrayLast()
$this->assertTrue(array_first([true, new \stdClass()]));
$this->assertEquals(new \stdClass(), array_last([true, new \stdClass()]));
}

public function testFilterExceptionClassesExist()
{
$this->assertTrue(class_exists(\Filter\FilterException::class));
$this->assertTrue(class_exists(\Filter\FilterFailedException::class));
}
}

class TestHandler
Expand Down
Loading