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

RFC/chore: deprecate Tokens::findGivenKind() when searching for multiple kinds #7600

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

keradus
Copy link
Member

@keradus keradus commented Dec 20, 2023

overall, I consider to replace the approach we introduced in past as shortcut of:
findOneOrMany(needle_oneOrMany)

and have following instead
findOne(needle_one)
findMany(needle_many)

WDYT ?

We can have workaround, like @return ($possibleKind is int ? array<int, Token> : array<int, array<int, Token>>), but it prevents stronger types at compile level

src/Tokenizer/Tokens.php Outdated Show resolved Hide resolved
@keradus keradus force-pushed the depr_aaa branch 2 times, most recently from 6e44fbf to 4d1d344 Compare December 30, 2023 23:13
@coveralls
Copy link

Coverage Status

coverage: 94.776% (+0.001%) from 94.775%
when pulling ef06efa on keradus:depr_aaa
into 88f3bf1 on PHP-CS-Fixer:master.

}

/**
* @param int|non-empty-list<int> $possibleKind kind or array of kinds
Copy link
Contributor

@mvorisek mvorisek Dec 30, 2023

Choose a reason for hiding this comment

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

Suggested change
* @param int|non-empty-list<int> $possibleKind kind or array of kinds
* @param int $possibleKind

to enforce the correct method softly/by static analysis

Copy link
Member Author

Choose a reason for hiding this comment

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

not on v3, where both calls are allowed, but one is deprecated.
it can blow-up SCA analysis for repos of custom fixers.

Copy link
Contributor

Choose a reason for hiding this comment

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

it can blow-up SCA analysis for repos of custom fixers.

Why is that a problem? It should be actually desired, as static analysis will tell the developers to use the other method, but the fixers will still run without issues as before.

Copy link
Member Author

@keradus keradus Dec 31, 2023

Choose a reason for hiding this comment

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

IMHO, when introducing such change, we shouldn't fail someone CI, but we should give them deprecation notice.

https://symfony.com/doc/current/contributing/code/bc.html#making-code-changes-in-a-backward-compatible-way
Screenshot 2023-12-31 at 18 13 41

This could break builds for custom fixers on Fixer non-major upgrade. Types of param/return in docblock are considered as BC contract. Imagine method prototype only allowing array $param, and phpdoc changes @parma list<int> $param into @parma list<string> $param

Copy link
Member Author

Choose a reason for hiding this comment

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

btw, consider to give opinion on RFC itself, not detail of phpdoc annotation.

Copy link

Since this pull request has not had any activity within the last 90 days, I have marked it as stale.

The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.

You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.

I will close it if no further activity occurs within the next 14 days.

Please keep your branch up-to-date by rebasing it when main branch is ahead of it, thanks in advance!

@github-actions github-actions bot added status/to verify issue needs to be confirmed or analysed to continue and removed status/stale labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/to verify issue needs to be confirmed or analysed to continue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants