Skip to content

Instantly share code, notes, and snippets.

@jk
Created December 25, 2014 12:41
Show Gist options
  • Save jk/e7ba80e288f10e499cd2 to your computer and use it in GitHub Desktop.
Save jk/e7ba80e288f10e499cd2 to your computer and use it in GitHub Desktop.
Generate cache key from method invocation
<?php
class MyClass {
public function myFunction($myParam) {
$callee = debug_backtrace(null, 2)[1];
$method_string = $callee['class'].$callee['type'].$callee['function'].'('.implode(', ', $callee['args']).')';
return $method_string;
}
}
class Runner {
public function run($param1, $param2) {
$c = new MyClass();
$r = $c->myFunction('test');
var_dump($r);
}
}
$c = new Runner();
$c->run('value1', 'value2');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment