You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interception hook follows the following contract:
It is only called if the included file exists.
The passed $path is the realpath.
If the hook returns null, no interception is performed.
If the hook returns a string, these are taken as the transformed content of the file.
For convenience, a FileFilter is provided that implements white- and black-listing
of files and directories. Paths passed to addBlackList() and addWhiteList() should
always be realpaths.
useNikic\IncludeInterceptor\Interceptor;
useNikic\IncludeInterceptor\FileFilter;
$fileFilter = FileFilter::createAllWhitelisted(); // Start with everything whitelisted$fileFilter->addBlackList(__DIR__ . '/src/'); // Blacklist the src/ directory$fileFilter->addWhiteList(__DIR__ . '/src/foo.php'); // But whitelist the src/foo.php file$interceptor = newInterceptor(function(string$path) use ($fileFilter) {
if (!$fileFilter->test($path)) {
returnnull;
}
returntransformCode(file_get_contents($path));
});
$interceptor->setUp();
require'src/foo.php';
About
Library to intercept and dynamically transform PHP includes. Forked from icewind1991/interceptor.