The database API seems to have ported really early in the process of PSR0, so things like @return and @param have been ignored.

The simplest kind of problem just misses the leading backslash:

* @return Drupal\Core\Database\Query\SelectInterface

Should be:

* @return \Drupal\Core\Database\Query\SelectInterface

Then we have renames and missing namespaces, usually at the same time:

* @return DatabaseStatementInterface

Should be:

* @return \Drupal\Core\Database\StatementInterface

Another kind:

* @return InsertQuery

Should be

* @return \Drupal\Core\Database\Query\Insert

@TODO Figure out a process, maybe per file or one in total.

CommentFileSizeAuthor
#19 param-return-2057809-19.interdiff.txt1.37 KBStephaneQ
#19 param-return-2057809-19.patch30.78 KBStephaneQ
#15 interdiff-13-15.txt5.06 KBStephaneQ
#15 param-return-2057809-15.patch30.51 KBStephaneQ
#13 param-return-2057809-13.patch25.45 KBStephaneQ
#12 param-return-2057809-12.patch22.05 KBStephaneQ
#7 contains-2057809-7.patch35.48 KBStephaneQ
#7 implements-2057809-7.patch19.53 KBStephaneQ
#7 param-2057809-7.patch5.7 KBStephaneQ
#7 return-2057809-7.patch21.93 KBStephaneQ
#7 see-2057809-7.patch6.12 KBStephaneQ
#7 throws-2057809-7.patch9.91 KBStephaneQ
#7 var-2057809-7.patch4.87 KBStephaneQ
#7 various-2057809-7.patch2.11 KBStephaneQ
#4 Connection.php-2057809-4.patch7.46 KBStephaneQ
#4 ConnectionNotDefinedException.php-2057809-4.patch520 bytesStephaneQ
#4 Database.php-2057809-4.patch2.11 KBStephaneQ
#4 DatabaseException.php-2057809-4.patch448 bytesStephaneQ
#4 DatabaseExceptionWrapper.php-2057809-4.patch492 bytesStephaneQ
#4 DatabaseNotFoundException.php-2057809-4.patch498 bytesStephaneQ
#4 DriverNotSpecifiedException.php-2057809-4.patch508 bytesStephaneQ
#4 IntegrityConstraintViolationException.php-2057809-4.patch568 bytesStephaneQ
#4 Log.php-2057809-4.patch364 bytesStephaneQ
#4 Schema.php-2057809-4.patch6.36 KBStephaneQ
#4 SchemaException.php-2057809-4.patch436 bytesStephaneQ
#4 SchemaObjectDoesNotExistException.php-2057809-4.patch544 bytesStephaneQ
#4 SchemaObjectExistsException.php-2057809-4.patch508 bytesStephaneQ
#4 Statement.php-2057809-4.patch658 bytesStephaneQ
#4 StatementEmpty.php-2057809-4.patch724 bytesStephaneQ
#4 StatementInterface.php-2057809-4.patch454 bytesStephaneQ
#4 StatementPrefetch.php-2057809-4.patch1.54 KBStephaneQ
#4 Transaction.php-2057809-4.patch956 bytesStephaneQ
#4 TransactionCommitFailedException.php-2057809-4.patch538 bytesStephaneQ
#4 TransactionException.php-2057809-4.patch466 bytesStephaneQ
#4 TransactionExplicitCommitNotAllowedException.php-2057809-4.patch610 bytesStephaneQ
#4 TransactionNameNonUniqueException.php-2057809-4.patch544 bytesStephaneQ
#4 TransactionNoActiveException.php-2057809-4.patch514 bytesStephaneQ
#4 TransactionOutOfOrderException.php-2057809-4.patch526 bytesStephaneQ
#2 documentation_correct_statements-2057809-2.patch27.7 KBStephaneQ
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Issue tags: +Novice

Add novice task

StephaneQ’s picture

Status: Active » Needs review
FileSize
27.7 KB

I started to work on it, I did the files in /core/lib/Drupal/Core/Database
Can you give me a feedback please ? If it's good, I'll continue with the sub-folders.

dawehner’s picture

Thank you for catching this up!

+++ b/core/lib/Drupal/Core/Database/Connection.phpundefined
@@ -2,7 +2,7 @@
+ * Definition of \Drupal\Core\Database\Connection

The core standard talks about "Contains \Drupal"...

