Skip to content

Instantly share code, notes, and snippets.

@kddlb
Last active November 16, 2018 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kddlb/3f89e3b7f5b5a26996953f0ca4294183 to your computer and use it in GitHub Desktop.
Save kddlb/3f89e3b7f5b5a26996953f0ca4294183 to your computer and use it in GitHub Desktop.
PeachPie compiled
<?php
$status = file_get_contents("https://s2k7tnzlhrpw.statuspage.io/api/v1/summary.json");
$statusData = json_decode($status);
//var_dump($statusData);
?>
<table>
<thead>
<tr>
<th>Component</th><th>Status</th><th>Date</th>
</tr>
</thead>
<tbody>
<?php
foreach($statusData->components as $component):
?>
<tr>
<th style="text-align: left;"><?php echo $component->name; ?></th><td><?php echo $component->status; ?></td><td><?php echo $component->updated_at; ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
// index_php
using <Root>;
using Pchp.CodeAnalysis.Semantics;
using Pchp.Core;
using Pchp.Core.Dynamic;
using Pchp.Core.QueryValue;
using Pchp.Library;
using System;
using System.Runtime.CompilerServices;
[Script("index.php")]
public static class index_php
{
private static readonly CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>> get_components?0 = CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>>.Create(BinderFactory.GetField("components", default(RuntimeTypeHandle), typeof(PhpValue).TypeHandle, AccessMask.Read));
private static readonly CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>> get_name?2 = CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>>.Create(BinderFactory.GetField("name", default(RuntimeTypeHandle), typeof(PhpValue).TypeHandle, AccessMask.Read));
private static readonly CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>> get_status?3 = CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>>.Create(BinderFactory.GetField("status", default(RuntimeTypeHandle), typeof(PhpValue).TypeHandle, AccessMask.Read));
private static readonly CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>> get_updated_at?4 = CallSite<Func<CallSite, PhpValue, Context, CallerTypeParam, PhpValue>>.Create(BinderFactory.GetField("updated_at", default(RuntimeTypeHandle), typeof(PhpValue).TypeHandle, AccessMask.Read));
public static long <Main>(Context <ctx>, PhpArray <locals>, object @this, RuntimeTypeHandle <self>)
{
<ctx>.OnInclude<index_php>();
IndirectLocal indirectLocal = new IndirectLocal(<locals>, new IntStringKey("status"));
IndirectLocal indirectLocal2 = new IndirectLocal(<locals>, new IntStringKey("statusData"));
IndirectLocal indirectLocal3 = new IndirectLocal(<locals>, new IntStringKey("component"));
IntStringKey key = new IntStringKey("status");
PhpString phpString = PhpPath.file_get_contents(<ctx>, (LocalVariables)<locals>, "https://s2k7tnzlhrpw.statuspage.io/api/v1/summary.json");
<locals>.SetItemValue(key, PhpString.IsNull(phpString) ? PhpValue.False : PhpValue.Create(new PhpString(phpString)));
<locals>.SetItemValue(new IntStringKey("statusData"), JsonSerialization.json_decode(<ctx>, <locals>.GetItemValue(new IntStringKey("status")).ToPhpString(<ctx>)));
<ctx>.Echo("<table>\r\n<thead>\r\n<tr>\r\n<th>Component</th><th>Status</th><th>Date</th>\r\n</tr>\r\n</thead>\r\n<tbody>\r\n");
IPhpEnumerator foreachEnumerator = Operators.GetForeachEnumerator(get_components?0.Target(get_components?0, <locals>.GetItemValue(new IntStringKey("statusData")), <ctx>, new CallerTypeParam(<self>)), aliasedValues: false, <self>);
try
{
while (foreachEnumerator.MoveNext())
{
<locals>.SetItemValue(new IntStringKey("component"), foreachEnumerator.CurrentValue);
<ctx>.Echo("<tr>\r\n<th style=\"text-align: left;\">");
<ctx>.Echo(get_name?2.Target(get_name?2, <locals>.GetItemValue(new IntStringKey("component")), <ctx>, new CallerTypeParam(<self>)));
<ctx>.Echo("</th><td>");
<ctx>.Echo(get_status?3.Target(get_status?3, <locals>.GetItemValue(new IntStringKey("component")), <ctx>, new CallerTypeParam(<self>)));
<ctx>.Echo("</td><td>");
<ctx>.Echo(get_updated_at?4.Target(get_updated_at?4, <locals>.GetItemValue(new IntStringKey("component")), <ctx>, new CallerTypeParam(<self>)));
<ctx>.Echo("</td>\r\n</tr>\r\n");
}
}
finally
{
foreachEnumerator.Dispose();
}
<ctx>.Echo("</tbody>\r\n</table>");
return 1L;
}
public static PhpValue <Main>`0(Context <ctx>, PhpArray <locals>, object @this, RuntimeTypeHandle <self>)
{
return PhpValue.Create(<Main>(<ctx>, <locals>, @this, <self>));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment