1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 02:27:10 +03:00

Merge pull request #325 from chr15m/php-interop-language-constructs

PHP: Wrap some native "language constructs".
This commit is contained in:
Joel Martin 2018-07-12 16:15:29 -07:00 committed by GitHub
commit ba36c146bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)) {