Skip to content

Commit 87c11d3

Browse files
author
Marc J. Schmidt
committed
Fixed trait use in classes, added 'resource' to noHintTypes and
added addSimpleDescParameter allowing us to define parameter with description.
1 parent effa3c8 commit 87c11d3

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

src/model/parts/ParametersTrait.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ public function addSimpleParameter($name, $type = null, $defaultValue = null)
4343
return $this;
4444
}
4545

46+
/**
47+
* @param string $name
48+
* @param null|string $type
49+
* @param null|string $typeDescription
50+
* @param mixed $defaultValue omit the argument to define now default value
51+
*
52+
* @return $this
53+
*/
54+
public function addSimpleDescParameter($name, $type = null, $typeDescription = null, $defaultValue = null)
55+
{
56+
$parameter = new PhpParameter($name);
57+
$parameter->setType($type);
58+
$parameter->setTypeDescription($typeDescription);
59+
60+
if (3 < func_num_args()) {
61+
$parameter->setDefaultValue($defaultValue);
62+
}
63+
64+
$this->addParameter($parameter);
65+
return $this;
66+
}
67+
4668
/**
4769
*
4870
* @param string|integer $nameOrIndex

src/visitor/DefaultVisitor.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class DefaultVisitor implements GeneratorVisitorInterface {
4848
'float',
4949
'double',
5050
'object',
51-
'mixed'
51+
'mixed',
52+
'resource'
5253
];
5354

5455
public function __construct() {
@@ -121,8 +122,8 @@ private function visitDocblock(DocblockInterface $model) {
121122

122123
private function visitTraits(TraitsInterface $struct) {
123124
foreach ($struct->getTraits() as $trait) {
124-
$this->writer->write('uses ');
125-
$this->writer->writeln($trait);
125+
$this->writer->write('use ');
126+
$this->writer->writeln($trait . ';');
126127
}
127128
}
128129

@@ -322,7 +323,7 @@ private function writeParameters(array $parameters) {
322323
}
323324
$first = false;
324325

325-
if (($type = $parameter->getType()) && !in_array($type, self::$noTypeHints)) {
326+
if (false === strpos($parameter->getType(), '|') && ($type = $parameter->getType()) && !in_array($type, self::$noTypeHints)) {
326327
$this->writer->write($type . ' ');
327328
}
328329

0 commit comments

Comments
 (0)