Skip to content

Commit 54e4ec6

Browse files
Stop using PHP_EOL (#18101)
* s/PHP_EOL/"\n" Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * PHP_EOL seems to have been intentional here Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Merge concats together Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 1210a25 commit 54e4ec6

14 files changed

Lines changed: 124 additions & 145 deletions

File tree

libraries/classes/Git.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
use function unpack;
4343

4444
use const DIRECTORY_SEPARATOR;
45-
use const PHP_EOL;
4645

4746
/**
4847
* Git class to manipulate Git data
@@ -486,7 +485,7 @@ private function getHashFromHeadRef(string $gitFolder, string $refHead): array
486485
}
487486

488487
// split file to lines
489-
$refLines = explode(PHP_EOL, $packedRefs);
488+
$refLines = explode("\n", $packedRefs);
490489
foreach ($refLines as $line) {
491490
// skip comments
492491
if ($line[0] === '#') {

libraries/classes/Plugins/Export/ExportCodegen.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
use function sprintf;
2424
use function ucfirst;
2525

26-
use const PHP_EOL;
27-
2826
/**
2927
* Handles the export for the CodeGen class
3028
*/
@@ -293,7 +291,7 @@ private function handleNHibernateCSBody($db, $table, array $aliases = [])
293291
$lines[] = ' #endregion';
294292
$lines[] = '}';
295293

296-
return implode(PHP_EOL, $lines);
294+
return implode("\n", $lines);
297295
}
298296

