Problem/Motivation
TypeError: PNX\Prometheus\Metric::__construct(): Argument #3 ($help) must be of type string, Drupal\Core\StringTranslation\TranslatableMarkup given, called in /data/app/modules/contrib/prometheus_webform/src/Plugin/MetricsCollector/SubmissionsCollector.php on line 61 in PNX\Prometheus\Metric->__construct() (line 46 of /data/vendor/previousnext/php-prometheus/src/Metric.php).
Steps to reproduce
Proposed resolution
Cast $this->getDescription() to string. Arguably the constructor could be updated to accept string|\Stringable.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork prometheus_exporter-3473714
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Issue fork prometheus_webform-3473714
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3473714-typeerror
changes, plain diff MR !3
Comments
Comment #3
mstrelan commentedComment #4
acbramley commentedI think string|\Stringable makes the most sense here.
Comment #5
mstrelan commentedI'm not sure about #4.
PNX\Prometheus\Metriccan't do anything special with Stringable objects we pass to it, so it makes sense to limit it to only primitive strings. What if instead we cast to string in\Drupal\prometheus_exporter\Plugin\BaseMetricsCollector::getDescription? That would mean the existing return type in\Drupal\prometheus_exporter\Plugin\MetricsCollectorInterface::getDescriptionis valid and we don't have to mess around with types in multiple places.Comment #6
mstrelan commentedMoved to Prometheus Exporter queue since any Drupal solution would apply to more than just Prometheus Webform, and any library solution can be discussed there. Wonder what that will do with the existing issue fork.
Comment #9
mstrelan commentedBoth the label and description are usually FormattableMarkup objects, or sometimes strings. Let's leave the library to require strings and do the casting on the Drupal side.
Comment #10
acbramley commentedComment #12
acbramley commented