Skip to content

Conversation

@cotcotquedec
Copy link

…and traits management from extended class, add export methods for write array a php 5.4 syntax

…and traits management from extended class, add export methods for write array a php 5.4 syntax
*/
public static function fromReflection(\ReflectionClass $ref) {

/**@var PhpClass $class */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For IDE autocompletion

@gossi
Copy link
Member

gossi commented Jun 30, 2016

Thanks a lot. I really like the bugfixes for reading classes from reflection, especially with parent classes, as I didn't cover them. What about interfaces and traits? Will they also inherit methods that are available through reflection? Could you check this situation, too and provide tests for reflection with parents?

Second, the php5.4 array syntax: I'm a bit wondering how you managed to achieve what you did. Probably because you don't know the separation of concerns of this lib (as they are in my mind ;). The most "suspicious" method I'm wondering about is the static export on PhpProperty. Since values (and expressions are handled on the ValuePart) there is now value and expression.

Here are some rules of the lib:

  • The model only consists of information
  • Parsing/reading is either done in the parser or the fromReflection method but nowhere else
  • Writing is done in the GeneratorVisitor and nowhere else

The Writer is "dumb", means it only flushes what it is been told. You teached him some logic, which isn't the right place here. This should be in the GeneratorVisitor and passing the right value to Writer.

Arrays: Arrays in php are so tricky in how they can look. It's also too risky to have an algorithm to parse/write them, as there is always a case a user wants that isn't catched in the algorithm. That's why there is now setValue() and setExpression(). The first is almost always escaped (through var_export()). However, if you want more control over your output, there is expression, which is never escaped, so you can pass code (especially useful for writing short php code statements and arrays as well, too).

So, could you rewrite your enhancements with this new knowledge?
Please feel free to ask questions.

@cotcotquedec
Copy link
Author

Hi, thank you for your answer,

I'm french so i have some trouble to fully understand everything but i try.

I use php-code-genertor to avoid copy-paste process and generated code using php-cli (in a laravel environenment at the time). So i always use it to add code or template of code inside an existing class and it's really important to not have regression of any kind (indentation and syntax included) after generation process.

  • Traits are ok for me at the time
  • Don't use it for manage interface

For php 5.4 syntax, i agree that it's a personnal choice and it will be better to extend the generatoir with my preferences.

I'm not sure to answer your questions!!!

I made some fix every day on, how do you wanna proceed?
i can make a branch for every patch and make a pull request?

Best regards,

@cotcotquedec
Copy link
Author

If you want, you can find the very early alpha of my project here
https://github.com/FrenchFrogs/maker

@gossi
Copy link
Member

gossi commented Nov 16, 2016

This can be closed as all the issues are being resolved with version 0.4.

@gossi gossi closed this Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants