Skip to content

Commit 4cf6902

Browse files
committed
DX: remove Utils::splitLines
1 parent 8dee338 commit 4cf6902

File tree

3 files changed

+2
-54
lines changed

3 files changed

+2
-54
lines changed

src/DocBlock/DocBlock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace PhpCsFixer\DocBlock;
1414

15-
use PhpCsFixer\Utils;
15+
use PhpCsFixer\Preg;
1616

1717
/**
1818
* This class represents a docblock.
@@ -44,7 +44,7 @@ class DocBlock
4444
*/
4545
public function __construct($content)
4646
{
47-
foreach (Utils::splitLines($content) as $line) {
47+
foreach (Preg::split('/([^\n\r]+\R*)/', $content, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $line) {
4848
$this->lines[] = new Line($line);
4949
}
5050
}

src/Utils.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,6 @@ public static function cmpInt($a, $b)
8282
return $a < $b ? -1 : 1;
8383
}
8484

85-
/**
86-
* Split a multi-line string up into an array of strings.
87-
*
88-
* We're retaining a newline character at the end of non-blank lines, and
89-
* discarding other lines, so this function is unsuitable for anyone for
90-
* wishing to retain the exact number of line endings. If a single-line
91-
* string is passed, we'll just return an array with a element.
92-
*
93-
* @param string $content
94-
*
95-
* @return string[]
96-
*/
97-
public static function splitLines($content)
98-
{
99-
Preg::matchAll("/[^\n\r]+[\r\n]*/", $content, $matches);
100-
101-
return $matches[0];
102-
}
103-
10485
/**
10586
* Calculate the trailing whitespace.
10687
*

tests/UtilsTest.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,6 @@ public function provideCmpIntCases()
9090
];
9191
}
9292

93-
/**
94-
* @param array $expected
95-
* @param string $input
96-
*
97-
* @dataProvider provideSplitLinesCases
98-
*/
99-
public function testSplitLines(array $expected, $input)
100-
{
101-
$this->assertSame($expected, Utils::splitLines($input));
102-
}
103-
104-
public function provideSplitLinesCases()
105-
{
106-
return [
107-
[
108-
["\t aaa\n", " bbb\n", "\t"],
109-
"\t aaa\n bbb\n\t",
110-
],
111-
[
112-
["aaa\r\n", " bbb\r\n"],
113-
"aaa\r\n bbb\r\n",
114-
],
115-
[
116-
["aaa\r\n", " bbb\n"],
117-
"aaa\r\n bbb\n",
118-
],
119-
[
120-
["aaa\r\n\n\n\r\n", " bbb\n"],
121-
"aaa\r\n\n\n\r\n bbb\n",
122-
],
123-
];
124-
}
125-
12693
/**
12794
* @param string $spaces
12895
* @param array|string $input token prototype

0 commit comments

Comments
 (0)