Skip to content

Conversation

ir-regular
Copy link

Reason for change

Multi-line strings get split by AbstractClassGenerator::prefixCodeWithSpaces() into separate lines and then each of these lines gets prefixed with spaces. This has the effect of inserting extra spaces into multi-line strings.

The specific area where this shows up is GraphQL schema element descriptions, which can be optionally formatted using Markdown syntax, and multiple spaces cause change of formatting.

Fix description

For multi-line strings, instead of using a raw var_export result, split the string into separate lines and concatenate newline-containing strings separately.

Copy link
Contributor

@mcg-web mcg-web left a comment

Choose a reason for hiding this comment

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

Thank you for contribution, some minor changes then we can merge this 👍

.gitignore Outdated
@@ -1,3 +1,4 @@
.idea/
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done in global gitignore file.

case is_object($var):
return $default;

case is_string($var):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test for this case please?

Copy link
Author

Choose a reason for hiding this comment

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

I updated the Star Wars schema to have a description which would trigger this bug - or would you prefer a more involved test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks you for the changes

jane-olszewska added 2 commits February 9, 2017 14:07
This prevents bugs that occur when extra spaces are inserted into a multi-line string in AbstractClassGenerator::prefixCodeWithSpaces call.
@ir-regular ir-regular force-pushed the remove-extra-spaces-description branch from 6a310ca to a2df905 Compare February 9, 2017 14:08
@mcg-web mcg-web merged commit 05df8b0 into overblog:master Feb 9, 2017
@ir-regular ir-regular deleted the remove-extra-spaces-description branch February 9, 2017 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants