Skip to content

fix(RemoveParentCallWithoutParentRector): skip cases when class reflection is not found - #7723

Closed
calebdw wants to merge 1 commit into
rectorphp:mainfrom
calebdw:calebdw/push-swmpxlxzuplk
Closed

fix(RemoveParentCallWithoutParentRector): skip cases when class reflection is not found#7723
calebdw wants to merge 1 commit into
rectorphp:mainfrom
calebdw:calebdw/push-swmpxlxzuplk

Conversation

@calebdw

@calebdw calebdw commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Hello!

This rule is removing the parent::__construct() calls when it shouldn't. After some digging I found that the following returns true when the class reflection can't be found, instead of assuming that it has no parents we should just skip:

 return $this->classMethodManipulator->hasParentMethodOrInterfaceMethod($class, $calledMethodName);

Thanks!

@samsonasik

Copy link
Copy Markdown
Member

Could you add fixture file for it? Thank you.

@calebdw

calebdw commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

I tried, but I couldn't replicate in the fixture. It has to do with the reflection provider not being able to find the class

@samsonasik

Copy link
Copy Markdown
Member

That's strange as class is a node the rule visited, that the ClassReflection exists. I assume you have duplicated class name so phpstan can't locate which one which.

@calebdw

calebdw commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

I think it's because I run rector on our tests, but I exclude the tests from phpstan because I don't care about all the warnings. This is the first time I've had any issues

@samsonasik

Copy link
Copy Markdown
Member

in that case, I guess you can add autoloadPaths it via withAutoloadPaths

https://getrector.com/documentation/static-reflection-and-autoload

@calebdw

calebdw commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

Hmm, doesn't look like that worked

@samsonasik

Copy link
Copy Markdown
Member

@calebdw

calebdw commented Dec 8, 2025

Copy link
Copy Markdown
Contributor Author

Hmm, looks like I needed to split excludePaths into a combination of analyse and analyseAndScan:

https://phpstan.org/config-reference#analysed-files

@calebdw calebdw closed this Dec 8, 2025
@calebdw
calebdw deleted the calebdw/push-swmpxlxzuplk branch December 8, 2025 13:48
@github-actions

Copy link
Copy Markdown
Contributor

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 May 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants