Skip to content
Open
Changes from 1 commit
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
13 changes: 11 additions & 2 deletions src/Php84/Resources/stubs/Deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION | Attribute::TARGET_CLASS_CONSTANT)]
final class Deprecated
{
public readonly ?string $message;
public readonly ?string $since;
/**
* @readonly
* @var ?string
*/
public $message;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep using typed properties. Attribute classes should not be autoloaded on PHP 7.x anyway as attributes are not supported.

Regarding the readonly keyword, it might make sense to use conditional class definitions to keep them readonly in PHP 8.1+

Copy link
Member Author

@Seldaek Seldaek Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the problem I had is that Composer's phar compiler is linting the files and that goes boom..

Edit: fixed in https://github.com/composer/composer/pull/12627/files#diff-df7082676f4891241241b23e47108e77b204ff234200bdc4203477d672e1554cR199

Maybe we can merge as is and undo it in #496 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I did some changes.. not a pro here with this conditional def mess, so please review carefully :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The composer compiler already have a list of files excluded from linting to account for the fact that Symfony polyfill packages contain some files loaded conditionally: https://github.com/composer/composer/blob/bfc0e3143841dd156d1099a9c6080e1870b470d2/src/Composer/Compiler.php#L192-L199

That's where the case of typed properties need to be handled IMO (the linter would stick complain about one of the files when using conditional definition files anyway, as the file targeting new PHP versions would still use the new syntaxes)


/**
* @readonly
* @var ?string
*/
public $since;

public function __construct(?string $message = null, ?string $since = null)
{
Expand Down
Loading