+++ b/core/lib/Drupal/Core/Database/Connection.phpundefined
@@ -330,7 +330,7 @@ public function tablePrefix($table = 'default') {
-   * @return Drupal\Core\Database\StatementInterface
+   * @return \Drupal\Core\Database\StatementInterface

@@ -402,7 +402,7 @@ public function setLogger(Log $logger) {
-   * @return DatabaseLog
+   * @return \Drupal\Core\Database\Log

@@ -666,7 +666,7 @@ public function getDriverClass($class) {
-   * @see Drupal\Core\Database\Query\Select
+   * @see \Drupal\Core\Database\Query\Select

These changes are exactly what I had in mind wonderful! On the other hand, maybe one patch per file is a better way as doing it all at once.

StephaneQ’s picture

jhodgdon’s picture

We can't really have one patch per file. How about splitting into one patch per "thing fixed"? Like, one patch that fixes @param, one that fixes @return (or these two could be combined), and one that adds \ before namespaced class names?

StephaneQ’s picture

Ok, I continued to work on it, I'll try to finish and post proper patches tomorrow.

StephaneQ’s picture

As promised, here is my work

Berdir’s picture

Note that each uploaded patch blocks a test bot for 30m-1h30, depending on the bot. This issue blocked (and still is) the whole test system for hours.

Either limit the number of patches you upload to (very) few or use the -do-not-test.patch suffix, as you're only making documentation changes that can't break tests.

jhodgdon’s picture

Berdir: I will not commit docs-only patches if they haven't been run through the test bot, just in case there is a stray character that wasn't noticed that then breaks HEAD.

That said, we generally only want one patch per issue. It's just very difficult to review #7 and keep track of "I'm reviewing this patch and it needs this work, while this other patch is ready" -- how do you set the issue status in that case?

So. We either need it all combined into one patch, or this issue needs to be broken up. And hopefully somone will then review the patch(es).

chx’s picture

Issue tags: +happy chx

StephaneQ, the lack of IDE integration for the database layer (due to broken @return doxygen) is a nightmare for me and I am totally shocked someone got this far so very fast. Thanks much!

I think this could be rolled into one patch. The one failed patch doesn't matter much, it's just a bot fluke, I checked it.

If you roll this together, I will RTBC it, if there's anything left out, we can pick up the slack later but this work really badly needs to find its way in.

chx’s picture

One more thing: all the Implements whateverinterface::method is just {@inheritdoc} now.

(I want to yell from the rooftops: yay, finally we are fixing the DBTNG documentation!)

StephaneQ’s picture

According to IRC discussion, we limit this issue to @return and @param. Here's an updated patch.

StephaneQ’s picture

Oops, forget the previous one, I did a mistake and @param fixes are missing

chx’s picture

Status: Needs review » Reviewed & tested by the community

Yay!

StephaneQ’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
30.51 KB
5.06 KB

Added fixes for database.inc

chx’s picture

Status: Needs review » Reviewed & tested by the community

*even better*

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs review

Thanks!

I'm not sure what you decided the scope of this issue is, but there are some additional @param/@return problems that are not fixed in this patch, and that affect lines in this patch:

a) @return statements need descriptions:

+ * @return \Drupal\Core\Database\Query\Condition
  */
 function db_or() {

This needs an additional line describing what is returned, which can be similar to the return statements for db_select() and the others. Same for db_and() and a few others.

b) There should be a blank line between @param and @return

  * @param $conjunction
  *   The conjunction to use for query conditions (AND, OR or XOR).
- * @return Condition
+ * @return \Drupal\Core\Database\Query\Condition
  */
 function db_condition($conjunction) {

This is I think the only place in the patch with this problem.

Feel free to tell me "out of scope", but I think it would be nice if an issue saying "correct the @param and @return statements" as its title made them completely correct. ;)

dawehner’s picture

Category: task » bug

Just wanted to say, impressive work! As D8 is basically impossible to use without a proper IDE having proper return statements is certainly a bug.

StephaneQ’s picture

I think it's in the scope jhodgdon, here's an updated patch. Thanks

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine to me, back to RTBC, don't think the bot is going to disagree :)

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Great work! Go StephaneQ!!!!

Committed to 8.x.

StephaneQ’s picture

I made another issue for @see, var and throws statements, as I did them here
#2064261: Correct the @var, @throws and @see statements on dbtng

sphism’s picture

This patch collided a bit with #1533096: Make includes directory, files starting with D-G pass Coder Review

But I've rerolled that one so it works again.

One thing I noticed while working on the patch above was that there's no type declarations for @param or @return

Would it be of any use if I made a patch to fix that? It's out of scope for the patch above, but i'm happy to do it if it's of any use

jhodgdon’s picture

RE #23... What are you talking about? I believe all the @param/@return statements do have types on them. That was the whole point of the patch above, to make the types actually be correct and with the correct namespaces. ??

sphism’s picture

@jhodgdon, as far as i know - the @return's now have the correct types, but the @param's only have their name, not their type

eg

* @param $query
* The prepared statement query to run..
* @param $args
* An array of values t...
* @param $options
* An array of options....

should be:
* @param string $query
* The prepared statement query to run..
* @param array $args
* An array of values t...
* @param array $options
* An array of options....

I think there's some debate about whether to add them, but certainly it's helpful if you use an ide

jhodgdon’s picture

Ah. The patch cleaned up a bunch of *incorrect* params that were using the wrong class names or lacked namespaces. But I guess it didn't go through and add missing types.

That would be a separate issue. Much of core suffers from the same problem and there was at one time an initiative to add them to all of core, but it's a HUGE job to write the patches (requires some care!), review the patches (more care!) and commit the patches (I personally never commit patches that I haven't also given a final correctness review to, so more care!). The effort required is therefore large, and the benefits... well, probably not as large? Anyway, search the issue queue and you can probably find the meta-issue and get it restarted if that is what you want to do. I personally think that fixing incorrect docs is a higher priority.

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

Anonymous’s picture

Issue summary: View changes

Updated issue summary.