Skip to content

Report uses of deprecated constants#2953

Merged
ondrejmirtes merged 6 commits intophpstan:1.10.xfrom
staabm:depr-const
Mar 5, 2024
Merged

Report uses of deprecated constants#2953
ondrejmirtes merged 6 commits intophpstan:1.10.xfrom
staabm:depr-const

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Mar 3, 2024

implement reflection for constants, to support use of @deprecated on const definitions

@staabm staabm changed the base branch from 1.11.x to 1.10.x March 3, 2024 07:54
@phpstan-bot
Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Mar 3, 2024

build errors should be adressed with phpstan/phpstan-deprecation-rules#112

I was not yet able to test it properly, as I did not yet found a way to use this phpstan-src patch in the deprecation-rules repo

@staabm staabm marked this pull request as ready for review March 3, 2024 09:26
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

yield [
new Name('\FILTER_SANITIZE_STRING'),
TrinaryLogic::createYes(),
'8.1', // deprecation message used in e.g. https://github.com/JetBrains/phpstorm-stubs/blob/9608c953230b08f07b703ecfe459cc58d5421437/filter/filter.php#L478
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be great to get rid of it, right. If the message === X.Y or X.Y.Z, we can remove it using regex

Copy link
Copy Markdown
Contributor Author

@staabm staabm Mar 5, 2024

Choose a reason for hiding this comment

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

filtered it out using regex.

looking into the CI errors https://github.com/phpstan/phpstan-src/actions/runs/8152892522/job/22283354469?pr=2953 I got the idea, we could also turn the deprecation-message into Use of constant %s is deprecated since PHP %s. instead of removing it completly. wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we could also turn the deprecation-message into Use of constant %s is deprecated since PHP %s. instead of removing it completly. wdyt?

We don't do this for any other feature, I don't think it's worth it. Passing different phpVersion or simply analysing it on phpstan.org/try makes it obvious what's going on.

@ondrejmirtes ondrejmirtes merged commit e85f63d into phpstan:1.10.x Mar 5, 2024
@ondrejmirtes
Copy link
Copy Markdown
Member

Thank you.

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.

4 participants