Repository navigation
Traits not being handled properly #111
Description
Activity
I can confirm the current version doesn't work with traits.
However, I couldn't think of a way to make our regex distingush:useoutsideclass {}useinsideclass {}(traits)
Maybe #101 or alternatives are worth investigating
What about a simple check if
{precedes theuse?I don't think the
usetag in the header can be in any{}I must admit confess I am bad at regex. Can you help with the regex please?
- Add a
use xxxxxxtrait in Dummy.php - Add the expected result in Expected.php
- Either change the regex in Transformer.php OR add a new transform function like the ones in
Transformer::doTransform $ composer test
- Add a
I'm a regex lame too 🙈 but let me see what I can do with this one
Well, look like #101 is a way to go indeed
Reacted by Tang Rufus- added a commit that references this issue
on Apr 8, 2020 @Kubitomakita I have started a PR #150 to workaround the traits issue because I need this for my own open-source project as mentioned in #149. But I need to quote myself for this here again:
RegExp is not the recommend way to do such transformations!! This is a simple workaround which works but you should really consider building your tool on top of an AST parser like
php-parser.Reacted by Jakub Mikita and Tang Rufus- added a commit that references this issue
on Apr 8, 2020
Trait:
Gets replaced with:
We could always backslashit:
use \Package\Traits\Common;but then it becomesuse Imposter\Prefix\\Package\Traits\CommonIs there any workaround? It might be related to #58 but this doesn't seem to apply to traits.