Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deprecation for symfony/serializer 6.3 #148

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
- name: PHP-CS-Fixer
uses: docker://jakzal/phpqa:php8.0
with:
args: php-cs-fixer fix --config=.php_cs.dist.php --dry-run
args: php-cs-fixer fix --config=.php_cs.dist.php --dry-run --diff
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"symfony/form": "^4.4|^5.3|^6.0",
"symfony/phpunit-bridge": "^6.2",
"symfony/property-access": "^4.4|^5.3|^6.0",
"symfony/serializer": "^4.4|^5.3|^6.0.1",
"symfony/twig-bundle": "^4.4|^5.3|^6.0",
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./vendor/autoload.php" colors="true">
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="999999" />
</php>
<testsuites>
<testsuite name="MisdPhoneNumberBundle Test Suite">
<directory>tests</directory>
Expand All @@ -11,4 +14,7 @@
<directory>src</directory>
</whitelist>
</filter>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
10 changes: 9 additions & 1 deletion src/Serializer/Normalizer/PhoneNumberNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public function denormalize($data, $class, $format = null, array $context = []):
*/
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
{
return 'libphonenumber\PhoneNumber' === $type && \is_string($data);
return PhoneNumber::class === $type && \is_string($data);
}

/**
* for symfony/serializer >= 6.3.
*/
public function getSupportedTypes(?string $format): array
{
return [PhoneNumber::class => false];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used false to indicate that we cannot cache the calls to supportsDenormalization because there we also check is_string($data)

}
}