-
Notifications
You must be signed in to change notification settings - Fork 14
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
Unable to pass checks with @param using constructor property promotion and readonly parameters #120
Comments
Hi @matthewhilton , As it happens I'm in the process of trying to fix this and related issues. This particular issue comes from the sister project we're trying to wind down - https://github.com/moodlehq/moodle-local_moodlecheck Over the next few weeks/months we're trying to move all sniffs from there to this project at which point this issue should go away. I have also struggled to find an official way to document these, but the consensus I've come across seems to be: class example {
/**
* Constructor.
*
* @param string $example The constructor argument
*/
public function __construct(
/** @var string The property description */
public readonly string $example,
) {
}
} |
Oh, and the {{@property-read}} class tag is for magic properties. |
And see moodlehq/moodle-local_moodlecheck#129 where there's a PR there too. |
Some references:
Note: This syntax does also work with the latest versions of phpdoc. |
I think that this can be safely closed now, as far as both the legacy tool (local_moodlecheck) and this (moodle-cs) are working ok with the Plus we already have the So, proceeding. If there is anything else pending, don't hesitate to ping me here. Ciao :-) |
Apologies if this is not the correct place to raise this; It's related to moodlecheck/phpdoc but I can see there is an effort to migrate the moodlecheck/phpdoc checks to this plugin, so i'm logging it here.
I've recently added a class using constructor promotion https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion and have set the param/property to
protected readonly
But this spits out the error
Phpdocs for function test::__construct has incomplete parameters list (error)
.If you remove the
readonly
(but leaveprotected
), it passes.Example class:
It looks as though phpdoc says nothing about this either https://docs.phpdoc.org/latest/guide/references/phpdoc/tags/param.html
I tried various combinations e.g.
@param-readonly
,@property-read
but no luckThe text was updated successfully, but these errors were encountered: