public static function getInstance(EventMessageInterface $event, \ReflectionMethod $handlerMethod)
 {
     $reader = new AnnotationReader();
     $handlerAnnotation = $reader->getMethodAnnotation($handlerMethod, SagaEventHandler::class);
     $associationProperty = PropertyAccessStrategy::getProperty($event->getPayload(), $handlerAnnotation->associationProperty);
     if (null === $associationProperty) {
         throw new \RuntimeException(sprintf("SagaEventHandler %s::%s defines a property %s that is not " . "defined on the Event it declares to handle (%s)", $handlerMethod->class, $handlerMethod->name, $handlerAnnotation->associationProperty, $event->getPayloadType()));
     }
     $associationKey = empty($handlerAnnotation->keyName) ? $handlerAnnotation->associationProperty : $handlerAnnotation->keyName;
     $startAnnotation = $reader->getMethodAnnotation($handlerMethod, StartSaga::class);
     if (null === $startAnnotation) {
         $sagaCreationPolicy = SagaCreationPolicy::NONE;
     } else {
         if ($startAnnotation->forceNew) {
             $sagaCreationPolicy = SagaCreationPolicy::ALWAYS;
         } else {
             $sagaCreationPolicy = SagaCreationPolicy::IF_NONE_FOUND;
         }
     }
     return new SagaMethodMessageHandler($sagaCreationPolicy, $associationKey, $associationProperty, $handlerMethod, $reader);
 }
 public function testPropertyIsNullIfNotResolved()
 {
     $property = PropertyAccessStrategy::getProperty($this->target, 'foobar');
     $this->assertNull($property);
 }