Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 671e412

Browse filesBrowse files
Merge branch '4.0' into 4.1
* 4.0: [minor] SCA [Serializer] Minor tweaks for a67b650 allow_extra_attributes does not throw an exception as documented [Cache] fix visibility of RedisTrait::init() [Serializer] Updates DocBlock to a mixed param type
2 parents f833167 + b4a58e2 commit 671e412
Copy full SHA for 671e412

File tree

9 files changed

+30
-15
lines changed
Filter options

9 files changed

+30
-15
lines changed

‎src/Symfony/Component/Cache/Traits/RedisTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Traits/RedisTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ trait RedisTrait
4141
/**
4242
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
4343
*/
44-
public function init($redisClient, $namespace = '', $defaultLifetime = 0)
44+
private function init($redisClient, $namespace = '', $defaultLifetime = 0)
4545
{
4646
parent::__construct($namespace, $defaultLifetime);
4747

‎src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/Configurator/DefaultsConfigurator.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class DefaultsConfigurator extends AbstractServiceConfigurator
3434
*/
3535
final public function tag(string $name, array $attributes = array())
3636
{
37-
if (!is_string($name) || '' === $name) {
37+
if ('' === $name) {
3838
throw new InvalidArgumentException('The tag name in "_defaults" must be a non-empty string.');
3939
}
4040

4141
foreach ($attributes as $attribute => $value) {
42-
if (!is_scalar($value) && null !== $value) {
42+
if (null !== $value && !is_scalar($value)) {
4343
throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type.', $name, $attribute));
4444
}
4545
}

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo
2828
*/
2929
public function __construct(?int $scale = 0, ?bool $grouping = false, int $roundingMode = self::ROUND_DOWN)
3030
{
31-
if (null === $roundingMode) {
32-
$roundingMode = self::ROUND_DOWN;
33-
}
34-
3531
parent::__construct(0, $grouping, $roundingMode);
3632
}
3733

‎src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(string $class, string $username, string $series, str
2929
if (empty($class)) {
3030
throw new \InvalidArgumentException('$class must not be empty.');
3131
}
32-
if ('' === $username || null === $username) {
32+
if ('' === $username) {
3333
throw new \InvalidArgumentException('$username must not be empty.');
3434
}
3535
if (empty($series)) {

‎src/Symfony/Component/Security/Core/User/LdapUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/LdapUserProvider.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ class LdapUserProvider implements UserProviderInterface
3737

3838
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = array(), string $uidKey = 'sAMAccountName', string $filter = '({uid_key}={username})', string $passwordAttribute = null)
3939
{
40-
if (null === $uidKey) {
41-
$uidKey = 'sAMAccountName';
42-
}
43-
4440
$this->ldap = $ldap;
4541
$this->baseDn = $baseDn;
4642
$this->searchDn = $searchDn;

‎src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,17 @@ protected function handleCircularReference($object)
212212
* @param array $context
213213
* @param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface}
214214
*
215+
* @throws LogicException if the 'allow_extra_attributes' context variable is false and no class metadata factory is provided
216+
*
215217
* @return string[]|AttributeMetadataInterface[]|bool
216218
*/
217219
protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
218220
{
219221
if (!$this->classMetadataFactory) {
222+
if (isset($context[static::ALLOW_EXTRA_ATTRIBUTES]) && !$context[static::ALLOW_EXTRA_ATTRIBUTES]) {
223+
throw new LogicException(sprintf('A class metadata factory must be provided in the constructor when setting "%s" to false.', static::ALLOW_EXTRA_ATTRIBUTES));
224+
}
225+
220226
return false;
221227
}
222228

‎src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface NormalizerInterface
2525
/**
2626
* Normalizes an object into a set of arrays/scalars.
2727
*
28-
* @param object $object Object to normalize
28+
* @param mixed $object Object to normalize
2929
* @param string $format Format the normalization result will be encoded as
3030
* @param array $context Context options for the normalizer
3131
*

‎src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
2020
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
2121
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
22+
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2223
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
2324
use Symfony\Component\Serializer\SerializerAwareInterface;
2425
use Symfony\Component\Serializer\SerializerInterface;
@@ -52,7 +53,8 @@ public function testInstantiateObjectDenormalizer()
5253
*/
5354
public function testDenormalizeWithExtraAttributes()
5455
{
55-
$normalizer = new AbstractObjectNormalizerDummy();
56+
$factory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
57+
$normalizer = new AbstractObjectNormalizerDummy($factory);
5658
$normalizer->denormalize(
5759
array('fooFoo' => 'foo', 'fooBar' => 'bar'),
5860
__NAMESPACE__.'\Dummy',
@@ -144,6 +146,21 @@ private function getDenormalizerForDummyCollection()
144146

145147
return $denormalizer;
146148
}
149+
150+
/**
151+
* Test that additional attributes throw an exception if no metadata factory is specified.
152+
*
153+
* @expectedException \Symfony\Component\Serializer\Exception\LogicException
154+
* @expectedExceptionMessage A class metadata factory must be provided in the constructor when setting "allow_extra_attributes" to false.
155+
*/
156+
public function testExtraAttributesException()
157+
{
158+
$normalizer = new ObjectNormalizer();
159+
160+
$normalizer->denormalize(array(), \stdClass::class, 'xml', array(
161+
'allow_extra_attributes' => false,
162+
));
163+
}
147164
}
148165

149166
class AbstractObjectNormalizerDummy extends AbstractObjectNormalizer

‎src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Extractor/AbstractFileExtractor.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function extractFiles($resource)
4545

4646
private function toSplFileInfo(string $file): \SplFileInfo
4747
{
48-
return ($file instanceof \SplFileInfo) ? $file : new \SplFileInfo($file);
48+
return new \SplFileInfo($file);
4949
}
5050

5151
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.