Skip to content

Commit 08af8b3

Browse files
committed
Using PHP8.4 Deprecated attributes and simplifying github actions
1 parent 1a31de9 commit 08af8b3

25 files changed

+71
-20
lines changed

.github/workflows/build.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ jobs:
1010
runs-on: ubuntu-20.04
1111
strategy:
1212
matrix:
13-
php: ['8.1', '8.2', '8.3']
13+
php: ['8.1', '8.2', '8.3', '8.4']
1414
stability: [prefer-lowest, prefer-stable]
15-
include:
16-
- php: '8.4'
17-
flags: "--ignore-platform-req=php"
18-
phpunit-flags: '--no-coverage'
19-
stability: prefer-stable
2015
steps:
2116
- name: Checkout code
2217
uses: actions/checkout@v3
@@ -50,11 +45,6 @@ jobs:
5045

5146
- name: Run Unit tests with coverage
5247
run: composer phpunit -- ${{ matrix.phpunit-flags }}
53-
if: ${{ matrix.php == '8.3' || matrix.php == '8.2' || matrix.php == '8.1'}}
54-
55-
- name: Run Unit tests without coverage
56-
run: composer phpunit:min
57-
if: ${{ matrix.php == '8.4'}}
5848

5949
- name: Run static analysis
6050
run: composer phpstan

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
- identifier: missingType.generics
99
- identifier: missingType.iterableValue
1010
- '#implements deprecated interface League\\Csv\\ByteSequence#'
11+
- '#Attribute class Deprecated does not exist.#'
1112
level: max
1213
paths:
1314
- src

src/AbstractCsv.php

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use Generator;
1718
use InvalidArgumentException;
1819
use RuntimeException;
@@ -399,6 +400,7 @@ public function addStreamFilter(string $filtername, null|array $params = null):
399400
*
400401
* Returns the stream filter mode.
401402
*/
403+
#[Deprecated(message:'Use AbstractCsv::supportsStreamFilterOnRead or AbstractCsv::supportsStreamFilterOnWrite instead', since:'league/csv:9.7.0')]
402404
public function getStreamFilterMode(): int
403405
{
404406
return static::STREAM_FILTER_MODE;
@@ -414,6 +416,7 @@ public function getStreamFilterMode(): int
414416
*
415417
* Tells whether the stream filter capabilities can be used.
416418
*/
419+
#[Deprecated(message:'Use AbstractCsv::supportsStreamFilterOnRead or AbstractCsv::supportsStreamFilterOnWrite instead', since:'league/csv:9.7.0')]
417420
public function supportsStreamFilter(): bool
418421
{
419422
return $this->document instanceof Stream;
@@ -428,6 +431,7 @@ public function supportsStreamFilter(): bool
428431
* @see AbstractCsv::toString
429432
* @codeCoverageIgnore
430433
*/
434+
#[Deprecated(message:'Use AbstractCsv::toString instead', since:'league/csv:9.7.0')]
431435
public function getContent(): string
432436
{
433437
return $this->toString();
@@ -442,6 +446,7 @@ public function getContent(): string
442446
*
443447
* Retrieves the CSV content
444448
*/
449+
#[Deprecated(message:'Use AbstractCsv::toString instead', since:'league/csv:9.1.0')]
445450
public function __toString(): string
446451
{
447452
return $this->toString();
@@ -462,6 +467,7 @@ public function __toString(): string
462467
* @deprecated since version 9.17.0
463468
* @see https://tools.ietf.org/html/rfc6266#section-4.3
464469
*/
470+
#[Deprecated(message:'Use HttpHeaders::forFileDownload instead', since:'league/csv:9.17.0')]
465471
protected function sendHeaders(string $filename): void
466472
{
467473
if (strlen($filename) !== strcspn($filename, '\\/')) {
@@ -501,6 +507,7 @@ protected function sendHeaders(string $filename): void
501507
*
502508
* @throws Exception
503509
*/
510+
#[Deprecated(message:'Use AbstractCsv::download instead', since:'league/csv:9.18.0')]
504511
public function output(?string $filename = null): int
505512
{
506513
try {

src/ByteSequence.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111

1212
namespace League\Csv;
1313

14+
use Deprecated;
15+
1416
/**
1517
* Defines constants for common BOM sequences.
1618
*
1719
* @deprecated since version 9.16.0
1820
* @see Bom
1921
*/
22+
#[Deprecated(message:'Use Bom Enum instead', since:'league/csv:9.16.0')]
2023
interface ByteSequence
2124
{
2225
public const BOM_UTF8 = "\xEF\xBB\xBF";

src/EncloseField.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use InvalidArgumentException;
1718
use php_user_filter;
1819

@@ -37,6 +38,7 @@
3738
* @see https://tools.ietf.org/html/rfc4180#section-2
3839
* @see https://bugs.php.net/bug.php?id=38301
3940
*/
41+
#[Deprecated(message:'Use Writter::forceEnclosure instead', since:'league/csv:9.10.0')]
4042
class EncloseField extends php_user_filter
4143
{
4244
public const FILTERNAME = 'convert.league.csv.enclosure';

src/EncloseFieldTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use InvalidArgumentException;
1718
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\Attributes\Group;
@@ -26,6 +27,7 @@
2627
* @deprecated since version 9.10.0
2728
*/
2829
#[Group('filter')]
30+
#[Deprecated(message:'Use Writer::forceEnclosure instead', since:'league/csv:9.10.0')]
2931
final class EncloseFieldTest extends TestCase
3032
{
3133
/**

src/EscapeFormula.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use InvalidArgumentException;
1718
use Stringable;
1819

@@ -138,6 +139,7 @@ protected function unescapeField(mixed $cell): mixed
138139
*
139140
* @param mixed $value value to check if it is stringable
140141
*/
142+
#[Deprecated(message:'No longer in use', since:'league/csv:9.7.2')]
141143
protected function isStringable(mixed $value): bool
142144
{
143145
return is_string($value) || $value instanceof Stringable;
@@ -151,6 +153,7 @@ protected function isStringable(mixed $value): bool
151153
*
152154
* @see escapeRecord
153155
*/
156+
#[Deprecated(message:'use EscapeFormula::escapeRecord instead', since:'league/csv:9.11.0')]
154157
public function __invoke(array $record): array
155158
{
156159
return $this->escapeRecord($record);

src/HTMLConverter.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use DOMDocument;
1718
use DOMElement;
1819
use DOMException;
@@ -39,9 +40,10 @@ public static function create(): self
3940
* DEPRECATION WARNING! This method will be removed in the next major point release.
4041
*
4142
* @throws DOMException
42-
* @see HTMLConverterTest::create()
43+
* @see HTMLConverter::create()
4344
* @deprecated since version 9.7.0
4445
*/
46+
#[Deprecated(message:'use HTNLConverter::create instead', since:'league/csv:9.7.0')]
4547
public function __construct()
4648
{
4749
$this->xml_converter = XMLConverter::create()

src/Info.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
17+
1618
use function array_fill_keys;
1719
use function array_filter;
1820
use function array_reduce;
@@ -33,6 +35,7 @@ final class Info implements ByteSequence
3335
* @see Bom::tryFromSequence()
3436
* @codeCoverageIgnore
3537
*/
38+
#[Deprecated(message:'use Bom::tryFromSequence instead', since:'league/csv:9.16.0')]
3639
public static function fetchBOMSequence(string $str): ?string
3740
{
3841
return Bom::tryFromSequence($str)?->value;

src/InvalidArgument.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use Throwable;
1718

1819
/**
@@ -25,6 +26,7 @@ class InvalidArgument extends Exception
2526
*
2627
* @deprecated since version 9.7.0
2728
*/
29+
#[Deprecated(message:'use its named constructor instead', since:'league/csv:9.7.0')]
2830
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
2931
{
3032
parent::__construct($message, $code, $previous);

src/JsonConverter.php

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use BadMethodCallException;
1717
use Closure;
18+
use Deprecated;
1819
use Exception;
1920
use InvalidArgumentException;
2021
use Iterator;
@@ -502,6 +503,7 @@ public function convert(iterable $records): Iterator
502503
*
503504
* @param int<1, max> $indentSize
504505
*/
506+
#[Deprecated(message:'Use JsonConverter::withPrettyPrint instead', since:'league/csv:9.19.0')]
505507
public function indentSize(int $indentSize): self
506508
{
507509
return match ($indentSize) {

src/RFC4180Field.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use InvalidArgumentException;
1718
use php_user_filter;
1819
use TypeError;
@@ -41,6 +42,7 @@
4142
*
4243
* @see https://tools.ietf.org/html/rfc4180#section-2
4344
*/
45+
#[Deprecated(message:'use its AbstractCsv::setEscape instead', since:'league/csv:9.2.0')]
4446
class RFC4180Field extends php_user_filter
4547
{
4648
public const FILTERNAME = 'convert.league.csv.rfc4180';

src/RFC4180FieldTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace League\Csv;
1515

16+
use Deprecated;
1617
use InvalidArgumentException;
1718
use PHPUnit\Framework\Attributes\DataProvider;
1819
use PHPUnit\Framework\Attributes\Group;
@@ -30,6 +31,7 @@
3031
* @deprecated since version 9.2.0
3132
*/
3233
#[Group('filter')]
34+
#[Deprecated(message:'Test will be removed their are left to avoid regression', since:'league/csv:9.2.0')]
3335
final class RFC4180FieldTest extends TestCase
3436
{
3537
/**

src/Reader.php

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use CallbackFilterIterator;
1717
use Closure;
18+
use Deprecated;
1819
use Iterator;
1920
use JsonSerializable;
2021
use League\Csv\Serializer\Denormalizer;
@@ -614,6 +615,7 @@ protected function combineHeader(Iterator $iterator, array $header): Iterator
614615
* @deprecated since version 9.9.0
615616
* @codeCoverageIgnore
616617
*/
618+
#[Deprecated(message:'Use Reader::nth instead', since:'league/csv:9.9.0')]
617619
public function fetchOne(int $nth_record = 0): array
618620
{
619621
return $this->nth($nth_record);
@@ -633,6 +635,7 @@ public function fetchOne(int $nth_record = 0): array
633635
* @throws MappingFailed
634636
* @throws TypeCastingFailed
635637
*/
638+
#[Deprecated(message:'Use Reader::getRecordsAsObject instead', since:'league/csv:9.15.0')]
636639
public function getObjects(string $className, array $header = []): Iterator
637640
{
638641
return $this->getRecordsAsObject($className, $header);

src/ResultSet.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use ArrayIterator;
1717
use CallbackFilterIterator;
1818
use Closure;
19+
use Deprecated;
1920
use Generator;
2021
use Iterator;
2122
use JsonSerializable;
@@ -546,6 +547,7 @@ public function fetchPairs($offset_index = 0, $value_index = 1): Iterator
546547
* @deprecated since version 9.9.0
547548
* @codeCoverageIgnore
548549
*/
550+
#[Deprecated(message:'Use Resultset::nth instead', since:'league/csv:9.9.0')]
549551
public function fetchOne(int $nth_record = 0): array
550552
{
551553
return $this->nth($nth_record);
@@ -554,7 +556,7 @@ public function fetchOne(int $nth_record = 0): array
554556
/**
555557
* DEPRECATION WARNING! This method will be removed in the next major point release.
556558
*
557-
* @see Reader::getRecordsAsObject()
559+
* @see ResultSet::getRecordsAsObject()
558560
* @deprecated Since version 9.15.0
559561
* @codeCoverageIgnore
560562
*
@@ -565,6 +567,7 @@ public function fetchOne(int $nth_record = 0): array
565567
* @throws MappingFailed
566568
* @throws TypeCastingFailed
567569
*/
570+
#[Deprecated(message:'Use ResultSet::getRecordsAsObject instead', since:'league/csv:9.15.0')]
568571
public function getObjects(string $className, array $header = []): Iterator
569572
{
570573
return $this->getRecordsAsObject($className, $header);

src/Serializer/AfterMapping.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace League\Csv\Serializer;
1515

1616
use Attribute;
17+
use Deprecated;
1718
use ReflectionAttribute;
1819
use ReflectionClass;
1920

@@ -23,6 +24,7 @@
2324
* @see MapRecord
2425
*/
2526
#[Attribute(Attribute::TARGET_CLASS)]
27+
#[Deprecated(message:'Use MapRecord attribute instead', since:'league/csv:9.17.0')]
2628
final class AfterMapping
2729
{
2830
public readonly MapRecord $mapRecord;

src/Serializer/CallbackCasting.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace League\Csv\Serializer;
1515

1616
use Closure;
17+
use Deprecated;
1718
use ReflectionClass;
1819
use ReflectionNamedType;
1920
use ReflectionParameter;
@@ -376,6 +377,7 @@ private static function getTypes(?ReflectionType $type): array
376377
* @see CallbackCasting::unregisterType()
377378
* @codeCoverageIgnore
378379
*/
380+
#[Deprecated(message:'Use CallbackCasting::unregisterType instead', since:'league/csv:9.13.0')]
379381
public static function unregister(string $type): bool
380382
{
381383
return self::unregisterType($type);

src/Serializer/Denormalizer.php

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace League\Csv\Serializer;
1515

1616
use Closure;
17+
use Deprecated;
1718
use Iterator;
1819
use League\Csv\MapIterator;
1920
use ReflectionAttribute;
@@ -65,6 +66,7 @@ public function __construct(string $className, array $propertyNames = [])
6566
*
6667
* Enables converting empty string to the null value.
6768
*/
69+
#[Deprecated(message:'Use MapRecord::$convertEmptyStringToNull or MapCell::$convertEmptyStringToNullinstead', since:'league/csv:9.17.0')]
6870
public static function allowEmptyStringAsNull(): void
6971
{
7072
self::$convertEmptyStringToNull = true;
@@ -78,6 +80,7 @@ public static function allowEmptyStringAsNull(): void
7880
*
7981
* Disables converting empty string to the null value.
8082
*/
83+
#[Deprecated(message:'Use MapRecord::$convertEmptyStringToNull or MapCell::$convertEmptyStringToNullinstead', since:'league/csv:9.17.0')]
8184
public static function disallowEmptyStringAsNull(): void
8285
{
8386
self::$convertEmptyStringToNull = false;

0 commit comments

Comments
 (0)