__zigar‐>unimport() ᴾᴴᴾ - chung-leong/zigar GitHub Wiki

JavaScript | PHP

Remove imported functions and constants from PHP's global namespace.

Usage:

const std = @import("std");

pub fn hello() void {
    return std.debug.print("Hello world\n", .{});
}
<?php

$m = zigar_use(__DIR__ . '/unimport-example-1.zig');
$m->__zigar->import(function($name, $type) {
    echo "$name = $type\n";
    return "duck_$name";
});

duck_hello();
$m->__zigar->unimport();
duck_hello();
hello = function
Hello world
PHP Fatal error:  Uncaught Error: Call to undefined function duck_hello() in /home/rwiggum/examples/unimport-example-1.php:11
Stack trace:
#0 {main}
  thrown in /home/rwiggum/examples/unimport-example-1.php on line 11


Special exports: __zigar | import()