Skip to content

Improve assert rule#7207

Merged
TomasVotruba merged 2 commits intomainfrom
tv-more-types
Sep 1, 2025
Merged

Improve assert rule#7207
TomasVotruba merged 2 commits intomainfrom
tv-more-types

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Sep 1, 2025

Follow up to #7206

@TomasVotruba TomasVotruba changed the title tv more types Improve assert rule Sep 1, 2025
@TomasVotruba TomasVotruba enabled auto-merge (squash) September 1, 2025 14:17
@TomasVotruba TomasVotruba merged commit b32cebd into main Sep 1, 2025
49 checks passed
@TomasVotruba TomasVotruba deleted the tv-more-types branch September 1, 2025 14:18

private function matchTypeToAssertMethod(Type $type): ?string
{
if ($type instanceof IntegerType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use $type->isInteger()->yes() so it works also with integer ranges ?

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 want to start with basic "strict" types first, test it in the wild and then we can iterate further.

@samsonasik
Copy link
Member

@TomasVotruba I think we need to have service like: WebmozartAssertAnalyzer which has task:

  • check if webmozart/assert exists in composer.json -> require, when it only exists under "require-dev", just skip.

@TomasVotruba
Copy link
Member Author

Agreed, this needs an improvement

If this rule is enabled, it should throw error instead if package is missing.
To avoid silent miss on magic condition.

arshidkv12 pushed a commit to arshidkv12/rector-src that referenced this pull request Sep 4, 2025
* add ASSERT set list

* add fixture to cover float and bool types
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants