Drupal.Semantics.FunctionTriggerError rule is not showing the full error message when it contains both __CLASS__ and __METHOD__
The class//method thing might not be the reason at all this goes wrong, but that is my guess looking at the actual trigger_error and the reported message.
FILE: core/modules/taxonomy/src/Entity/Term.php
------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------
276 | ERROR | The deprecation message '::bundle() instead to get the vocabulary ID.' does not match the standard format: %thing% is deprecated in %in-version%. %extra-info%. See %cr-link%
------------------------------------------------------------------------------
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3050697-3.concats_in_trigger_error.patch | 7.5 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 commentedThanks for spotting this. The code line in question is
I think an original assumption (may have been written somewhere as a guide) is that the text would cater for one concatenation at the start of the message, such as __NAMESPACE__, but the rest of the message would be in one string. But clearly that is not going to be adequate, as this example demonstrates.
It should not be too difficult to allow constants within the message. I don't see any need to evaluate (or even verify) the actual constants, just cater for them when building up the entire string to check.
Comment #3
jonathan1055 commentedWhen the message is made with sprintf() when we use ->findnext to get the string as before. But now, in all other cases we need to build up the message to check from all the parts within the argument 'start' and 'end', i.e. including concatenated strings and constants. This adds one small complication in that quotes around the strings become embedded as part of the message (and cause incorrect standards messages). So we remove the quotes and adjust the regex not to expect quotes at the start and end.
Using the example above, the output is now:
Here's a patch for review, with adjusted test data, but I will alos create a pull request on github.
Comment #4
jonathan1055 commentedHere is the PR https://github.com/pfrenssen/coder/pull/38
Comment #6
klausiThanks, committed!