Skip to content

Commit

Permalink
Using PHP8.4 Deprecated attributes and simplifying github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Nov 22, 2024
1 parent 1a31de9 commit 08af8b3
Show file tree
Hide file tree
Showing 25 changed files with 71 additions and 20 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
php: ['8.1', '8.2', '8.3']
php: ['8.1', '8.2', '8.3', '8.4']
stability: [prefer-lowest, prefer-stable]
include:
- php: '8.4'
flags: "--ignore-platform-req=php"
phpunit-flags: '--no-coverage'
stability: prefer-stable
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -50,11 +45,6 @@ jobs:

- name: Run Unit tests with coverage
run: composer phpunit -- ${{ matrix.phpunit-flags }}
if: ${{ matrix.php == '8.3' || matrix.php == '8.2' || matrix.php == '8.1'}}

- name: Run Unit tests without coverage
run: composer phpunit:min
if: ${{ matrix.php == '8.4'}}

- name: Run static analysis
run: composer phpstan
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ parameters:
- identifier: missingType.generics
- identifier: missingType.iterableValue
- '#implements deprecated interface League\\Csv\\ByteSequence#'
- '#Attribute class Deprecated does not exist.#'
level: max
paths:
- src
Expand Down
7 changes: 7 additions & 0 deletions src/AbstractCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Csv;

use Deprecated;
use Generator;
use InvalidArgumentException;
use RuntimeException;
Expand Down Expand Up @@ -399,6 +400,7 @@ public function addStreamFilter(string $filtername, null|array $params = null):
*
* Returns the stream filter mode.
*/
#[Deprecated(message:'Use AbstractCsv::supportsStreamFilterOnRead or AbstractCsv::supportsStreamFilterOnWrite instead', since:'league/csv:9.7.0')]
public function getStreamFilterMode(): int
{
return static::STREAM_FILTER_MODE;
Expand All @@ -414,6 +416,7 @@ public function getStreamFilterMode(): int
*
* Tells whether the stream filter capabilities can be used.
*/
#[Deprecated(message:'Use AbstractCsv::supportsStreamFilterOnRead or AbstractCsv::supportsStreamFilterOnWrite instead', since:'league/csv:9.7.0')]
public function supportsStreamFilter(): bool
{
return $this->document instanceof Stream;
Expand All @@ -428,6 +431,7 @@ public function supportsStreamFilter(): bool
* @see AbstractCsv::toString
* @codeCoverageIgnore
*/
#[Deprecated(message:'Use AbstractCsv::toString instead', since:'league/csv:9.7.0')]
public function getContent(): string
{
return $this->toString();
Expand All @@ -442,6 +446,7 @@ public function getContent(): string
*
* Retrieves the CSV content
*/
#[Deprecated(message:'Use AbstractCsv::toString instead', since:'league/csv:9.1.0')]
public function __toString(): string
{
return $this->toString();
Expand All @@ -462,6 +467,7 @@ public function __toString(): string
* @deprecated since version 9.17.0
* @see https://tools.ietf.org/html/rfc6266#section-4.3
*/
#[Deprecated(message:'Use HttpHeaders::forFileDownload instead', since:'league/csv:9.17.0')]
protected function sendHeaders(string $filename): void
{
if (strlen($filename) !== strcspn($filename, '\\/')) {
Expand Down Expand Up @@ -501,6 +507,7 @@ protected function sendHeaders(string $filename): void
*
* @throws Exception
*/
#[Deprecated(message:'Use AbstractCsv::download instead', since:'league/csv:9.18.0')]
public function output(?string $filename = null): int
{
try {
Expand Down
3 changes: 3 additions & 0 deletions src/ByteSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

namespace League\Csv;

use Deprecated;

/**
* Defines constants for common BOM sequences.
*
* @deprecated since version 9.16.0
* @see Bom
*/
#[Deprecated(message:'Use Bom Enum instead', since:'league/csv:9.16.0')]
interface ByteSequence
{
public const BOM_UTF8 = "\xEF\xBB\xBF";
Expand Down
2 changes: 2 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 All @@ -37,6 +38,7 @@
* @see https://tools.ietf.org/html/rfc4180#section-2
* @see https://bugs.php.net/bug.php?id=38301
*/
#[Deprecated(message:'Use Writter::forceEnclosure instead', since:'league/csv:9.10.0')]
class EncloseField extends php_user_filter
{
public const FILTERNAME = 'convert.league.csv.enclosure';
Expand Down
2 changes: 2 additions & 0 deletions src/EncloseFieldTest.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 PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
Expand All @@ -26,6 +27,7 @@
* @deprecated since version 9.10.0
*/
#[Group('filter')]
#[Deprecated(message:'Use Writer::forceEnclosure instead', since:'league/csv:9.10.0')]
final class EncloseFieldTest extends TestCase
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/EscapeFormula.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 Stringable;

Expand Down Expand Up @@ -138,6 +139,7 @@ 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 All @@ -151,6 +153,7 @@ protected function isStringable(mixed $value): bool
*
* @see escapeRecord
*/
#[Deprecated(message:'use EscapeFormula::escapeRecord instead', since:'league/csv:9.11.0')]
public function __invoke(array $record): array
{
return $this->escapeRecord($record);
Expand Down
4 changes: 3 additions & 1 deletion src/HTMLConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Csv;

use Deprecated;
use DOMDocument;
use DOMElement;
use DOMException;
Expand All @@ -39,9 +40,10 @@ public static function create(): self
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @throws DOMException
* @see HTMLConverterTest::create()
* @see HTMLConverter::create()
* @deprecated since version 9.7.0
*/
#[Deprecated(message:'use HTNLConverter::create instead', since:'league/csv:9.7.0')]
public function __construct()
{
$this->xml_converter = XMLConverter::create()
Expand Down
3 changes: 3 additions & 0 deletions src/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace League\Csv;

use Deprecated;

use function array_fill_keys;
use function array_filter;
use function array_reduce;
Expand All @@ -33,6 +35,7 @@ final class Info implements ByteSequence
* @see Bom::tryFromSequence()
* @codeCoverageIgnore
*/
#[Deprecated(message:'use Bom::tryFromSequence instead', since:'league/csv:9.16.0')]
public static function fetchBOMSequence(string $str): ?string
{
return Bom::tryFromSequence($str)?->value;
Expand Down
2 changes: 2 additions & 0 deletions src/InvalidArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace League\Csv;

use Deprecated;
use Throwable;

/**
Expand All @@ -25,6 +26,7 @@ class InvalidArgument extends Exception
*
* @deprecated since version 9.7.0
*/
#[Deprecated(message:'use its named constructor instead', since:'league/csv:9.7.0')]
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
Expand Down
2 changes: 2 additions & 0 deletions src/JsonConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use BadMethodCallException;
use Closure;
use Deprecated;
use Exception;
use InvalidArgumentException;
use Iterator;
Expand Down Expand Up @@ -502,6 +503,7 @@ public function convert(iterable $records): Iterator
*
* @param int<1, max> $indentSize
*/
#[Deprecated(message:'Use JsonConverter::withPrettyPrint instead', since:'league/csv:9.19.0')]
public function indentSize(int $indentSize): self
{
return match ($indentSize) {
Expand Down
2 changes: 2 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 @@ -41,6 +42,7 @@
*
* @see https://tools.ietf.org/html/rfc4180#section-2
*/
#[Deprecated(message:'use its AbstractCsv::setEscape instead', since:'league/csv:9.2.0')]
class RFC4180Field extends php_user_filter
{
public const FILTERNAME = 'convert.league.csv.rfc4180';
Expand Down
2 changes: 2 additions & 0 deletions src/RFC4180FieldTest.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 PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
Expand All @@ -30,6 +31,7 @@
* @deprecated since version 9.2.0
*/
#[Group('filter')]
#[Deprecated(message:'Test will be removed their are left to avoid regression', since:'league/csv:9.2.0')]
final class RFC4180FieldTest extends TestCase
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use CallbackFilterIterator;
use Closure;
use Deprecated;
use Iterator;
use JsonSerializable;
use League\Csv\Serializer\Denormalizer;
Expand Down Expand Up @@ -614,6 +615,7 @@ protected function combineHeader(Iterator $iterator, array $header): Iterator
* @deprecated since version 9.9.0
* @codeCoverageIgnore
*/
#[Deprecated(message:'Use Reader::nth instead', since:'league/csv:9.9.0')]
public function fetchOne(int $nth_record = 0): array
{
return $this->nth($nth_record);
Expand All @@ -633,6 +635,7 @@ public function fetchOne(int $nth_record = 0): array
* @throws MappingFailed
* @throws TypeCastingFailed
*/
#[Deprecated(message:'Use Reader::getRecordsAsObject instead', since:'league/csv:9.15.0')]
public function getObjects(string $className, array $header = []): Iterator
{
return $this->getRecordsAsObject($className, $header);
Expand Down
5 changes: 4 additions & 1 deletion src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use ArrayIterator;
use CallbackFilterIterator;
use Closure;
use Deprecated;
use Generator;
use Iterator;
use JsonSerializable;
Expand Down Expand Up @@ -546,6 +547,7 @@ public function fetchPairs($offset_index = 0, $value_index = 1): Iterator
* @deprecated since version 9.9.0
* @codeCoverageIgnore
*/
#[Deprecated(message:'Use Resultset::nth instead', since:'league/csv:9.9.0')]
public function fetchOne(int $nth_record = 0): array
{
return $this->nth($nth_record);
Expand All @@ -554,7 +556,7 @@ public function fetchOne(int $nth_record = 0): array
/**
* DEPRECATION WARNING! This method will be removed in the next major point release.
*
* @see Reader::getRecordsAsObject()
* @see ResultSet::getRecordsAsObject()
* @deprecated Since version 9.15.0
* @codeCoverageIgnore
*
Expand All @@ -565,6 +567,7 @@ public function fetchOne(int $nth_record = 0): array
* @throws MappingFailed
* @throws TypeCastingFailed
*/
#[Deprecated(message:'Use ResultSet::getRecordsAsObject instead', since:'league/csv:9.15.0')]
public function getObjects(string $className, array $header = []): Iterator
{
return $this->getRecordsAsObject($className, $header);
Expand Down
2 changes: 2 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 @@ -23,6 +24,7 @@
* @see MapRecord
*/
#[Attribute(Attribute::TARGET_CLASS)]
#[Deprecated(message:'Use MapRecord attribute instead', since:'league/csv:9.17.0')]
final class AfterMapping
{
public readonly MapRecord $mapRecord;
Expand Down
2 changes: 2 additions & 0 deletions src/Serializer/CallbackCasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace League\Csv\Serializer;

use Closure;
use Deprecated;
use ReflectionClass;
use ReflectionNamedType;
use ReflectionParameter;
Expand Down Expand Up @@ -376,6 +377,7 @@ private static function getTypes(?ReflectionType $type): array
* @see CallbackCasting::unregisterType()
* @codeCoverageIgnore
*/
#[Deprecated(message:'Use CallbackCasting::unregisterType instead', since:'league/csv:9.13.0')]
public static function unregister(string $type): bool
{
return self::unregisterType($type);
Expand Down
3 changes: 3 additions & 0 deletions src/Serializer/Denormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace League\Csv\Serializer;

use Closure;
use Deprecated;
use Iterator;
use League\Csv\MapIterator;
use ReflectionAttribute;
Expand Down Expand Up @@ -65,6 +66,7 @@ public function __construct(string $className, array $propertyNames = [])
*
* Enables converting empty string to the null value.
*/
#[Deprecated(message:'Use MapRecord::$convertEmptyStringToNull or MapCell::$convertEmptyStringToNullinstead', since:'league/csv:9.17.0')]
public static function allowEmptyStringAsNull(): void
{
self::$convertEmptyStringToNull = true;
Expand All @@ -78,6 +80,7 @@ public static function allowEmptyStringAsNull(): void
*
* Disables converting empty string to the null value.
*/
#[Deprecated(message:'Use MapRecord::$convertEmptyStringToNull or MapCell::$convertEmptyStringToNullinstead', since:'league/csv:9.17.0')]
public static function disallowEmptyStringAsNull(): void
{
self::$convertEmptyStringToNull = false;
Expand Down
Loading

0 comments on commit 08af8b3

Please sign in to comment.