original_string: private function reconstructPath(ViolationPath $violationPath, FormInterface $origin)
      {
          $propertyPathBuilder = new PropertyPathBuilder($violationPath);
          $it = $violationPath->getIterator();
          $scope = $origin;
  
          // Remember the current index in the builder
          $i = 0;
  
          // Expand elements that map to a form (like "children[address]")
          for ($it->rewind(); $it->valid() && $it->mapsForm(); $it->next()) {
              if (!$scope->has($it->current())) {
                  // Scope relates to a form that does not exist
                  // Bail out
                  break;
              }
  
              // Process child form
              $scope = $scope->get($it->current());
  
              if ($scope->getConfig()->getInheritData()) {
                  // Form inherits its parent data
                  // Cut the piece out of the property path and proceed
                  $propertyPathBuilder->remove($i);
              } elseif (!$scope->getConfig()->getMapped()) {
                  // Form is not mapped
                  // Set the form as new origin and strip everything
                  // we have so far in the path
                  $origin = $scope;
                  $propertyPathBuilder->remove(0, $i + 1);
                  $i = 0;
              } else {
                  /* @var \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath */
                  $propertyPath = $scope->getPropertyPath();
  
                  if (null === $propertyPath) {
                      // Property path of a mapped form is null
                      // Should not happen, bail out
                      break;
                  }
  
                  $propertyPathBuilder->replace($i, 1, $propertyPath);
                  $i += $propertyPath->getLength();
              }
          }
  
          $finalPath = $propertyPathBuilder->getPropertyPath();
  
          return null !== $finalPath ? new RelativePath($origin, $finalPath) : null;
      }
code: private function reconstructPath(ViolationPath $violationPath, FormInterface $origin)
      {
          $propertyPathBuilder = new PropertyPathBuilder($violationPath);
          $it = $violationPath->getIterator();
          $scope = $origin;
  
          // Remember the current index in the builder
          $i = 0;
  
          // Expand elements that map to a form (like "children[address]")
          for ($it->rewind(); $it->valid() && $it->mapsForm(); $it->next()) {
              if (!$scope->has($it->current())) {
                  // Scope relates to a form that does not exist
                  // Bail out
                  break;
              }
  
              // Process child form
              $scope = $scope->get($it->current());
  
              if ($scope->getConfig()->getInheritData()) {
                  // Form inherits its parent data
                  // Cut the piece out of the property path and proceed
                  $propertyPathBuilder->remove($i);
              } elseif (!$scope->getConfig()->getMapped()) {
                  // Form is not mapped
                  // Set the form as new origin and strip everything
                  // we have so far in the path
                  $origin = $scope;
                  $propertyPathBuilder->remove(0, $i + 1);
                  $i = 0;
              } else {
                  /* @var \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath */
                  $propertyPath = $scope->getPropertyPath();
  
                  if (null === $propertyPath) {
                      // Property path of a mapped form is null
                      // Should not happen, bail out
                      break;
                  }
  
                  $propertyPathBuilder->replace($i, 1, $propertyPath);
                  $i += $propertyPath->getLength();
              }
          }
  
          $finalPath = $propertyPathBuilder->getPropertyPath();
  
          return null !== $finalPath ? new RelativePath($origin, $finalPath) : null;
      }
code_tokens: private function reconstructPath ( ViolationPath $ violationPath , FormInterface $ origin ) { $ propertyPathBuilder = new PropertyPathBuilder ( $ violationPath ) ; $ it = $ violationPath -> getIterator ( ) ; $ scope = $ origin ; // Remember the current index in the builder $ i = 0 ; // Expand elements that map to a form (like "children[address]") for ( $ it -> rewind ( ) ; $ it -> valid ( ) && $ it -> mapsForm ( ) ; $ it -> next ( ) ) { if ( ! $ scope -> has ( $ it -> current ( ) ) ) { // Scope relates to a form that does not exist // Bail out break ; } // Process child form $ scope = $ scope -> get ( $ it -> current ( ) ) ; if ( $ scope -> getConfig ( ) -> getInheritData ( ) ) { // Form inherits its parent data // Cut the piece out of the property path and proceed $ propertyPathBuilder -> remove ( $ i ) ; } elseif ( ! $ scope -> getConfig ( ) -> getMapped ( ) ) { // Form is not mapped // Set the form as new origin and strip everything // we have so far in the path $ origin = $ scope ; $ propertyPathBuilder -> remove ( 0 , $ i + 1 ) ; $ i = 0 ; } else { /* @var \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath */ $ propertyPath = $ scope -> getPropertyPath ( ) ; if ( null === $ propertyPath ) { // Property path of a mapped form is null // Should not happen, bail out break ; } $ propertyPathBuilder -> replace ( $ i , 1 , $ propertyPath ) ; $ i += $ propertyPath -> getLength ( ) ; } } $ finalPath = $ propertyPathBuilder -> getPropertyPath ( ) ; return null !== $ finalPath ? new RelativePath ( $ origin , $ finalPath ) : null ; }
docstring: Reconstructs a property path from a violation path and a form tree.
  
  @param ViolationPath $violationPath The violation path
  @param FormInterface $origin        The root form of the tree
  
  @return RelativePath The reconstructed path
docstring_tokens: Reconstructs a property path from a violation path and a form tree .