|
9 | 9 |
|
10 | 10 | use Nette; |
11 | 11 | use Nette\Application\BadRequestException; |
| 12 | +use Nette\Reflection\ClassType; |
| 13 | +use Nette\Reflection\Method; |
12 | 14 |
|
13 | 15 |
|
14 | 16 | /** |
15 | 17 | * Helpers for Presenter & PresenterComponent. |
| 18 | + * @property-read string $name |
| 19 | + * @property-read string $fileName |
16 | 20 | * @internal |
17 | 21 | */ |
18 | | -class PresenterComponentReflection extends Nette\Reflection\ClassType |
| 22 | +class PresenterComponentReflection extends \ReflectionClass |
19 | 23 | { |
| 24 | + use Nette\SmartObject; |
| 25 | + |
20 | 26 | /** @var array getPersistentParams cache */ |
21 | 27 | private static $ppCache = []; |
22 | 28 |
|
@@ -229,4 +235,76 @@ public static function getParameterType(\ReflectionParameter $param) |
229 | 235 | } |
230 | 236 | } |
231 | 237 |
|
| 238 | + |
| 239 | + /********************* compatiblity with Nette\Reflection ****************d*g**/ |
| 240 | + |
| 241 | + |
| 242 | + public function getMethod($name) |
| 243 | + { |
| 244 | + return new MethodCompatibility($this->getName(), $name); |
| 245 | + } |
| 246 | + |
| 247 | + |
| 248 | + public function getMethods($filter = -1) |
| 249 | + { |
| 250 | + foreach ($res = parent::getMethods($filter) as $key => $val) { |
| 251 | + $res[$key] = new MethodCompatibility($this->getName(), $val->getName()); |
| 252 | + } |
| 253 | + return $res; |
| 254 | + } |
| 255 | + |
| 256 | + |
| 257 | + public function __toString() |
| 258 | + { |
| 259 | + trigger_error(__METHOD__ . ' is deprecated.', E_USER_DEPRECATED); |
| 260 | + return $this->getName(); |
| 261 | + } |
| 262 | + |
| 263 | + |
| 264 | + public function __get($name) |
| 265 | + { |
| 266 | + trigger_error("getReflection()->$name is deprecated.", E_USER_DEPRECATED); |
| 267 | + return (new ClassType($this->getName()))->$name; |
| 268 | + } |
| 269 | + |
| 270 | + |
| 271 | + public function __call($name, $args) |
| 272 | + { |
| 273 | + if (method_exists(ClassType::class, $name)) { |
| 274 | + trigger_error("getReflection()->$name() is deprecated, use Nette\\Reflection\\ClassType::from(\$presenter)->$name()", E_USER_DEPRECATED); |
| 275 | + return call_user_func_array([new ClassType($this->getName()), $name], $args); |
| 276 | + } |
| 277 | + Nette\Utils\ObjectMixin::strictCall(get_class($this), $name); |
| 278 | + } |
| 279 | + |
| 280 | +} |
| 281 | + |
| 282 | + |
| 283 | +/** |
| 284 | + * @internal |
| 285 | + */ |
| 286 | +class MethodCompatibility extends \ReflectionMethod |
| 287 | +{ |
| 288 | + use Nette\SmartObject; |
| 289 | + |
| 290 | + public function __toString() |
| 291 | + { |
| 292 | + trigger_error(__METHOD__ . ' is deprecated.', E_USER_DEPRECATED); |
| 293 | + return parent::getDeclaringClass()->getName() . '::' . $this->getName() . '()'; |
| 294 | + } |
| 295 | + |
| 296 | + |
| 297 | + public function __get($name) |
| 298 | + { |
| 299 | + trigger_error("getMethod('{$this->getName()}')->$name is deprecated.", E_USER_DEPRECATED); |
| 300 | + return (new Method(parent::getDeclaringClass()->getName(), $this->getName()))->$name; |
| 301 | + } |
| 302 | + |
| 303 | + |
| 304 | + public function __call($name, $args) |
| 305 | + { |
| 306 | + trigger_error("getMethod('{$this->getName()}')->$name() is deprecated, use Nette\\Reflection\\Method::from(\$presenter, '{$this->getName()}')->$name()", E_USER_DEPRECATED); |
| 307 | + return call_user_func_array([new Method(parent::getDeclaringClass()->getName(), $this->getName()), $name], $args); |
| 308 | + } |
| 309 | + |
232 | 310 | } |
0 commit comments