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

make:serializer:normalizer Passing null to parameter #2 ($replace) of type array|string is deprecated #1208

Closed
bechir opened this issue Sep 25, 2022 · 1 comment · Fixed by #1210
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer

Comments

@bechir
Copy link
Contributor

bechir commented Sep 25, 2022

when I make FooNormalizer with make:serializer:normalizer, I got this output:

<?php

namespace App\Serializer\Normalizer;

use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;

class FooNormalizer implements NormalizerInterface, CacheableSupportsMethodInterface
{
    // ...
    public function supportsNormalization($data, string $format = null, array $context = []): bool
    {
        return $data instanceof \App\Entity\
Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in vendor/symfony/maker-bundle/src/Resources/skeleton/serializer/Normalizer.tpl.php on line 24
Foo;
    }
}

PHP version: 8.1
Maker v1.45.0

Solution

Replace null with '' ?

return $data instanceof \App\Entity\<?= str_replace('Normalizer', '', $class_name) ?>;
@jrushlow
Copy link
Collaborator

Thanks for giving us a heads up @bechir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug Fix Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants