Join GitHub today
Umple's PHP method generation fails to create valid method parameters #964
When Umple generates PHP code, it fails to adjust method parameters so that they are valid PHP method parameters. To be more exact, the generated PHP code fails to prepend the parameter name with the "$" symbol. As a result, parsing errors occur when PHP attempts to process the generated code.
This was discovered when attempting to fix the "GeometricSystem.ump" UmpleOnline example for PHP compilation in issue #758.
Minimum Steps to Reproduce
Consider the following Umple code
In the generated Canvas.php, for the paint, update, and example, we would expect the following:
If a method's parameter is a primitive type in the Umple code (ex. void example(boolean b)), the corresponding generated method in the PHP code should not include the type (ex. public function example($b)) . Otherwise, we keep the method parameter's type in the generated PHP method.
For both cases, the parameter name must be prepended with the "$" symbol.
Primitive types include strings, booleans, integers, floats, doubles, and booleans.
referenced this issue
Jan 21, 2017
Based on PHP's documentation it appears that no special syntax is required for passing an array as an argument:
However, it is possible to explicitly declare an argument as an array with the
I am wondering if there are preferences on how this should be performed.
For now, I am commenting out the line
I am also wondering what happens when there is a non-primitive array. I didn't find anything too clear in the PHP documentation, but based on comments in my stack overflow post, we must declare the function as
Some of the tests which fail when I fixed this issue have method parameters of type
On top of this, I am wondering why the generated PHP code contains
If there are int variables in test cases, your can change it to Integer. However, that test cases might be used in different languages so you need to check those test cases.