nanch / phpfmt_stable

This is a stable snapshot (version 6125cf9) of the phpfmt plugin for Sublime Text
143 stars 34 forks source link

ClassToStatic replacing to self, not static #31

Open kokokurak opened 6 years ago

kokokurak commented 6 years ago

Like said in the title, ClassToStatic pass is not working at all. It works just like ClassToSelf.

I'm opening this issue to ask what is the status of phpfmt? There are tons of bugs in this project, which makes it hardly usable. Also, the general design of passes and config hierarchy is confusing and just broken.

Are there any better alternatives to phpfmt available? Something that would actually work perhaps?

MKCG commented 6 years ago

Well, ClassToStatic extends ClassToSelf and was using a constant to determine the placeholder to replace.

So there is ClassToSelf::PLACEHOLDER = 'self' and ClassToStatic::PLACEHOLDER = 'static'.

But the ClassToSelf::convertToPlaceholder is using self:: instead of static:: to apply the change.

Ironic, isn't it ?

The change must be applied in the fmt.stub.php line 8324 :

                $this->tkns[$i] = [T_STRING, self::PLACEHOLDER];

should be :

                $this->tkns[$i] = [T_STRING, static::PLACEHOLDER];

I fixed this issue in another repository : https://github.com/MKCG/phpfmt_7-1

I'm starting to think that I should have made a fork in the first place.