Skip to content

Commit 22cf7f1

Browse files
author
Robin Geuze
committed
Fix some scrutinizer issues
1 parent 156ba28 commit 22cf7f1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/visitor/DefaultVisitor.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ public function visitMethod(PhpMethod $method) {
267267

268268
$this->writeParameters($method->getParameters());
269269
$this->writer->write(")");
270-
if ($this->returnTypeHints && false === strpos($method->getType(), '|')) {
271-
$this->writer->write(": {$method->getType()}");
272-
}
270+
$this->writeFunctionReturnType($method->getType());
273271

274272
if ($method->isAbstract() || $method->getParent() instanceof PhpInterface) {
275273
$this->writer->write(";\n\n");
@@ -308,10 +306,8 @@ public function visitFunction(PhpFunction $function) {
308306

309307
$this->writer->write("function {$function->getName()}(");
310308
$this->writeParameters($function->getParameters());
311-
$this->writer->write(")");
312-
if ($this->returnTypeHints && false === strpos($function->getType(), '|')) {
313-
$this->writer->write(": {$function->getType()}");
314-
}
309+
$this->writer->write(')');
310+
$this->writeFunctionReturnType($function->getType());
315311
$this->writer->write(" {\n")->indent()->writeln(trim($function->getBody()))->outdent()->rtrim()->write('}');
316312
}
317313

@@ -355,4 +351,10 @@ protected function writeParameters(array $parameters) {
355351
}
356352
}
357353
}
354+
355+
protected function writeFunctionReturnType($type) {
356+
if ($this->returnTypeHints && false === strpos($type, '|')) {
357+
$this->writer->write(': ')->write($type);
358+
}
359+
}
358360
}

0 commit comments

Comments
 (0)