Skip to content

Conversation

gharlan
Copy link
Member

@gharlan gharlan commented Aug 31, 2025

No description provided.

@coveralls
Copy link

coveralls commented Aug 31, 2025

Coverage Status

coverage: 94.706% (+0.01%) from 94.693%
when pulling a845a07 on gharlan:code-sample-nowdoc
into f6b7742 on PHP-CS-Fixer:master.

Copy link
Member Author

@gharlan gharlan left a comment

Choose a reason for hiding this comment

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

The main work was done by MultilineStringToHeredocFixer, where I temporary changed the heredoc/nowdoc marker from "EOD" to "PHP".

@@ -33,10 +33,16 @@ public function getDefinition(): FixerDefinitionInterface
{
return new FixerDefinition(
'If the function explicitly returns an array, and has the return type `iterable`, then `yield from` must be used instead of `return`.',
[new CodeSample('<?php function giveMeData(): iterable {
Copy link
Member Author

Choose a reason for hiding this comment

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

In those cases I manually added newlines after the changes of the fixer.

@@ -120,33 +120,48 @@ public function getDefinition(): FixerDefinitionInterface
'Ordering `use` statements.',
[
new CodeSample(
"<?php\nuse function AAC;\nuse const AAB;\nuse AAA;\n"
<<<'PHP'
Copy link
Member Author

Choose a reason for hiding this comment

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

The fixer didn't change these oneliners. I converted some of them manually.

+sample(); $test = 1;
+sample(); $test = 2;
+for ( ; ; ++$sample) {
}
Copy link
Member Author

Choose a reason for hiding this comment

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

You can see that the string content of the samples didn't changed because the generated doc files didn't changed.
Only exception was this sample here where I changed the indentation intentionally..

@keradus keradus changed the title chore: use nowdoc for code samples chore: apply (partially) multiline_string_to_heredoc Sep 1, 2025
@keradus
Copy link
Member

keradus commented Sep 1, 2025

thank you

@keradus keradus merged commit 743fd25 into PHP-CS-Fixer:master Sep 1, 2025
31 checks passed
@gharlan gharlan deleted the code-sample-nowdoc branch September 1, 2025 09:25
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.

3 participants