Problem/Motivation
The documentation for \Drupal\views\Plugin\views\join\JoinPluginInterface is incorrect/incomplete:
- The parameter
$select_queryasks for an instance of\Drupal\Core\Database\Query\Select, but that should probably be\Drupal\Core\Database\Query\SelectInterface. I don't see a reason why 'Select' was used in #3478172: Add MissingParamType for views. - Parameter
$tableis defined as a string, while in practise it is used as an array. - The parameter descriptions are too brief. @joachim mentions this specifically for the $select_query parameter in #29, but I think that the other parameters are brief as well.
Original report by hardik_patel_12
Type hint "\Drupal\Core\Database\Query\SelectInterface" missing for $select_query
Type hint "\Drupal\views\Plugin\views\query\QueryPluginBase" missing for $view_query
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | type_hint_missing-3104796-18.patch | 5.12 KB | hardik_patel_12 |
| #18 | interdiff-3104796-9-18.txt | 1.71 KB | hardik_patel_12 |
Issue fork drupal-3104796
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hardik_patel_12 commentedComment #4
hardik_patel_12 commentedKindly follow a new patch
Comment #6
daffie commented@Hardik_Patel_12: You must add:
use Drupal\Core\Database\Query\SelectInterface;for your patch to work. Without it PHP thinks that SelectInterface is in the current namespace.Comment #7
hardik_patel_12 commented@daffie , thankyou for help. Kindly review a new patch.
Comment #9
hardik_patel_12 commentedkindly review a new patch
Comment #11
hardik_patel_12 commentedkindly review a new patch
Comment #12
naresh_bavaskarComment #13
naresh_bavaskar#11 looks good to me
Comment #14
naresh_bavaskarComment #15
lendudeSome more clean up can be done here while we are touching this
Needs a newline between the use statement and the docblock
Can we fix this typo while we are touching this? 'an select' => 'a select'
Can we update the docblock for Subquery to just be {@inheritdoc}?
Comment #16
daffie commented@lendude: Do you know if there are contrib modules that extend the
buildJoinmethod? If so, then that would result in a BC-break.Comment #17
daffie commentedI have just one remark:
You do not need to add type hints in method calls.
Comment #18
hardik_patel_12 commentedKindly review a new patch
Comment #19
hardik_patel_12 commentedComment #20
lendudeYeah was thinking about that too. Quick check in my contrib folder:
SearchAPI => \Drupal\search_api\Plugin\views\join\SearchApiJoin
So this a no-go in D8 and since it probably needs a deprecation or something, it probably would need to be announced/deprecated in D9 and then go into D10 :/
So I would probably just advice to leave this and when we start adding return type hints and break everything anyway, we can break this too ¯\_(ツ)_/¯
Comment #21
daffie commentedThe adding of parameter type hints need to go, but what we still can do is the docblock parts.
Comment #29
joachim commentedIMO fixing this typo is out of scope here.
Besides, the docs need more detail -- what about the select query object? What is it here for, what does this method do with it?
Comment #34
megachrizI came here because the type for the parameter
$tableis incorrect. In the interface it is documented as a string, but\Drupal\views\Plugin\views\join\JoinPluginBaseuses it as if it is an array:On a local project I use a custom ViewsJoin plugin, and now PHPStan complains that
$tablecannot be an array.Since I think that also the type of parameter
$select_querywould better be\Drupal\Core\Database\Query\SelectInterfacethan\Drupal\Core\Database\Query\Select, I thought the changes to the$tableparameter would fit within this issue.In the MR, the descriptions of the parameters are generated by AI, as I'm not an expert on the Views code. I did attempt to verify if the generated documentation is correct and removed a part generated by AI that looked more like a reaction to my prompt.
Comment #35
joachim commentedLooks good overall, just a few small suggestions.
Comment #36
megachrizI've attempted to address the feedback by @joachim.
Comment #37
joachim commentedThanks! Left a few comments.
Comment #38
megachrizComment #39
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #40
joachim commentedThis looks great, just needs a rebase according to the bot.