diff --git a/README.md b/README.md index 5b5c913e..06b757d7 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Polyfills are provided for: - the `mb_trim`, `mb_ltrim` and `mb_rtrim` functions introduced in PHP 8.4; - the `CURL_HTTP_VERSION_3` and `CURL_HTTP_VERSION_3ONLY` constants introduced in PHP 8.4; - the `get_error_handler` and `get_exception_handler` functions introduced in PHP 8.5; +- the `NoDiscard` attribute 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 diff --git a/composer.json b/composer.json index 3ac20a3a..bfd95859 100644 --- a/composer.json +++ b/composer.json @@ -63,6 +63,7 @@ "src/Intl/Icu/Resources/stubs", "src/Intl/MessageFormatter/Resources/stubs", "src/Intl/Normalizer/Resources/stubs", + "src/Php85/Resources/stubs", "src/Php84/Resources/stubs", "src/Php83/Resources/stubs", "src/Php82/Resources/stubs", diff --git a/src/Php85/README.md b/src/Php85/README.md index 2ac492ab..6381a9be 100644 --- a/src/Php85/README.md +++ b/src/Php85/README.md @@ -4,6 +4,7 @@ Symfony Polyfill / Php85 This component provides features added to PHP 8.5 core: - [`get_error_handler` and `get_exception_handler`](https://wiki.php.net/rfc/get-error-exception-handler) +- [`NoDiscard`](https://wiki.php.net/rfc/marking_return_value_as_important) More information can be found in the [main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). diff --git a/src/Php85/Resources/stubs/NoDiscard.php b/src/Php85/Resources/stubs/NoDiscard.php new file mode 100644 index 00000000..bc2c36d9 --- /dev/null +++ b/src/Php85/Resources/stubs/NoDiscard.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (\PHP_VERSION_ID < 80500) { + #[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)] + final class NoDiscard + { + public ?string $message; + + public function __construct(?string $message = null) + { + $this->message = $message; + } + } +} diff --git a/src/Php85/composer.json b/src/Php85/composer.json index 26bedf53..ef0ec8d1 100644 --- a/src/Php85/composer.json +++ b/src/Php85/composer.json @@ -20,7 +20,8 @@ }, "autoload": { "psr-4": { "Symfony\\Polyfill\\Php85\\": "" }, - "files": [ "bootstrap.php" ] + "files": [ "bootstrap.php" ], + "classmap": [ "Resources/stubs" ] }, "minimum-stability": "dev", "extra": {