Skip to content

Commit

Permalink
Update develop dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Aug 4, 2023
1 parent ea3fd8d commit c3a4d0d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"require-dev": {
"ext-dom": "*",
"ext-xdebug": "*",
"doctrine/collections": "^2.1.2",
"friendsofphp/php-cs-fixer": "^v3.14.3",
"phpbench/phpbench": "^1.2.10",
"phpstan/phpstan": "^1.10.10",
"doctrine/collections": "^2.1.3",
"friendsofphp/php-cs-fixer": "^v3.22.0",
"phpbench/phpbench": "^1.2.14",
"phpstan/phpstan": "^1.10.26",
"phpstan/phpstan-deprecation-rules": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.3.11",
"phpstan/phpstan-phpunit": "^1.3.13",
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^10.0.19",
"symfony/var-dumper": "^6.3"
"phpunit/phpunit": "^10.3.1",
"symfony/var-dumper": "^6.3.3"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 5 additions & 3 deletions docs/9.0/connections/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ try {
}
```

When using a non-seekable `SplFileObject`, a `RuntimeException` is thrown instead of a `League\Csv\Exception` when using features that require a seekable CSV document. In the following example a seekable CSV document is required to update the inserted newline.
When using a non-seekable `SplFileObject`, a `RuntimeException` is thrown instead of a `League\Csv\Exception`
when using features that require a seekable CSV document. In the following example a seekable CSV document
is required to update the inserted end of line sequence.

```php
use League\Csv\Exception;
use League\Csv\Writer;

try {
$csv = Writer::createFromFileObject(new SplFileObject('php://output', 'w'));
$csv->setNewline("\r\n");
$csv->setEndOfLine("\r\n");
$csv->insertOne(["foo", "bar"]);
} catch (Exception | RuntimeException $e) {
echo $e->getMessage(), PHP_EOL;
}

//in order to change the CSV document newline a seekable CSV document is required
//in order to change the CSV document end of line a seekable CSV document is required
```
21 changes: 12 additions & 9 deletions docs/9.0/writer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ echo $writer->toString();

<p class="message-notice">The addition of this new feature means the deprecation of <a href="/9.0/interoperability/rfc4180-field/">RFC4180Field</a>.</p>

<p class="message-notice">You still need to set the newline sequence as shown below</p>
<p class="message-notice">You still need to set the end of line sequence as shown below</p>

## Handling newline
## Handling end of line

Because PHP's `fputcsv` implementation has a hardcoded `\n`, we need to be able to replace the last `LF` code with one supplied by the developer for more interoperability between CSV packages on different platforms. The newline sequence will be appended to each newly inserted CSV record.
Because PHP's `fputcsv` implementation uses a hardcoded `\n`, we need to be able to replace the last `LF` code
with one supplied by the developer for more interoperability between CSV packages on different platforms.
The end of line sequence will be appended to each newly inserted CSV record.

### Description

<p class="message-notice"><code>setEndOfline</code> and <code>getEndOfLine</code> are available since version <code>9.10.0</code>.</p>
<p class="message-notice"><code>setEndOfline</code> and <code>getEndOfLine</code> are available since version
<code>9.10.0</code>.</p>

```php
public Writer::setEndOfline(string $sequence): self
Expand All @@ -97,16 +100,16 @@ public Writer::getEndOfLine(void): string
use League\Csv\Writer;

$writer = Writer::createFromFileObject(new SplFileObject());
$newline = $writer->getEndOfLine(); //equals "\n";
$writer->getEndOfLine(); //returns "\n";
$writer->setEndOfLine("\r\n");
$newline = $writer->getEndOfLine(); //equals "\r\n";
$writer->getEndOfLine(); //returns "\r\n";
$writer->insertOne(["one", "two"]);
echo $writer->toString(); //displays "one,two\r\n";
echo $writer->toString(); //displays "one,two\r\n";
```

<p class="message-notice"><code>setNewline</code> and <code>getNewLine</code> are deprecated since version <code>9.10.0</code>.</p>
<p class="message-info">The default newline sequence is <code>\n</code>;</p>
<p class="message-warning">If you are using a non-seekable CSV document, changing the newline character will trigger an exception.</p>
<p class="message-info">The default end of line sequence is <code>\n</code>;</p>
<p class="message-warning">If you are using a non-seekable CSV document, changing the end of line character will trigger an exception.</p>

## Flushing the buffer

Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ parameters:
path: src/ReaderTest.php
- message: '#Parameter \#2 \$header of method League\\Csv\\Statement::process\(\) expects array<string>, array<int, int\|string> given.#'
path: src/ResultSetTest.php
- '#Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert::assertStringContainsString\(\)#'
- '#Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert::assertStringNotContainsString\(\)#'
- '#Parameter \#1 \$needle of static method PHPUnit\\Framework\\Assert::assertStringContainsString\(\)#'
reportUnmatchedIgnoredErrors: true

0 comments on commit c3a4d0d

Please sign in to comment.