Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

[Rector] Ordering #7

Open
olivernybroe opened this issue May 28, 2020 · 4 comments
Open

[Rector] Ordering #7

olivernybroe opened this issue May 28, 2020 · 4 comments
Labels
enhancement New feature or request polish If related to polishing pest test

Comments

@olivernybroe
Copy link
Member

Let's create a new rector which orders the test alphabetically

The reason for using a new rector is so we can optionally enable/disable it and decouple it from the base rector which is about just refactoring to pest test cases, not making them nicer.

@olivernybroe olivernybroe added the enhancement New feature or request label May 28, 2020
@olivernybroe olivernybroe added the polish If related to polishing pest test label Jul 22, 2020
@owenvoke
Copy link
Member

owenvoke commented Sep 9, 2020

I've been looking into this, and I can't work out if this is actually possible. This is what I've started with, however the FuncCall doesn't appear to have access to other functions in the same file. I was looking at this set for ideas, but that's all about re-ordering class nodes, etc. 🤔

@olivernybroe
Copy link
Member Author

olivernybroe commented Sep 10, 2020

Hmm...

@TomasVotruba how do we create a rector for reordering function calls in a file?
Normally I would take the parent node, but the parent node is the file itself and I can't find a node type for that.
Any help would be highly appreciated ❤️

@TomasVotruba
Copy link
Contributor

Quick answer from phone: use Class_ and stmts.

Best practice: Parents are hard to change, as in real life ;), so better go with the higher node and change its children.

Also check for Order Rector rules in core. There might be some inspiration ☺️

Let me know if you need more.

@owenvoke
Copy link
Member

Does Class_ work when there isn't a class in the file? It's just function calls such as:

it('does test1')->skip();
it('does test2')->skip();

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request polish If related to polishing pest test
Projects
None yet
Development

No branches or pull requests

3 participants