Source for file Annotations.php

Documentation is available at Annotations.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  7. 7:  * @license    http://nettephp.com/license  Nette license
  8. 8:  * @link       http://nettephp.com
  9. 9:  * @category   Nette
  10. 10:  * @package    Nette
  11. 11:  */
  12. 12:  
  13. 13:  
  14. 14:  
  15. 15: /**
  16. 16:  * Annotations support for PHP.
  17. 17:  *
  18. 18:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  19. 19:  * @package    Nette
  20. 20:  * @deprecated
  21. 21:  */
  22. 22: final class Annotations
  23. 23: {
  24. 24:     /** @var bool */
  25. 25:     public static $useReflection;
  26. 26:  
  27. 27:  
  28. 28:  
  29. 29:     /**
  30. 30:      * Has class/method/property specified annotation?
  31. 31:      * @param  ReflectionClass|\ReflectionMethod|\ReflectionProperty
  32. 32:      * @param  string    annotation name
  33. 33:      * @return bool 
  34. 34:      */
  35. 35:     public static function has(Reflector $r$name)
  36. 36:     {
  37. 37:         trigger_error(__METHOD__ . '() is deprecated; use getReflection()->hasAnnotation() instead.'E_USER_WARNING);
  38. 38:         $cache AnnotationsParser::getAll($r);
  39. 39:         return !empty($cache[$name]);
  40. 40:     }
  41. 41:  
  42. 42:  
  43. 43:  
  44. 44:     /**
  45. 45:      * Returns an annotation value.
  46. 46:      * @param  ReflectionClass|\ReflectionMethod|\ReflectionProperty
  47. 47:      * @param  string    annotation name
  48. 48:      * @return array 
  49. 49:      */
  50. 50:     public static function get(Reflector $r$name)
  51. 51:     {
  52. 52:         trigger_error(__METHOD__ . '() is deprecated; use getReflection()->getAnnotation() instead.'E_USER_WARNING);
  53. 53:         $cache AnnotationsParser::getAll($r);
  54. 54:         return isset($cache[$name]end($cache[$name]NULL;
  55. 55:     }
  56. 56:  
  57. 57:  
  58. 58:  
  59. 59:     /**
  60. 60:      * Returns all annotations.
  61. 61:      * @param  ReflectionClass|\ReflectionMethod|\ReflectionProperty
  62. 62:      * @param  string    annotation name
  63. 63:      * @return array 
  64. 64:      */
  65. 65:     public static function getAll(Reflector $r$name NULL)
  66. 66:     {
  67. 67:         trigger_error(__METHOD__ . '() is deprecated; use getReflection()->getAnnotations() instead.'E_USER_WARNING);
  68. 68:         $cache AnnotationsParser::getAll($r);
  69. 69:  
  70. 70:         if ($name === NULL{
  71. 71:             return $cache;
  72. 72:  
  73. 73:         elseif (isset($cache[$name])) {
  74. 74:             return $cache[$name];
  75. 75:  
  76. 76:         else {
  77. 77:             return array();
  78. 78:         }
  79. 79:     }
  80. 80:  
  81. 81: }