Skip to content

Generic/LowerCaseKeyword: add support for asym visibility keywords #1117

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

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Jun 6, 2025

Description

Suggested changelog entry

  • Added support for PHP 8.4 asymmetric visibility modifiers to the following sniffs:
    • Generic.PHP.LowerCaseKeyword

Related issues/external references

Follow up on #851
Follow up on #1116

Related to #734

@jrfnl jrfnl added this to the 3.13.1 milestone Jun 6, 2025
@jrfnl jrfnl marked this pull request as draft June 6, 2025 00:29
@jrfnl jrfnl mentioned this pull request Jun 6, 2025
43 tasks
Comment on lines 62 to 75

class AsymmetricVisibility {
public(set) int $correctPublicSet;
protected(set) int $correctProtectedSet;
private(set) int $correctPrivateSet;

PubliC(SeT) int $wrongCasePublic;
PROTECTED(set) array $wrongCaseProtected;
protected(sEt) int $wrongCaseProtectedSet;
Private(set) int $wrongCasePrivate;
private(SET) readonly ?string $wrongCasePrivateSet;
}

__HALT_COMPILER(); // An exception due to phar support.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to also provide some test cases where we specify both the get and set visibilities?

Example from https://www.php.net/manual/en/language.oop5.visibility.php#language.oop5.visibility-members-aviz

<?php
class Book
{
    public function __construct(
        public private(set) string $title,
        public protected(set) string $author,
        protected private(set) int $pubYear,
    ) {}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I've done that in most other PRs, but this sniff doesn't look "around", i.e. it doesn't do any token walking, it just looks at the token passed as $stackPtr, so in this case, making the tests more diverse would not add any value (as it wouldn't be testing anything which isn't already being tested).

Base automatically changed from php-8.4/feature/file-methods-support-asym-visibility to master June 9, 2025 01:45
@jrfnl jrfnl marked this pull request as ready for review June 9, 2025 01:53
@jrfnl jrfnl merged commit 87beff1 into master Jun 9, 2025
66 checks passed
@jrfnl jrfnl deleted the php-8.4/feature/generic-lowercasekeyword-support-asym-visibility branch June 9, 2025 02: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.

2 participants