Skip to content

Commit 9b07634

Browse files
Merge branch '5.4' into 6.0
* 5.4: [PropertyAccess] Fix Regression in PropertyAccessor::isWritable() [Mime] Allow array as input for RawMessage [Mesenger] Add support for resetting container services after each messenger message. [RateLimiter][Runtime][Translation] remove `@experimental` flag Reword return type deprecation message
2 parents 9046f1e + bd3efa2 commit 9b07634

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Diff for: PropertyAccessor.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@ public function isWritable(object|array $objectOrArray, string|PropertyPathInter
260260
if (!$zval[self::VALUE] instanceof \ArrayAccess && !\is_array($zval[self::VALUE])) {
261261
return false;
262262
}
263-
} else {
264-
if (!$this->isPropertyWritable($zval[self::VALUE], $propertyPath->getElement($i))) {
265-
return false;
266-
}
263+
} elseif (!\is_object($zval[self::VALUE]) || !$this->isPropertyWritable($zval[self::VALUE], $propertyPath->getElement($i))) {
264+
return false;
267265
}
268266

269267
if (\is_object($zval[self::VALUE])) {
@@ -603,10 +601,6 @@ private function getWriteInfo(string $class, string $property, mixed $value): Pr
603601
*/
604602
private function isPropertyWritable(object $object, string $property): bool
605603
{
606-
if (!\is_object($object)) {
607-
return false;
608-
}
609-
610604
$mutatorForArray = $this->getWriteInfo(\get_class($object), $property, []);
611605

612606
if (PropertyWriteInfo::TYPE_NONE !== $mutatorForArray->getType() || ($object instanceof \stdClass && property_exists($object, $property))) {

Diff for: Tests/PropertyAccessorArrayAccessTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function getValidPropertyPaths()
3838
];
3939
}
4040

41+
public function getInvalidPropertyPaths()
42+
{
43+
return [
44+
[$this->getContainer(['firstName' => 'Bernhard']), 'firstName', 'Bernhard'],
45+
[$this->getContainer(['person' => $this->getContainer(['firstName' => 'Bernhard'])]), 'person.firstName', 'Bernhard'],
46+
];
47+
}
48+
4149
/**
4250
* @dataProvider getValidPropertyPaths
4351
*/
@@ -83,4 +91,12 @@ public function testIsWritable($collection, $path)
8391
{
8492
$this->assertTrue($this->propertyAccessor->isWritable($collection, $path));
8593
}
94+
95+
/**
96+
* @dataProvider getInvalidPropertyPaths
97+
*/
98+
public function testIsNotWritable($collection, $path)
99+
{
100+
$this->assertFalse($this->propertyAccessor->isWritable($collection, $path));
101+
}
86102
}

0 commit comments

Comments
 (0)