Skip to content

Commit c74cd4a

Browse files
committed
minor symfony#14206 [2.3] SCA for Components - reference mismatches (kalessil)
This PR was squashed before being merged into the 2.3 branch (closes symfony#14206). Discussion ---------- [2.3] SCA for Components - reference mismatches | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Static Code Analysis with Php Inspections (EA Extended), no functional changes: - worked out some of reference mismatches Commits ------- f732659 [2.3] SCA for Components - reference mismatches
2 parents 49cbf1c + f732659 commit c74cd4a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __construct($storageKey = '_sf2_attributes', $namespaceCharacter
4343
*/
4444
public function has($name)
4545
{
46+
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
4647
$attributes = $this->resolveAttributePath($name);
4748
$name = $this->resolveKey($name);
4849

@@ -58,6 +59,7 @@ public function has($name)
5859
*/
5960
public function get($name, $default = null)
6061
{
62+
// reference mismatch: if fixed, re-introduced in array_key_exists; keep as it is
6163
$attributes = $this->resolveAttributePath($name);
6264
$name = $this->resolveKey($name);
6365

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ private function writeProperty(&$object, $property, $singular, $value)
304304
// see https://github.com/symfony/symfony/issues/4670
305305
$itemsToAdd = is_object($value) ? iterator_to_array($value) : $value;
306306
$itemToRemove = array();
307-
$propertyValue = $this->readProperty($object, $property);
307+
$propertyValue = &$this->readProperty($object, $property);
308308
$previousValue = $propertyValue[self::VALUE];
309+
// remove reference to avoid modifications
310+
unset($propertyValue);
309311

310312
if (is_array($previousValue) || $previousValue instanceof \Traversable) {
311313
foreach ($previousValue as $previousItem) {

0 commit comments

Comments
 (0)