From 4a95db4f80fe5992dd955b478af5937589574c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 8 Jan 2024 09:22:56 +0100 Subject: [PATCH] Remove usages of PHP_EOL --- examples/gridfs_stream.php | 8 +++----- examples/gridfs_stream_wrapper.php | 16 +++++++--------- examples/gridfs_upload.php | 8 +++----- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/examples/gridfs_stream.php b/examples/gridfs_stream.php index 8dd99a9eb..12db71d8a 100644 --- a/examples/gridfs_stream.php +++ b/examples/gridfs_stream.php @@ -19,8 +19,6 @@ use function getenv; use function strlen; -use const PHP_EOL; - require __DIR__ . '/../vendor/autoload.php'; $client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/'); @@ -31,7 +29,7 @@ $stream = $bucket->openUploadStream('hello.txt'); for ($i = 0; $i < 1_000_000; $i++) { - fwrite($stream, 'Hello line ' . $i . PHP_EOL); + fwrite($stream, 'Hello line ' . $i . "\n"); } // Last data are flushed to the server when the stream is closed @@ -46,11 +44,11 @@ $size += strlen($data); } -echo 'Read a total of ' . $size . ' bytes' . PHP_EOL; +echo 'Read a total of ' . $size . ' bytes' . "\n"; // Retrieve the file ID to delete it $id = $bucket->getFileIdForStream($stream); assert($id instanceof ObjectId); $bucket->delete($id); -echo 'Deleted file with ID: ' . $id . PHP_EOL; +echo 'Deleted file with ID: ' . $id . "\n"; diff --git a/examples/gridfs_stream_wrapper.php b/examples/gridfs_stream_wrapper.php index e07285fa0..3371022c7 100644 --- a/examples/gridfs_stream_wrapper.php +++ b/examples/gridfs_stream_wrapper.php @@ -18,8 +18,6 @@ use function getenv; use function stream_context_create; -use const PHP_EOL; - require __DIR__ . '/../vendor/autoload.php'; $client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/'); @@ -31,29 +29,29 @@ echo 'File exists: '; echo file_exists('gridfs://mybucket/hello.txt') ? 'yes' : 'no'; -echo PHP_EOL; +echo "\n"; echo 'Writing file'; file_put_contents('gridfs://mybucket/hello.txt', 'Hello, GridFS!'); -echo PHP_EOL; +echo "\n"; echo 'File exists: '; echo file_exists('gridfs://mybucket/hello.txt') ? 'yes' : 'no'; -echo PHP_EOL; +echo "\n"; echo 'Reading file: '; echo file_get_contents('gridfs://mybucket/hello.txt'); -echo PHP_EOL; +echo "\n"; echo 'Writing new version of the file'; file_put_contents('gridfs://mybucket/hello.txt', 'Hello, GridFS! (v2)'); -echo PHP_EOL; +echo "\n"; echo 'Reading new version of the file: '; echo file_get_contents('gridfs://mybucket/hello.txt'); -echo PHP_EOL; +echo "\n"; echo 'Reading previous version of the file: '; $context = stream_context_create(['gridfs' => ['revision' => -2]]); echo file_get_contents('gridfs://mybucket/hello.txt', false, $context); -echo PHP_EOL; +echo "\n"; diff --git a/examples/gridfs_upload.php b/examples/gridfs_upload.php index c290be093..64bd3ea1c 100644 --- a/examples/gridfs_upload.php +++ b/examples/gridfs_upload.php @@ -19,8 +19,6 @@ use function rewind; use function stream_get_contents; -use const PHP_EOL; - require __DIR__ . '/../vendor/autoload.php'; $client = new Client(getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1/'); @@ -35,16 +33,16 @@ // Upload to GridFS from the stream $id = $gridfs->uploadFromStream('hello.txt', $stream); assert($id instanceof ObjectId); -echo 'Inserted file with ID: ' . $id . PHP_EOL; +echo 'Inserted file with ID: ', $id, "\n"; fclose($stream); // Download the file and print the contents directly to an in-memory stream, chunk by chunk $stream = fopen('php://temp', 'w+'); $gridfs->downloadToStreamByName('hello.txt', $stream); rewind($stream); -echo 'File contents: ' . stream_get_contents($stream) . PHP_EOL; +echo 'File contents: ', stream_get_contents($stream), "\n"; // Delete the file $gridfs->delete($id); -echo 'Deleted file with ID: ' . $id . PHP_EOL; +echo 'Deleted file with ID: ', $id, "\n";