annotations.php 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?
  2. chdir("..");
  3. include "common.php";
  4. class DefaultController {
  5. const TYPE_PLAIN = 1;
  6. const TYPE_HTML = 2;
  7. public $type;
  8. public $length;
  9. }
  10. /**
  11. * @ann1('me'=>'you');
  12. */
  13. class something{
  14. /**
  15. * @var string
  16. * @Controller(type => DefaultController::TYPE_PLAIN, length => 100)
  17. */
  18. public $propertyA;
  19. /**
  20. * @var string
  21. * @Controller(type => DefaultController::TYPE_HTML, length => 100)
  22. */
  23. public function methodB () {
  24. return "aap";
  25. }
  26. }
  27. /* Annotation example */
  28. $rel = new IPReflectionClass("something");
  29. $properties = $rel->getProperties();
  30. $methods = $rel->getMethods();
  31. var_dump($rel->getAnnotation("ann1", "stdClass"));
  32. $property = $properties["propertyA"];
  33. $ann = $property->getAnnotation("Controller", "DefaultController");
  34. var_dump($ann);
  35. $method = $methods["methodB"];
  36. $ann = $method->getAnnotation("Controller", "DefaultController");
  37. var_dump($ann);
  38. ?>