Hi Nikita, > Hi internals, > > Currently, placing an attribute on property (or constant) groups is not > allowed: > > class Foo { > #[NonNegative] > public int $x, $y, $z; > } > // Fatal error: Cannot apply attributes to a group of properties > > This is a case that was not explicitly mentioned in the RFC and we decided > to be conversative when landing the initial implementation. > > However, this restriction seems pretty arbitrary to me, and I think we > should remove it. While there is some potential ambiguity as to whether the > attribute applies to all properties or only the first one, I think the > general expectation is that it should apply to all properties, just like > the property type does. > > PR to allow this: https://github.com/php/php-src/pull/6186 > > Any thoughts on this?
That seems like a good idea and doesn't seem like an ABI change. I'm surprised this was a special case in the original implementation. I wouldn't consider it a BC break if code that was previously a CompileError no longer threw a CompileError. The attribute node occurs before property modifiers such as `private static`, which already pretty clearly apply to all elements in an attribute group, not just the first element. Regards, - Tyson -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php