-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong wrapping condition in array formater #45
Comments
This would be very neat, indeed. Hopefully this’ll get implemented. |
Having changed /**
* The attributes that should be mutated to dates.
*
* @var array $dates
*/
public $dates = [
self::CREATED_AT,
self::UPDATED_AT,
]; What normally happens is the following: /**
* The attributes that should be mutated to dates.
*
* @var array $dates
*/
public $dates = [self::CREATED_AT, self::UPDATED_AT]; I personally prefer the former over the latter and I'd like to be able to configure this setting. Thanks for your time! Tom |
Thank you! |
@ttomdewit I currently struggle with the same issue, where I also would prefer the former version where each item of the array is in separate line. How do I get there with the latest version? I would need to update Do you have any suggestion? |
@duxthefux I haven’t worked on my project for a very long time so I’m afraid I’m not able to help a ton. As soon as I’m back on it I’ll try and see if this works now. |
@duxthefux The former version of the generator also decide to wrap the code or not, but the algorithm counts the length of line without the length of the property name. This fix just changes the counting mechanism to wrap the code more frequently. To add the possibility of "wrap always", it will be necessary to add public static variable Will you prepare the feature request and pull request? |
@zeleznypa just created an MR #56 |
@duxthefux Thanks for the contribution, but:
But as I said, it is not up to me... |
Version: 3.2.*
Bug Description
Wrapping condition ignore the length of the property name and needed characters
$ = []
https://github.com/nette/php-generator/blob/master/src/PhpGenerator/Helpers.php#L97
Steps To Reproduce
Actual generator produce code:
Expected Behavior
Generate code:
Possible Solution
Add possibility to modify Helper::WRAP_LENGTH by custom length that will be filled here by
str_len($property->getName()) + 6
The text was updated successfully, but these errors were encountered: