Skip to content

Commit

Permalink
fix Deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Nov 22, 2024
1 parent 1d08538 commit 3cfd85f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"benchmark": "phpbench run src --report=default",
"phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -vvv --diff --dry-run --allow-risky=yes --ansi",
"phpcs:fix": "php-cs-fixer fix -vvv --allow-risky=yes --ansi",
"phpstan": "phpstan analyse -c phpstan.neon --ansi --memory-limit=192M",
"phpstan": "phpstan analyse -c phpstan.neon --ansi --memory-limit=256M",
"phpunit": "XDEBUG_MODE=coverage phpunit --coverage-text",
"phpunit:min": "phpunit --no-coverage",
"test": [
Expand Down
7 changes: 7 additions & 0 deletions src/ByteSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace League\Csv;

use Deprecated;

/**
* Defines constants for common BOM sequences.
*
Expand All @@ -19,9 +21,14 @@
*/
interface ByteSequence
{
#[Deprecated(message: 'Use Bom:Utf8 instead', since: 'league/csv:9.16.0')]
public const BOM_UTF8 = "\xEF\xBB\xBF";
#[Deprecated(message: 'Use Bom:Utf16be instead', since: 'league/csv:9.16.0')]
public const BOM_UTF16_BE = "\xFE\xFF";
#[Deprecated(message: 'Use Bom:Utf16Le instead', since: 'league/csv:9.16.0')]
public const BOM_UTF16_LE = "\xFF\xFE";
#[Deprecated(message: 'Use Bom:Utf32Be instead', since: 'league/csv:9.16.0')]
public const BOM_UTF32_BE = "\x00\x00\xFE\xFF";
#[Deprecated(message: 'Use Bom:Utf32Le instead', since: 'league/csv:9.16.0')]
public const BOM_UTF32_LE = "\xFF\xFE\x00\x00";
}
6 changes: 6 additions & 0 deletions src/EncloseField.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Csv;

use Deprecated;
use InvalidArgumentException;
use php_user_filter;

Expand Down Expand Up @@ -49,6 +50,7 @@ class EncloseField extends php_user_filter
/**
* Static method to return the stream filter filtername.
*/
#[Deprecated(message: 'Use Writer::forceEnclosure instead', since: 'league/csv:9.10.0')]
public static function getFiltername(): string
{
return self::FILTERNAME;
Expand All @@ -57,6 +59,7 @@ public static function getFiltername(): string
/**
* Static method to register the class as a stream filter.
*/
#[Deprecated(message: 'Use Writer::forceEnclosure instead', since: 'league/csv:9.10.0')]
public static function register(): void
{
if (!in_array(self::FILTERNAME, stream_get_filters(), true)) {
Expand All @@ -70,6 +73,7 @@ public static function register(): void
* @throws InvalidArgumentException if the sequence is malformed
* @throws Exception
*/
#[Deprecated(message: 'Use Writer::forceEnclosure instead', since: 'league/csv:9.10.0')]
public static function addTo(Writer $csv, string $sequence): Writer
{
self::register();
Expand All @@ -93,6 +97,7 @@ protected static function isValidSequence(string $sequence): bool
return strlen($sequence) !== strcspn($sequence, self::$force_enclosure);
}

#[Deprecated(message: 'Use Writer::forceEnclosure instead', since: 'league/csv:9.10.0')]
public function onCreate(): bool
{
return is_array($this->params)
Expand All @@ -105,6 +110,7 @@ public function onCreate(): bool
* @param resource $out
* @param int $consumed
*/
#[Deprecated(message: 'Use Writer::forceEnclosure instead', since: 'league/csv:9.10.0')]
public function filter($in, $out, &$consumed, bool $closing): int
{
/** @var array $params */
Expand Down
1 change: 0 additions & 1 deletion src/EscapeFormula.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ protected function unescapeField(mixed $cell): mixed
*
* @param mixed $value value to check if it is stringable
*/
#[Deprecated(message:'No longer in use', since:'league/csv:9.7.2')]
protected function isStringable(mixed $value): bool
{
return is_string($value) || $value instanceof Stringable;
Expand Down
7 changes: 7 additions & 0 deletions src/RFC4180Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Csv;

use Deprecated;
use InvalidArgumentException;
use php_user_filter;
use TypeError;
Expand Down Expand Up @@ -67,6 +68,7 @@ class RFC4180Field extends php_user_filter
/**
* Static method to add the stream filter to a {@link AbstractCsv} object.
*/
#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public static function addTo(AbstractCsv $csv, string $whitespace_replace = ''): AbstractCsv
{
self::register();
Expand All @@ -89,6 +91,7 @@ public static function addTo(AbstractCsv $csv, string $whitespace_replace = ''):
* Add a formatter to the {@link Writer} object to format the record
* field to avoid enclosure around a field with an empty space.
*/
#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public static function addFormatterTo(Writer $csv, string $whitespace_replace): Writer
{
if ('' == $whitespace_replace || strlen($whitespace_replace) !== strcspn($whitespace_replace, self::$force_enclosure)) {
Expand All @@ -105,6 +108,7 @@ public static function addFormatterTo(Writer $csv, string $whitespace_replace):
/**
* Static method to register the class as a stream filter.
*/
#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public static function register(): void
{
if (!in_array(self::FILTERNAME, stream_get_filters(), true)) {
Expand All @@ -115,6 +119,7 @@ public static function register(): void
/**
* Static method to return the stream filter filtername.
*/
#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public static function getFiltername(): string
{
return self::FILTERNAME;
Expand All @@ -125,6 +130,7 @@ public static function getFiltername(): string
* @param resource $out
* @param int $consumed
*/
#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public function filter($in, $out, &$consumed, bool $closing): int
{
while (null !== ($bucket = stream_bucket_make_writeable($in))) {
Expand All @@ -136,6 +142,7 @@ public function filter($in, $out, &$consumed, bool $closing): int
return PSFS_PASS_ON;
}

#[Deprecated(message: 'Use Reader::setEscape or Writer::setEscape instead', since: 'league/csv:9.2.0')]
public function onCreate(): bool
{
if (!is_array($this->params)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Serializer/AfterMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace League\Csv\Serializer;

use Attribute;
use Deprecated;
use ReflectionAttribute;
use ReflectionClass;

Expand All @@ -28,12 +29,14 @@ final class AfterMapping
public readonly MapRecord $mapRecord;
public readonly array $methods;

#[Deprecated(message: 'Use Leauge\Csv\Serializer\MapRecord instead', since: 'league/csv:9.17.0')]
public function __construct(string ...$methods)
{
$this->mapRecord = new MapRecord($methods);
$this->methods = $this->mapRecord->afterMapping;
}

#[Deprecated(message: 'Use Leauge\Csv\Serializer\MapRecord instead', since: 'league/csv:9.17.0')]
public static function from(ReflectionClass $class): ?self
{
$attributes = $class->getAttributes(self::class, ReflectionAttribute::IS_INSTANCEOF);
Expand Down

0 comments on commit 3cfd85f

Please sign in to comment.