暂无描述

Analyzer.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* ===========================================================================
  3. * Copyright (c) 2018-2021 Zindex Software
  4. *
  5. * Licensed under the MIT License
  6. * =========================================================================== */
  7. namespace Opis\Closure;
  8. use Closure;
  9. use SuperClosure\Analyzer\ClosureAnalyzer;
  10. /**
  11. * @deprecated We'll remove this class
  12. */
  13. class Analyzer extends ClosureAnalyzer
  14. {
  15. /**
  16. * Analyzer a given closure.
  17. *
  18. * @param Closure $closure
  19. *
  20. * @return array
  21. */
  22. public function analyze(Closure $closure)
  23. {
  24. $reflection = new ReflectionClosure($closure);
  25. $scope = $reflection->getClosureScopeClass();
  26. $data = [
  27. 'reflection' => $reflection,
  28. 'code' => $reflection->getCode(),
  29. 'hasThis' => $reflection->isBindingRequired(),
  30. 'context' => $reflection->getUseVariables(),
  31. 'hasRefs' => false,
  32. 'binding' => $reflection->getClosureThis(),
  33. 'scope' => $scope ? $scope->getName() : null,
  34. 'isStatic' => $reflection->isStatic(),
  35. ];
  36. return $data;
  37. }
  38. /**
  39. * @param array $data
  40. * @return mixed
  41. */
  42. protected function determineCode(array &$data)
  43. {
  44. return null;
  45. }
  46. /**
  47. * @param array $data
  48. * @return mixed
  49. */
  50. protected function determineContext(array &$data)
  51. {
  52. return null;
  53. }
  54. }