Skip to content

Commit 08476e2

Browse files
committed
runtime conversion of enum type to PhpValue
ref #845 (comment)
1 parent e848e2b commit 08476e2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Peachpie.Runtime/Dynamic/ConvertExpression.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ public static Expression BindToValue(Expression expr)
524524
if (source == typeof(uint)) return Expression.Call(typeof(PhpValue).GetMethod("Create", Cache.Types.Long), Expression.Convert(expr, typeof(long)));
525525
if (source == typeof(ulong)) return Expression.Call(typeof(PhpValue).GetMethod("Create", Cache.Types.UInt64), expr);
526526

527+
if (source.IsEnum)
528+
{
529+
// (PhpValue)(int)enum
530+
return BindToValue(Expression.Convert(expr, source.GetEnumUnderlyingType()));
531+
}
532+
527533
throw new NotImplementedException(source.FullName);
528534
}
529535
else if (

0 commit comments

Comments
 (0)