Пример #1
0
function getCalledClass()
{
    return Stack\topCalledClass();
}
function getFunction()
{
    return Stack\top('function');
}
function getMethod()
{
    return getFunction();
}
function configure($dir)
{
    Config\locate($dir);
}
if (array_filter(get_defined_functions()['user'], 'Patchwork\\Utils\\isForeignName') != []) {
    trigger_error('Please import Patchwork from a point in your code ' . 'where no user-defined function is yet defined.', E_USER_WARNING);
}
Utils\alias('Patchwork', ['redefine' => ['replace', 'replaceLater'], 'relay' => 'callOriginal', 'fallBack' => 'pass', 'restore' => 'undo', 'restoreAll' => 'undoAll']);
if (Utils\runningOnHHVM()) {
    # no preprocessor needed on HHVM;
    # just let Patchwork become a wrapper for fb_intercept()
    spl_autoload_register('Patchwork\\CallRerouting\\deployQueue');
    return;
}
Config\locate(__DIR__);
CodeManipulation\Stream::wrap();
CodeManipulation\register([CodeManipulation\Actions\CodeManipulation\propagateThroughEval(), CodeManipulation\Actions\CallRerouting\injectCallInterceptionCode(), CodeManipulation\Actions\CallRerouting\injectQueueDeploymentCode()]);
CodeManipulation\onImport([CodeManipulation\Actions\CallRerouting\markPreprocessedFiles()]);
Utils\clearOpcodeCaches();
Пример #2
0
    Config\locate();
}
function hasMissed($callable)
{
    return Utils\callableWasMissed($callable);
}
function always($value)
{
    return function () use($value) {
        return $value;
    };
}
Utils\alias('Patchwork', ['redefine' => ['replace', 'replaceLater'], 'relay' => 'callOriginal', 'fallBack' => 'pass', 'restore' => 'undo', 'restoreAll' => 'undoAll']);
configure();
Utils\markMissedCallables();
if (Utils\runningOnHHVM()) {
    # no preprocessor needed on HHVM;
    # just let Patchwork become a wrapper for fb_intercept()
    spl_autoload_register('Patchwork\\CallRerouting\\deployQueue');
    return;
}
CodeManipulation\Stream::wrap();
CodeManipulation\register([CodeManipulation\Actions\CodeManipulation\propagateThroughEval(), CodeManipulation\Actions\CallRerouting\injectCallInterceptionCode(), CodeManipulation\Actions\CallRerouting\injectQueueDeploymentCode(), CodeManipulation\Actions\RedefinitionOfInternals\spliceNamedFunctionCalls(), CodeManipulation\Actions\RedefinitionOfInternals\spliceDynamicCalls()]);
CodeManipulation\onImport([CodeManipulation\Actions\CallRerouting\markPreprocessedFiles()]);
Utils\clearOpcodeCaches();
register_shutdown_function('Patchwork\\Utils\\clearOpcodeCaches');
CallRerouting\createStubsForInternals();
CallRerouting\connectDefaultInternals();
if (Utils\wasRunAsConsoleApp()) {
    require __DIR__ . '/src/Console.php';
}