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

Command icon 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:

Command icon 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:

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
acbramley’s picture

Status: Needs review » Needs work

I think string|\Stringable makes the most sense here.

mstrelan’s picture

I'm not sure about #4. PNX\Prometheus\Metric can'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::getDescription is valid and we don't have to mess around with types in multiple places.

mstrelan’s picture

Project: Prometheus Webform » Prometheus Exporter

Moved 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.

mstrelan changed the visibility of the branch 3473714-typeerror to hidden.

mstrelan’s picture

Version: 1.0.x-dev » 2.x-dev
Status: Needs work » Needs review

Both 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.

acbramley’s picture

acbramley’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.