299297
/**
@@ -360,7 +358,7 @@ private function handleNHibernateXMLBody(
360358
$lines[] = ' </class>';
361359
$lines[] = '</hibernate-mapping>';
362360

363-
return implode(PHP_EOL, $lines);
361+
return implode("\n", $lines);
364362
}
365363

366364
/**

libraries/classes/Plugins/Export/ExportCsv.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use function preg_replace;
2525
use function str_replace;
2626

27-
use const PHP_EOL;
28-
2927
/**
3028
* Handles the export for the CSV format
3129
*/
@@ -132,7 +130,7 @@ public function exportHeader(): bool
132130
}
133131
} else {
134132
if (empty($GLOBALS['csv_terminated']) || mb_strtolower($GLOBALS['csv_terminated']) === 'auto') {
135-
$GLOBALS['csv_terminated'] = PHP_EOL;
133+
$GLOBALS['csv_terminated'] = "\n";
136134
} else {
137135
$GLOBALS['csv_terminated'] = str_replace(
138136
[

libraries/classes/Plugins/Export/ExportJson.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
use const JSON_PRETTY_PRINT;
2727
use const JSON_UNESCAPED_UNICODE;
28-
use const PHP_EOL;
2928

3029
/**
3130
* Handles the export for the JSON format
@@ -116,15 +115,15 @@ public function exportHeader(): bool
116115
return false;
117116
}
118117

119-
return $this->export->outputHandler('[' . PHP_EOL . $data . ',' . PHP_EOL);
118+
return $this->export->outputHandler('[' . "\n" . $data . ',' . "\n");
120119
}
121120

122121
/**
123122
* Outputs export footer
124123
*/
125124
public function exportFooter(): bool
126125
{
127-
return $this->export->outputHandler(']' . PHP_EOL);
126+
return $this->export->outputHandler(']' . "\n");
128127
}
129128

130129
/**
@@ -144,7 +143,7 @@ public function exportDBHeader($db, $dbAlias = ''): bool
144143
return false;
145144
}
146145

147-
return $this->export->outputHandler($data . ',' . PHP_EOL);
146+
return $this->export->outputHandler($data . ',' . "\n");
148147
}
149148

150149
/**
@@ -233,7 +232,7 @@ protected function doExportForQuery(
233232
): bool {
234233
[$header, $footer] = explode('"@@DATA@@"', $buffer);
235234

236-
if (! $this->export->outputHandler($header . PHP_EOL . '[' . PHP_EOL)) {
235+
if (! $this->export->outputHandler($header . "\n" . '[' . "\n")) {
237236
return false;
238237
}
239238

@@ -260,7 +259,7 @@ protected function doExportForQuery(
260259

261260
// Output table name as comment if this is the first record of the table
262261
if ($record_cnt > 1) {
263-
if (! $this->export->outputHandler(',' . PHP_EOL)) {
262+
if (! $this->export->outputHandler(',' . "\n")) {
264263
return false;
265264
}
266265
}
@@ -302,7 +301,7 @@ protected function doExportForQuery(
302301
}
303302
}
304303

305-
return $this->export->outputHandler(PHP_EOL . ']' . PHP_EOL . $footer . PHP_EOL);
304+
return $this->export->outputHandler("\n" . ']' . "\n" . $footer . "\n");
306305
}
307306

308307
/**

libraries/classes/Plugins/Export/ExportLatex.php

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use function str_repeat;
2828
use function str_replace;
2929

30-
use const PHP_EOL;
3130
use const PHP_VERSION;
3231

3332
/**
@@ -204,20 +203,20 @@ protected function setProperties(): ExportPluginProperties
204203
*/
205204
public function exportHeader(): bool
206205
{
207-
$head = '% phpMyAdmin LaTeX Dump' . PHP_EOL
208-
. '% version ' . Version::VERSION . PHP_EOL
209-
. '% https://www.phpmyadmin.net/' . PHP_EOL
210-
. '%' . PHP_EOL
206+
$head = '% phpMyAdmin LaTeX Dump' . "\n"
207+
. '% version ' . Version::VERSION . "\n"
208+
. '% https://www.phpmyadmin.net/' . "\n"
209+
. '%' . "\n"
211210
. '% ' . __('Host:') . ' ' . $GLOBALS['cfg']['Server']['host'];
212211
if (! empty($GLOBALS['cfg']['Server']['port'])) {
213212
$head .= ':' . $GLOBALS['cfg']['Server']['port'];
214213
}
215214

216-
$head .= PHP_EOL
215+
$head .= "\n"
217216
. '% ' . __('Generation Time:') . ' '
218-
. Util::localisedDate() . PHP_EOL
219-
. '% ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . PHP_EOL
220-
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . PHP_EOL;
217+
. Util::localisedDate() . "\n"
218+
. '% ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . "\n"
219+
. '% ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n";
221220

222221
return $this->export->outputHandler($head);
223222
}
@@ -242,9 +241,9 @@ public function exportDBHeader($db, $dbAlias = ''): bool
242241
$dbAlias = $db;
243242
}
244243

245-
$head = '% ' . PHP_EOL
246-
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . PHP_EOL
247-
. '% ' . PHP_EOL;
244+
$head = '% ' . "\n"
245+
. '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . "\n"
246+
. '% ' . "\n";
248247

249248
return $this->export->outputHandler($head);
250249
}
@@ -309,14 +308,14 @@ public function exportData(
309308
$columns_alias[$i] = $col_as;
310309
}
311310

312-
$buffer = PHP_EOL . '%' . PHP_EOL . '% ' . __('Data:') . ' ' . $table_alias
313-
. PHP_EOL . '%' . PHP_EOL . ' \\begin{longtable}{|';
311+
$buffer = "\n" . '%' . "\n" . '% ' . __('Data:') . ' ' . $table_alias
312+
. "\n" . '%' . "\n" . ' \\begin{longtable}{|';
314313

315314
$buffer .= str_repeat('l|', $columns_cnt);
316315

317-
$buffer .= '} ' . PHP_EOL;
316+
$buffer .= '} ' . "\n";
318317

319-
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . PHP_EOL;
318+
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . "\n";
320319
if (isset($GLOBALS['latex_caption'])) {
321320
$buffer .= ' \\caption{'
322321
. Util::expandUserString(
@@ -349,7 +348,7 @@ public function exportData(
349348
}
350349

351350
$buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
352-
if (! $this->export->outputHandler($buffer . ' \\endfirsthead ' . PHP_EOL)) {
351+
if (! $this->export->outputHandler($buffer . ' \\endfirsthead ' . "\n")) {
353352
return false;
354353
}
355354

@@ -369,7 +368,7 @@ public function exportData(
369368
}
370369
}
371370

372-
if (! $this->export->outputHandler($buffer . '\\endhead \\endfoot' . PHP_EOL)) {
371+
if (! $this->export->outputHandler($buffer . '\\endhead \\endfoot' . "\n")) {
373372
return false;
374373
}
375374
} else {
@@ -397,13 +396,13 @@ public function exportData(
397396
}
398397
}
399398

400-
$buffer .= ' \\\\ \\hline ' . PHP_EOL;
399+
$buffer .= ' \\\\ \\hline ' . "\n";
401400
if (! $this->export->outputHandler($buffer)) {
402401
return false;
403402
}
404403
}
405404

406-
$buffer = ' \\end{longtable}' . PHP_EOL;
405+
$buffer = ' \\end{longtable}' . "\n";
407406

408407
return $this->export->outputHandler($buffer);
409408
}
@@ -494,8 +493,8 @@ public function exportStructure(
494493
/**
495494
* Displays the table structure
496495
*/
497-
$buffer = PHP_EOL . '%' . PHP_EOL . '% ' . __('Structure:') . ' '
498-
. $table_alias . PHP_EOL . '%' . PHP_EOL . ' \\begin{longtable}{';
496+
$buffer = "\n" . '%' . "\n" . '% ' . __('Structure:') . ' '
497+
. $table_alias . "\n" . '%' . "\n" . ' \\begin{longtable}{';
499498
if (! $this->export->outputHandler($buffer)) {
500499
return false;
501500
}
@@ -513,7 +512,7 @@ public function exportStructure(
513512
$alignment .= 'l|';
514513
}
515514

516-
$buffer = $alignment . '} ' . PHP_EOL;
515+
$buffer = $alignment . '} ' . "\n";
517516

518517
$header = ' \\hline ';
519518
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column')
@@ -551,11 +550,11 @@ public function exportStructure(
551550
'database' => $db_alias,
552551
]
553552
)
554-
. '} \\\\' . PHP_EOL;
553+
. '} \\\\' . "\n";
555554
}
556555

557-
$buffer .= $header . ' \\\\ \\hline \\hline' . PHP_EOL
558-
. '\\endfirsthead' . PHP_EOL;
556+
$buffer .= $header . ' \\\\ \\hline \\hline' . "\n"
557+
. '\\endfirsthead' . "\n";
559558
// Table caption on next pages
560559
if (isset($GLOBALS['latex_caption'])) {
561560
$buffer .= ' \\caption{'
@@ -564,10 +563,10 @@ public function exportStructure(
564563
[static::class, 'texEscape'],
565564
['table' => $table_alias, 'database' => $db_alias]
566565
)
567-
. '} \\\\ ' . PHP_EOL;
566+
. '} \\\\ ' . "\n";
568567
}
569568

570-
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . PHP_EOL;
569+
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . "\n";
571570

572571
if (! $this->export->outputHandler($buffer)) {
573572
return false;
@@ -628,14 +627,14 @@ public function exportStructure(
628627
}
629628

630629
$buffer = str_replace("\000", ' & ', $local_buffer);
631-
$buffer .= ' \\\\ \\hline ' . PHP_EOL;
630+
$buffer .= ' \\\\ \\hline ' . "\n";
632631

633632
if (! $this->export->outputHandler($buffer)) {
634633
return false;
635634
}
636635
}
637636

638-
$buffer = ' \\end{longtable}' . PHP_EOL;
637+
$buffer = ' \\end{longtable}' . "\n";
639638

640639
return $this->export->outputHandler($buffer);
641640
}

libraries/classes/Plugins/Export/ExportPhparray.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
use function strtr;
2424
use function var_export;
2525

26-
use const PHP_EOL;
27-
2826
/**
2927
* Handles the export for the PHP Array class
3028
*/
@@ -83,11 +81,11 @@ public function commentString($string)
8381
public function exportHeader(): bool
8482
{
8583
$this->export->outputHandler(
86-
'<?php' . PHP_EOL
87-
. '/**' . PHP_EOL
88-
. ' * Export to PHP Array plugin for PHPMyAdmin' . PHP_EOL
89-
. ' * @version ' . Version::VERSION . PHP_EOL
90-
. ' */' . PHP_EOL . PHP_EOL
84+
'<?php' . "\n"
85+
. '/**' . "\n"
86+
. ' * Export to PHP Array plugin for PHPMyAdmin' . "\n"
87+
. ' * @version ' . Version::VERSION . "\n"
88+
. ' */' . "\n\n"
9189
);
9290

9391
return true;
@@ -114,9 +112,9 @@ public function exportDBHeader($db, $dbAlias = ''): bool
114112
}
115113

116114
$this->export->outputHandler(
117-
'/**' . PHP_EOL
115+
'/**' . "\n"
118116
. ' * Database ' . $this->commentString(Util::backquote($dbAlias))
119-
. PHP_EOL . ' */' . PHP_EOL
117+
. "\n" . ' */' . "\n"
120118
);
121119

122120
return true;
@@ -198,9 +196,9 @@ public function exportData(
198196
$buffer = '';
199197
$record_cnt = 0;
200198
// Output table name as comment
201-
$buffer .= PHP_EOL . '/* '
199+
$buffer .= "\n" . '/* '
202200
. $this->commentString(Util::backquote($db_alias)) . '.'
203-
. $this->commentString(Util::backquote($table_alias)) . ' */' . PHP_EOL;
201+
. $this->commentString(Util::backquote($table_alias)) . ' */' . "\n";
204202
$buffer .= '$' . $tablefixed . ' = array(';
205203
if (! $this->export->outputHandler($buffer)) {
206204
return false;
@@ -212,9 +210,9 @@ public function exportData(
212210
$record_cnt++;
213211

214212
if ($record_cnt == 1) {
215-
$buffer .= PHP_EOL . ' array(';
213+
$buffer .= "\n" . ' array(';
216214
} else {
217-
$buffer .= ',' . PHP_EOL . ' array(';
215+
$buffer .= ',' . "\n" . ' array(';
218216
}
219217

220218
for ($i = 0; $i < $columns_cnt; $i++) {
@@ -232,7 +230,7 @@ public function exportData(
232230
$buffer = '';
233231
}
234232

235-
$buffer .= PHP_EOL . ');' . PHP_EOL;
233+
$buffer .= "\n" . ');' . "\n";
236234

237235
return $this->export->outputHandler($buffer);
238236
}

0 commit comments

Comments
 (0)