Skip to content

Commit f03dcfd

Browse files
committed
PresenterComponentReflection: implemented hasAnnotation() and getAnnotation()
BC break: unlike nette/reflection this parser ignores text in `@annotation text`
1 parent 70f974a commit f03dcfd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/Application/UI/PresenterComponentReflection.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,29 @@ public static function getParameterType(\ReflectionParameter $param)
239239
/********************* compatiblity with Nette\Reflection ****************d*g**/
240240

241241

242+
/**
243+
* Has class specified annotation?
244+
* @param string
245+
* @return bool
246+
*/
247+
public function hasAnnotation($name)
248+
{
249+
return (bool) self::parseAnnotation($this, $name);
250+
}
251+
252+
253+
/**
254+
* Returns an annotation value.
255+
* @param string
256+
* @return string|NULL
257+
*/
258+
public function getAnnotation($name)
259+
{
260+
$res = self::parseAnnotation($this, $name);
261+
return $res ? end($res) : NULL;
262+
}
263+
264+
242265
public function getMethod($name)
243266
{
244267
return new MethodCompatibility($this->getName(), $name);
@@ -287,6 +310,29 @@ class MethodCompatibility extends \ReflectionMethod
287310
{
288311
use Nette\SmartObject;
289312

313+
/**
314+
* Has method specified annotation?
315+
* @param string
316+
* @return bool
317+
*/
318+
public function hasAnnotation($name)
319+
{
320+
return (bool) PresenterComponentReflection::parseAnnotation($this, $name);
321+
}
322+
323+
324+
/**
325+
* Returns an annotation value.
326+
* @param string
327+
* @return string|NULL
328+
*/
329+
public function getAnnotation($name)
330+
{
331+
$res = PresenterComponentReflection::parseAnnotation($this, $name);
332+
return $res ? end($res) : NULL;
333+
}
334+
335+
290336
public function __toString()
291337
{
292338
trigger_error(__METHOD__ . ' is deprecated.', E_USER_DEPRECATED);

0 commit comments

Comments
 (0)