Get the code of the inner callback as string.
public getCallbackCode ( ) : string | ||
리턴 | string |
public function testGetCallbackCode() { $closure = function () { echo 'Some nifty code'; }; $callback = new Callback($closure); $result = $callback->getCallbackCode(); // Adding this ad-hoc regular expression to minimize the possible errors // that might occur while trying to match the source code string against an // expected value. $regexp = '#^\\s*function\\s*\\(\\s*\\)\\s*{\\s*echo\\s*\'Some nifty code\';\\s*}\\s*$#'; $this->assertRegExp($regexp, $result); }