From 9ab0b10a0f9343bb149571a82f128abb62e4b19a Mon Sep 17 00:00:00 2001 From: jmsche Date: Fri, 29 May 2020 11:55:08 +0200 Subject: [PATCH 1/5] Contributing: added info about code style --- CONTRIBUTING.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8fa35c5..5db0f6e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,21 @@ This will add your changes on top of what's already in upstream, minimizing merg Make sure that all tests are passing before submitting a pull request. -### Step 8: Send the pull request +### Step 8: Fix code style + +Run the following command to check the code style of your changes: + +``` +vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run --diff-format=udiff +``` + +This will print a diff of proposed code style changes. To apply these suggestions, run the following command: + +``` +vendor/bin/php-cs-fixer fix --config=.php_cs.dist +``` + +### Step 9: Send the pull request Send the pull request from your feature branch to us. Be sure to include a description that lets us know what work you did. From 0f20c99a7f8b8792840ac061c34f3450641a03cc Mon Sep 17 00:00:00 2001 From: Andrii Dembitskyi Date: Fri, 2 Oct 2020 21:28:30 +0300 Subject: [PATCH 2/5] Fix constant usage in example --- .../_pages/guides/4-symfony-stream-content-large-spreadsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_pages/guides/4-symfony-stream-content-large-spreadsheet.md b/docs/_pages/guides/4-symfony-stream-content-large-spreadsheet.md index fb203ae..165a4b3 100644 --- a/docs/_pages/guides/4-symfony-stream-content-large-spreadsheet.md +++ b/docs/_pages/guides/4-symfony-stream-content-large-spreadsheet.md @@ -94,7 +94,7 @@ class MyStreamController extends Controller $i++; // Flushing the buffer every N rows to stream echo'ed content. - if ($i % FLUSH_THRESHOLD === 0) { + if ($i % self::FLUSH_THRESHOLD === 0) { flush(); } } From df9d96366f775c2b059d96ec9ef66767d6599942 Mon Sep 17 00:00:00 2001 From: yiranzai Date: Wed, 27 May 2020 20:24:14 +0800 Subject: [PATCH 3/5] Fixed WriterAbstract::openToBrowser meet RFC6266 --- src/Spout/Writer/WriterAbstract.php | 33 ++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php index bbaa735..93f9891 100644 --- a/src/Spout/Writer/WriterAbstract.php +++ b/src/Spout/Writer/WriterAbstract.php @@ -112,7 +112,7 @@ abstract class WriterAbstract implements WriterInterface * @codeCoverageIgnore * {@inheritdoc} */ - public function openToBrowser($outputFileName) + public function openToBrowser($outputFileName, array $headers = []) { $this->outputFilePath = $this->globalFunctionsHelper->basename($outputFileName); @@ -123,9 +123,26 @@ abstract class WriterAbstract implements WriterInterface // @see https://github.com/box/spout/issues/241 $this->globalFunctionsHelper->ob_end_clean(); - // Set headers + /* + * Set headers + * + * For newer browsers such as Firefox, Chrome, Opera, Safari, etc., they all support and use `filename*` + * specified by the new standard, even if they do not automatically decode filename; it does not matter; + * and for older versions of Internet Explorer, they are not recognized `filename*`, will automatically + * ignore it and use the old `filename` (the only minor flaw is that there must be an English suffix name). + * In this way, the multi-browser multi-language compatibility problem is perfectly solved, which does not + * require UA judgment and is more in line with the standard. + * + * @see https://github.com/box/spout/issues/745 + * @see https://tools.ietf.org/html/rfc6266 + * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition + */ $this->globalFunctionsHelper->header('Content-Type: ' . static::$headerContentType); - $this->globalFunctionsHelper->header('Content-Disposition: attachment; filename="' . $this->outputFilePath . '"'); + $this->globalFunctionsHelper->header( + 'Content-Disposition: attachment; ' . + 'filename="' . rawurldecode($this->outputFilePath) . '"; ' . + 'filename*=UTF-8\'\'' . rawurldecode($this->outputFilePath) + ); /* * When forcing the download of a file over SSL,IE8 and lower browsers fail @@ -137,6 +154,16 @@ abstract class WriterAbstract implements WriterInterface $this->globalFunctionsHelper->header('Cache-Control: max-age=0'); $this->globalFunctionsHelper->header('Pragma: public'); + /* + * Set custom Headers + * Sometimes need to output or cover more headers. + * + * @see https://github.com/box/spout/issues/745 + */ + foreach ($headers as $header){ + $this->globalFunctionsHelper->header($header); + } + $this->openWriter(); $this->isWriterOpened = true; From 03e1ce438a7c4099b192240c8dec7f28ae6098cc Mon Sep 17 00:00:00 2001 From: yiranzai Date: Wed, 27 May 2020 20:41:01 +0800 Subject: [PATCH 4/5] Fixed Code Style --- src/Spout/Writer/WriterAbstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php index 93f9891..6c4191a 100644 --- a/src/Spout/Writer/WriterAbstract.php +++ b/src/Spout/Writer/WriterAbstract.php @@ -160,7 +160,7 @@ abstract class WriterAbstract implements WriterInterface * * @see https://github.com/box/spout/issues/745 */ - foreach ($headers as $header){ + foreach ($headers as $header) { $this->globalFunctionsHelper->header($header); } From 91f756be0b0bf78f79f93a36ffdc240a5bf4099d Mon Sep 17 00:00:00 2001 From: yiranzai Date: Thu, 18 Mar 2021 16:13:48 +0800 Subject: [PATCH 5/5] remove custom headers --- src/Spout/Writer/WriterAbstract.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php index 6c4191a..36a583f 100644 --- a/src/Spout/Writer/WriterAbstract.php +++ b/src/Spout/Writer/WriterAbstract.php @@ -112,7 +112,7 @@ abstract class WriterAbstract implements WriterInterface * @codeCoverageIgnore * {@inheritdoc} */ - public function openToBrowser($outputFileName, array $headers = []) + public function openToBrowser($outputFileName) { $this->outputFilePath = $this->globalFunctionsHelper->basename($outputFileName); @@ -154,16 +154,6 @@ abstract class WriterAbstract implements WriterInterface $this->globalFunctionsHelper->header('Cache-Control: max-age=0'); $this->globalFunctionsHelper->header('Pragma: public'); - /* - * Set custom Headers - * Sometimes need to output or cover more headers. - * - * @see https://github.com/box/spout/issues/745 - */ - foreach ($headers as $header) { - $this->globalFunctionsHelper->header($header); - } - $this->openWriter(); $this->isWriterOpened = true;