I did it for whole drupal core with ONE exception in install.inc

/**
 * Helper for drupal_rewrite_settings().
 *
 * Dump the value of a value property and adds the comment if it exists.
 *
 * @param stdClass $variable
 *   A stdClass object with at least a value property.
 * @param string $prefix
 *   A string to prepend to the variable's value.
 * @param string $suffix
 *   A string to append to the variable's value.
 *
 * @return string
 *   A string containing valid PHP code of the variable suitable for placing
 *   into settings.php.
 */
function _drupal_rewrite_settings_dump_one(\stdClass $variable, $prefix = '', $suffix = '') {
  $return = $prefix . var_export($variable->value, TRUE) . ';';
  if (!empty($variable->comment)) {
    $return .= ' // ' . $variable->comment;
  }
  $return .= $suffix;
  return $return;
}

There is an explicit \stdClass and I don't want to change the signature of that method. I did not even knew that you can do this in PHP now. But it seems the namespaces have that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ro-no-lo’s picture

I would like to see this \stdClass everwhere where a simpe object MUST be the argument type. That would bring Drupal even further to be type aware and guideful for developers to use the correct types for function calls.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks, good effort! Can you restrict your patch to just this one change though (as described in the issue title)? Some of what you put in isn't OK, such as:

+   * @param bool $allow_invalid
+   *

Every @param needs a description and this doesn't have one, and there should also not be a blank line between the two @param sections.

And in this change

+   * @throws Exception
+   *

that should be a separate issue. Thanks!

zhuber’s picture

Status: Needs work » Needs review
FileSize
4.03 KB

I was looking through the issue queue and this one looked like a simple fix that I could help with.

Here is a patch that just renames the out-dated stdClass documentation.

jhodgdon’s picture

Status: Needs review » Fixed

Thanks! The patch in #3 is correct and complete. Committed to 8.x.

Status: Fixed » Closed (fixed)

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