Skip to content

Commit

Permalink
Make line endings mostly all the same
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jul 3, 2019
1 parent 2a08afc commit df3d7e1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/Psalm/Codebase.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ public function getCompletionItemsForPartialSymbol(
$position, $position,
$position $position
), ),
\PHP_EOL . 'use ' . $storage->name . ';' "\n" . 'use ' . $storage->name . ';'
); );
} else { } else {
$position = self::getPositionFromOffset($aliases->namespace_first_stmt_start, $file_contents); $position = self::getPositionFromOffset($aliases->namespace_first_stmt_start, $file_contents);
Expand All @@ -1437,7 +1437,7 @@ public function getCompletionItemsForPartialSymbol(
$position, $position,
$position $position
), ),
'use ' . $storage->name . ';' . \PHP_EOL . \PHP_EOL 'use ' . $storage->name . ';' . "\n" . "\n"
); );
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public static function addForCodeLocation(


$file_contents = $codebase->getFileContents($code_location->file_path); $file_contents = $codebase->getFileContents($code_location->file_path);


if (($file_contents[$bounds[0] - 1] ?? null) === PHP_EOL if (($file_contents[$bounds[0] - 1] ?? null) === "\n"
&& ($file_contents[$bounds[0] - 2] ?? null) === PHP_EOL && ($file_contents[$bounds[0] - 2] ?? null) === "\n"
) { ) {
$bounds[0] -= 2; $bounds[0] -= 2;
} }
Expand Down Expand Up @@ -164,11 +164,11 @@ public static function getMigrationManipulations(FileProvider $file_provider)
$manipulation = new FileManipulation( $manipulation = new FileManipulation(
$code_migration->destination_start + $destination_start_offset, $code_migration->destination_start + $destination_start_offset,
$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), $file_provider->getContents($code_migration->source_file_path),
$delete_file_manipulation->start, $delete_file_manipulation->start,
$delete_file_manipulation->end - $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()] $code_migration_manipulations[$code_migration->destination_file_path][$manipulation->getKey()]
Expand Down
8 changes: 4 additions & 4 deletions src/Psalm/Internal/Fork/Pool.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function __construct(
foreach ($task_data_iterator as $i => $task_data) { foreach ($task_data_iterator as $i => $task_data) {
$task_result = $task_closure($i, $task_data); $task_result = $task_closure($i, $task_data);
$task_done_message = new ForkTaskDoneMessage($task_result); $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) { if (strlen($serialized_message) > 200) {
$bytes_written = @fwrite($write_stream, $serialized_message); $bytes_written = @fwrite($write_stream, $serialized_message);
Expand All @@ -202,7 +202,7 @@ public function __construct(


// Serialize this child's produced results and send them to the parent. // Serialize this child's produced results and send them to the parent.
$process_done_message = new ForkProcessDoneMessage($results ?: []); $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_to_write = strlen($serialized_message);
$bytes_written = 0; $bytes_written = 0;
Expand Down Expand Up @@ -314,8 +314,8 @@ private function readResultsFromChildren()
$content[intval($file)] .= $buffer; $content[intval($file)] .= $buffer;
} }


if (strpos($buffer, PHP_EOL) !== false) { if (strpos($buffer, "\n") !== false) {
$serialized_messages = explode(PHP_EOL, $content[intval($file)]); $serialized_messages = explode("\n", $content[intval($file)]);
$content[intval($file)] = array_pop($serialized_messages); $content[intval($file)] = array_pop($serialized_messages);


foreach ($serialized_messages as $serialized_message) { foreach ($serialized_messages as $serialized_message) {
Expand Down
6 changes: 3 additions & 3 deletions src/Psalm/Report/CompactReport.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function create(): string
$output[] = $buffer->fetch(); $output[] = $buffer->fetch();
} }


$output[] = 'FILE: ' . $issue_data['file_name'] . PHP_EOL; $output[] = 'FILE: ' . $issue_data['file_name'] . "\n";


$buffer = new BufferedOutput(); $buffer = new BufferedOutput();
$table = new Table($buffer); $table = new Table($buffer);
Expand All @@ -59,7 +59,7 @@ public function create(): string
// so we have clean tables. // so we have clean tables.
$message = $issue_data['message']; $message = $issue_data['message'];
if (strlen($message) > 70) { if (strlen($message) > 70) {
$message = implode(PHP_EOL, str_split($message, 70)); $message = implode("\n", str_split($message, 70));
} }


$table->addRow([ $table->addRow([
Expand All @@ -78,6 +78,6 @@ public function create(): string
} }
} }


return implode(PHP_EOL, $output); return implode("\n", $output);
} }
} }
6 changes: 3 additions & 3 deletions src/Psalm/Storage/FunctionLikeStorage.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ public function getSignature(bool $allow_newlines = false): string
{ {
$newlines = $allow_newlines && !empty($this->params); $newlines = $allow_newlines && !empty($this->params);


$symbol_text = 'function ' . $this->cased_name . '(' . ($newlines ? PHP_EOL : '') . implode( $symbol_text = 'function ' . $this->cased_name . '(' . ($newlines ? "\n" : '') . implode(
',' . ($newlines ? PHP_EOL : ' '), ',' . ($newlines ? "\n" : ' '),
array_map( array_map(
function (FunctionLikeParameter $param) use ($newlines) : string { function (FunctionLikeParameter $param) use ($newlines) : string {
return ($newlines ? ' ' : '') . ($param->type ?: 'mixed') . ' $' . $param->name; return ($newlines ? ' ' : '') . ($param->type ?: 'mixed') . ' $' . $param->name;
}, },
$this->params $this->params
) )
) . ($newlines ? PHP_EOL : '') . ') : ' . ($this->return_type ?: 'mixed'); ) . ($newlines ? "\n" : '') . ') : ' . ($this->return_type ?: 'mixed');


if (!$this instanceof MethodStorage) { if (!$this instanceof MethodStorage) {
return $symbol_text; return $symbol_text;
Expand Down
4 changes: 2 additions & 2 deletions tests/LanguageServer/CompletionTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ function foo() : void {


$this->assertNotNull($completion_items[0]->additionalTextEdits); $this->assertNotNull($completion_items[0]->additionalTextEdits);
$this->assertCount(1, $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(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
$this->assertSame(16, $completion_items[0]->additionalTextEdits[0]->range->start->character); $this->assertSame(16, $completion_items[0]->additionalTextEdits[0]->range->start->character);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line); $this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
Expand Down Expand Up @@ -780,7 +780,7 @@ function foo() : void {


$this->assertNotNull($completion_items[0]->additionalTextEdits); $this->assertNotNull($completion_items[0]->additionalTextEdits);
$this->assertCount(1, $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(3, $completion_items[0]->additionalTextEdits[0]->range->start->line);
$this->assertSame(44, $completion_items[0]->additionalTextEdits[0]->range->start->character); $this->assertSame(44, $completion_items[0]->additionalTextEdits[0]->range->start->character);
$this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line); $this->assertSame(3, $completion_items[0]->additionalTextEdits[0]->range->end->line);
Expand Down
20 changes: 10 additions & 10 deletions tests/ReportOutputTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -400,16 +400,16 @@ public function testCompactReport()
$compact_report_options->use_color = false; $compact_report_options->use_color = false;


$this->assertSame( $this->assertSame(
'FILE: somefile.php' . PHP_EOL . 'FILE: somefile.php' . "\n" .
PHP_EOL . "\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL . '+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n" .
'| SEVERITY | LINE | ISSUE | DESCRIPTION |' . PHP_EOL . '| SEVERITY | LINE | ISSUE | DESCRIPTION |' . "\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL . '+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n" .
'| ERROR | 3 | UndefinedVariable | Cannot find referenced variable $as_you |' . PHP_EOL . '| ERROR | 3 | UndefinedVariable | Cannot find referenced variable $as_you |' . "\n" .
'| ERROR | 2 | MixedInferredReturnType | Could not verify return type \'string|null\' for psalmCanVerify |' . PHP_EOL . '| ERROR | 2 | MixedInferredReturnType | Could not verify return type \'string|null\' for psalmCanVerify |' . "\n" .
'| ERROR | 7 | UndefinedConstant | Const CHANGE_ME is not defined |' . PHP_EOL . '| ERROR | 7 | UndefinedConstant | Const CHANGE_ME is not defined |' . "\n" .
'| INFO | 15 | PossiblyUndefinedGlobalVariable | Possibly undefined global variable $a, first seen on line 10 |' . PHP_EOL . '| INFO | 15 | PossiblyUndefinedGlobalVariable | Possibly undefined global variable $a, first seen on line 10 |' . "\n" .
'+----------+------+---------------------------------+---------------------------------------------------------------+' . PHP_EOL, '+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n",
IssueBuffer::getOutput($compact_report_options) IssueBuffer::getOutput($compact_report_options)
); );
} }
Expand Down

0 comments on commit df3d7e1

Please sign in to comment.