Skip to content

Commit b93c1d8

Browse files
Merge branch '4.4' into 5.0
* 4.4: [PropertyAccess] fix tests [WebProfilerBundle] fix test remove assertions that can never be reached [PropertyAccess] Improve message of unitialized property in php 7.4 [HttpFoundation] Fixed session migration with custom cookie lifetime [HttpKernel][FrameworkBundle] fix compat with Debug component [Serializer] Remove unused variable Allow URL-encoded special characters in basic auth part of URLs [Serializer] Fix unitialized properties (from PHP 7.4.2) when serializing context for the cache key [Validator] Add missing Ukrainian and Russian translations Track session usage when setting the token [4.4][MonologBridge] Fix $level type No need to reconnect the bags to the session Support for Content Security Policy style-src-elem and script-src-elem in WebProfiler [PropertyInfo][ReflectionExtractor] Check the array mutator prefixes last when the property is singular [Security][Http][SwitchUserListener] Ignore all non existent username protection errors Add installation and minimal example to README
2 parents 6b14bd5 + afe626c commit b93c1d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

PropertyAccessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid
385385
} catch (\TypeError $e) {
386386
// handle uninitialized properties in PHP >= 7
387387
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)) {
388-
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);
388+
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);
389389
}
390390

391391
throw $e;
@@ -418,7 +418,7 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid
418418
if (\PHP_VERSION_ID >= 70400 && preg_match('/^Typed property ([\w\\\]+)::\$(\w+) must not be accessed before initialization$/', $e->getMessage(), $matches)) {
419419
$r = new \ReflectionProperty($matches[1], $matches[2]);
420420

421-
throw new AccessException(sprintf('The property "%s::$%s" is not readable because it is typed "%3$s". You should either initialize it or make it nullable using "?%3$s" instead.', $r->getDeclaringClass()->getName(), $r->getName(), $r->getType()->getName()), 0, $e);
421+
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);
422422
}
423423

424424
throw $e;

Tests/PropertyAccessorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnab
139139
public function testGetValueThrowsExceptionIfUninitializedProperty()
140140
{
141141
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException');
142-
$this->expectExceptionMessage('The property "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedProperty::$uninitialized" is not readable because it is typed "string". You should either initialize it or make it nullable using "?string" instead.');
142+
$this->expectExceptionMessage('The property "Symfony\Component\PropertyAccess\Tests\Fixtures\UninitializedProperty::$uninitialized" is not readable because it is typed "string". You should initialize it or declare a default value instead.');
143143

144144
$this->propertyAccessor->getValue(new UninitializedProperty(), 'uninitialized');
145145
}
@@ -150,7 +150,7 @@ public function testGetValueThrowsExceptionIfUninitializedProperty()
150150
public function testGetValueThrowsExceptionIfUninitializedPropertyWithGetter()
151151
{
152152
$this->expectException('Symfony\Component\PropertyAccess\Exception\AccessException');
153-
$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?');
153+
$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"?');
154154

155155
$this->propertyAccessor->getValue(new UninitializedPrivateProperty(), 'uninitialized');
156156
}

0 commit comments

Comments
 (0)