php-generator icon indicating copy to clipboard operation
php-generator copied to clipboard

Promoted properties & reflection consistency

Open jkuchar opened this issue 3 years ago • 2 comments

We have built grifart/caffolder on top of php-generator. As we need to also read the state from php-generator I have found an inconsistency with php-reflection.

With php reflection you get properties & promoted properties when retrieving $class->getProperties(). However when using php generator one has to use $class->getProperties() for old-style properties and $class->getMethod('__construct')->getParameters(). See this utils method for more info.

Wouldn't it be nicer to have property accessible directly using $class->getProperties()?

jkuchar avatar Aug 04 '22 07:08 jkuchar

It would be a BC break, I don't really want to deal with it.

dg avatar Aug 05 '22 02:08 dg

Also it does not make sense to me. PhpGenerator internal structure is AST-like, meaning it corresponds to the code structure, not to the code meaning. So for example PHP reflection will also return methods from traits/parents, but PhpGenerator will not.

JanTvrdik avatar Aug 05 '22 08:08 JanTvrdik