Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently doing code inspections for core/modules folder
Found few places that are missing @return tags
need suggestions!
Comment | File | Size | Author |
---|---|---|---|
#62 | interdiff-2594909-9-10.txt | 806 bytes | rakesh.gectcr |
#62 | 2594909-10.patch | 1.63 KB | rakesh.gectcr |
#59 | interdiff-2594909-8-9.txt | 950 bytes | rakesh.gectcr |
#59 | 2594909-9.patch | 1.57 KB | rakesh.gectcr |
#56 | interdiff-2594909-7-8.txt | 914 bytes | rakesh.gectcr |
Comments
Comment #2
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedAttached patch
review required
Comment #3
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedComment #4
dawehnerIt would be nice to not loose this particular bit of information
Can we have a new line in between and why does one have a different return value than the other one even if its the same method?
Comment #5
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedAgreed, But all the functions inside ContextualLinks.php are using
{@inheritdoc}
. So if we want to keep information then we need to change all functions. Suggest me can i proceed to change ?Updated data type with null.
Comment #6
cilefen CreditAttribution: cilefen commentedI agree this is rc eligible.
Comment #7
jhodgdonThanks! Needs a bit of work though:
There should be a blank line before a @return
I also don't understand this documentation -- "output" of a field? You mean the rendered field value?
And I doubt it is really a string that is returned, wouldn't it be a render array or something like that? Just seems wrong.
Anyway I have no idea what "output" means.
Need blank line before @return
Again, what is "output"?
Comment #8
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedFixed @jhodgdon comment.
Comment #9
jhodgdonWhen you make a new patch in the future, please include an interdiff file. Thanks! Well, it's probably not all that necessary on such a small patch, but still a good idea.
Anyway... I looked carefully at this patch and went and read the code. The docs in OpmlFields and RssFields are totally wrong about the return values. Please go read the code. Those methods do not return NULL, MarkupInterface, or an array.
Comment #10
rakesh.gectcr@ jhodgdon
The following is the function in the 'OpmlFields.php' .
Is the return is showing
return (string) $this->view->style_plugin->getField($index, $field_id);
Isn't that returning the String of rendered field values ?Comment #11
rakesh.gectcrComment #12
rakesh.gectcrCorrect me if I am wrong!
@jhodgdon
I understand the function
public function getField
returns string.@dawehner
Is the same function
public function getField
is using in both RssFields.php and OpmlFields.php.I believe its same because both are trying to retrieve the views field value. If it is , then there is
(string)
is missingComment #15
rakesh.gectcrAs of my understanding, in both RssFields.php and OpmlFields.php files, it @retruns string and the doc comment like follows
Please find my final patch for review
Comment #18
cilefen CreditAttribution: cilefen commentedThis is a documentation issue but you are changing code. That is not totally wrong, but it will have implications. Let's see what others say.
Comment #19
rakesh.gectcrComment #20
rakesh.gectcrComment #21
rakesh.gectcr@cilefen
I created separate issue , as a child of this issue. Please find the following link for that
https://www.drupal.org/node/2597862
Comment #26
rakesh.gectcrComment #27
rakesh.gectcr@here
I create new issue for the code change , which is https://www.drupal.org/node/2597862
We are keeping this issue only for documentation, that will be make things clear.
Please review the latest patch only having the documentation changes.
Comment #28
rakesh.gectcrComment #33
jhodgdonRight. This patch is correct for changing the docs so it says that it returns a string. You could have put a "the" in there but it's OK as is, at least correct and clear.
I have no comment about changing the code, but if you do that on another issue, please also make sure to change the corresponding documentation.
Comment #34
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedNew patch
Added 'The' as suggested by @jhodgdon & for latest code too.
Thanks!
Comment #39
krknth CreditAttribution: krknth as a volunteer and at Valuebound commentedHiding the patches which are failed
Comment #40
jhodgdonThanks! New patch even more RTBC. ;) Hopefully the test bot will eventually stop trying to test the old patches. ?!?
Comment #41
alexpottSee the return value of
StylePluginBase::getField()
this returns\Drupal\Component\Render\MarkupInterface|null
Comment #42
jhodgdonYes the base class method does, but not this one if you look at its code.
Comment #43
rakesh.gectcrComment #44
rakesh.gectcrComment #45
rakesh.gectcrComment #46
jhodgdonOK. Verified this is now correct return value on the Rss class. @alexpott - thanks for catching that. @rakesh.gectcr thanks for patching!
Comment #47
xjmSo by switching this to
{@inheritdoc}
, we lose the two@see
. Have we adopted a standard for this yet? Previously, we would copy the entire docblock (which is what HEAD does) and add the additional information. We could leave it as is in HEAD. Other options are:(which appears to work in IDEs, at least PHPStorm, but I am not sure api.d.o supports it yet)
or adding elsewhere, e.g. as inline comments at the beginning of the method, which I think is non-ideal since it makes it less visible.
I think maybe there is an existing issue for this? Especially now that #2502621: Replace implement notes with inheritdoc tag is in, it would be good to adopt a standard for the scenario where we want to inherit most, but not all of the documentation. @jhodgdon, thoughts?
Comment #48
jhodgdonThere is NO documentation parser out there that supports inheritdoc that means "Inherit and then allow overrides". It is just not feasible. We have an issue about that but it's really a "won't fix". Some docs parsers support "inheritdoc means inherit everything", like we do. Some have it mean "inherit this little piece of something depending on where it's placed", which is pretty limited and not how we're using it. No one does the really really really really complicated logic of "inherit everything and then allow overrides". It is in the category of unicorns.
This comes up *all the time* and there are doc blocks that are trying to do this in Core and it just will not work.
Anyway... rant aside... If we feel that we really need those two @see items, we cannot use @inheritdoc. We can, however, say something like "See .... for documentation of parameters and return value" rather than duplicating the docs completely, although it is not all that wonderful to do that because it means the docs are not there if someone needs them.
Comment #49
YesCT CreditAttribution: YesCT commentedthe issue about partial inheritdoc is #1994890: Allow {@inheritdoc} and additional documentation
Comment #50
dawehnerWell, there is the one in phpstorm which is certainly using some form of documentation parser, isn't it?
Comment #51
rakesh.gectcr@xjm, @jhodgdon, @YesCT , @dawehner
Well, Please give me a conclusion, So that i can go forward and work accordingly.
Comment #52
jhodgdonRight now we do not allow @inheritdoc with additions. So let's just leave this documentation block unchanged in this patch. Thanks!
Comment #53
rakesh.gectcr@jhodgdon
I removed the
{@inheritdoc}
. Please find the attached patch and interdiff fileComment #54
jhodgdonThanks!
Comment #55
alexpott... is unfortunate
So we return an empty string if there is no style plugin or if the field_id is empty (I wonder if this is even possible). And we return a NULL if the field is actually empty - otherwise we return a MarkupInterface object.
Anyhow this should be documented. See the documentation for StylePluginBase::getField() for a start of how to write this...
Comment #56
rakesh.gectcr@alexpott
:D , I have done the changes according to your comment.
Comment #57
rakesh.gectcrComment #58
jhodgdonGood start but this needs some wording/grammar cleanup...
Also, use English in documentation. So instead of "field_id" say "field ID".
And we don't normally want to start a @return with "It returns". Leave that out.
And it shouldn't have [the rendered field value] in it... what is that for? Either use () (which is what you would use in English text), or leave out the [].
Comment #59
rakesh.gectcr@jhodgdon
I have done the changes.
Comment #60
rakesh.gectcrComment #61
jhodgdonMuch better!
So... What does "if the field is actually empty" mean? The arguments here are $index and $field_id, so I am not sure what this means. I also wouldn't use the word "actually".
Then I would also suggest breaking up the second line (once it is clarified) into two sentences, and not starting with "And".
And finally, this isn't telling me what the MarkupInterface object contains (which is probably something about the rendered field value, right?).
So ... I think it should say something like:
NULL if .... If neither of these conditions apply, a MarkupInterface object containing ....
And you'll need to figure out what to substitute in for the .... parts.
Thanks!
Comment #62
rakesh.gectcrComment #63
jhodgdonGreat! Very clear, and I have also verified it is correct. Thanks!
Comment #64
alexpottCommitted 98e9354 and pushed to 8.0.x. Thanks!