This is a sub-issue of #1800046: [META] Add missing type hinting to core docblocks, fix Drupal.Commenting.FunctionComment.Missing* focused on correctly adding @param and @return type hinting to the Simpletest module. This does not include the base test files in lib\Drupal\simpletest. Those files are being covered by Issue [].

Documentation patches that include type hinting are time consuming to both review and commit because one must dig into the actual code to confirm that the type hints are both correct and complete. Hence, please be patient and try to limit type hint patches to covering only a limited number of docblocks (20-25 as a guess).

How To Review This Issue

  1. Attempt to apply the patch to see if it needs a reroll.
  2. Use the phpcs one-liner to evaluate whether all the relevant standards errors have been resolved: https://gist.github.com/paul-m/227822ac7723b0e90647
  3. Look at each change and determine whether the type hint is correct.

Related sprint issues:

Sprint Topic Sub Issue
#1518116: [meta] Make Core pass Coder Review #1533432: Make simpletest module pass Coder Review
#1310084: [meta] API documentation cleanup sprint #1431636: Clean up API docs for simpletests module (excluding files subdirectory)
#500866: [META] remove t() from assert message #1797514: Remove t() from assertion messages in tests for the simpletest module
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lars Toomre’s picture

Status: Active » Postponed
Lars Toomre’s picture

Status: Postponed » Needs review
FileSize
1.28 KB

Here is a small patch adding type hinting to the missing hooks in simpletest.api.php file.

Mile23’s picture

Issue summary: View changes

The blocking issue is marked closed.

YesCT’s picture

I would be willing to review or work on this.

Mile23’s picture

FileSize
8.28 KB

Patch in #2 wouldn't apply, but the changes are reflected here, as well.

Try the API docs, .module file, and unit tests for starters.

filijonka’s picture

FileSize
5.97 KB

a reroll, mostly removing stuff from the patch cause it's been taken care of already

Status: Needs review » Needs work

The last submitted patch, 6: 1805340-6.patch, failed testing.

Status: Needs work » Needs review

filijonka queued 6: 1805340-6.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 6: 1805340-6.patch, failed testing.

Status: Needs work » Needs review

filijonka queued 6: 1805340-6.patch for re-testing.

Mile23’s picture

FileSize
50.79 KB
45.06 KB

MOAR.

Note that I kind of generated this in the process: #2403007: Drupal\simpletest\WebTestBase::drupalHead doesn't store results despite documentation..

This patch fixes these files:

$ git diff 8.0.x --name-only
core/modules/simpletest/simpletest.api.php
core/modules/simpletest/simpletest.module
core/modules/simpletest/src/TestBase.php
core/modules/simpletest/src/Tests/SimpleTestTest.php
core/modules/simpletest/src/WebTestBase.php
core/modules/simpletest/tests/src/Unit/PhpUnitErrorTest.php
core/modules/simpletest/tests/src/Unit/TestBaseTest.php

Note that I used a phpcs/NetBeans toolchain to find the errors, and you can use it to review the patch, like this: http://youtu.be/H6pWz_6XoiQ

Status: Needs review » Needs work

The last submitted patch, 11: 1805340_11.patch, failed testing.

Mile23’s picture

Status: Needs work » Needs review
FileSize
51.57 KB
1.4 KB

This might be a little out of scope but it solves the issue and improves the documentation.

Status: Needs review » Needs work

The last submitted patch, 13: 1805340_13.patch, failed testing.

Mile23’s picture

Mile23’s picture

FileSize
50.77 KB
1.26 KB

OK, so it doesn't solve the problem. Reverting back to the original code, changing only the docblock.

Mile23’s picture

Status: Needs work » Needs review
Mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
mrjmd’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
50.72 KB

Reroll attached. There were conflicts in WebTestBase.php and simpletest.module, both because a few types in head were being hinted like this:

@param \Drupal\Core\Url|string $path

I switched them to just:

@param string $path

But I'm not sure that's right. I also fixed a typo from the patch in #16 that had "arrau" instead of array for a type hint for function drupalGet().

daffie queued 19: 1805340_19.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 19: 1805340_19.patch, failed testing.

daffie’s picture

Issue tags: +Needs reroll

The patch looks good.

