diff --git a/src/Application/MicroPresenter.php b/src/Application/MicroPresenter.php index b6d4091bb..25c80aad4 100644 --- a/src/Application/MicroPresenter.php +++ b/src/Application/MicroPresenter.php @@ -78,7 +78,7 @@ public function run(Application\Request $request) if ($this->context) { foreach ($reflection->getParameters() as $param) { - if ($param->getClassName()) { + if ($param->getClass()) { unset($params[$param->getPosition()]); } } diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 21e9b2e00..974ae19fb 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -176,7 +176,7 @@ public function run(Application\Request $request) } $this->initGlobalParameters(); - $this->checkRequirements($this->getReflection()); + $this->checkRequirements(new \ReflectionClass($this)); $this->startup(); if (!$this->startupCheck) { $class = $this->getReflection()->getMethod('startup')->getDeclaringClass()->getName(); diff --git a/src/Application/UI/PresenterComponentReflection.php b/src/Application/UI/PresenterComponentReflection.php index 18901fbf7..376ccf91b 100644 --- a/src/Application/UI/PresenterComponentReflection.php +++ b/src/Application/UI/PresenterComponentReflection.php @@ -9,14 +9,20 @@ use Nette; use Nette\Application\BadRequestException; +use Nette\Reflection\ClassType; +use Nette\Reflection\Method; /** * Helpers for Presenter & PresenterComponent. + * @property-read string $name + * @property-read string $fileName * @internal */ -class PresenterComponentReflection extends Nette\Reflection\ClassType +class PresenterComponentReflection extends \ReflectionClass { + use Nette\SmartObject; + /** @var array getPersistentParams cache */ private static $ppCache = []; @@ -229,4 +235,76 @@ public static function getParameterType(\ReflectionParameter $param) } } + + /********************* compatiblity with Nette\Reflection ****************d*g**/ + + + public function getMethod($name) + { + return new MethodCompatibility($this->getName(), $name); + } + + + public function getMethods($filter = -1) + { + foreach ($res = parent::getMethods($filter) as $key => $val) { + $res[$key] = new MethodCompatibility($this->getName(), $val->getName()); + } + return $res; + } + + + public function __toString() + { + trigger_error(__METHOD__ . ' is deprecated.', E_USER_DEPRECATED); + return $this->getName(); + } + + + public function __get($name) + { + trigger_error("getReflection()->$name is deprecated.", E_USER_DEPRECATED); + return (new ClassType($this->getName()))->$name; + } + + + public function __call($name, $args) + { + if (method_exists(ClassType::class, $name)) { + trigger_error("getReflection()->$name() is deprecated, use Nette\\Reflection\\ClassType::from(\$presenter)->$name()", E_USER_DEPRECATED); + return call_user_func_array([new ClassType($this->getName()), $name], $args); + } + Nette\Utils\ObjectMixin::strictCall(get_class($this), $name); + } + +} + + +/** + * @internal + */ +class MethodCompatibility extends \ReflectionMethod +{ + use Nette\SmartObject; + + public function __toString() + { + trigger_error(__METHOD__ . ' is deprecated.', E_USER_DEPRECATED); + return parent::getDeclaringClass()->getName() . '::' . $this->getName() . '()'; + } + + + public function __get($name) + { + trigger_error("getMethod('{$this->getName()}')->$name is deprecated.", E_USER_DEPRECATED); + return (new Method(parent::getDeclaringClass()->getName(), $this->getName()))->$name; + } + + + public function __call($name, $args) + { + trigger_error("getMethod('{$this->getName()}')->$name() is deprecated, use Nette\\Reflection\\Method::from(\$presenter, '{$this->getName()}')->$name()", E_USER_DEPRECATED); + return call_user_func_array([new Method(parent::getDeclaringClass()->getName(), $this->getName()), $name], $args); + } + }