Skip to content

Commit

Permalink
Deprecate Writer::relaxEnclosure method
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 9, 2025
1 parent a0774c9 commit 83b2aa9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ All Notable changes to `Csv` will be documented in this file

### Added

- None
- `Writer::necessaryEnclosure`

### Deprecated

- None
- `Writer::relaxEnclosure` use `Writer::necessaryEnclosure`

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion docs/9.0/writer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ By default, `getFlushTreshold` returns `null`.

```php
public Writer::forceEnclosure(): self
public Writer::relaxEnclosure(): self
public Writer::necessaryEnclosure(): self
public Writer::noEnclosure(): self
public Writer::encloseAll(): bool
public Writer::encloseNecessary(): bool
Expand All @@ -149,6 +149,7 @@ With this feature, you can:

<p class="message-warning">When this feature is activated the <code>$escape</code> character is completely ignored (it is the same as setting it to the empty string.)</p>
<p class="message-warning">When no enclosure is used, the library <strong>DO NOT CHECK</strong> for multiline fields.</p>
<p class="message-notice"><code>relaxEnclosure</code> is deprecated since version <code>9.22.0</code> and is replaced by <code>necessaryEnclosure</code></p>

```php
<?php
Expand Down
17 changes: 16 additions & 1 deletion src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function setFlushThreshold(?int $threshold): self
return $this;
}

public function relaxEnclosure(): self
public function necessaryEnclosure(): self
{
$this->enclose_all = self::ENCLOSE_NECESSARY;
$this->resetProperties();
Expand Down Expand Up @@ -338,4 +338,19 @@ public function setNewline(string $newline): self
{
return $this->setEndOfLine($newline);
}

/**
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @see Writer::necessaryEnclosure()
* @deprecated Since version 9.22.0
* @codeCoverageIgnore
*
* Sets the enclosure threshold to only enclose necessary fields.
*/
#[Deprecated(message:'use League\Csv\Writer::necessaryEnclosure()', since:'league/csv:9.22.0')]
public function relaxEnclosure(): self
{
return $this->necessaryEnclosure();
}
}
2 changes: 1 addition & 1 deletion src/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function testForceEnclosure(): void
self::assertStringContainsString('"value 2-0","value 2-1"'."\n", $csv);
self::assertStringContainsString('"to""to","foo\"bar"'."\n", $csv);

$writer->relaxEnclosure();
$writer->necessaryEnclosure();
self::assertFalse($writer->encloseAll());
}

Expand Down

0 comments on commit 83b2aa9

Please sign in to comment.