Skip to content

Transform existing ->and() calls to expect() - #6

Open
pxlrbt wants to merge 3 commits into
pestphp:5.xfrom
pxlrbt:feature/transform-existing-ands
Open

Transform existing ->and() calls to expect()#6
pxlrbt wants to merge 3 commits into
pestphp:5.xfrom
pxlrbt:feature/transform-existing-ands

Conversation

@pxlrbt

@pxlrbt pxlrbt commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Follow up to #4

I realized while the new merge_different_variables option does not transform expect() to ->and() it keeps existing ->and() calls which causes a non-uniform syntax. Added a method to also transform existing code.

Let me know what you think.

@MrPunyapal

Copy link
Copy Markdown
Collaborator

I think new rule will be good? 👀

@pxlrbt

pxlrbt commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

It's the same behavior as the original configuration only that this also transforms existing ->and() calls ones while the current option only keeps existing expect()s. The goal is the same: No ->and() in the code base.

Maybe it should have been a separate rule from the beginning then? But I think they have a lot of overlap. Would you still move everything to a new rule? What about naming? ChainExpectCallsWithoutAnd?

@MrPunyapal

Copy link
Copy Markdown
Collaborator

I was wondering new rule for making expect() from ->and() which will be not part of any sets.

That way rule cannot touch default behaviour and it will be useful for everyone who do not want to use ->and().

@pxlrbt

pxlrbt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

I'll look into it.

@pxlrbt

pxlrbt commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@MrPunyapal I updated the PR and move the logic to a new ConvertAndToExpectRector. What do you think?

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.

2 participants