This is a minor point...the sky is not falling, but it is something which could cause some confusion in contrib.

There are three examples in where aClass::compile() returns a value extending/violating the following interface.

Drupal\Core\Database\Query\ConditionInterface::compile()

Drupal\Core\Database\Query\Delete
Drupal\Core\Database\Query\Merge
Drupal\Core\Database\Query\Update

Alternatively think $this->condition->compile() is void a method and its result is used!!!!

  public function compile(Connection $connection, PlaceholderInterface $queryPlaceholder) {
    return $this->condition->compile($connection, $queryPlaceholder);
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

So yeah the compile() method explicit tells about not returning anything. We could start using @return voidto make that fact documented.

martin107’s picture

FileSize
593 bytes
2.45 KB

That solution, I prefer....

  /**
   * Compiles the saved conditions for later retrieval.
   *
   * This method does not return anything, but simply prepares data to be
   * retrieved via __toString() and arguments().
   *
   * @param $connection
   *   The database connection for which to compile the conditionals.
   * @param $queryPlaceholder
   *   The query this condition belongs to. If not given, the current query is
   *   used.
+ * 
+ * @return void
   */

There must be many other interface definitions which make a similar assumption about the return type ....

from https://www.drupal.org/coding-standards/docs
under the "Drupal API documentation standards for functions" I have this line

If there is no return value for a function, there must not be a @return tag.

It make me feel better, when I see that the developer before me explicitly inserted warning text about the return type in this instance.

The exception to the rule would have to be This is an interface definition, so normal function rules do not apply!

Anyway this needs review.

On a completely separate point, Core is trying to appear standardized while not actually being standardized.

Please note that \Drupal\Core\Entity\ConditionInterface also implements a compile() function and is its annotation is in error, in another direction.
The error is that the interface should indicate a return type, as functions that implement it do return a value.

I am still pondering what to do there...in what is not a database issue and the gate for API changes is closed.

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.

markdorison’s picture

Version: 8.1.x-dev » 8.3.x-dev
daffie’s picture

Status: Needs review » Closed (outdated)

The compile method is now implemented by the QueryConditionTrait and there is the method compile not returning anything. So I am closing this issue for being outdated.