Added parameter types for some methods and fixed a wrong return type of the __get() method


edwardaa created an issue. See original summary.

edwardaa’s picture

Status: Active » Needs review
1.77 KB
FeyP’s picture

Status: Needs review » Needs work

Thanks for the patch, @edwardaa. It applies and is definitely a documentation improvement. I noticed, that the @return tag for storageSettingsForm() is still missing a type hint. Let's add that to the patch while we're at it.

edwardaa’s picture

Status: Needs work » Needs review
2.13 KB

Thanks for you feedback, added return type of array for storageSettingsForm()

FeyP’s picture

Assigned: edwardaa » Unassigned
Status: Needs review » Reviewed & tested by the community

Thanks, looks good. The patch still applies and it still is a documentation improvement. During the CI run I checked FieldItemBase and a few other random implementations to verify that the new type hints actually make sense. Marking as RTBC.

Wim Leers’s picture

Component: documentation » typed data system
Issue tags: +documentation, +Needs subsystem maintainer review
+++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php
@@ -114,11 +114,11 @@ public function getFieldDefinition();
-   * @return \Drupal\Core\TypedData\TypedDataInterface
-   *   The property object.
+   * @return mixed
+   *   The property value.

@@ -128,9 +128,9 @@ public function __get($property_name);
-   * @param $property_name
+   * @param string $property_name
-   * @param $value
+   * @param mixed $value

Are you sure this is correct?

edwardaa’s picture

Yes, the __get() method returns the value of typed data rather than the typed data itself.

I am not pretty sure there is any case where the $property_name is anything else except 'string'