@@ -573,12 +573,28 @@ public static function getValidReadPropertyPaths(): iterable
573573 yield [(object ) ['foo ' => null ], 'foo?.bar.baz ' , null ];
574574 yield [(object ) ['foo ' => (object ) ['bar ' => null ]], 'foo?.bar?.baz ' , null ];
575575 yield [(object ) ['foo ' => (object ) ['bar ' => null ]], 'foo.bar?.baz ' , null ];
576+
577+ yield from self ::getNullSafeIndexPaths ();
578+ }
579+
580+ public static function getNullSafeIndexPaths (): iterable
581+ {
576582 yield [(object ) ['foo ' => ['bar ' => null ]], 'foo[bar?].baz ' , null ];
577583 yield [[], '[foo?] ' , null ];
578584 yield [['foo ' => ['firstName ' => 'Bernhard ' ]], '[foo][bar?] ' , null ];
579585 yield [['foo ' => ['firstName ' => 'Bernhard ' ]], '[foo][bar?][baz?] ' , null ];
580586 }
581587
588+ /**
589+ * @dataProvider getNullSafeIndexPaths
590+ */
591+ public function testNullSafeIndexWithThrowOnInvalidIndex ($ objectOrArray , $ path , $ value )
592+ {
593+ $ this ->propertyAccessor = new PropertyAccessor (PropertyAccessor::DISALLOW_MAGIC_METHODS , PropertyAccessor::THROW_ON_INVALID_INDEX | PropertyAccessor::THROW_ON_INVALID_PROPERTY_PATH );
594+
595+ $ this ->assertSame ($ value , $ this ->propertyAccessor ->getValue ($ objectOrArray , $ path ));
596+ }
597+
582598 public function testTicket5755 ()
583599 {
584600 $ object = new Ticket5775Object ();
0 commit comments