@@ -21,7 +21,7 @@ internal class PhpDeserializer {
2121 } ;
2222 private static readonly object TypeLookupCacheSyncObject = new ( ) ;
2323
24- private static readonly Dictionary < Type , Dictionary < string , PropertyInfo > > PropertyInfoCache = new ( ) ;
24+ private static readonly Dictionary < Type , Dictionary < object , PropertyInfo > > PropertyInfoCache = new ( ) ;
2525 private static readonly object PropertyInfoCacheSyncObject = new ( ) ;
2626
2727 private static Dictionary < Type , Dictionary < string , FieldInfo > > FieldInfoCache { get ; set ; } = new ( ) ;
@@ -103,8 +103,7 @@ private object MakeClass(PhpSerializeToken token) {
103103 object constructedObject ;
104104 Type targetType = null ;
105105 if ( typeName != "stdClass" && this . _options . EnableTypeLookup ) {
106- lock ( TypeLookupCacheSyncObject )
107- {
106+ lock ( TypeLookupCacheSyncObject ) {
108107 if ( TypeLookupCache . ContainsKey ( typeName ) ) {
109108 targetType = TypeLookupCache [ typeName ] ;
110109 } else {
@@ -393,7 +392,7 @@ private object MakeStruct(Type targetType, PhpSerializeToken token) {
393392
394393 private object MakeObject ( Type targetType , PhpSerializeToken token ) {
395394 var result = Activator . CreateInstance ( targetType ) ;
396- Dictionary < string , PropertyInfo > properties ;
395+ Dictionary < object , PropertyInfo > properties ;
397396 lock ( PropertyInfoCacheSyncObject ) {
398397 if ( PropertyInfoCache . ContainsKey ( targetType ) ) {
399398 properties = PropertyInfoCache [ targetType ] ;
@@ -406,7 +405,18 @@ private object MakeObject(Type targetType, PhpSerializeToken token) {
406405 }
407406
408407 for ( int i = 0 ; i < token . Children . Length ; i += 2 ) {
409- var propertyName = this . _options . CaseSensitiveProperties ? token . Children [ i ] . Value : token . Children [ i ] . Value . ToLower ( ) ;
408+ object propertyName ;
409+ if ( token . Children [ i ] . Type == PhpSerializerType . String ) {
410+ propertyName = this . _options . CaseSensitiveProperties ? token . Children [ i ] . Value : token . Children [ i ] . Value . ToLower ( ) ;
411+ } else if ( token . Children [ i ] . Type == PhpSerializerType . Integer ) {
412+ propertyName = token . Children [ i ] . ToLong ( ) ;
413+ } else {
414+ throw new DeserializationException (
415+ $ "Error encountered deserizalizing an object of type '{ targetType . FullName } ': " +
416+ $ "The key '{ token . Children [ i ] . Value } ' (from the token at position { token . Children [ i ] . Position } ) has an unsupported type of '{ token . Children [ i ] . Type } '."
417+ ) ;
418+ }
419+
410420 var valueToken = token . Children [ i + 1 ] ;
411421
412422 if ( ! properties . ContainsKey ( propertyName ) ) {
0 commit comments