cycleErrorMessage() static public method

static public cycleErrorMessage ( $fragmentName, $spreadNames )
Exemplo n.º 1
0
 private function detectCycleRecursive($fragmentName, array $spreadsInFragment, \SplObjectStorage $knownToLeadToCycle, $initialName, array &$spreadPath, &$errors)
 {
     $spreadNodes = $spreadsInFragment[$fragmentName];
     for ($i = 0; $i < count($spreadNodes); ++$i) {
         $spreadNode = $spreadNodes[$i];
         if (isset($knownToLeadToCycle[$spreadNode])) {
             continue;
         }
         if ($spreadNode->name->value === $initialName) {
             $cyclePath = array_merge($spreadPath, [$spreadNode]);
             foreach ($cyclePath as $spread) {
                 $knownToLeadToCycle[$spread] = true;
             }
             $errors[] = new Error(Messages::cycleErrorMessage($initialName, array_map(function ($s) {
                 return $s->name->value;
             }, $spreadPath)), $cyclePath);
             continue;
         }
         foreach ($spreadPath as $spread) {
             if ($spread === $spreadNode) {
                 continue 2;
             }
         }
         $spreadPath[] = $spreadNode;
         $this->detectCycleRecursive($spreadNode->name->value, $spreadsInFragment, $knownToLeadToCycle, $initialName, $spreadPath, $errors);
         array_pop($spreadPath);
     }
 }
Exemplo n.º 2
0
 private function cycleError($fargment, $spreadNames, $line, $column)
 {
     return new FormattedError(Messages::cycleErrorMessage($fargment, $spreadNames), [new SourceLocation($line, $column)]);
 }