I am being prompted by the following lint error
Method __toString is not implemented for the following objects. .... \Drupal\Core\Database\Query\SelectInterface
This is a child issue of #2344799: [Meta issue] Clear _toString is not implemented errors.
The idea is that we must enforce a __toString() method on all objects implementing
\Drupal\Core\Database\Query\SelectInterface
outputting a representation as a string is fundamental to how the query select in used.
This to my mind is a reasonable nit-picky improvement that not only clears a "Probably a bug" lint error, but is a DX thing as it will prompt developers into doing the right thing, quickly and all of the time.
Beta phase evaluation
Issue category | Bug because it's a documentation error. |
---|---|
Issue priority | Normal because nothing is broken other than docs. |
Unfrozen changes | Unfrozen because it documents an interface. |
Prioritized changes | Prioritized because it improves DX. |
Comment | File | Size | Author |
---|---|---|---|
#4 | select-2344831-4.patch | 1.05 KB | martin107 |
#2 | select-2344831-2.patch | 622 bytes | martin107 |
select-0.patch | 598 bytes | martin107 | |
Comments
Comment #1
tstoecklerI don't think it's too late for this. As you say the method is already de facto required because we use
(string) $query
, so I don't see how you could use a query that doesn't have it. Enforcing this on the method is more a matter of documentation than an actual API change. I would even suggest backporting this.I think the comment could be improved a bit to mention that the "string representation" of the query is the query itself, i.e. how it will be executed in SQL. also there should be a blank line after the method before the closing brace.
Comment #2
martin107 CreditAttribution: martin107 commentedI agree... thanks for the prompt reply... next iteration is less recursive, and to my eyes does read better.
Comment #3
Mile23Drupal\Core\Database\Query\Select
implements_toString()
and documents it as{@inheritdoc}
, so I'd say this is a good idea.However, the patch doesn't apply.
Comment #4
martin107 CreditAttribution: martin107 commentedRerolled and I have added an inheritdoc to SelectExtender.php
Plus fixed some of my broken english in the issue summary.
Comment #5
martin107 CreditAttribution: martin107 commentedWhile working on #4 I noticed SelectExtender was missing an @inheritdoc or ... two
So I opened an issue for that
Comment #6
jhodgdonThis seems perfectly reasonable to me.
Comment #8
jhodgdonSome random test failure.
Comment #9
webchickCommitted and pushed to 8.0.x. Thanks!