Skip to content

Commit 463c24c

Browse files
committed
Fix Windows builds.
1 parent a474424 commit 463c24c

File tree

6 files changed

+139
-121
lines changed

6 files changed

+139
-121
lines changed

.github/settings.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ labels:
3636
repository:
3737
allow_merge_commit: true
3838
allow_rebase_merge: false
39-
allow_squash_merge: false
39+
allow_squash_merge: true
4040
default_branch: master
4141
description: "An implementation of tree data structure"
4242
topics: tree,data-structure,binary-tree

.github/workflows/continuous-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
4747

4848
- name: Run Grumphp
49-
run: vendor/bin/grumphp run
49+
run: vendor/bin/grumphp run --no-ansi -n
5050
env:
5151
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
5252

spec/loophp/phptree/Exporter/AsciiSpec.php

+73-69
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use loophp\phptree\Exporter\Ascii;
88
use loophp\phptree\Node\ValueNode;
99
use PhpSpec\ObjectBehavior;
10+
use const PHP_EOL;
1011

1112
class AsciiSpec extends ObjectBehavior
1213
{
@@ -20,75 +21,78 @@ public function it_can_export_to_ascii(): void
2021

2122
$tree->add(...array_values($nodes));
2223

23-
$expected = <<<'EOF'
24-
├─ root
25-
└─┐
26-
├─┐
27-
│ ├─ A
28-
│ └─┐
29-
│ ├─┐
30-
│ │ ├─ C
31-
│ │ └─┐
32-
│ │ ├─┐
33-
│ │ │ ├─ G
34-
│ │ │ └─┐
35-
│ │ │ ├─┐
36-
│ │ │ │ └─ O
37-
│ │ │ └─┐
38-
│ │ │ └─ P
39-
│ │ └─┐
40-
│ │ ├─ H
41-
│ │ └─┐
42-
│ │ ├─┐
43-
│ │ │ └─ Q
44-
│ │ └─┐
45-
│ │ └─ R
46-
│ └─┐
47-
│ ├─ D
48-
│ └─┐
49-
│ ├─┐
50-
│ │ ├─ I
51-
│ │ └─┐
52-
│ │ ├─┐
53-
│ │ │ └─ S
54-
│ │ └─┐
55-
│ │ └─ T
56-
│ └─┐
57-
│ ├─ J
58-
│ └─┐
59-
│ ├─┐
60-
│ │ └─ U
61-
│ └─┐
62-
│ └─ V
63-
└─┐
64-
├─ B
65-
└─┐
66-
├─┐
67-
│ ├─ E
68-
│ └─┐
69-
│ ├─┐
70-
│ │ ├─ K
71-
│ │ └─┐
72-
│ │ ├─┐
73-
│ │ │ └─ W
74-
│ │ └─┐
75-
│ │ └─ X
76-
│ └─┐
77-
│ ├─ L
78-
│ └─┐
79-
│ ├─┐
80-
│ │ └─ Y
81-
│ └─┐
82-
│ └─ Z
83-
└─┐
84-
├─ F
85-
└─┐
86-
├─┐
87-
│ └─ M
88-
└─┐
89-
└─ N
90-
91-
EOF;
24+
$expected = implode(
25+
PHP_EOL,
26+
[
27+
'├─ root',
28+
'└─┐',
29+
' ├─┐',
30+
' │ ├─ A',
31+
' │ └─┐',
32+
' │ ├─┐',
33+
' │ │ ├─ C',
34+
' │ │ └─┐',
35+
' │ │ ├─┐',
36+
' │ │ │ ├─ G',
37+
' │ │ │ └─┐',
38+
' │ │ │ ├─┐',
39+
' │ │ │ │ └─ O',
40+
' │ │ │ └─┐',
41+
' │ │ │ └─ P',
42+
' │ │ └─┐',
43+
' │ │ ├─ H',
44+
' │ │ └─┐',
45+
' │ │ ├─┐',
46+
' │ │ │ └─ Q',
47+
' │ │ └─┐',
48+
' │ │ └─ R',
49+
' │ └─┐',
50+
' │ ├─ D',
51+
' │ └─┐',
52+
' │ ├─┐',
53+
' │ │ ├─ I',
54+
' │ │ └─┐',
55+
' │ │ ├─┐',
56+
' │ │ │ └─ S',
57+
' │ │ └─┐',
58+
' │ │ └─ T',
59+
' │ └─┐',
60+
' │ ├─ J',
61+
' │ └─┐',
62+
' │ ├─┐',
63+
' │ │ └─ U',
64+
' │ └─┐',
65+
' │ └─ V',
66+
' └─┐',
67+
' ├─ B',
68+
' └─┐',
69+
' ├─┐',
70+
' │ ├─ E',
71+
' │ └─┐',
72+
' │ ├─┐',
73+
' │ │ ├─ K',
74+
' │ │ └─┐',
75+
' │ │ ├─┐',
76+
' │ │ │ └─ W',
77+
' │ │ └─┐',
78+
' │ │ └─ X',
79+
' │ └─┐',
80+
' │ ├─ L',
81+
' │ └─┐',
82+
' │ ├─┐',
83+
' │ │ └─ Y',
84+
' │ └─┐',
85+
' │ └─ Z',
86+
' └─┐',
87+
' ├─ F',
88+
' └─┐',
89+
' ├─┐',
90+
' │ └─ M',
91+
' └─┐',
92+
' └─ N',
93+
'',
94+
]
95+
);
9296

9397
$this
9498
->export($tree)

spec/loophp/phptree/Exporter/GvSpec.php

+47-38
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use loophp\phptree\Node\AttributeNode;
99
use loophp\phptree\Node\ValueNode;
1010
use PhpSpec\ObjectBehavior;
11+
use const PHP_EOL;
1112

1213
class GvSpec extends ObjectBehavior
1314
{
@@ -54,52 +55,60 @@ public function it_can_export_to_dot_gv(): void
5455
'value' => $child4->getValue(),
5556
];
5657

57-
$result = <<<EOF
58-
digraph PHPTreeGraph {
59-
// The graph attributes.
60-
ratio = fill
61-
node [style="filled"]
58+
$result = implode(
59+
PHP_EOL,
60+
[
61+
'digraph PHPTreeGraph {',
62+
'// The graph attributes.',
63+
' ratio = fill',
64+
' node [style="filled"]',
65+
'',
66+
'// The graph nodes.',
67+
" \"{$nodes['root']['hash']}\" [label=\"{$nodes['root']['value']}\"]",
68+
" \"{$nodes['child1']['hash']}\" [label=\"{$nodes['child1']['value']}\"]",
69+
" \"{$nodes['child4']['hash']}\" [label=\"{$nodes['child4']['value']}\"]",
70+
" \"{$nodes['child2']['hash']}\" [label=\"{$nodes['child2']['value']}\"]",
71+
" \"{$nodes['child3']['hash']}\" [label=\"{$nodes['child3']['value']}\"]",
72+
'',
73+
'// The graph edges.',
74+
" \"{$nodes['root']['hash']}\" -> \"{$nodes['child1']['hash']}\";",
75+
" \"{$nodes['child1']['hash']}\" -> \"{$nodes['child4']['hash']}\";",
76+
" \"{$nodes['root']['hash']}\" -> \"{$nodes['child2']['hash']}\";",
77+
" \"{$nodes['root']['hash']}\" -> \"{$nodes['child3']['hash']}\";",
78+
'}',
79+
]
80+
);
6281

63-
// The graph nodes.
64-
"{$nodes['root']['hash']}" [label="{$nodes['root']['value']}"]
65-
"{$nodes['child1']['hash']}" [label="{$nodes['child1']['value']}"]
66-
"{$nodes['child4']['hash']}" [label="{$nodes['child4']['value']}"]
67-
"{$nodes['child2']['hash']}" [label="{$nodes['child2']['value']}"]
68-
"{$nodes['child3']['hash']}" [label="{$nodes['child3']['value']}"]
69-
70-
// The graph edges.
71-
"{$nodes['root']['hash']}" -> "{$nodes['child1']['hash']}";
72-
"{$nodes['child1']['hash']}" -> "{$nodes['child4']['hash']}";
73-
"{$nodes['root']['hash']}" -> "{$nodes['child2']['hash']}";
74-
"{$nodes['root']['hash']}" -> "{$nodes['child3']['hash']}";
75-
}
76-
EOF;
7782
$this
7883
->export($tree)
7984
->shouldReturn($result);
8085

8186
$this->setDirected(false);
8287

83-
$result = <<<EOF
84-
graph PHPTreeGraph {
85-
// The graph attributes.
86-
ratio = fill
87-
node [style="filled"]
88+
$result = implode(
89+
PHP_EOL,
90+
[
91+
'graph PHPTreeGraph {',
92+
'// The graph attributes.',
93+
' ratio = fill',
94+
' node [style="filled"]',
95+
'',
96+
'// The graph nodes.',
97+
" \"{$nodes['root']['hash']}\" [label=\"{$nodes['root']['value']}\"]",
98+
" \"{$nodes['child1']['hash']}\" [label=\"{$nodes['child1']['value']}\"]",
99+
" \"{$nodes['child4']['hash']}\" [label=\"{$nodes['child4']['value']}\"]",
100+
" \"{$nodes['child2']['hash']}\" [label=\"{$nodes['child2']['value']}\"]",
101+
" \"{$nodes['child3']['hash']}\" [label=\"{$nodes['child3']['value']}\"]",
102+
'',
103+
'// The graph edges.',
104+
" \"{$nodes['root']['hash']}\" -- \"{$nodes['child1']['hash']}\";",
105+
" \"{$nodes['child1']['hash']}\" -- \"{$nodes['child4']['hash']}\";",
106+
" \"{$nodes['root']['hash']}\" -- \"{$nodes['child2']['hash']}\";",
107+
" \"{$nodes['root']['hash']}\" -- \"{$nodes['child3']['hash']}\";",
108+
'}',
109+
]
110+
);
88111

89-
// The graph nodes.
90-
"{$nodes['root']['hash']}" [label="{$nodes['root']['value']}"]
91-
"{$nodes['child1']['hash']}" [label="{$nodes['child1']['value']}"]
92-
"{$nodes['child4']['hash']}" [label="{$nodes['child4']['value']}"]
93-
"{$nodes['child2']['hash']}" [label="{$nodes['child2']['value']}"]
94-
"{$nodes['child3']['hash']}" [label="{$nodes['child3']['value']}"]
95-
96-
// The graph edges.
97-
"{$nodes['root']['hash']}" -- "{$nodes['child1']['hash']}";
98-
"{$nodes['child1']['hash']}" -- "{$nodes['child4']['hash']}";
99-
"{$nodes['root']['hash']}" -- "{$nodes['child2']['hash']}";
100-
"{$nodes['root']['hash']}" -- "{$nodes['child3']['hash']}";
101-
}
102-
EOF;
103112
$this
104113
->export($tree)
105114
->shouldReturn($result);

spec/loophp/phptree/Exporter/ImageSpec.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function it_can_set_and_get_the_executable(): void
2323
{
2424
$this
2525
->getExecutable()
26-
->shouldBe('dot');
26+
->shouldContain('dot');
2727

2828
$this
2929
->setExecutable('foo')
@@ -55,6 +55,6 @@ public function it_is_initializable(): void
5555

5656
$this
5757
->getExecutable()
58-
->shouldReturn('dot');
58+
->shouldNotBeNull();
5959
}
6060
}

src/Exporter/Gv.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,21 @@ private function getGv(string $attributes = '', string $nodes = '', string $edge
192192
'digraph' :
193193
'graph';
194194

195-
return sprintf('%s PHPTreeGraph {
196-
// The graph attributes.
197-
%s
198-
199-
// The graph nodes.
200-
%s
201-
202-
// The graph edges.
203-
%s
204-
}', $graphType, $attributes, $nodes, $edges);
195+
return implode(
196+
PHP_EOL,
197+
[
198+
sprintf('%s PHPTreeGraph {', $graphType),
199+
'// The graph attributes.',
200+
$attributes,
201+
'',
202+
'// The graph nodes.',
203+
$nodes,
204+
'',
205+
'// The graph edges.',
206+
$edges,
207+
'}',
208+
]
209+
);
205210
}
206211

207212
/**

0 commit comments

Comments
 (0)