Merge branch '3.1' into 3.2

* 3.1:
  Write an exception message in a one heading line
  [Finder] Refine phpdoc about argument for NumberComparator
  Fixed max width from ajax request url element (td)
  Fix unresolved parameters from default bundle configs in debug:config
  [github] Tweak PR template
  [Serializer] Optimize max depth checking
This commit is contained in:
Fabien Potencier 2016-12-13 10:39:43 +01:00
commit 1943c26d47
6 changed files with 36 additions and 35 deletions

View File

@ -1,11 +1,19 @@
| Q | A
| ------------- | ---
| Branch? | "master" for new features / 2.7, 2.8 or 3.1 for fixes
| Branch? | master / 2.7, 2.8, 3.1 or 3.2 <!--see comment below-->
| Bug fix? | yes/no
| New feature? | yes/no
| BC breaks? | yes/no
| Deprecations? | yes/no
| Tests pass? | yes/no
| Fixed tickets | comma-separated list of tickets fixed by the PR, if any
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | reference to the documentation PR, if any
| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->
<!--
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->

View File

@ -105,7 +105,7 @@ EOF
$io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
$io->writeln(Yaml::dump($config, 10));
$io->writeln(Yaml::dump($container->getParameterBag()->resolveValue($config), 10));
}
private function compileContainer()

View File

@ -9,9 +9,7 @@
<div class="text-exception">
<div class="open-quote">“</div>
<h1>
{{ exception.message|nl2br|format_file_from_text }}
</h1>
<h1>{{ exception.message|nl2br|format_file_from_text }}</h1>
<div>
<strong>{{ status_code }}</strong> {{ status_text }} - {{ exception.class|abbr_class }}

View File

@ -37,7 +37,7 @@ class NumberComparator extends Comparator
/**
* Constructor.
*
* @param string $test A comparison string
* @param string|int $test A comparison string or an integer
*
* @throws \InvalidArgumentException If the test is not understood
*/

View File

@ -111,7 +111,7 @@ class Finder implements \IteratorAggregate, \Countable
* $finder->depth('> 1') // the Finder will start matching at level 1.
* $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
*
* @param int $level The depth level expression
* @param string|int $level The depth level expression
*
* @return Finder|SplFileInfo[] The current Finder instance
*
@ -283,7 +283,7 @@ class Finder implements \IteratorAggregate, \Countable
* $finder->size('<= 1Ki');
* $finder->size(4);
*
* @param string $size A size range string
* @param string|int $size A size range string or an integer
*
* @return Finder|SplFileInfo[] The current Finder instance
*

View File

@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
@ -67,9 +68,10 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
$stack = array();
$attributes = $this->getAttributes($object, $format, $context);
$class = get_class($object);
$attributesMetadata = $this->classMetadataFactory ? $this->classMetadataFactory->getMetadataFor($class)->getAttributesMetadata() : null;
foreach ($attributes as $attribute) {
if ($this->isMaxDepthReached($class, $attribute, $context)) {
if (null !== $attributesMetadata && $this->isMaxDepthReached($attributesMetadata, $class, $attribute, $context)) {
continue;
}
@ -289,42 +291,35 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
/**
* Is the max depth reached for the given attribute?
*
* @param string $class
* @param string $attribute
* @param array $context
* @param AttributeMetadataInterface[] $attributesMetadata
* @param string $class
* @param string $attribute
* @param array $context
*
* @return bool
*/
private function isMaxDepthReached($class, $attribute, array &$context)
private function isMaxDepthReached(array $attributesMetadata, $class, $attribute, array &$context)
{
if (!$this->classMetadataFactory || !isset($context[static::ENABLE_MAX_DEPTH])) {
return false;
}
$classMetadata = $this->classMetadataFactory->getMetadataFor($class);
$attributesMetadata = $classMetadata->getAttributesMetadata();
if (!isset($attributesMetadata[$attribute])) {
return false;
}
$maxDepth = $attributesMetadata[$attribute]->getMaxDepth();
if (null === $maxDepth) {
if (
!isset($context[static::ENABLE_MAX_DEPTH]) ||
!isset($attributesMetadata[$attribute]) ||
null === $maxDepth = $attributesMetadata[$attribute]->getMaxDepth()
) {
return false;
}
$key = sprintf(static::DEPTH_KEY_PATTERN, $class, $attribute);
$keyExist = isset($context[$key]);
if (!isset($context[$key])) {
$context[$key] = 1;
if ($keyExist && $context[$key] === $maxDepth) {
return false;
}
if ($context[$key] === $maxDepth) {
return true;
}
if ($keyExist) {
++$context[$key];
} else {
$context[$key] = 1;
}
++$context[$key];
return false;
}