PHP-Parser icon indicating copy to clipboard operation
PHP-Parser copied to clipboard

Move the class modifiers consts to the ClassLike class

Open tomzx opened this issue 7 years ago • 3 comments

Since the modifiers apply to all of the ClassLike classes, it seems it would make more sense if those const where in this class instead.

This will likely require a major bump.

Thoughts?

tomzx avatar Feb 15 '18 20:02 tomzx

I think if we move those constants, it might be best to create a separate Modifiers class for it. After all, they are not specific to classes, but are also used in methods, properties and constants.

nikic avatar Feb 28 '18 21:02 nikic

+1 for:

it might be best to create a separate Modifiers class for it

Not directly using PHP-Parser in PHP, but taking it as reference for some other language related work. I agree It would be better if treated those as separate.

The same idea apply to Visibility. Currently Modifiers as well as Visibility are treated the same, as flags, if I have understood well the code in Class_ and ClassMethod.

Please take in consideration i am not aware about implementation issues this could bring. Just providing my 2 cents.

davidmpaz avatar May 19 '18 08:05 davidmpaz

@davidmpaz The reason why I wouldn't separate visibility and other modifiers is that they are not ordered. I.e. both public static and static public are valid. It doesn't really matter in the current design where the modifiers are flags, but it would be a problem if we would also try to preserve the order in which the modifiers were declared in the future.

nikic avatar May 19 '18 09:05 nikic