File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed
Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 33## 2.5.1 under development
44
55- Bug #776 : Take ` PropertyTranslatorProviderInterface ` into account during context validation (@vjik )
6+ - Enh #???: Default Intl locale in tests (@batyrmastyr )
7+ - Enh #???: Support validation of uninitialized properties (@batyrmastyr )
68
79## 2.5.0 July 19, 2025
810
Original file line number Diff line number Diff line change 1515>
1616 <php >
1717 <ini name =" error_reporting" value =" -1" />
18+ <ini name =" intl.default_locale" value =" en" />
1819 </php >
1920
2021 <testsuites >
Original file line number Diff line number Diff line change @@ -279,8 +279,13 @@ public function getLabels(): array
279279 */
280280 public function getPropertyValue (string $ property ): mixed
281281 {
282- return is_object ($ this ->source )
283- ? ($ this ->getReflectionProperties ()[$ property ] ?? null )?->getValue($ this ->source )
282+ if (!is_object ($ this ->source )) {
283+ return null ;
284+ }
285+
286+ $ reflectionProperty = $ this ->getReflectionProperties ()[$ property ] ?? null ;
287+ return $ reflectionProperty ?->isInitialized($ this ->source )
288+ ? $ reflectionProperty ?->getValue($ this ->source )
284289 : null ;
285290 }
286291
@@ -312,6 +317,9 @@ public function getData(): array
312317
313318 $ data = [];
314319 foreach ($ this ->getReflectionProperties () as $ name => $ property ) {
320+ if (!$ property ->isInitialized ($ this ->source )) {
321+ continue ;
322+ }
315323 /** @var mixed */
316324 $ data [$ name ] = $ property ->getValue ($ this ->source );
317325 }
Original file line number Diff line number Diff line change @@ -178,4 +178,18 @@ public function testDisabledCache(): void
178178 $ this ->assertNotSame ($ rules , $ parser ->getRules ());
179179 $ this ->assertArrayNotHasKey ($ cacheKey , $ cacheProperty ->getValue ());
180180 }
181+
182+ public function testUninitializedProperty (): void
183+ {
184+ $ parser = new ObjectParser (new class () {
185+ public int $ a = 4 ;
186+ public int $ uninitialized ;
187+ });
188+
189+ $ this ->assertNull ($ parser ->getPropertyValue ('not-existing ' ));
190+ $ this ->assertSame (4 , $ parser ->getPropertyValue ('a ' ));
191+ $ this ->assertNull ($ parser ->getPropertyValue ('uninitialized ' ));
192+
193+ $ this ->assertSame (['a ' => 4 ], $ parser ->getData ());;
194+ }
181195}
You can’t perform that action at this time.
0 commit comments