Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require constructor property promotion #283

Merged
merged 2 commits into from Aug 26, 2022

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Jul 20, 2022

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.

@@ -25,20 +25,10 @@ class Example implements IteratorAggregate
{
private const VERSION = PHP_VERSION - (PHP_MINOR_VERSION * 100) - PHP_PATCH_VERSION;

private int|null $foo = null;

/** @var string[] */
Copy link
Member Author

Choose a reason for hiding this comment

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

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,
   …
) {

Copy link
Member

Choose a reason for hiding this comment

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

I use the following:

/** @param list<EntitySlot> $slots */
public function __construct(
    private readonly array $slots,
) {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as @morozov

Copy link
Contributor

Choose a reason for hiding this comment

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

@greg0ire I can add some options to the sniff if needed (in August).

Copy link
Member

Choose a reason for hiding this comment

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

I think, this is fine. We have other sniffs plus static analysis in place that should already complain about the missing @param annotation.

Copy link
Member Author

@greg0ire greg0ire Jul 21, 2022

Choose a reason for hiding this comment

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

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?

Copy link
Member

Choose a reason for hiding this comment

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

Or just keep as is so that this disappearance stays documented?

Keeping it as it is, is fine I guess.

@greg0ire greg0ire marked this pull request as ready for review August 26, 2022 10:26
@greg0ire greg0ire requested a review from a team as a code owner August 26, 2022 10:26
@Ocramius Ocramius added this to the 10.0.0 milestone Aug 26, 2022
@greg0ire greg0ire requested review from a team and morozov August 26, 2022 10:44
@ostrolucky ostrolucky merged commit 7903671 into doctrine:10.0.x Aug 26, 2022
@greg0ire greg0ire deleted the require-cpp branch August 26, 2022 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants