graphql-php icon indicating copy to clipboard operation
graphql-php copied to clipboard

Remove pass-by-reference for `$result` in `ReferenceExecutor`

Open spawnia opened this issue 4 months ago • 4 comments

Follows up on https://github.com/webonyx/graphql-php/pull/1776#discussion_r2411090574

spawnia avatar Oct 08 '25 06:10 spawnia

Tests pass, I don't see how this change could be problematic.

spawnia avatar Oct 08 '25 06:10 spawnia

Since the ReferenceExecutor is not final, one could be extending it.

For example:

final class TestReferenceExecutor extends ReferenceExecutor {
    protected function completeAbstractValue(
        AbstractType $returnType,
        \ArrayObject $fieldNodes,
        ResolveInfo $info,
        array $path,
        array $unaliasedPath,
        &$result,
        $contextValue)
    {
        return parent::completeAbstractValue(
            $returnType,
            $fieldNodes,
            $info,
            $path,
            $unaliasedPath,
            $result,
            $contextValue,
        );
    }
}

This would fail now:

Declaration should be compatible with ReferenceExecutor->completeAbstractValue(returnType: \GraphQL\Type\Definition\AbstractType|\GraphQL\Type\Definition\Type&\GraphQL\Type\Definition\AbstractType, fieldNodes: \ArrayObject, info: \GraphQL\Type\Definition\ResolveInfo, path: int[]|string[], unaliasedPath: int[]|string[], result: mixed, contextValue: mixed) 

ruudk avatar Oct 08 '25 07:10 ruudk

We do mark public elements of our API with @api, so I would categorize this as internal and non-breaking.

spawnia avatar Oct 08 '25 08:10 spawnia

In that case, let's ship this! Way better indeed.

ruudk avatar Oct 08 '25 08:10 ruudk

Released with https://github.com/webonyx/graphql-php/releases/tag/v15.29.3.

spawnia avatar Dec 29 '25 13:12 spawnia