Spurious deprecated to string call (issue #212) - #213
Conversation
…call-warning Fix ToStringCall cast detection
|
Small "please merge" bump, after a year. 😇 |
|
@HenkPoley sorry, missed a notification. 👀 |
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
🟡 Changes recommended
The new visitPhpMethodReference early-return appears broader than the PSI shape described in the issue and can unintentionally disable inspection coverage for legitimate string-cast method calls depending on receiver form.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR targets Issue #212 by addressing a false-positive “Deprecated __toString call” inspection warning triggered by (string)$obj->method()-style expressions, and adds a regression test for that scenario.
Changes:
- Added a new regression test covering
(string)$another->returnsBlaFoo()(Issue #212). - Updated
ToStringCallInspectionvisitor logic to special-case cast/method-reference PSI shapes to avoid spurious reporting.
File summaries
| File | Description |
|---|---|
src/main/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallInspection.kt |
Adds guard logic in variable/method-reference visitors to avoid false positives caused by PSI grouping/precedence. |
src/test/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallIssue212Test.kt |
Introduces a regression test for the Issue #212 cast + method call pattern. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (reference.parent is UnaryExpression && reference.classReference is Variable) { | ||
| return | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Adds a test for the erroneous 'Deprecated __toString call' warning for code like
(string)$another->returnsBlaFoo();Isrc/test/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallIssue212Test.ktAttempts to fix the issue inside
buildVisitor()andvisitPhpMethodReference()overrides insrc/main/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallInspection.ktShould fix Issue #212. But I'm not too familiar with this codebase.