NoneAnnotation.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace EasySwoole\HttpAnnotation\Tests\TestController;
  3. use EasySwoole\Component\Di;
  4. use EasySwoole\HttpAnnotation\AnnotationController;
  5. use EasySwoole\HttpAnnotation\AnnotationTag\Api;
  6. class NoneAnnotation extends AnnotationController
  7. {
  8. public $gc = 1;
  9. function index()
  10. {
  11. $this->gc = time();
  12. $this->response()->write('index');
  13. }
  14. protected function onRequest(?string $action): ?bool
  15. {
  16. if ($action == 'testOnRequest') {
  17. $this->response()->write('testOnRequest');
  18. return false;
  19. }
  20. return true;
  21. }
  22. function afterAction(?string $actionName): void
  23. {
  24. Di::getInstance()->set("afterAction", 'afterAction');
  25. }
  26. protected function noneAction()
  27. {
  28. $this->response()->write('noneAction');
  29. }
  30. function actionNotFound(?string $action)
  31. {
  32. $this->response()->write(404);
  33. }
  34. /**
  35. * @Api(path="/testR",name="exec")
  36. */
  37. function exception()
  38. {
  39. $this->gc = time();
  40. new AAAAAAAAAAA();
  41. }
  42. /**
  43. * @Api(name="deprecated",path="/testDeprecated",deprecated=true)
  44. */
  45. public function testDeprecated()
  46. {
  47. }
  48. protected function onException(\Throwable $throwable): void
  49. {
  50. $this->response()->write('exception');
  51. }
  52. }