protected function collectConflictsBetweenFieldsAndFragment(
        ComparisonContext $context,
        array &$comparedFragments,
        array $fieldMap,
        string $fragmentName,
        bool $areMutuallyExclusive
    ): void {
        // Memoize so a fragment is not compared for conflicts more than once.
        if (isset($comparedFragments[$fragmentName])) {
            return;
        }

        $comparedFragments[$fragmentName] = true;

        $fragment = $this->getContext()->getFragment($fragmentName);

        if (null === $fragment) {
            return;
        }

        $contextB = $this->getReferencedFieldsAndFragmentNames($fragment);

        $fieldMapB = $contextB->getFieldMap();

        // Do not compare a fragment's fieldMap to itself.
        if ($fieldMap == $fieldMapB) {
            return;
        }

        // (D) First collect any conflicts between the provided collection of fields
        // and the collection of fields represented by the given fragment.
        $this->collectConflictsBetween(
            $context,
            $fieldMap,
            $fieldMapB,
            $areMutuallyExclusive
        );

        $fragmentNamesB = $contextB->getFragmentNames();

        // (E) Then collect any conflicts between the provided collection of fields
        // and any fragment names found in the given fragment.
        if (!empty($fragmentNamesB)) {
            $fragmentNamesBCount = \count($fragmentNamesB);

            /** @noinspection ForeachInvariantsInspection */
            for ($i = 0; $i < $fragmentNamesBCount; $i++) {
                $this->collectConflictsBetweenFieldsAndFragment(
                    $context,
                    $comparedFragments,
                    $fieldMap,
                    $fragmentNamesB[$i],
                    $areMutuallyExclusive
                );
            }
        }
    }
protected function collectConflictsBetweenFieldsAndFragment(
        ComparisonContext $context,
        array &$comparedFragments,
        array $fieldMap,
        string $fragmentName,
        bool $areMutuallyExclusive
    ): void {
        // Memoize so a fragment is not compared for conflicts more than once.
        if (isset($comparedFragments[$fragmentName])) {
            return;
        }

        $comparedFragments[$fragmentName] = true;

        $fragment = $this->getContext()->getFragment($fragmentName);

        if (null === $fragment) {
            return;
        }

        $contextB = $this->getReferencedFieldsAndFragmentNames($fragment);

        $fieldMapB = $contextB->getFieldMap();

        // Do not compare a fragment's fieldMap to itself.
        if ($fieldMap == $fieldMapB) {
            return;
        }

        // (D) First collect any conflicts between the provided collection of fields
        // and the collection of fields represented by the given fragment.
        $this->collectConflictsBetween(
            $context,
            $fieldMap,
            $fieldMapB,
            $areMutuallyExclusive
        );

        $fragmentNamesB = $contextB->getFragmentNames();

        // (E) Then collect any conflicts between the provided collection of fields
        // and any fragment names found in the given fragment.
        if (!empty($fragmentNamesB)) {
            $fragmentNamesBCount = \count($fragmentNamesB);

            /** @noinspection ForeachInvariantsInspection */
            for ($i = 0; $i < $fragmentNamesBCount; $i++) {
                $this->collectConflictsBetweenFieldsAndFragment(
                    $context,
                    $comparedFragments,
                    $fieldMap,
                    $fragmentNamesB[$i],
                    $areMutuallyExclusive
                );
            }
        }
    }
protected function collectConflictsBetweenFieldsAndFragment ( ComparisonContext $ context , array & $ comparedFragments , array $ fieldMap , string $ fragmentName , bool $ areMutuallyExclusive ) : void { // Memoize so a fragment is not compared for conflicts more than once. if ( isset ( $ comparedFragments [ $ fragmentName ] ) ) { return ; } $ comparedFragments [ $ fragmentName ] = true ; $ fragment = $ this -> getContext ( ) -> getFragment ( $ fragmentName ) ; if ( null === $ fragment ) { return ; } $ contextB = $ this -> getReferencedFieldsAndFragmentNames ( $ fragment ) ; $ fieldMapB = $ contextB -> getFieldMap ( ) ; // Do not compare a fragment's fieldMap to itself. if ( $ fieldMap == $ fieldMapB ) { return ; } // (D) First collect any conflicts between the provided collection of fields // and the collection of fields represented by the given fragment. $ this -> collectConflictsBetween ( $ context , $ fieldMap , $ fieldMapB , $ areMutuallyExclusive ) ; $ fragmentNamesB = $ contextB -> getFragmentNames ( ) ; // (E) Then collect any conflicts between the provided collection of fields // and any fragment names found in the given fragment. if ( ! empty ( $ fragmentNamesB ) ) { $ fragmentNamesBCount = \ count ( $ fragmentNamesB ) ; /** @noinspection ForeachInvariantsInspection */ for ( $ i = 0 ; $ i < $ fragmentNamesBCount ; $ i ++ ) { $ this -> collectConflictsBetweenFieldsAndFragment ( $ context , $ comparedFragments , $ fieldMap , $ fragmentNamesB [ $ i ] , $ areMutuallyExclusive ) ; } } }
Collect all conflicts found between a set of fields and a fragment reference
including via spreading in any nested fragments.

@param ComparisonContext $context
@param array             $comparedFragments
@param array             $fieldMap
@param string            $fragmentName
@param bool              $areMutuallyExclusive
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException
Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments .