Skip to content

Commit

Permalink
fix: PHP 8.4 compatibility (#105)
Browse files Browse the repository at this point in the history
* test: test php 8.4

* require later version of polyfill-php83

* bump psalm

* run psalm only on highest dep

* test phpstan using 8.4

* fix implicit nullable

* changelog
  • Loading branch information
priyadi authored Sep 16, 2024
1 parent 1644c6a commit a2b3585
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -55,6 +55,7 @@ jobs:

- name: Run psalm
run: vendor/bin/psalm
if: matrix.dep == 'highest'

- name: Run phpstan
run: vendor/bin/phpstan analyse
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* feat: add `AllowTargetDelete`, similar to `AllowDelete` but defined on the
source side
* fix: PHP 8.4 compatibility

## 1.5.7

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
phpVersion: 80400
level: max
paths:
- src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/MainTransformer/Implementation/MainTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/MainTransformer/MainTransformerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public function transform(
?Type $sourceType,
array $targetTypes,
Context $context,
string $path = null,
?string $path = null,
): mixed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/Exception/NotAClassException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NotAClassException extends NotMappableValueException
{
public function __construct(
string $class,
Context $context = null,
?Context $context = null,
) {
parent::__construct(
message: \sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/Transformer/Exception/UnableToReadException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/Transformer/Exception/UnableToWriteException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit a2b3585

Please sign in to comment.