Its possible for \Drupal\Core\TypedData\TypedDataInterface::getName to return both string and integer, return type doc state only string is returned. However string and [true] integer are both valid types, even the @return documentation for the method mentions that integer is possible (common?):

If the data is an item of a list, the name is the numeric position of the item in the list, starting with 0. Otherwise, NULL is returned.

Comments

dpi created an issue. See original summary.

dpi’s picture

Assigned: dpi » Unassigned
Status: Active » Needs review
Issue tags: +Documentation
StatusFileSize
new671 bytes
panshulk’s picture

Assigned: Unassigned » panshulk
Issue tags: +DIACWApril2020
panshulk’s picture

Assigned: panshulk » Unassigned
surabhi-gokte’s picture

Assigned: Unassigned » surabhi-gokte
surabhi-gokte’s picture

StatusFileSize
new25.22 KB

Reviewed the patch by applying on my local. All looks good, moving the issue to RTBC.

surabhi-gokte’s picture

Assigned: surabhi-gokte » Unassigned
Status: Needs review » Reviewed & tested by the community

added attribution

jungle’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
@@ -105,7 +105,7 @@ interface TypedDataInterface {
    *   item in the list, starting with 0. Otherwise, NULL is returned.

It‘s possible to be NULL from the comment. Let's change it to string|int|null

kishor_kolekar’s picture

StatusFileSize
new1.29 KB
new1.48 KB

address comment #8 please review the patch.

kishor_kolekar’s picture

Status: Needs work » Needs review
jungle’s picture

Title: Update documentation for TypedDataInterface::getName » Update documentation for TypedDataInterface

Thanks @kishor_kolekar! Let's enlarge the scope a bit to inline with the patch in #9. If the testing passes, this is RTBC.

johnwebdev’s picture

+++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
@@ -43,6 +43,7 @@ public function getDataDefinition();
+   *   the data value.

the => The

suresh prabhu parkala’s picture

StatusFileSize
new1.65 KB

Please review. updated as per #12.

jungle’s picture

Status: Needs review » Needs work

#12 nice catch, thank you!

+++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
@@ -105,7 +107,7 @@ public function applyDefaultValue($notify = TRUE);
diff --git a/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php b/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php

diff --git a/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php b/core/tests/Drupal/FunctionalTests/Core/Batch/BatchNotFoundTest.php
deleted file mode 100644

deleted file mode 100644
index e69de29bb2..0000000000

Re #13 unexpected change made.

suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new1.45 KB

Sorry for that. This is a new patch. Please review!

kishor_kolekar’s picture

patch #15 LGTM, If the testing passes, this is RTBC.

jungle’s picture

BTW, It's fine having no interdiff here as the patch is very small, however, it's a good habit to attach interdiff where applicable. In general, it makes review easier more or less. Especially, for larger patches. See "Creating an interdiff" https://www.drupal.org/documentation/git/interdiff

jungle’s picture

Status: Needs review » Needs work

As the declaration of TypedDataInterface::createInstance() changed, \Drupal\Core\TypedData\TypedData::createInstance() should change accordingly (file: core/lib/Drupal/Core/TypedData/TypedData.php)

-  public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
+  public static function createInstance(DataDefinitionInterface $definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
kishor_kolekar’s picture

Status: Needs work » Needs review
StatusFileSize
new579 bytes
new2.16 KB

address comment #18 please review the patch.

jungle’s picture

Title: Update documentation for TypedDataInterface » Update documentation and fix type hinting for TypedDataInterface
Status: Needs review » Reviewed & tested by the community

Testings against 4 branches passed.

Rethinking about the scope here, the patch did 3 things

  1. +++ b/core/lib/Drupal/Core/TypedData/TypedData.php
    @@ -43,7 +43,7 @@ abstract class TypedData implements TypedDataInterface, PluginInspectionInterfac
    -  public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
    +  public static function createInstance( DataDefinitionInterface $definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
    
    +++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
    @@ -29,7 +29,7 @@ interface TypedDataInterface {
    -  public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL);
    +  public static function createInstance(DataDefinitionInterface $definition, $name = NULL, TraversableTypedDataInterface $parent = NULL);
    

    Fix type hitting

  2. +++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
    @@ -43,6 +43,7 @@ public function getDataDefinition();
        * @return mixed
    +   *   The data value.
    
    @@ -68,6 +69,7 @@ public function setValue($value, $notify = TRUE);
        * @return string
    +   *   The string representation of the data.
    

    Fix missing desctiptions of @return

  3. +++ b/core/lib/Drupal/Core/TypedData/TypedDataInterface.php
    @@ -105,7 +107,7 @@ public function applyDefaultValue($notify = TRUE);
    -   * @return string
    +   * @return string|int|null
    

    Fix wrong type of @return

Actually, each one could have a larger scope and be fixed in a separate issue. RTBC this to see what committer(s) would say.

jungle’s picture

Version: 8.9.x-dev » 9.1.x-dev
jungle’s picture

Status: Reviewed & tested by the community » Needs work

2 coding standards messages
✗ 2 more than branch result

/var/lib/drupalci/workspace/jenkins-drupal_patches-42618/source/core/lib/Drupal/Core/TypedData/TypedData.php ✗ 2 more
line 46 Expected 0 spaces after opening parenthesis; 1 found
46 There should be no white space after an opening "("

Oh, no, 2 coding standard violations, but one change is enough -- remove the space right after the opening parenthesis

+++ b/core/lib/Drupal/Core/TypedData/TypedData.php
@@ -43,7 +43,7 @@ abstract class TypedData implements TypedDataInterface, PluginInspectionInterfac
-  public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
+  public static function createInstance( DataDefinitionInterface $definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) {
suresh prabhu parkala’s picture

Status: Needs work » Needs review
StatusFileSize
new2.05 KB

updated patch. Please review!

jungle’s picture

Status: Needs review » Reviewed & tested by the community

Setting to RTBC again

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs followup

Thanks for your work on this!

We should change this patch to be limited to the documentation improvements only. Adding typehints is disruptive and can be a BC break. Let's look at the missing typehints in a separate issue, which will probably be part of a meta about how to add missing typehints.

(Saving issue credit.)

xjm’s picture

Title: Update documentation and fix type hinting for TypedDataInterface » Update missing @param and @return documentation and docs typehints for TypedDataInterface
xjm’s picture

Version: 9.1.x-dev » 8.8.x-dev

With the modified scope of "docs only", this is eligible for backport to the bugfix branch. (The stuff with the typehints is 9.1 material, so the followup should be against 9.1 and probably part of a larger project to identify and handle missing signature typehints.

Thanks!

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new1.36 KB
new1.08 KB

@xjm, Thank you! Now the patch is simpler and docs only.

jungle’s picture

Looks like a follow-up is unnecessary, there are type hinting relevant issues including meta too.

jungle’s picture

Status: Needs review » Reviewed & tested by the community

Setting back to RTBC, please do not take this as a self-RTBC :)

xjm’s picture

Status: Reviewed & tested by the community » Needs review

@jungle, you do still need someone else to review your changes since #28. :) I could +1 the RTBC but then I can't commit it. :D So if someone's available to give it quick review then we can get this in. :)

johnwebdev’s picture

Status: Needs review » Reviewed & tested by the community

Interdiff looks good!

RTBC.

xjm’s picture

Thanks!

Saving credits.

  • xjm committed 84dadf6 on 9.1.x
    Issue #3094067 by kishor_kolekar, Suresh Prabhu Parkala, jungle, dpi,...

  • xjm committed 9141f3f on 9.0.x
    Issue #3094067 by kishor_kolekar, Suresh Prabhu Parkala, jungle, dpi,...

  • xjm committed f407994 on 8.9.x
    Issue #3094067 by kishor_kolekar, Suresh Prabhu Parkala, jungle, dpi,...

  • xjm committed 6ab038c on 8.8.x
    Issue #3094067 by kishor_kolekar, Suresh Prabhu Parkala, jungle, dpi,...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 9.1.x, 9.0.x, 8.9.x, and 8.8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.