ClassWithClosure.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace EasySwoole\DoctrineAnnotation\Tests\Fixtures;
  3. use EasySwoole\DoctrineAnnotation\Tests\Fixtures\AnnotationTargetAll;
  4. use EasySwoole\DoctrineAnnotation\Tests\Fixtures\AnnotationTargetAnnotation;
  5. /**
  6. * @AnnotationTargetAll("Foo")
  7. */
  8. final class ClassWithClosure
  9. {
  10. /**
  11. * @AnnotationTargetAll(@AnnotationTargetAnnotation)
  12. * @var string
  13. */
  14. public $value;
  15. /**
  16. * @return \Closure
  17. *
  18. * @AnnotationTargetAll(@AnnotationTargetAnnotation)
  19. */
  20. public function methodName(\Closure $callback)
  21. {
  22. return static function () use ($callback) {
  23. return $callback;
  24. };
  25. }
  26. /**
  27. * @param integer $year
  28. * @param integer $month
  29. * @param integer $day
  30. *
  31. * @return \Doctrine\Common\Collections\ArrayCollection
  32. */
  33. public function getEventsForDate($year, $month, $day)
  34. {
  35. $extractEvents = null; // check if date of item is inside day given
  36. $extractEvents = $this->events->filter(static function ($item) use ($year, $month, $day) {
  37. $leftDate = new \DateTime($year . '-' . $month . '-' . $day . ' 00:00');
  38. $rigthDate = new \DateTime($year . '-' . $month . '-' . $day . ' +1 day 00:00');
  39. return ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate );
  40. });
  41. return $extractEvents;
  42. }
  43. }