ClassWithClosure.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Doctrine\Tests\Common\Annotations\Fixtures;
  3. use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll;
  4. use Doctrine\Tests\Common\Annotations\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. * @AnnotationTargetAll(@AnnotationTargetAnnotation)
  17. *
  18. * @param \Closure $callback
  19. * @return \Closure
  20. */
  21. public function methodName(\Closure $callback)
  22. {
  23. $self = $this;
  24. return function() use ($self, $callback) {
  25. return $callback;
  26. };
  27. }
  28. /**
  29. * @param integer $year
  30. * @param integer $month
  31. * @param integer $day
  32. * @return \Doctrine\Common\Collections\ArrayCollection
  33. */
  34. public function getEventsForDate($year, $month, $day){
  35. $extractEvents = null; // check if date of item is inside day given
  36. $extractEvents = $this->events->filter(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. );
  42. return $extractEvents;
  43. }
  44. }