diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b4bfc89d..4b6774fa 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php: [ '8.2', '8.3' ] + php: [ '8.2', '8.3', '8.4' ] symfony: [ '6.4.*', '7.*' ] dep: [highest,lowest] @@ -55,6 +55,7 @@ jobs: - name: Run psalm run: vendor/bin/psalm + if: matrix.dep == 'highest' - name: Run phpstan run: vendor/bin/phpstan analyse diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b9a4649..caabaa48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * feat: add `AllowTargetDelete`, similar to `AllowDelete` but defined on the source side +* fix: PHP 8.4 compatibility ## 1.5.7 diff --git a/composer.json b/composer.json index 87a839c8..75c9c495 100644 --- a/composer.json +++ b/composer.json @@ -58,13 +58,14 @@ "rector/rector": "^1.2", "symfony/framework-bundle": "^6.4 || ^7.0", "symfony/http-kernel": "^6.4 || ^7.0", + "symfony/polyfill-php83": "^1.30", "symfony/runtime": "^6.4 || ^7.0", "symfony/uid": "^6.4 || ^7.0", "symfony/var-dumper": "^6.4 || ^7.0", "symfony/yaml": "^6.4 || ^7.0", "tomasvotruba/unused-public": "^0.3.5", "twig/twig": "^2.12|^3.0", - "vimeo/psalm": "^5.18" + "vimeo/psalm": "^5.26" }, "autoload": { "psr-4": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 1d511783..a7f71f59 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,4 +1,5 @@ parameters: + phpVersion: 80400 level: max paths: - src diff --git a/src/MainTransformer/Exception/CircularReferenceException.php b/src/MainTransformer/Exception/CircularReferenceException.php index 323a1eab..dde4ce51 100644 --- a/src/MainTransformer/Exception/CircularReferenceException.php +++ b/src/MainTransformer/Exception/CircularReferenceException.php @@ -24,7 +24,7 @@ class CircularReferenceException extends RuntimeException implements ExceptionIn public function __construct( mixed $source, Type $targetType, - Context $context = null, + ?Context $context = null, ?\Throwable $previous = null, ) { parent::__construct( diff --git a/src/MainTransformer/Implementation/MainTransformer.php b/src/MainTransformer/Implementation/MainTransformer.php index b0a9f1a2..6674545d 100644 --- a/src/MainTransformer/Implementation/MainTransformer.php +++ b/src/MainTransformer/Implementation/MainTransformer.php @@ -75,7 +75,7 @@ public function transform( ?Type $sourceType, array $targetTypes, Context $context, - string $path = null, + ?string $path = null, ): mixed { // if MapperOptions is not provided, use the default options diff --git a/src/MainTransformer/MainTransformerInterface.php b/src/MainTransformer/MainTransformerInterface.php index 6411eec8..3d41fc46 100644 --- a/src/MainTransformer/MainTransformerInterface.php +++ b/src/MainTransformer/MainTransformerInterface.php @@ -28,6 +28,6 @@ public function transform( ?Type $sourceType, array $targetTypes, Context $context, - string $path = null, + ?string $path = null, ): mixed; } diff --git a/src/Transformer/Exception/ClassNotInstantiableException.php b/src/Transformer/Exception/ClassNotInstantiableException.php index bb0c25e2..0f68fbd4 100644 --- a/src/Transformer/Exception/ClassNotInstantiableException.php +++ b/src/Transformer/Exception/ClassNotInstantiableException.php @@ -20,7 +20,7 @@ class ClassNotInstantiableException extends NotMappableValueException /** * @param class-string $class */ - public function __construct(string $class, Context $context = null) + public function __construct(string $class, ?Context $context = null) { parent::__construct( message: \sprintf('Trying to instantiate "%s", but it is not instantiable. You might solve this problem by adding an "InheritanceMap" to the class, so the mapper will know which concrete class to instantiate.', $class), diff --git a/src/Transformer/Exception/InternalClassUnsupportedException.php b/src/Transformer/Exception/InternalClassUnsupportedException.php index c2893516..2eee95e7 100644 --- a/src/Transformer/Exception/InternalClassUnsupportedException.php +++ b/src/Transformer/Exception/InternalClassUnsupportedException.php @@ -22,8 +22,8 @@ class InternalClassUnsupportedException extends NotMappableValueException */ public function __construct( string $class, - \Throwable $previous = null, - Context $context = null, + ?\Throwable $previous = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf( diff --git a/src/Transformer/Exception/InvalidTypeInArgumentException.php b/src/Transformer/Exception/InvalidTypeInArgumentException.php index 3bbc9e89..9d7d92f4 100644 --- a/src/Transformer/Exception/InvalidTypeInArgumentException.php +++ b/src/Transformer/Exception/InvalidTypeInArgumentException.php @@ -23,7 +23,7 @@ class InvalidTypeInArgumentException extends InvalidArgumentException public function __construct( string $printfMessage, ?Type $expectedType, - Context $context = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf($printfMessage, TypeUtil::getDebugType($expectedType)), diff --git a/src/Transformer/Exception/MissingMemberKeyTypeException.php b/src/Transformer/Exception/MissingMemberKeyTypeException.php index 3bac9ea8..dbd93b1f 100644 --- a/src/Transformer/Exception/MissingMemberKeyTypeException.php +++ b/src/Transformer/Exception/MissingMemberKeyTypeException.php @@ -23,7 +23,7 @@ class MissingMemberKeyTypeException extends MissingMemberTypeException public function __construct( ?Type $sourceType, Type $targetType, - Context $context = null, + ?Context $context = null, ) { if (null === $sourceType) { $sourceType = MixedType::instance(); diff --git a/src/Transformer/Exception/MissingMemberValueTypeException.php b/src/Transformer/Exception/MissingMemberValueTypeException.php index 182c9771..c09f8c3f 100644 --- a/src/Transformer/Exception/MissingMemberValueTypeException.php +++ b/src/Transformer/Exception/MissingMemberValueTypeException.php @@ -23,7 +23,7 @@ class MissingMemberValueTypeException extends MissingMemberTypeException public function __construct( ?Type $sourceType, Type $targetType, - Context $context = null, + ?Context $context = null, ) { if (null === $sourceType) { $sourceType = MixedType::instance(); diff --git a/src/Transformer/Exception/NotAClassException.php b/src/Transformer/Exception/NotAClassException.php index cec0d946..8a945181 100644 --- a/src/Transformer/Exception/NotAClassException.php +++ b/src/Transformer/Exception/NotAClassException.php @@ -19,7 +19,7 @@ class NotAClassException extends NotMappableValueException { public function __construct( string $class, - Context $context = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf( diff --git a/src/Transformer/Exception/SourceClassNotInInheritanceMapException.php b/src/Transformer/Exception/SourceClassNotInInheritanceMapException.php index aa93a223..313d3e48 100644 --- a/src/Transformer/Exception/SourceClassNotInInheritanceMapException.php +++ b/src/Transformer/Exception/SourceClassNotInInheritanceMapException.php @@ -25,7 +25,7 @@ class SourceClassNotInInheritanceMapException extends NotMappableValueException public function __construct( string $sourceClass, string $targetClass, - Context $context = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf( diff --git a/src/Transformer/Exception/UnableToReadException.php b/src/Transformer/Exception/UnableToReadException.php index 6cca2d88..86204491 100644 --- a/src/Transformer/Exception/UnableToReadException.php +++ b/src/Transformer/Exception/UnableToReadException.php @@ -20,8 +20,8 @@ class UnableToReadException extends NotMappableValueException public function __construct( mixed $source, string $property, - \Throwable $previous = null, - Context $context = null, + ?\Throwable $previous = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf( diff --git a/src/Transformer/Exception/UnableToWriteException.php b/src/Transformer/Exception/UnableToWriteException.php index a014468c..cfced51c 100644 --- a/src/Transformer/Exception/UnableToWriteException.php +++ b/src/Transformer/Exception/UnableToWriteException.php @@ -20,8 +20,8 @@ class UnableToWriteException extends NotMappableValueException public function __construct( mixed $target, string $propertyName, - \Throwable $previous = null, - Context $context = null, + ?\Throwable $previous = null, + ?Context $context = null, ) { parent::__construct( message: \sprintf( diff --git a/src/Transformer/Implementation/ObjectToObjectTransformer.php b/src/Transformer/Implementation/ObjectToObjectTransformer.php index feec436a..0003bfa9 100644 --- a/src/Transformer/Implementation/ObjectToObjectTransformer.php +++ b/src/Transformer/Implementation/ObjectToObjectTransformer.php @@ -55,7 +55,7 @@ public function __construct( private ContainerInterface $propertyMapperLocator, private SubMapperFactoryInterface $subMapperFactory, private ProxyFactoryInterface $proxyFactory, - ReaderWriter $readerWriter = null, + ?ReaderWriter $readerWriter = null, ) { $this->readerWriter = $readerWriter ?? new ReaderWriter(); }