Skip to content

Spurious deprecated to string call (issue #212) - #213

Open
HenkPoley wants to merge 3 commits into
funivan:masterfrom
HenkPoley:spurious-deprecated-to-string-call
Open

Spurious deprecated to string call (issue #212)#213
HenkPoley wants to merge 3 commits into
funivan:masterfrom
HenkPoley:spurious-deprecated-to-string-call

Conversation

@HenkPoley

@HenkPoley HenkPoley commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Adds a test for the erroneous 'Deprecated __toString call' warning for code like (string)$another->returnsBlaFoo(); I src/test/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallIssue212Test.kt

Attempts to fix the issue inside buildVisitor() and visitPhpMethodReference() overrides in src/main/kotlin/com/funivan/idea/phpClean/inspections/toStringCall/ToStringCallInspection.kt

Should fix Issue #212. But I'm not too familiar with this codebase.

@HenkPoley

Copy link
Copy Markdown
Contributor Author

Small "please merge" bump, after a year. 😇

@funivan

funivan commented Aug 28, 2026

Copy link
Copy Markdown
Owner

@HenkPoley sorry, missed a notification. 👀

@mergify

mergify Bot commented Aug 28, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 ToStringCallInspection visitor 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.

Comment on lines +61 to +63
if (reference.parent is UnaryExpression && reference.classReference is Variable) {
return
}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

3 participants