@@ -18,7 +18,7 @@ final class ObjectSchema extends AbstractSchema implements ObjectSchemaInterface
1818 /**
1919 * @var array<string, SchemaInterface>
2020 */
21- private array $ fieldNameToSchema ;
21+ private array $ fieldToSchema ;
2222
2323 /**
2424 * @var null|array<string>
@@ -31,16 +31,16 @@ final class ObjectSchema extends AbstractSchema implements ObjectSchemaInterface
3131 private ?array $ optional = null ;
3232
3333 /**
34- * @param array<string, SchemaInterface> $fieldNameToSchema
34+ * @param array<string, SchemaInterface> $fieldToSchema
3535 * @param class-string $classname
3636 */
37- public function __construct (array $ fieldNameToSchema , private string $ classname = \stdClass::class)
37+ public function __construct (array $ fieldToSchema , private string $ classname = \stdClass::class)
3838 {
39- foreach ($ fieldNameToSchema as $ fieldName => $ fieldSchema ) {
39+ foreach ($ fieldToSchema as $ fieldName => $ fieldSchema ) {
4040 if (!\is_string ($ fieldName )) {
4141 throw new \InvalidArgumentException (
4242 \sprintf (
43- 'Argument #1 name #%s ($fieldNameToSchema ) must be of type string, %s given ' ,
43+ 'Argument #1 name #%s ($fieldToSchema ) must be of type string, %s given ' ,
4444 $ fieldName ,
4545 $ this ->getDataType ($ fieldName )
4646 )
@@ -50,7 +50,7 @@ public function __construct(array $fieldNameToSchema, private string $classname
5050 if (!$ fieldSchema instanceof SchemaInterface) {
5151 throw new \InvalidArgumentException (
5252 \sprintf (
53- 'Argument #1 value of #%s ($fieldNameToSchema ) must be of type %s, %s given ' ,
53+ 'Argument #1 value of #%s ($fieldToSchema ) must be of type %s, %s given ' ,
5454 $ fieldName ,
5555 SchemaInterface::class,
5656 $ this ->getDataType ($ fieldSchema )
@@ -59,7 +59,7 @@ public function __construct(array $fieldNameToSchema, private string $classname
5959 }
6060 }
6161
62- $ this ->fieldNameToSchema = $ fieldNameToSchema ;
62+ $ this ->fieldToSchema = $ fieldToSchema ;
6363 }
6464
6565 public function parse (mixed $ input ): mixed
@@ -111,9 +111,17 @@ public function parse(mixed $input): mixed
111111 }
112112 }
113113
114- public function getFieldSchema (string $ fieldName ): ?SchemaInterface
114+ /**
115+ * @return array<string, SchemaInterface>
116+ */
117+ public function getFieldToSchema (): array
118+ {
119+ return $ this ->fieldToSchema ;
120+ }
121+
122+ public function getFieldSchema (string $ field ): ?SchemaInterface
115123 {
116- return $ this ->fieldNameToSchema [ $ fieldName ] ?? null ;
124+ return $ this ->fieldToSchema [ $ field ] ?? null ;
117125 }
118126
119127 /**
@@ -150,7 +158,7 @@ private function unknownFields(array $input, ParserErrorException $childrenParse
150158 }
151159
152160 foreach (array_keys ($ input ) as $ fieldName ) {
153- if (!\in_array ($ fieldName , $ this ->strict , true ) && !isset ($ this ->fieldNameToSchema [$ fieldName ])) {
161+ if (!\in_array ($ fieldName , $ this ->strict , true ) && !isset ($ this ->fieldToSchema [$ fieldName ])) {
154162 $ childrenParserErrorException ->addError (new Error (
155163 self ::ERROR_UNKNOWN_FIELD_CODE ,
156164 self ::ERROR_UNKNOWN_FIELD_TEMPLATE ,
@@ -165,7 +173,7 @@ private function unknownFields(array $input, ParserErrorException $childrenParse
165173 */
166174 private function parseFields (array $ input , object $ object , ParserErrorException $ childrenParserErrorException ): void
167175 {
168- foreach ($ this ->fieldNameToSchema as $ fieldName => $ fieldSchema ) {
176+ foreach ($ this ->fieldToSchema as $ fieldName => $ fieldSchema ) {
169177 try {
170178 if (
171179 !\array_key_exists ($ fieldName , $ input )
0 commit comments