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

Skip to content

Commit c6de408

Browse files
Merge branch '5.2' into 5.x
* 5.2: [PropertyInfo][Serializer] Fixed extracting ignored properties [travis] fix checking if the current branch has same major as the next release
2 parents 67d2a20 + 613ac0c commit c6de408

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ install:
233233
234234
- |
235235
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
236-
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git ls-remote -q --heads | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*') ]] && export LEGACY=,legacy
236+
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git ls-remote -q --heads | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*' | head -n 1) ]] && export LEGACY=,legacy
237237
238238
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
239239
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi

src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getProperties(string $class, array $context = []): ?array
4747
$serializerClassMetadata = $this->classMetadataFactory->getMetadataFor($class);
4848

4949
foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
50-
$ignored = method_exists($serializerClassMetadata, 'isIgnored') && $serializerAttributeMetadata->isIgnored();
50+
$ignored = method_exists($serializerAttributeMetadata, 'isIgnored') && $serializerAttributeMetadata->isIgnored();
5151
if (!$ignored && (null === $context['serializer_groups'] || array_intersect($context['serializer_groups'], $serializerAttributeMetadata->getGroups()))) {
5252
$properties[] = $serializerAttributeMetadata->getName();
5353
}

src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
17+
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
18+
use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy;
19+
use Symfony\Component\Serializer\Annotation\Ignore;
1720
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
1821
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
1922

@@ -41,8 +44,17 @@ public function testGetProperties()
4144
);
4245
}
4346

47+
public function testGetPropertiesWithIgnoredProperties()
48+
{
49+
if (!class_exists(Ignore::class)) {
50+
$this->markTestSkipped('Ignore annotation is not implemented in current symfony/serializer version');
51+
}
52+
53+
$this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['a']]));
54+
}
55+
4456
public function testGetPropertiesWithAnyGroup()
4557
{
46-
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy', ['serializer_groups' => null]));
58+
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties(AdderRemoverDummy::class, ['serializer_groups' => null]));
4759
}
4860
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
13+
14+
use Symfony\Component\Serializer\Annotation\Groups;
15+
use Symfony\Component\Serializer\Annotation\Ignore;
16+
17+
/**
18+
* @author Vadim Borodavko <[email protected]>
19+
*/
20+
class IgnorePropertyDummy
21+
{
22+
/**
23+
* @Groups({"a"})
24+
*/
25+
public $visibleProperty;
26+
27+
/**
28+
* @Groups({"a"})
29+
* @Ignore
30+
*/
31+
private $ignoredProperty;
32+
}

0 commit comments

Comments
 (0)