Skip to content

Instantly share code, notes, and snippets.

@macek
Created December 7, 2011 23:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macek/1445216 to your computer and use it in GitHub Desktop.
Save macek/1445216 to your computer and use it in GitHub Desktop.
Patchwork Sample
<pre>
<?php
class Loader {
static public function helper($class){
echo "including concrete5 {$class}\n";
}
}
class MyLoader {
static public function helper($class){
if($class == "captcha"){
echo "loading my super secret {$class}\n";
}
else {
Patchwork\pass();
}
}
}
$hijack = Patchwork\replace('Loader::helper', 'MyLoader::helper');
Loader::helper("captcha");
Loader::helper("foobar");
Patchwork\undo($hijack);
Loader::helper("captcha");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment