Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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);
}
Comment | File | Size | Author |
---|---|---|---|
#2 | unused-2359129-2.patch | 2.45 KB | martin107 |
#2 | interdiff-0-2.txt | 593 bytes | martin107 |
unused-0.patch | 1.87 KB | martin107 | |
Comments
Comment #1
dawehnerSo yeah the compile() method explicit tells about not returning anything. We could start using
@return void
to make that fact documented.Comment #2
martin107 CreditAttribution: martin107 commentedThat solution, I prefer....
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
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.
Comment #4
markdorisonComment #5
daffie CreditAttribution: daffie commentedThe 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.