1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-13 01:43:50 +03:00

PHP: Wrap some native "language constructs".

Common ones which can't be called otherwise.
Can now be reached via php/exit, php/print, php/require.

Fixes chr15m/frock#7
This commit is contained in:
Chris McCormick 2018-07-12 20:21:03 +08:00
parent 810ec74a67
commit 634ca5e98b

View File

@ -52,6 +52,22 @@ function _to_native($name, $env) {
$res = call_user_func_array($name, $args);
return _to_mal($res);
});
// special case for language constructs
} else if ($name == "print") {
return _function(function($value) {
print(_to_php($value));
return null;
});
} else if ($name == "exit") {
return _function(function($value) {
exit(_to_php($value));
return null;
});
} else if ($name == "require") {
return _function(function($value) {
require(_to_php($value));
return null;
});
} else if (in_array($name, ["_SERVER", "_GET", "_POST", "_FILES", "_REQUEST", "_SESSION", "_ENV", "_COOKIE"])) {
$val = $GLOBALS[$name];
} else if (defined($name)) {