/** * Retrieve reflection for anonymous function * @param string $file * @throws ApplicationException * @return Reflection */ public function reflection($file) { // cache for reflection data if (!($reflection = Cache::get('reflection:' . $file))) { $reflection = new Reflection($file); $reflection->process(); Cache::set('reflection:' . $file, $reflection); Cache::addTag('reflection:' . $file, 'reflection'); } return $reflection; }
<?php /** * Get custom reflection data * * @category Application * * @author dark * @created 17.05.13 17:05 */ namespace Application; use Bluz\Controller\Reflection; use Bluz\Proxy\Layout; return function ($id = 0, $other = "default value") use($view) { /** * @var Bootstrap $this * @var \Bluz\View\View $view */ Layout::breadCrumbs([$view->ahref('Test', ['test', 'index']), 'Reflection of this controllers']); $reflection = new Reflection(__FILE__); $reflection->process(); $view->functionData = file_get_contents(__FILE__); $view->reflectionData = $this->reflection(__FILE__); $view->id = $id; $view->other = $other; };
/** * Retrieve reflection for anonymous function * @return Reflection * @throws \Bluz\Common\Exception\ComponentException */ protected function setReflection() { // cache for reflection data if (!($reflection = Cache::get('reflection:' . $this->module . ':' . $this->controller))) { $reflection = new Reflection($this->getFile()); $reflection->process(); Cache::set('reflection:' . $this->module . ':' . $this->controller, $reflection); Cache::addTag('reflection:' . $this->module . ':' . $this->controller, 'reflection'); } $this->reflection = $reflection; }
/** * Test reflection without return structure * @expectedException \Bluz\Common\Exception\ComponentException */ public function testReflectionWithoutReturn() { $controllerFile = dirname(__FILE__) . '/../Fixtures/Controllers/ConcreteWithoutReturn.php'; $reflection = new Reflection($controllerFile); $reflection->process(); }