Skip to content

Commit 276c184

Browse files
[PropertyAccess] fix tests
1 parent c1cd27d commit 276c184

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

PropertyAccessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private function readProperty($zval, $property)
472472
} catch (\TypeError $e) {
473473
// handle uninitialized properties in PHP >= 7
474474
if (preg_match((sprintf('/^Return value of %s::%s\(\) must be of the type (\w+), null returned$/', preg_quote(\get_class($object)), $access[self::ACCESS_NAME])), $e->getMessage(), $matches)) {
475-
throw new AccessException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Have you forgotten to initialize a property or to make the return type nullable using "?%3$s" instead?', \get_class($object), $access[self::ACCESS_NAME], $matches[1]), 0, $e);
475+
throw new AccessException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?', \get_class($object), $access[self::ACCESS_NAME], $matches[1]), 0, $e);
476476
}
477477

478478
throw $e;
@@ -505,7 +505,7 @@ private function readProperty($zval, $property)
505505
if (\PHP_VERSION_ID >= 70400 && preg_match('/^Typed property ([\w\\\]+)::\$(\w+) must not be accessed before initialization$/', $e->getMessage(), $matches)) {
506506
$r = new \ReflectionProperty($matches[1], $matches[2]);
507507

508-
throw new AccessException(sprintf('The property "%s::$%s" is not readable because it is typed "%2$s". You should initialize it or declare a default value instead.', $r->getDeclaringClass()->getName(), $r->getType()->getName()), 0, $e);
508+
throw new AccessException(sprintf('The property "%s::$%s" is not readable because it is typed "%s". You should initialize it or declare a default value instead.', $r->getDeclaringClass()->getName(), $r->getName(), $r->getType()->getName()), 0, $e);
509509
}
510510

511511
throw $e;

Tests/PropertyAccessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function testGetValueThrowsExceptionIfUninitializedProperty()
137137
public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetter()
138138
{
139139
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException');
140-
$this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty::getUninitialized()" returned "null", but expected type "array". Have you forgotten to initialize a property or to make the return type nullable using "?array" instead?');
140+
$this->expectExceptionMessage('The method "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedPrivateProperty::getUninitialized()" returned "null", but expected type "array". Did you forget to initialize a property or to make the return type nullable using "?array"?');
141141

142142
$this->propertyAccessor->getValue(new UninitializedPrivateProperty(), 'uninitialized');
143143
}

0 commit comments

Comments
 (0)