Skip to content
Permalink
Browse files

Make line endings mostly all the same

  • Loading branch information...
muglug committed Jul 3, 2019
1 parent 2a08afc commit df3d7e1d2cff4ef25934cad500240ef70989d77c
@@ -1428,7 +1428,7 @@ public function getCompletionItemsForPartialSymbol(
$position,
$position
),
\PHP_EOL . 'use ' . $storage->name . ';'
"\n" . 'use ' . $storage->name . ';'
);
} else {
$position = self::getPositionFromOffset($aliases->namespace_first_stmt_start, $file_contents);
@@ -1437,7 +1437,7 @@ public function getCompletionItemsForPartialSymbol(
$position,
$position
),
'use ' . $storage->name . ';' . \PHP_EOL . \PHP_EOL
'use ' . $storage->name . ';' . "\n" . "\n"
);
}
@@ -90,8 +90,8 @@ public static function addForCodeLocation(
$file_contents = $codebase->getFileContents($code_location->file_path);
if (($file_contents[$bounds[0] - 1] ?? null) === PHP_EOL
&& ($file_contents[$bounds[0] - 2] ?? null) === PHP_EOL
if (($file_contents[$bounds[0] - 1] ?? null) === "\n"
&& ($file_contents[$bounds[0] - 2] ?? null) === "\n"
) {
$bounds[0] -= 2;
}
@@ -164,11 +164,11 @@ public static function getMigrationManipulations(FileProvider $file_provider)
$manipulation = new FileManipulation(
$code_migration->destination_start + $destination_start_offset,
$code_migration->destination_start + $destination_start_offset,
PHP_EOL . substr(
"\n" . substr(
$file_provider->getContents($code_migration->source_file_path),
$delete_file_manipulation->start,
$delete_file_manipulation->end - $delete_file_manipulation->start
) . PHP_EOL
) . "\n"
);
$code_migration_manipulations[$code_migration->destination_file_path][$manipulation->getKey()]
@@ -181,7 +181,7 @@ public function __construct(
foreach ($task_data_iterator as $i => $task_data) {
$task_result = $task_closure($i, $task_data);
$task_done_message = new ForkTaskDoneMessage($task_result);
$serialized_message = $task_done_buffer . base64_encode(serialize($task_done_message)) . PHP_EOL;
$serialized_message = $task_done_buffer . base64_encode(serialize($task_done_message)) . "\n";
if (strlen($serialized_message) > 200) {
$bytes_written = @fwrite($write_stream, $serialized_message);
@@ -202,7 +202,7 @@ public function __construct(
// Serialize this child's produced results and send them to the parent.
$process_done_message = new ForkProcessDoneMessage($results ?: []);
$serialized_message = $task_done_buffer . base64_encode(serialize($process_done_message)) . PHP_EOL;
$serialized_message = $task_done_buffer . base64_encode(serialize($process_done_message)) . "\n";
$bytes_to_write = strlen($serialized_message);
$bytes_written = 0;
@@ -314,8 +314,8 @@ private function readResultsFromChildren()
$content[intval($file)] .= $buffer;
}
if (strpos($buffer, PHP_EOL) !== false) {
$serialized_messages = explode(PHP_EOL, $content[intval($file)]);
if (strpos($buffer, "\n") !== false) {
$serialized_messages = explode("\n", $content[intval($file)]);
$content[intval($file)] = array_pop($serialized_messages);
foreach ($serialized_messages as $serialized_message) {
@@ -41,7 +41,7 @@ public function create(): string
$output[] = $buffer->fetch();
}
$output[] = 'FILE: ' . $issue_data['file_name'] . PHP_EOL;
$output[] = 'FILE: ' . $issue_data['file_name'] . "\n";
$buffer = new BufferedOutput();
$table = new Table($buffer);
@@ -59,7 +59,7 @@ public function create(): string
// so we have clean tables.
$message = $issue_data['message'];
if (strlen($message) > 70) {
$message = implode(PHP_EOL, str_split($message, 70));
$message = implode("\n", str_split($message, 70));
}
$table->addRow([
@@ -78,6 +78,6 @@ public function create(): string
}
}
return implode(PHP_EOL, $output);
return implode("\n", $output);
}
}
@@ -176,15 +176,15 @@ public function getSignature(bool $allow_newlines = false): string
{
$newlines = $allow_newlines && !empty($this->params);
$symbol_text = 'function ' . $this->cased_name . '(' . ($newlines ? PHP_EOL : '') . implode(
',' . ($newlines ? PHP_EOL : ' '),
$symbol_text = 'function ' . $this->cased_name . '(' . ($newlines ? "\n" : '') . implode(
',' . ($newlines ? "\n" : ' '),
array_map(
function (FunctionLikeParameter $param) use ($newlines) : string {
return ($newlines ? ' ' : '') . ($param->type ?: 'mixed') . ' $' . $param->name;
},
$this->params
)
) . ($newlines ? PHP_EOL : '') . ') : ' . ($this->return_type ?: 'mixed');
) . ($newlines ? "\n" : '') . ') : ' . ($this->return_type ?: 'mixed');
if (!$this instanceof MethodStorage) {
return $symbol_text;
@@ -728,7 +728,7 @@ function foo() : void {
$this->assertNotNull($completion_items[0]->additionalTextEdits);
$this->assertCount(1, $completion_items[0]->additionalTextEdits);
$this->assertSame('use Exception;' . \PHP_EOL . \PHP_EOL, $completion_items[0]->additionalTextEdits[0]->newText);
$this->assertSame('use Exception;' . "\n" . "\n", $completion_items[0]->additionalTextEdits[0]->newText);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
$this->assertSame(16, $completion_items[0]->additionalTextEdits[0]->range->start->character);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
@@ -780,7 +780,7 @@ function foo() : void {
$this->assertNotNull($completion_items[0]->additionalTextEdits);
$this->assertCount(1, $completion_items[0]->additionalTextEdits);
$this->assertSame(\PHP_EOL . 'use ArrayObject;', $completion_items[0]->additionalTextEdits[0]->newText);
$this->assertSame("\n" . 'use ArrayObject;', $completion_items[0]->additionalTextEdits[0]->newText);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
$this->assertSame(44, $completion_items[0]->additionalTextEdits[0]->range->start->character);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
@@ -400,16 +400,16 @@ public function testCompactReport()
$compact_report_options->use_color = false;
$this->assertSame(
'FILE: somefile.php' . PHP_EOL .
PHP_EOL .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL .
'| SEVERITY | LINE | ISSUE | DESCRIPTION |' . PHP_EOL .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL .
'| ERROR | 3 | UndefinedVariable | Cannot find referenced variable $as_you |' . PHP_EOL .
'| ERROR | 2 | MixedInferredReturnType | Could not verify return type \'string|null\' for psalmCanVerify |' . PHP_EOL .
'| ERROR | 7 | UndefinedConstant | Const CHANGE_ME is not defined |' . PHP_EOL .
'| INFO | 15 | PossiblyUndefinedGlobalVariable | Possibly undefined global variable $a, first seen on line 10 |' . PHP_EOL .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL,
'FILE: somefile.php' . "\n" .
"\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n" .
'| SEVERITY | LINE | ISSUE | DESCRIPTION |' . "\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n" .
'| ERROR | 3 | UndefinedVariable | Cannot find referenced variable $as_you |' . "\n" .
'| ERROR | 2 | MixedInferredReturnType | Could not verify return type \'string|null\' for psalmCanVerify |' . "\n" .
'| ERROR | 7 | UndefinedConstant | Const CHANGE_ME is not defined |' . "\n" .
'| INFO | 15 | PossiblyUndefinedGlobalVariable | Possibly undefined global variable $a, first seen on line 10 |' . "\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n",
IssueBuffer::getOutput($compact_report_options)
);
}

0 comments on commit df3d7e1

Please sign in to comment.
You can’t perform that action at this time.