Skip to content

Commit 6e86a5b

Browse files
committed
Dumper: refactoring
1 parent 2402e8a commit 6e86a5b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/PhpGenerator/Dumper.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ public function format(string $statement, ...$args): string
192192
: $tmp;
193193

194194
} else { // $ -> ::
195-
$res .= substr($token, 0, -1) . $this->formatMember(array_shift($args));
195+
$arg = array_shift($args);
196+
if ($arg instanceof PhpLiteral || !Helpers::isIdentifier($arg)) {
197+
$arg = '{' . $this->dumpVar($arg) . '}';
198+
}
199+
$res .= substr($token, 0, -1) . $arg;
196200
}
197201
}
198202
if ($args) {
@@ -202,17 +206,6 @@ public function format(string $statement, ...$args): string
202206
}
203207

204208

205-
/**
206-
* Returns a PHP representation of a object member.
207-
*/
208-
private function formatMember($name): string
209-
{
210-
return $name instanceof PhpLiteral || !Helpers::isIdentifier($name)
211-
? '{' . $this->dumpVar($name) . '}'
212-
: $name;
213-
}
214-
215-
216209
/**
217210
* @return object
218211
* @internal

0 commit comments

Comments
 (0)