We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eeded27 commit 5e94567Copy full SHA for 5e94567
1 file changed
src/Exporter/Gv.php
@@ -138,12 +138,20 @@ public function setGraphAttributes(array $attributes): self
138
*/
139
protected function attributesArrayToText(array $attributes): string
140
{
141
- $attributesText = array_map(
142
- static function ($key, $value) {
143
- return sprintf('%s="%s"', $key, $value);
144
- },
145
- array_keys($attributes),
146
- $attributes
+ $attributesText = array_filter(
+ array_map(
+ static function ($key, $value) {
+ if (null === $value || is_scalar($value) || method_exists($value, '__toString')) {
+ $value = (string) $value;
+ } else {
147
+ return null;
148
+ }
149
+
150
+ return sprintf('%s="%s"', $key, $value);
151
+ },
152
+ array_keys($attributes),
153
+ $attributes
154
+ )
155
);
156
157
return '[' . implode(' ', $attributesText) . ']';
0 commit comments