Skip to content

Commit

Permalink
minor #35786 Do not rely on the current locale when dumping a Graphvi…
Browse files Browse the repository at this point in the history
…z object (lyrixx)

This PR was merged into the 3.4 branch.

Discussion
----------

Do not rely on the current locale when dumping a Graphviz object

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

---

Funny bug !

With `de_DE.UTF-8` as locale:
```
php > echo sprintf('%s', 0.5);
0,5
php > echo sprintf('%d', 0.5);
0
php > echo sprintf('%f', 0.5);
0,500000
php > echo (string) 0.5;
0,5
```

(so external tools like graphviz could not parse `0,5` - and so skipped the arrow)

So now we force `'0.5'`

/cc @OskarStark

Commits
-------

094e4bb Do not rely on the current locale when dumping a Graphviz object
  • Loading branch information
nicolas-grekas committed Feb 19, 2020
2 parents 1c24ccc + 094e4bb commit 7225a01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -32,10 +32,11 @@ class GraphvizDumper extends Dumper
{
private $nodes;
private $edges;
// All values should be strings
private $options = [
'graph' => ['ratio' => 'compress'],
'node' => ['fontsize' => 11, 'fontname' => 'Arial', 'shape' => 'record'],
'edge' => ['fontsize' => 9, 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => 0.5],
'node' => ['fontsize' => '11', 'fontname' => 'Arial', 'shape' => 'record'],
'edge' => ['fontsize' => '9', 'fontname' => 'Arial', 'color' => 'grey', 'arrowhead' => 'open', 'arrowsize' => '0.5'],
'node.instance' => ['fillcolor' => '#9999ff', 'style' => 'filled'],
'node.definition' => ['fillcolor' => '#eeeeee'],
'node.missing' => ['fillcolor' => '#ff9999', 'style' => 'filled'],
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php
Expand Up @@ -26,10 +26,11 @@
*/
class GraphvizDumper implements DumperInterface
{
// All values should be strings
protected static $defaultOptions = [
'graph' => ['ratio' => 'compress', 'rankdir' => 'LR'],
'node' => ['fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'fillcolor' => 'lightblue', 'fixedsize' => true, 'width' => 1],
'edge' => ['fontsize' => 9, 'fontname' => 'Arial', 'color' => '#333333', 'arrowhead' => 'normal', 'arrowsize' => 0.5],
'node' => ['fontsize' => '9', 'fontname' => 'Arial', 'color' => '#333333', 'fillcolor' => 'lightblue', 'fixedsize' => '1', 'width' => '1'],
'edge' => ['fontsize' => '9', 'fontname' => 'Arial', 'color' => '#333333', 'arrowhead' => 'normal', 'arrowsize' => '0.5'],
];

/**
Expand Down

0 comments on commit 7225a01

Please sign in to comment.