@@ -295,40 +295,40 @@ protected function _createFromArray($className, $data)
295295 $ camelCaseProperty = SimpleDataObjectConverter::snakeCaseToUpperCamelCase ($ propertyName );
296296 try {
297297 $ methodName = $ this ->getNameFinder ()->getGetterMethodName ($ class , $ camelCaseProperty );
298- } catch (\LogicException $ e ) {
299- $ this ->processInputError ([$ camelCaseProperty ]);
300- }
301- if (!isset ($ this ->methodReflectionStorage [$ className . $ methodName ])) {
302- $ this ->methodReflectionStorage [$ className . $ methodName ] = $ class ->getMethod ($ methodName );
303- }
304- $ methodReflection = $ this ->methodReflectionStorage [$ className . $ methodName ];
305- if ($ methodReflection ->isPublic ()) {
306- $ returnType = $ this ->typeProcessor ->getGetterReturnType ($ methodReflection )['type ' ];
307- try {
308- $ setterName = $ this ->getNameFinder ()->getSetterMethodName ($ class , $ camelCaseProperty );
309- } catch (\Exception $ e ) {
310- if (empty ($ value )) {
311- continue ;
312- } else {
313- throw $ e ;
314- }
298+ if (!isset ($ this ->methodReflectionStorage [$ className . $ methodName ])) {
299+ $ this ->methodReflectionStorage [$ className . $ methodName ] = $ class ->getMethod ($ methodName );
315300 }
316- try {
317- if ($ camelCaseProperty === 'CustomAttributes ' ) {
318- $ setterValue = $ this ->convertCustomAttributeValue ($ value , $ className );
319- } else {
320- $ setterValue = $ this ->convertValue ($ value , $ returnType );
301+ $ methodReflection = $ this ->methodReflectionStorage [$ className . $ methodName ];
302+ if ($ methodReflection ->isPublic ()) {
303+ $ returnType = $ this ->typeProcessor ->getGetterReturnType ($ methodReflection )['type ' ];
304+ try {
305+ $ setterName = $ this ->getNameFinder ()->getSetterMethodName ($ class , $ camelCaseProperty );
306+ } catch (\Exception $ e ) {
307+ if (empty ($ value )) {
308+ continue ;
309+ } else {
310+ throw $ e ;
311+ }
321312 }
322- } catch (SerializationException $ e ) {
323- throw new SerializationException (
324- new Phrase (
325- 'Error occurred during "%field_name" processing. %details ' ,
326- ['field_name ' => $ propertyName , 'details ' => $ e ->getMessage ()]
327- )
328- );
313+ try {
314+ if ($ camelCaseProperty === 'CustomAttributes ' ) {
315+ $ setterValue = $ this ->convertCustomAttributeValue ($ value , $ className );
316+ } else {
317+ $ setterValue = $ this ->convertValue ($ value , $ returnType );
318+ }
319+ } catch (SerializationException $ e ) {
320+ throw new SerializationException (
321+ new Phrase (
322+ 'Error occurred during "%field_name" processing. %details ' ,
323+ ['field_name ' => $ propertyName , 'details ' => $ e ->getMessage ()]
324+ )
325+ );
326+ }
327+ $ this ->serviceInputValidator ->validateEntityValue ($ object , $ propertyName , $ setterValue );
328+ $ object ->{$ setterName }($ setterValue );
329329 }
330- $ this -> serviceInputValidator -> validateEntityValue ( $ object , $ propertyName , $ setterValue );
331- $ object ->{ $ setterName }( $ setterValue );
330+ } catch ( \ LogicException $ e ) {
331+ $ this -> processInputError ([ $ camelCaseProperty ] );
332332 }
333333 }
334334
0 commit comments