14
14
namespace phpDocumentor \GraphViz ;
15
15
16
16
use InvalidArgumentException ;
17
+
17
18
use function array_merge ;
18
19
use function escapeshellarg ;
19
20
use function exec ;
26
27
use function sys_get_temp_dir ;
27
28
use function tempnam ;
28
29
use function unlink ;
30
+
29
31
use const DIRECTORY_SEPARATOR ;
30
32
use const PHP_EOL ;
31
33
@@ -78,7 +80,7 @@ class Graph
78
80
*
79
81
* @return Graph
80
82
*/
81
- public static function create (string $ name = 'G ' , bool $ directional = true ) : self
83
+ public static function create (string $ name = 'G ' , bool $ directional = true ): self
82
84
{
83
85
$ graph = new self ();
84
86
$ graph
@@ -93,7 +95,7 @@ public static function create(string $name = 'G', bool $directional = true) : se
93
95
*
94
96
* @param string $path The path to execute dot from
95
97
*/
96
- public function setPath (string $ path ) : self
98
+ public function setPath (string $ path ): self
97
99
{
98
100
$ realpath = realpath ($ path );
99
101
if ($ path && $ path === $ realpath ) {
@@ -111,7 +113,7 @@ public function setPath(string $path) : self
111
113
*
112
114
* @param string $name The new name for this graph.
113
115
*/
114
- public function setName (string $ name ) : self
116
+ public function setName (string $ name ): self
115
117
{
116
118
$ this ->name = $ name ;
117
119
@@ -121,7 +123,7 @@ public function setName(string $name) : self
121
123
/**
122
124
* Returns the name for this Graph.
123
125
*/
124
- public function getName () : string
126
+ public function getName (): string
125
127
{
126
128
return $ this ->name ;
127
129
}
@@ -134,7 +136,7 @@ public function getName() : string
134
136
* @throws InvalidArgumentException If $type is not "digraph", "graph" or
135
137
* "subgraph".
136
138
*/
137
- public function setType (string $ type ) : self
139
+ public function setType (string $ type ): self
138
140
{
139
141
if (!in_array ($ type , ['digraph ' , 'graph ' , 'subgraph ' ], true )) {
140
142
throw new InvalidArgumentException (
@@ -151,7 +153,7 @@ public function setType(string $type) : self
151
153
/**
152
154
* Returns the type of this Graph.
153
155
*/
154
- public function getType () : string
156
+ public function getType (): string
155
157
{
156
158
return $ this ->type ;
157
159
}
@@ -160,14 +162,14 @@ public function getType() : string
160
162
* Set if the Graph should be strict. If the graph is strict then
161
163
* multiple edges are not allowed between the same pairs of nodes
162
164
*/
163
- public function setStrict (bool $ isStrict ) : self
165
+ public function setStrict (bool $ isStrict ): self
164
166
{
165
167
$ this ->strict = $ isStrict ;
166
168
167
169
return $ this ;
168
170
}
169
171
170
- public function isStrict () : bool
172
+ public function isStrict (): bool
171
173
{
172
174
return $ this ->strict ;
173
175
}
@@ -215,7 +217,7 @@ public function __call(string $name, array $arguments)
215
217
* @param Graph $graph The graph to add onto this graph as
216
218
* subgraph.
217
219
*/
218
- public function addGraph (self $ graph ) : self
220
+ public function addGraph (self $ graph ): self
219
221
{
220
222
$ graph ->setType ('subgraph ' );
221
223
$ this ->graphs [$ graph ->getName ()] = $ graph ;
@@ -228,7 +230,7 @@ public function addGraph(self $graph) : self
228
230
*
229
231
* @param string $name Name of the graph to find.
230
232
*/
231
- public function hasGraph (string $ name ) : bool
233
+ public function hasGraph (string $ name ): bool
232
234
{
233
235
return isset ($ this ->graphs [$ name ]);
234
236
}
@@ -238,7 +240,7 @@ public function hasGraph(string $name) : bool
238
240
*
239
241
* @param string $name Name of the requested graph.
240
242
*/
241
- public function getGraph (string $ name ) : self
243
+ public function getGraph (string $ name ): self
242
244
{
243
245
return $ this ->graphs [$ name ];
244
246
}
@@ -253,7 +255,7 @@ public function getGraph(string $name) : self
253
255
*
254
256
* @param Node $node The node to set onto this Graph.
255
257
*/
256
- public function setNode (Node $ node ) : self
258
+ public function setNode (Node $ node ): self
257
259
{
258
260
$ this ->nodes [$ node ->getName ()] = $ node ;
259
261
@@ -265,7 +267,7 @@ public function setNode(Node $node) : self
265
267
*
266
268
* @param string $name Name of the node to find.
267
269
*/
268
- public function findNode (string $ name ) : ?Node
270
+ public function findNode (string $ name ): ?Node
269
271
{
270
272
if (isset ($ this ->nodes [$ name ])) {
271
273
return $ this ->nodes [$ name ];
@@ -289,7 +291,7 @@ public function findNode(string $name) : ?Node
289
291
* @param string $name Name of the node.
290
292
* @param Node $value Node to set on the given name.
291
293
*/
292
- public function __set (string $ name , Node $ value ) : void
294
+ public function __set (string $ name , Node $ value ): void
293
295
{
294
296
$ this ->nodes [$ name ] = $ value ;
295
297
}
@@ -301,7 +303,7 @@ public function __set(string $name, Node $value) : void
301
303
*
302
304
* @param string $name The name of the node to retrieve.
303
305
*/
304
- public function __get (string $ name ) : ?Node
306
+ public function __get (string $ name ): ?Node
305
307
{
306
308
return $ this ->nodes [$ name ] ?? null ;
307
309
}
@@ -313,7 +315,7 @@ public function __get(string $name) : ?Node
313
315
*
314
316
* @param Edge $edge The link between two classes.
315
317
*/
316
- public function link (Edge $ edge ) : self
318
+ public function link (Edge $ edge ): self
317
319
{
318
320
$ this ->edges [] = $ edge ;
319
321
@@ -334,7 +336,7 @@ public function link(Edge $edge) : self
334
336
*
335
337
* @throws Exception If an error occurred in GraphViz.
336
338
*/
337
- public function export (string $ type , string $ filename ) : self
339
+ public function export (string $ type , string $ filename ): self
338
340
{
339
341
$ type = escapeshellarg ($ type );
340
342
$ filename = escapeshellarg ($ filename );
@@ -368,7 +370,7 @@ public function export(string $type, string $filename) : self
368
370
* GraphViz is not used in this method; it is safe to call it even without
369
371
* GraphViz installed.
370
372
*/
371
- public function __toString () : string
373
+ public function __toString (): string
372
374
{
373
375
$ elements = array_merge (
374
376
$ this ->graphs ,
0 commit comments