phpfmt_stable icon indicating copy to clipboard operation
phpfmt_stable copied to clipboard

ClassToStatic replacing to self, not static

Open kokokurak opened this issue 8 years ago • 1 comments

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?

kokokurak avatar Aug 04 '17 02:08 kokokurak

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.

MKCG avatar Dec 05 '17 23:12 MKCG