Require constructor property promotion#283
Conversation
|
|
||
| private int|null $foo = null; | ||
|
|
||
| /** @var string[] */ |
There was a problem hiding this comment.
This comment is lost. Should I report a bug about it? I've tried adding an @param phpdoc to the constructor, and it stays.
In your projects, when you use CPP, do you use @param, or do you annotate properties, like this:
public function __construct(
/** @var list<string> */
private array $someProperty,
…
) {There was a problem hiding this comment.
I use the following:
/** @param list<EntitySlot> $slots */
public function __construct(
private readonly array $slots,
) {
}There was a problem hiding this comment.
@greg0ire I can add some options to the sniff if needed (in August).
There was a problem hiding this comment.
I think, this is fine. We have other sniffs plus static analysis in place that should already complain about the missing @param annotation.
There was a problem hiding this comment.
There seems to be an agreement. What should I do then? Use @param in tests/fixed/example-class.php and fix the patches so that they apply cleanly? Or just keep as is so that this disappearance stays documented?
There was a problem hiding this comment.
Or just keep as is so that this disappearance stays documented?
Keeping it as it is, is fine I guess.
880a095 to
e0b40d9
Compare
I need to add more tests and to update the patches, but let's first examine together what happens on existing code and what to do about that.