Skip to content

Commit 5e94567

Browse files
committed
Update GV exporter, do not export attributes that are not "Stringable".
1 parent eeded27 commit 5e94567

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Exporter/Gv.php

+14-6
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,20 @@ public function setGraphAttributes(array $attributes): self
138138
*/
139139
protected function attributesArrayToText(array $attributes): string
140140
{
141-
$attributesText = array_map(
142-
static function ($key, $value) {
143-
return sprintf('%s="%s"', $key, $value);
144-
},
145-
array_keys($attributes),
146-
$attributes
141+
$attributesText = array_filter(
142+
array_map(
143+
static function ($key, $value) {
144+
if (null === $value || is_scalar($value) || method_exists($value, '__toString')) {
145+
$value = (string) $value;
146+
} else {
147+
return null;
148+
}
149+
150+
return sprintf('%s="%s"', $key, $value);
151+
},
152+
array_keys($attributes),
153+
$attributes
154+
)
147155
);
148156

149157
return '[' . implode(' ', $attributesText) . ']';

0 commit comments

Comments
 (0)