From a2b70f2fcddcf0ada74fcdb1b4c721ae6b36b508 Mon Sep 17 00:00:00 2001 From: Klaus Purer <klaus.purer@protonmail.ch> Date: Fri, 4 Apr 2025 16:13:10 +0200 Subject: [PATCH 1/3] docs(phpdoc): Add return type doc comments part 1 --- phpcs.xml.dist | 102 +----------------- src/Entity/ServerInterface.php | 9 ++ src/Form/PersistedQueriesForm.php | 1 + src/Plugin/DataProducerPluginInterface.php | 6 ++ .../GraphQL/DataProducer/String/Uppercase.php | 6 ++ .../DataProducer/TypedData/PropertyPath.php | 13 +++ .../GraphQL/DataProducer/XML/XMLAttribute.php | 3 + .../GraphQL/DataProducer/XML/XMLContent.php | 3 + .../GraphQL/DataProducer/XML/XMLParse.php | 3 + .../GraphQL/DataProducer/XML/XMLXpath.php | 1 + src/Plugin/SchemaExtensionPluginManager.php | 1 + 11 files changed, 47 insertions(+), 101 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 22ac8731..aebc7c4c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -39,111 +39,11 @@ <exclude-pattern>src/SubRequestResponse.php</exclude-pattern> <exclude-pattern>tests/src/Traits/QueryResultAssertionTrait.php</exclude-pattern> <exclude-pattern>tests/src/Traits/MockingTrait.php</exclude-pattern> - </rule> - - <rule ref="Drupal.Commenting.FunctionComment.MissingParamComment"> - <exclude-pattern>src/PermissionProvider.php</exclude-pattern> - <exclude-pattern>src/Config/LanguageConfigOverride.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Path.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/ResolverInterface.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/SourceContext.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Condition.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Callback.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Composite.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Argument.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Value.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Context.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Map.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Resolver/Tap.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverRegistryInterface.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/Executor.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/FieldContext.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/ExecutorFactory.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/ResolveContext.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverBuilder.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Utility/DocumentSerializer.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Utility/DeferredUtility.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverRegistry.php</exclude-pattern> - <exclude-pattern>src/Event/OperationEvent.php</exclude-pattern> - <exclude-pattern>src/Form/PersistedQueriesForm.php</exclude-pattern> - <exclude-pattern>src/EventSubscriber/OperationSubscriber.php</exclude-pattern> - <exclude-pattern>src/EventSubscriber/SubrequestSubscriber.php</exclude-pattern> - <exclude-pattern>src/Entity/ServerInterface.php</exclude-pattern> - <exclude-pattern>src/Entity/Server.php</exclude-pattern> - <exclude-pattern>src/Plugin/LanguageNegotiation/OperationLanguageNegotiation.php</exclude-pattern> - <exclude-pattern>src/Plugin/PersistedQueryPluginManager.php</exclude-pattern> - <exclude-pattern>src/Plugin/DataProducerPluginInterface.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/String/Uppercase.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/DataProducerProxy.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Images/ImageResourceUrl.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Field/EntityReference.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLinks.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeLink.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkAttribute.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkUrl.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkExpanded.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkDescription.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Routing/Url/UrlPath.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityPublished.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityRendered.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityType.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLanguage.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityOwner.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityDescription.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityTranslations.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageUrl.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityId.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityAccess.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityBundle.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php</exclude-pattern> - <exclude-pattern>src/Plugin/DataProducerPluginManager.php</exclude-pattern> - <exclude-pattern>src/Controller/RequestController.php</exclude-pattern> - <exclude-pattern>examples/graphql_example/src/Wrappers/QueryConnection.php</exclude-pattern> - <exclude-pattern>examples/graphql_example/src/Plugin/GraphQL/DataProducer/QueryArticles.php</exclude-pattern> - <exclude-pattern>examples/graphql_example/src/Plugin/GraphQL/Schema/ExampleSchema.php</exclude-pattern> - <exclude-pattern>examples/graphql_example/src/Plugin/GraphQL/SchemaExtension/ExampleSchemaExtension.php</exclude-pattern> - <exclude-pattern>tests/src/Traits/MockingTrait.php</exclude-pattern> - <exclude-pattern>tests/src/Traits/DataProducerExecutionTrait.php</exclude-pattern> - <exclude-pattern>tests/src/Kernel/ResolverBuilderTest.php</exclude-pattern> + <exclude-pattern>src/Plugin/DataProducerPluginInterface.php</exclude-pattern> </rule> <rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment"> - <exclude-pattern>src/GraphQL/Resolver/ResolverInterface.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverRegistryInterface.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/Executor.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/FieldContext.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/ExecutorFactory.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Execution/ResolveContext.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverBuilder.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Utility/DocumentSerializer.php</exclude-pattern> - <exclude-pattern>src/GraphQL/Utility/DeferredUtility.php</exclude-pattern> - <exclude-pattern>src/GraphQL/ResolverRegistry.php</exclude-pattern> - <exclude-pattern>src/Event/OperationEvent.php</exclude-pattern> - <exclude-pattern>src/Form/PersistedQueriesForm.php</exclude-pattern> - <exclude-pattern>src/Routing/QueryRouteEnhancer.php</exclude-pattern> - <exclude-pattern>src/Entity/ServerInterface.php</exclude-pattern> - <exclude-pattern>src/Plugin/SchemaExtensionPluginManager.php</exclude-pattern> - <exclude-pattern>src/Plugin/DataProducerPluginInterface.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/String/Uppercase.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/XML/XMLParse.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/XML/XMLContent.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/XML/XMLAttribute.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/DataProducerProxy.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Images/ImageResourceUrl.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Field/EntityReference.php</exclude-pattern> diff --git a/src/Entity/ServerInterface.php b/src/Entity/ServerInterface.php index 6351911d..1538d0d7 100644 --- a/src/Entity/ServerInterface.php +++ b/src/Entity/ServerInterface.php @@ -17,6 +17,12 @@ interface ServerInterface extends ConfigEntityInterface { /** * Execute an operation on this server. + * + * @param \GraphQL\Server\OperationParams $operation + * The operation parameters. + * + * @return \Drupal\graphql\GraphQL\Execution\ExecutionResult + * The execution result. */ public function executeOperation(OperationParams $operation): ExecutionResult; @@ -24,8 +30,10 @@ interface ServerInterface extends ConfigEntityInterface { * Execute multiple operations as batch on this server. * * @param array<\GraphQL\Server\OperationParams> $operations + * A list of operations to execute in the batch. * * @return array<\Drupal\graphql\GraphQL\Execution\ExecutionResult> + * The execution results for each operation. */ public function executeBatch(array $operations): array; @@ -59,6 +67,7 @@ interface ServerInterface extends ConfigEntityInterface { * Returns the current persisted queries set, sorted by the plugins weight. * * @return array<\Drupal\graphql\Plugin\PersistedQueryPluginInterface> + * The persisted query plugin instances, sorted by weight. */ public function getPersistedQueryInstances(): array; diff --git a/src/Form/PersistedQueriesForm.php b/src/Form/PersistedQueriesForm.php index 8aa82737..890f22dc 100644 --- a/src/Form/PersistedQueriesForm.php +++ b/src/Form/PersistedQueriesForm.php @@ -197,6 +197,7 @@ class PersistedQueriesForm extends EntityForm { * Returns an array with all the available persisted query plugins. * * @return array<\Drupal\graphql\Plugin\PersistedQueryPluginInterface> + * All persisted query plugins available through plugins. */ protected function getAllPersistedQueryPlugins(): array { $plugins = []; diff --git a/src/Plugin/DataProducerPluginInterface.php b/src/Plugin/DataProducerPluginInterface.php index 45cc7b1e..e3b4119e 100644 --- a/src/Plugin/DataProducerPluginInterface.php +++ b/src/Plugin/DataProducerPluginInterface.php @@ -19,6 +19,12 @@ interface DataProducerPluginInterface extends ContextAwarePluginInterface, Cache /** * Resolves the queried field with the given context. + * + * @param \Drupal\graphql\GraphQL\Execution\FieldContext $field + * The field context that is passed down from the parent. + * + * @return mixed + * The resolved field value based on the plugin's implementation. */ public function resolveField(FieldContext $field): mixed; diff --git a/src/Plugin/GraphQL/DataProducer/String/Uppercase.php b/src/Plugin/GraphQL/DataProducer/String/Uppercase.php index 0a0ddbd9..69083540 100644 --- a/src/Plugin/GraphQL/DataProducer/String/Uppercase.php +++ b/src/Plugin/GraphQL/DataProducer/String/Uppercase.php @@ -27,6 +27,12 @@ class Uppercase extends DataProducerPluginBase { /** * Value resolver. + * + * @param string $string + * The input string to convert to uppercase. + * + * @return string + * The input string converted to uppercase. */ public function resolve(string $string): string { return strtoupper($string); diff --git a/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php b/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php index d44f49d1..9be57842 100644 --- a/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php +++ b/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php @@ -43,6 +43,19 @@ class PropertyPath extends DataProducerPluginBase { /** * Resolve the property path. + * + * @param string $path + * The property path to resolve. + * @param mixed $value + * The root value to resolve the path from. + * @param string|null $type + * The type of the value to start from, it will be used to get the + * corresponding type data definition and wrap the vlaue in it. + * @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata + * The refinable metadata object. + * + * @return mixed + * The resolved value at the given property path, or NULL if not found. */ public function resolve(string $path, mixed $value, ?string $type, RefinableCacheableDependencyInterface $metadata): mixed { if (!($value instanceof TypedDataInterface) && !empty($type)) { diff --git a/src/Plugin/GraphQL/DataProducer/XML/XMLAttribute.php b/src/Plugin/GraphQL/DataProducer/XML/XMLAttribute.php index c6c6b558..2ef14faf 100644 --- a/src/Plugin/GraphQL/DataProducer/XML/XMLAttribute.php +++ b/src/Plugin/GraphQL/DataProducer/XML/XMLAttribute.php @@ -35,6 +35,9 @@ class XMLAttribute extends DataProducerPluginBase { * The source (root) DOM element. * @param string $name * The name of the attribute. + * + * @return string + * The attribute value. */ public function resolve(\DOMElement $dom, string $name): string { return $dom->getAttribute($name); diff --git a/src/Plugin/GraphQL/DataProducer/XML/XMLContent.php b/src/Plugin/GraphQL/DataProducer/XML/XMLContent.php index e2cc0f4c..d01d3eaf 100644 --- a/src/Plugin/GraphQL/DataProducer/XML/XMLContent.php +++ b/src/Plugin/GraphQL/DataProducer/XML/XMLContent.php @@ -30,6 +30,9 @@ class XMLContent extends DataProducerPluginBase { * * @param \DOMElement $dom * The source (root) DOM element. + * + * @return string + * The XML content as string. */ public function resolve(\DOMElement $dom): string { return implode('', array_map(function ($child) { diff --git a/src/Plugin/GraphQL/DataProducer/XML/XMLParse.php b/src/Plugin/GraphQL/DataProducer/XML/XMLParse.php index cf77f7c3..28109818 100644 --- a/src/Plugin/GraphQL/DataProducer/XML/XMLParse.php +++ b/src/Plugin/GraphQL/DataProducer/XML/XMLParse.php @@ -30,6 +30,9 @@ class XMLParse extends DataProducerPluginBase { * * @param string $input * The source input. + * + * @return \DOMElement + * The parsed XML document element. */ public function resolve(string $input): \DOMElement { $document = new \DOMDocument(); diff --git a/src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php b/src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php index 99c6f091..dbd7a34c 100644 --- a/src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php +++ b/src/Plugin/GraphQL/DataProducer/XML/XMLXpath.php @@ -38,6 +38,7 @@ class XMLXpath extends DataProducerPluginBase { * The xpath query. * * @return array<\DOMElement> + * Array of DOM elements matching the xpath query. */ public function resolve(\DOMElement $dom, string $query): array { $xpath = new \DOMXPath($dom->ownerDocument); diff --git a/src/Plugin/SchemaExtensionPluginManager.php b/src/Plugin/SchemaExtensionPluginManager.php index 8a1ffb24..4ffbb960 100644 --- a/src/Plugin/SchemaExtensionPluginManager.php +++ b/src/Plugin/SchemaExtensionPluginManager.php @@ -72,6 +72,7 @@ class SchemaExtensionPluginManager extends DefaultPluginManager { * The id of the schema plugin to retrieve the extensions for. * * @return array<\Drupal\graphql\Plugin\SchemaExtensionPluginInterface> + * An array of schema extension plugin instances sorted by priority. */ public function getExtensions(string $id): array { if (!isset($this->extensions[$id])) { -- GitLab From ac4851386475ec27822280c87133bfc3a1aac02e Mon Sep 17 00:00:00 2001 From: Klaus Purer <klaus.purer@protonmail.ch> Date: Fri, 4 Apr 2025 16:18:17 +0200 Subject: [PATCH 2/3] typo --- src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php b/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php index 9be57842..e6a2de09 100644 --- a/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php +++ b/src/Plugin/GraphQL/DataProducer/TypedData/PropertyPath.php @@ -50,7 +50,7 @@ class PropertyPath extends DataProducerPluginBase { * The root value to resolve the path from. * @param string|null $type * The type of the value to start from, it will be used to get the - * corresponding type data definition and wrap the vlaue in it. + * corresponding type data definition and wrap the value in it. * @param \Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata * The refinable metadata object. * -- GitLab From 25b3b7b18b3593db2a221297f081cb1510fc8896 Mon Sep 17 00:00:00 2001 From: Klaus Purer <klaus.purer@protonmail.ch> Date: Fri, 4 Apr 2025 17:37:58 +0200 Subject: [PATCH 3/3] more phpcs fixes --- phpcs.xml.dist | 11 +---------- src/Plugin/GraphQL/DataProducer/DataProducerProxy.php | 8 ++++++++ .../GraphQL/DataProducer/Entity/EntityChanged.php | 5 +++++ .../GraphQL/DataProducer/Entity/EntityCreated.php | 4 ++++ src/Plugin/GraphQL/DataProducer/Entity/EntityId.php | 3 +++ .../GraphQL/DataProducer/Entity/EntityLabel.php | 4 ++++ src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php | 6 +++++- src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php | 3 +++ .../DataProducer/Menu/MenuLink/MenuLinkLabel.php | 3 +++ .../DataProducer/Menu/MenuTree/MenuTreeSubtree.php | 1 + 10 files changed, 37 insertions(+), 11 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index aebc7c4c..8e32af49 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -35,6 +35,7 @@ <exclude-pattern>src/GraphQL/Execution/FieldContext.php</exclude-pattern> <exclude-pattern>src/GraphQL/Execution/ResolveContext.php</exclude-pattern> <exclude-pattern>src/GraphQL/Utility/FileUpload.php</exclude-pattern> + <exclude-pattern>src/Plugin/GraphQL/DataProducer/DataProducerProxy.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Utility/Seek.php</exclude-pattern> <exclude-pattern>src/SubRequestResponse.php</exclude-pattern> <exclude-pattern>tests/src/Traits/QueryResultAssertionTrait.php</exclude-pattern> @@ -44,37 +45,27 @@ </rule> <rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment"> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/DataProducerProxy.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Images/ImageResourceUrl.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Field/EntityReference.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLinks.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeLink.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkAttribute.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkUrl.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkExpanded.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkDescription.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Routing/Url/UrlPath.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Routing/RouteLoad.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityPublished.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityRendered.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityType.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLanguage.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoadMultiple.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityOwner.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityDescription.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityTranslation.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoad.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityTranslations.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageUrl.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityId.php</exclude-pattern> - <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityAccess.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityLoadByUuid.php</exclude-pattern> <exclude-pattern>src/Plugin/GraphQL/DataProducer/Entity/EntityBundle.php</exclude-pattern> diff --git a/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php b/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php index 4f74c81f..d643737b 100644 --- a/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php +++ b/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php @@ -88,6 +88,9 @@ class DataProducerProxy implements ResolverInterface { /** * Create a new data producer proxy. + * + * @return mixed + * A new data producer proxy instance created via the plugin manager. */ public static function create(string $id, array $mapping = [], array $config = []): mixed { $manager = \Drupal::service('plugin.manager.graphql.data_producer'); @@ -118,6 +121,9 @@ class DataProducerProxy implements ResolverInterface { * Resolve field value. * * @throws \Drupal\Component\Plugin\Exception\PluginException + * + * @return mixed + * The resolved field value from the data producer plugin. */ public function resolve(mixed $value, array $args, ResolveContext $context, ResolveInfo $info, FieldContext $field): mixed { $plugin = $this->prepare($value, $args, $context, $info, $field); @@ -222,6 +228,8 @@ class DataProducerProxy implements ResolverInterface { * Cache lookup. * * @return array|null + * The cached data containing value and metadata, or NULL if no cache entry + * found. */ protected function cacheRead(string $prefix): ?array { if ($cache = $this->cacheBackend->get("$prefix:context")) { diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php index 6e3e1660..323ac825 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityChanged.php @@ -36,6 +36,11 @@ class EntityChanged extends DataProducerPluginBase { * Resolver. * * @throws \Exception + * When there are date handling errors. + * + * @return string|null + * The formatted entity changed timestamp, or NULL if the entity does not + * implement EntityChangedInterface. */ public function resolve(EntityInterface $entity, ?string $format = NULL): ?string { if ($entity instanceof EntityChangedInterface) { diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php index fd2344ae..bb47a8e4 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityCreated.php @@ -33,6 +33,10 @@ class EntityCreated extends DataProducerPluginBase { /** * Resolver. + * + * @return string|null + * The formatted entity creation timestamp, or NULL if the entity does not + * support creation time. */ public function resolve(EntityInterface $entity, ?string $format = NULL): ?string { // `getCreatedTime` is on NodeInterface which feels weird, since there diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityId.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityId.php index cbd9e750..aa60d0b8 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityId.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityId.php @@ -28,6 +28,9 @@ class EntityId extends DataProducerPluginBase { /** * Resolver. + * + * @return int|string|null + * The entity ID as integer or string, null if the entity has no ID yet. */ public function resolve(EntityInterface $entity): int|string|null { return $entity->id(); diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php index 539d4d2b..32d53ce2 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityLabel.php @@ -36,6 +36,10 @@ class EntityLabel extends DataProducerPluginBase implements DataProducerPluginCa /** * Resolver. + * + * @return string|null + * The entity label, or NULL if access to the entity label is denied for the + * given user. */ public function resolve(EntityInterface $entity, ?AccountInterface $accessUser, FieldContext $context): ?string { /** @var \Drupal\Core\Access\AccessResultInterface $accessResult */ diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php index 01f1a198..4a46b5fe 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityUrl.php @@ -43,11 +43,15 @@ class EntityUrl extends DataProducerPluginBase { * @param \Drupal\Core\Entity\EntityInterface $entity * The entity to create a canonical URL for. * @param string|null $rel - * The link relationship type, for example: canonical or edit-form. + * The link relation type, for example: canonical or edit-form. * @param array|null $options * The options to provided to the URL generator. * * @throws \Drupal\Core\Entity\EntityMalformedException + * When the entity cannot provide a URL. + * + * @return \Drupal\Core\Url + * The URL object for the entity with the given relation. */ public function resolve(EntityInterface $entity, ?string $rel, ?array $options): Url { return $entity->toUrl($rel ?? 'canonical', $options ?? []); diff --git a/src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php b/src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php index aebda13e..658df01a 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/EntityUuid.php @@ -28,6 +28,9 @@ class EntityUuid extends DataProducerPluginBase { /** * Resolver. + * + * @return string|null + * The entity UUID, or NULL if the entity doesn't have a UUID. */ public function resolve(EntityInterface $entity): ?string { return $entity->uuid(); diff --git a/src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php b/src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php index 094b95b6..30fe13b4 100644 --- a/src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php +++ b/src/Plugin/GraphQL/DataProducer/Menu/MenuLink/MenuLinkLabel.php @@ -30,6 +30,9 @@ class MenuLinkLabel extends DataProducerPluginBase { /** * Resolver. + * + * @return string + * The menu link title. */ public function resolve(MenuLinkInterface $link): string { return $link->getTitle(); diff --git a/src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php b/src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php index 3dd194ea..1368c3fd 100644 --- a/src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php +++ b/src/Plugin/GraphQL/DataProducer/Menu/MenuTree/MenuTreeSubtree.php @@ -33,6 +33,7 @@ class MenuTreeSubtree extends DataProducerPluginBase { * Resolver. * * @return array<\Drupal\Core\Menu\MenuLinkTreeElement> + * An array of enabled menu link tree elements in the subtree. */ public function resolve(MenuLinkTreeElement $element): array { return array_filter($element->subtree, function (MenuLinkTreeElement $item) { -- GitLab