Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Application/MicroPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
80 changes: 79 additions & 1 deletion src/Application/UI/PresenterComponentReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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);
}

}