Skip to content

Commit d77d651

Browse files
authored
Merge pull request #738 from PHPCSStandards/feature/generator-text-trim-code-titles
Generators/Text: trim code titles
2 parents fbe7599 + 5a36502 commit d77d651

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Generators/Text.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function printCodeComparisonBlock(DOMNode $node)
133133
{
134134
$codeBlocks = $node->getElementsByTagName('code');
135135
$first = trim($codeBlocks->item(0)->nodeValue);
136-
$firstTitle = $codeBlocks->item(0)->getAttribute('title');
136+
$firstTitle = trim($codeBlocks->item(0)->getAttribute('title'));
137137

138138
$firstTitleLines = [];
139139
$tempTitle = '';
@@ -168,7 +168,7 @@ protected function printCodeComparisonBlock(DOMNode $node)
168168
$firstLines = explode("\n", $first);
169169

170170
$second = trim($codeBlocks->item(1)->nodeValue);
171-
$secondTitle = $codeBlocks->item(1)->getAttribute('title');
171+
$secondTitle = trim($codeBlocks->item(1)->getAttribute('title'));
172172

173173
$secondTitleLines = [];
174174
$tempTitle = '';

tests/Core/Generators/Expectations/ExpectedOutputCodeTitleWhitespace.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
This is a standard block.
77

88
----------------------------------------- CODE COMPARISON ------------------------------------------
9-
| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. |
10-
| | |
9+
| Valid: spaces at start of description. | Invalid: spaces at end making line > 46 chars. |
1110
----------------------------------------------------------------------------------------------------
1211
| // Dummy. | // Dummy. |
1312
----------------------------------------------------------------------------------------------------
1413

1514
----------------------------------------- CODE COMPARISON ------------------------------------------
16-
| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. |
17-
| | |
15+
| Valid: spaces at start + end of description. | Invalid: spaces ' ' in description. |
1816
----------------------------------------------------------------------------------------------------
1917
| // Note: description above without the | // Dummy. |
2018
| // trailing whitespace fits in 46 chars. | |

0 commit comments

Comments
 (0)