Skip to content
This repository was archived by the owner on Dec 29, 2020. It is now read-only.

Commit 6b28c41

Browse files
committed
Merge pull request #8 from mfn/param-without-type
converter: handle params in phpdoc without type declaration
2 parents feda240 + dede655 commit 6b28c41

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/Converter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ private function getType(Tag $tag): array
455455
{
456456
$type = $tag->getType();
457457

458+
if (null === $type) {
459+
// No type specified
460+
return [];
461+
}
462+
458463
if ($type instanceof Compound) {
459464
if ($type->has(2)) {
460465
// Several types, cannot guess

tests/Fixtures/param_no_type.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* @param $noType
4+
*/
5+
function param_no_type($noType)
6+
{
7+
}

tests/test.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,21 @@ public function baz(array $a, int $b): float
220220
}
221221
}
222222

223+
$projectFactory = ProjectFactory::createInstance();
224+
$project = $projectFactory->create('paramNoType', [__DIR__.'/Fixtures/param_no_type.php']);
225+
226+
foreach ($project->getFiles() as $path => $file) {
227+
same(<<<'PHP'
228+
<?php
229+
/**
230+
* @param $noType
231+
*/
232+
function param_no_type($noType)
233+
{
234+
}
235+
236+
PHP
237+
, $converter->convert($project, $file));
238+
}
239+
223240
echo 'Good job! Everything is fine.'.PHP_EOL;

0 commit comments

Comments
 (0)