Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Serializer\Normalizer;

use Symfony\Component\Serializer\Annotation\Ignore as LegacyIgnore;
use Symfony\Component\Serializer\Attribute\Ignore;

/**
Expand Down Expand Up @@ -97,7 +98,7 @@ private function supports(string $class): bool
private function isGetMethod(\ReflectionMethod $method): bool
{
return !$method->isStatic()
&& !$method->getAttributes(Ignore::class)
&& !($method->getAttributes(Ignore::class) || $method->getAttributes(LegacyIgnore::class))
&& !$method->getNumberOfRequiredParameters()
&& ((2 < ($methodLength = \strlen($method->name)) && str_starts_with($method->name, 'is'))
|| (3 < $methodLength && (str_starts_with($method->name, 'has') || str_starts_with($method->name, 'get')))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes;

use Symfony\Component\Serializer\Annotation\Ignore;

class ClassWithIgnoreAnnotation
{
public string $foo;

#[Ignore]
public function isSomeIgnoredMethod(): bool
{
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ClassWithIgnoreAnnotation;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\ClassWithIgnoreAttribute;
use Symfony\Component\Serializer\Tests\Fixtures\Attributes\GroupDummy;
use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy;
Expand Down Expand Up @@ -427,9 +428,22 @@ public function testNoStaticGetSetSupport()
$this->assertFalse($this->normalizer->supportsNormalization(new ObjectWithJustStaticSetterDummy()));
}

public function testNotIgnoredMethodSupport()
/**
* @param class-string $class
*
* @dataProvider provideNotIgnoredMethodSupport
*/
public function testNotIgnoredMethodSupport(string $class)
{
$this->assertFalse($this->normalizer->supportsNormalization(new ClassWithIgnoreAttribute()));
$this->assertFalse($this->normalizer->supportsNormalization(new $class()));
}

public static function provideNotIgnoredMethodSupport(): iterable
{
return [
[ClassWithIgnoreAttribute::class],
[ClassWithIgnoreAnnotation::class],
];
}

public function testPrivateSetter()
Expand Down