Skip to content

Commit

Permalink
Add #[Deprecated] to the PHP 8.4 polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 19, 2024
1 parent 1754fe1 commit 1bd9f75
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Polyfills are provided for:
- the `SQLite3Exception` class introduced in PHP 8.3;
- the `mb_ucfirst` and `mb_lcfirst` functions introduced in PHP 8.4;
- the `array_find`, `array_find_key`, `array_any` and `array_all` functions introduced in PHP 8.4;
- the `Deprecated` attribute introduced in PHP 8.4;

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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"src/Intl/Icu/Resources/stubs",
"src/Intl/MessageFormatter/Resources/stubs",
"src/Intl/Normalizer/Resources/stubs",
"src/Php84/Resources/stubs",
"src/Php83/Resources/stubs",
"src/Php82/Resources/stubs",
"src/Php81/Resources/stubs",
Expand Down
3 changes: 1 addition & 2 deletions src/Php83/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
}
],
"require": {
"php": ">=7.1",
"symfony/polyfill-php80": "^1.14"
"php": ">=7.1"
},
"autoload": {
"psr-4": { "Symfony\\Polyfill\\Php83\\": "" },
Expand Down
1 change: 1 addition & 0 deletions src/Php84/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This component provides features added to PHP 8.4 core:

- [`mb_ucfirst` and `mb_lcfirst`](https://wiki.php.net/rfc/mb_ucfirst)
- [`array_find`, `array_find_key`, `array_any` and `array_all`](https://wiki.php.net/rfc/array_find)
- [`Deprecated`](https://wiki.php.net/rfc/deprecated_attribute)

More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
Expand Down
25 changes: 25 additions & 0 deletions src/Php84/Resources/stubs/Deprecated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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 < 80400) {
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION | Attribute::TARGET_CLASS_CONSTANT)]
final class Deprecated
{
public readonly ?string $message;
public readonly ?string $since;

public function __construct(?string $message = null, ?string $since = null)
{
$this->message = $message;
$this->since = $since;
}
}
}
3 changes: 2 additions & 1 deletion src/Php84/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
},
"autoload": {
"psr-4": { "Symfony\\Polyfill\\Php84\\": "" },
"files": [ "bootstrap.php" ]
"files": [ "bootstrap.php" ],
"classmap": [ "Resources/stubs" ]
},
"minimum-stability": "dev",
"extra": {
Expand Down

0 comments on commit 1bd9f75

Please sign in to comment.