+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1481,15 +1490,15 @@ protected function isInChildSite() {
-   * @param \Drupal\Core\Url|string $path
+   * @param string $path

@@ -2449,21 +2460,21 @@ protected function drupalGetMails($filter = array()) {
-   * @param \Drupal\Core\Url|string $path
+   * @param string $path

In both instances the parameter can be an URL. So can you remove these changes.

mrjmd’s picture

Status: Needs work » Needs review
FileSize
49.61 KB

Thanks for the feedback @daffie, I've added those back in and rerolled.

There was one conflict in /core/modules/simpletest/tests/src/Unit/TestBaseTest.php, looks like a method had been renamed while making our fix obsolete.

daffie’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Looks good to me. Thanks mrjmd for the reroll.
This issue is all about documention of tests. So allowed as a beta change.

Mile23’s picture

Still applies.

Mile23’s picture

Issue summary: View changes
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/simpletest/simpletest.api.php
@@ -13,7 +13,7 @@
+ * @param array $groups

+++ b/core/modules/simpletest/simpletest.module
@@ -115,7 +114,7 @@ function _simpletest_format_summary_line($summary) {
+ * @param array $test_list

@@ -166,9 +165,9 @@ function simpletest_run_tests($test_list) {
+ * @param array $unescaped_test_classnames

@@ -363,6 +362,21 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) {
+ * @param array $results
...
+ * @param array $operations

+++ b/core/modules/simpletest/src/TestBase.php
@@ -363,20 +363,20 @@ protected function storeAssertion(array $assertion) {
+   * @param array $caller

@@ -830,21 +830,21 @@ protected function fail($message = NULL, $group = 'Other') {
+   * @param array $caller

@@ -1551,11 +1551,11 @@ protected function getRandomGenerator() {
+   * @param array $parameters

+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1280,15 +1282,15 @@ protected function curlInitialize() {
+   * @param array $curl_options

@@ -1483,13 +1492,13 @@ protected function isInChildSite() {
+   * @param array $options
...
+   * @param array $headers

@@ -1562,7 +1570,7 @@ protected function drupalGetAJAX($path, array $options = array(), array $headers
+   * @param array $edit

@@ -1589,7 +1597,7 @@ protected function drupalGetAJAX($path, array $options = array(), array $headers
+   * @param array $submit

@@ -1614,19 +1622,19 @@ protected function drupalGetAJAX($path, array $options = array(), array $headers
+   * @param array $options
...
+   * @param array $headers

@@ -1726,36 +1734,36 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array(
+   * @param array $edit

@@ -2082,16 +2090,18 @@ protected function checkForMetaRefresh() {
+   * @param array $options
...
+   * @param array $headers

@@ -2115,17 +2125,18 @@ protected function drupalHead($path, array $options = array(), array $headers =
+   * @param array $post
...
+   * @param array $edit
...
+   * @param array $form

@@ -2423,11 +2434,11 @@ protected function drupalGetHeader($name, $all_requests = FALSE) {
+   * @param array $filter

@@ -2451,19 +2462,19 @@ protected function drupalGetMails($filter = array()) {
+   * @param array $options

@@ -2662,11 +2677,12 @@ protected function verboseEmail($count = 1) {
+   * @param array $override_server_vars

Shouldn't we be type-hinting in the function too? Eg:

protected function prepareRequestForGenerator($clean_urls = TRUE, array $override_server_vars = array()) {

Also:

+++ b/core/modules/simpletest/simpletest.module
@@ -1,4 +1,8 @@
 <?php
+/**

Needs a new line before the file doc.

mrjmd’s picture

Status: Needs work » Needs review
FileSize
54.83 KB
7.63 KB

I've added typehints to the function names everywhere phpcs pointed them out, and added the new line before the file doc. There are still a lot of other phpcs warnings in simpletest but I didn't want to go out of scope for this issue.

Status: Needs review » Needs work

The last submitted patch, 28: 1805340_28.patch, failed testing.

Mile23’s picture

Some of the issues for this meta include type hinting in the function signatures, some don't.

My understanding is that ones which do not can be documentation issues, whereas ones which do are code changes. A maintainer could please talk about such a distinction on the meta if it matters.

deepakaryan1988’s picture

Assigned: Unassigned » deepakaryan1988
deepakaryan1988’s picture

Status: Needs work » Needs review
Issue tags: +india, +SprintWeekend2015
FileSize
51.66 KB

Re-rolling the patch#28

deepakaryan1988’s picture

Assigned: deepakaryan1988 » Unassigned

Status: Needs review » Needs work
Mile23’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs work » Needs review
FileSize
45.87 KB

All docblock @param and @return filled in.

Running the phpcs gist in the issue summary only yields one false-positive CS error. (It's complaining about the lack of description in a @param, but the type hinting is there.)

Status: Needs review » Needs work

The last submitted patch, 35: 1805340_35.patch, failed testing.

Mile23’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Needs work » Needs review
FileSize
45.6 KB

Turns out we can get documentation into 8.0.x.

Needed a re-roll, but I couldn't get that to work easily, so I used git apply --reject and re-did the other work. This only affected WebTestBase.php.

phpcs reports only one false-positive of a @param without a comment.

Status: Needs review » Needs work

The last submitted patch, 37: 1805340_37.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Title: Add missing type hinting to Simpletest module docblocks » Add missing type hinting to Simpletest module docblocks (excluding test base classes)
Mile23’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

snehalgaikwad’s picture

Status: Needs work » Needs review
FileSize
34.08 KB
quietone’s picture

Project: Drupal core » SimpleTest
Version: 8.9.x-dev » 8.x-3.x-dev
Component: simpletest.module » Code

The simpletest module is no longer in core, moving to the SimpleTest project.

quietone’s picture

It doesn't seem to make sense to have this as a child of a core issue, so removing parent.