Skip to content

False positives in DebugClassLoader when @param documentation mentions another $variable #43936

Closed
@longwave

Description

@longwave

Symfony version(s) affected

5.4

Description

When running Drupal core tests against Symfony 5.4, the DebugClassLoader is reporting false positives when an @param tag contains documentation that mentions another $variable.

How to reproduce

Sample test output from Drupal 9.4 patched for Symfony 5.4 (with patch from e.g. https://www.drupal.org/project/drupal/issues/3161889#comment-14281559)

Remaining self deprecation notices (2)

  1x: The "Drupal\Core\Database\Query\Select::havingCondition()" method will require a new "$value The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator." argument in the next major version of its interface "Drupal\Core\Database\Query\SelectInterface", not defining it is deprecated.
    1x in OrderByTest::setUp from Drupal\Tests\Core\Database

  1x: The "Drupal\Core\Database\Query\Select::fields()" method will require a new "$fields An indexed array of fields present in the specified table that should be included in this query. If not specified, $table_alias.*" argument in the next major version of its interface "Drupal\Core\Database\Query\SelectInterface", not defining it is deprecated.
    1x in OrderByTest::setUp from Drupal\Tests\Core\Database

SelectInterface has these docblocks:

  /**
   * Helper function to build most common HAVING conditional clauses.
   *
   * This method can take a variable number of parameters. If called with two
   * parameters, they are taken as $field and $value with $operator having a value
   * of IN if $value is an array and = otherwise.
   *
   * @param $field
   *   The name of the field to check. If you would like to add a more complex
   *   condition involving operators or functions, use having().
   * @param $value
   *   The value to test the field against. In most cases, this is a scalar. For more
   *   complex options, it is an array. The meaning of each element in the array is
   *   dependent on the $operator.
   * @param $operator
   *   The comparison operator, such as =, <, or >=. It also accepts more complex
   *   options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array
   *   = otherwise.
   *
   * @return \Drupal\Core\Database\Query\ConditionInterface
   *   The called object.
   */
  public function havingCondition($field, $value = NULL, $operator = NULL);

  /**
   * Add multiple fields from the same table to be SELECTed.
   *
   * This method does not return the aliases set for the passed fields. In the
   * majority of cases that is not a problem, as the alias will be the field
   * name. However, if you do need to know the alias you can call getFields()
   * and examine the result to determine what alias was created. Alternatively,
   * simply use addField() for the few fields you care about and this method for
   * the rest.
   *
   * @param $table_alias
   *   The name of the table from which the field comes, as an alias. Generally
   *   you will want to use the return value of join() here to ensure that it is
   *   valid.
   * @param $fields
   *   An indexed array of fields present in the specified table that should be
   *   included in this query. If not specified, $table_alias.* will be generated
   *   without any aliases.
   *
   * @return $this
   *   The called object.
   */
  public function fields($table_alias, array $fields = []);

Select defines these interfaces correctly:

  /**
   * {@inheritdoc}
   */
  public function havingCondition($field, $value = NULL, $operator = NULL) {

  /**
   * {@inheritdoc}
   */
  public function fields($table_alias, array $fields = []) {

Possible Solution

There are a few more similar cases; in all cases that I have found, the @param tag happens to mention a variable so this looks like a parsing issue with docblocks.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions