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

Add support for readonly constructor properties #129

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

andrewnicols
Copy link
Contributor

@andrewnicols andrewnicols commented Feb 17, 2024

public function __construct(
    public readonly int $foo,
    protected readonly int $bar,
) {}

The readonly keywords were being detected as types.

@andrewnicols andrewnicols force-pushed the readonlyConstructorProperties branch 2 times, most recently from 81ea129 to 393aac6 Compare February 17, 2024 22:23
@andrewnicols andrewnicols force-pushed the readonlyConstructorProperties branch from 393aac6 to 94e5298 Compare March 14, 2024 08:53
@andrewnicols andrewnicols force-pushed the readonlyConstructorProperties branch 2 times, most recently from 3784ec3 to 4f6c3cc Compare March 14, 2024 13:31
@andrewnicols andrewnicols force-pushed the readonlyConstructorProperties branch from 4f6c3cc to 4de827f Compare March 14, 2024 14:03
@andrewnicols andrewnicols requested a review from stronk7 March 14, 2024 14:18
@andrewnicols
Copy link
Contributor Author

Okay, this should now be sorted.

PHP 8.0 and earlier lack the T_READONLY const so I had to refactor for that, and then realised that correct commenting for promoted properties also broke the sniff.

Copy link
Member

@stronk7 stronk7 left a comment

Choose a reason for hiding this comment

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

I assume that CodeSniffer handles these? Just thinking in advance for anything we may have there related.

@stronk7 stronk7 merged commit 478b16f into moodlehq:main Mar 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants