Skip to content

Commit 413488c

Browse files
committed
Remove usages of PHP_EOL
1 parent 3f2e3aa commit 413488c

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

examples/gridfs_stream.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use function getenv;
2020
use function strlen;
2121

22-
use const PHP_EOL;
23-
2422
require __DIR__ . '/../vendor/autoload.php';
2523

2624
$client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/');
@@ -31,7 +29,7 @@
3129
$stream = $bucket->openUploadStream('hello.txt');
3230

3331
for ($i = 0; $i < 1_000_000; $i++) {
34-
fwrite($stream, 'Hello line ' . $i . PHP_EOL);
32+
fwrite($stream, 'Hello line ' . $i . "\n");
3533
}
3634

3735
// Last data are flushed to the server when the stream is closed
@@ -46,11 +44,11 @@
4644
$size += strlen($data);
4745
}
4846

49-
echo 'Read a total of ' . $size . ' bytes' . PHP_EOL;
47+
echo 'Read a total of ' . $size . ' bytes' . "\n";
5048

5149
// Retrieve the file ID to delete it
5250
$id = $bucket->getFileIdForStream($stream);
5351
assert($id instanceof ObjectId);
5452
$bucket->delete($id);
5553

56-
echo 'Deleted file with ID: ' . $id . PHP_EOL;
54+
echo 'Deleted file with ID: ' . $id . "\n";

examples/gridfs_stream_wrapper.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
use function getenv;
1919
use function stream_context_create;
2020

21-
use const PHP_EOL;
22-
2321
require __DIR__ . '/../vendor/autoload.php';
2422

2523
$client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/');
@@ -31,29 +29,29 @@
3129

3230
echo 'File exists: ';
3331
echo file_exists('gridfs://mybucket/hello.txt') ? 'yes' : 'no';
34-
echo PHP_EOL;
32+
echo "\n";
3533

3634
echo 'Writing file';
3735
file_put_contents('gridfs://mybucket/hello.txt', 'Hello, GridFS!');
38-
echo PHP_EOL;
36+
echo "\n";
3937

4038
echo 'File exists: ';
4139
echo file_exists('gridfs://mybucket/hello.txt') ? 'yes' : 'no';
42-
echo PHP_EOL;
40+
echo "\n";
4341

4442
echo 'Reading file: ';
4543
echo file_get_contents('gridfs://mybucket/hello.txt');
46-
echo PHP_EOL;
44+
echo "\n";
4745

4846
echo 'Writing new version of the file';
4947
file_put_contents('gridfs://mybucket/hello.txt', 'Hello, GridFS! (v2)');
50-
echo PHP_EOL;
48+
echo "\n";
5149

5250
echo 'Reading new version of the file: ';
5351
echo file_get_contents('gridfs://mybucket/hello.txt');
54-
echo PHP_EOL;
52+
echo "\n";
5553

5654
echo 'Reading previous version of the file: ';
5755
$context = stream_context_create(['gridfs' => ['revision' => -2]]);
5856
echo file_get_contents('gridfs://mybucket/hello.txt', false, $context);
59-
echo PHP_EOL;
57+
echo "\n";

examples/gridfs_upload.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use function rewind;
2020
use function stream_get_contents;
2121

22-
use const PHP_EOL;
23-
2422
require __DIR__ . '/../vendor/autoload.php';
2523

2624
$client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/');
@@ -35,16 +33,16 @@
3533
// Upload to GridFS from the stream
3634
$id = $gridfs->uploadFromStream('hello.txt', $stream);
3735
assert($id instanceof ObjectId);
38-
echo 'Inserted file with ID: ' . $id . PHP_EOL;
36+
echo 'Inserted file with ID: ', $id, "\n";
3937
fclose($stream);
4038

4139
// Download the file and print the contents directly to an in-memory stream, chunk by chunk
4240
$stream = fopen('php://temp', 'w+');
4341
$gridfs->downloadToStreamByName('hello.txt', $stream);
4442
rewind($stream);
45-
echo 'File contents: ' . stream_get_contents($stream) . PHP_EOL;
43+
echo 'File contents: ', stream_get_contents($stream), "\n";
4644

4745
// Delete the file
4846
$gridfs->delete($id);
4947

50-
echo 'Deleted file with ID: ' . $id . PHP_EOL;
48+
echo 'Deleted file with ID: ', $id, "\n";

0 commit comments

Comments
 (0)