8000 Removed deprecations in Serializer component by dosten · Pull Request #14151 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Removed deprecations in Serializer component #14151

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

Closed
wants to merge 2 commits into from
Closed
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
21 changes: 0 additions & 21 deletions src/Symfony/Component/Serializer/Exception/Exception.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface ExceptionInterface extends Exception
interface ExceptionInterface
{
}
49 changes: 0 additions & 49 deletions src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
Expand Down Expand Up @@ -140,37 +138,6 @@ public function setIgnoredAttributes(array $ignoredAttributes)
return $this;
}

/**
* Set attributes to be camelized on denormalize.
*
* @deprecated Deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter instead.
*
* @param array $camelizedAttributes
*
* @return self
*
* @throws LogicException
*/
public function setCamelizedAttributes(array $camelizedAttributes)
{
trigger_error(sprintf('%s is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter instead.', __METHOD__), E_USER_DEPRECATED);

if ($this->nameConverter && !$this->nameConverter instanceof CamelCaseToSnakeCaseNameConverter) {
throw new LogicException(sprintf('%s cannot be called if a custom Name Converter is defined.', __METHOD__));
}

$attributes = array();
foreach ($camelizedAttributes as $camelizedAttribute) {
$attributes[] = lcfirst(preg_replace_callback('/(^|_|\.)+(.)/', function ($match) {
return ('.' === $match[1] ? '_' : '').strtoupper($match[2]);
}, $camelizedAttribute));
}

$this->nameConverter = new CamelCaseToSnakeCaseNameConverter($attributes);

return $this;
}

/**
* Detects if the configured circular reference limit is reached.
*
Expand Down Expand Up @@ -221,22 +188,6 @@ protected function handleCircularReference($object)
throw new CircularReferenceException(sprintf('A circular reference has been detected (configured limit: %d).', $this->circularReferenceLimit));
}

/**
* Format an attribute name, for example to convert a snake_case name to camelCase.
*
* @deprecated Deprecated since version 2.7, to be removed in 3.0. Use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter instead.
*
* @param string $attributeName
*
* @return string
*/
protected function formatAttribute($attributeName)
{
trigger_error(sprintf('%s is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter instead.', __METHOD__), E_USER_DEPRECATED);

return $this->nameConverter ? $this->nameConverter->normalize($attributeName) : $attributeName;
}

/**
* Gets attributes to normalize using groups.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,79 +99,11 @@ public function testDenormalizeWithObject()
$this->assertEquals('bar', $obj->getBar());
}

/**
* @group legacy
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'camelCase'),
__NAMESPACE__.'\GetSetDummy'
);

$this->assertEquals('camelCase', $obj->getCamelCase());
}

public function testDenormalizeNull()
{
$this->assertEquals(new GetSetDummy(), $this->normalizer->denormalize(null, __NAMESPACE__.'\GetSetDummy'));
}

/**
* @group legacy
*/
public function testLegacyCamelizedAttributesNormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$obj = new GetCamelizedDummy('dunglas.fr');
$obj->setFooBar('les-tilleuls.coop');
$obj->setBar_foo('lostinthesupermarket.fr');

$this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
$this->assertEquals($this->normalizer->normalize($obj), array(
'kevin_dunglas' => 'dunglas.fr',
'fooBar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
));

$this->normalizer->setCamelizedAttributes(array('foo_bar'));
$this->assertEquals($this->normalizer->normalize($obj), array(
'kevinDunglas' => 'dunglas.fr',
'foo_bar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
));
}

/**
* @group legacy
*/
public function testLegacyCamelizedAttributesDenormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$obj = new GetCamelizedDummy('dunglas.fr');
$obj->setFooBar('les-tilleuls.coop');
$obj->setBar_foo('lostinthesupermarket.fr');

$this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
$this->assertEquals($this->normalizer->denormalize(array(
'kevin_dunglas' => 'dunglas.fr',
'fooBar' => 'les-tilleuls. E29B coop',
'bar_foo' => 'lostinthesupermarket.fr',
), __NAMESPACE__.'\GetCamelizedDummy'), $obj);

$this->normalizer->setCamelizedAttributes(array('foo_bar'));
$this->assertEquals($this->normalizer->denormalize(array(
'kevinDunglas' => 'dunglas.fr',
'foo_bar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
), __NAMESPACE__.'\GetCamelizedDummy'), $obj);
}

public function testConstructorDenormalize()
{
$obj = $this->normalizer->denormalize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ public function testDenormalizeWithObject()
$this->assertEquals('bar', $obj->bar);
}

/**
* @group legacy
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'camelCase'),
__NAMESPACE__.'\ObjectDummy'
);
$this->assertEquals('camelCase', $obj->getCamelCase());
}

public function testDenormalizeNull()
{
$this->assertEquals(new ObjectDummy(), $this->normalizer->denormalize(null, __NAMESPACE__.'\ObjectDummy'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,73 +62,6 @@ public function testDenormalize()
$this->assertEquals('bar', $obj->getBar());
}

/**
* @group legacy
*/
public function testLegacyDenormalizeOnCamelCaseFormat()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$this->normalizer->setCamelizedAttributes(array('camel_case'));
$obj = $this->normalizer->denormalize(
array('camel_case' => 'value'),
__NAMESPACE__.'\PropertyDummy'
);
$this->assertEquals('value', $obj->getCamelCase());
}

/**
* @group legacy
*/
public function testLegacyCamelizedAttributesNormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$obj = new PropertyCamelizedDummy('dunglas.fr');
$obj->fooBar = 'les-tilleuls.coop';
$obj->bar_foo = 'lostinthesupermarket.fr';

$this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
$this->assertEquals($this->normalizer->normalize($obj), array(
'kevin_dunglas' => 'dunglas.fr',
'fooBar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
));

$this->normalizer->setCamelizedAttributes(array('foo_bar'));
$this->assertEquals($this->normalizer->normalize($obj), array(
'kevinDunglas' => 'dunglas.fr',
'foo_bar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
));
}

/**
* @group legacy
*/
public function testLegacyCamelizedAttributesDenormalize()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$obj = new PropertyCamelizedDummy('dunglas.fr');
$obj->fooBar = 'les-tilleuls.coop';
$obj->bar_foo = 'lostinthesupermarket.fr';

$this->normalizer->setCamelizedAttributes(array('kevin_dunglas'));
$this->assertEquals($this->normalizer->denormalize(array(
'kevin_dunglas' => 'dunglas.fr',
'fooBar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
), __NAMESPACE__.'\PropertyCamelizedDummy'), $obj);

$this->normalizer->setCamelizedAttributes(array('foo_bar'));
$this->assertEquals($this->normalizer->denormalize(array(
'kevinDunglas' => 'dunglas.fr',
'foo_bar' => 'les-tilleuls.coop',
'bar_foo' => 'lostinthesupermarket.fr',
), __NAMESPACE__.'\PropertyCamelizedDummy'), $obj);
}

public function testConstructorDenormalize()
{
$obj = $this->normalizer->denormalize(
Expand Down
0