Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit c71dcaf

Browse files
committed
bug #327 Fix type null for nullable type parameters not added as type (CharlotteDunois)
This PR was merged into the 4.0-dev branch. Discussion ---------- Fix type null for nullable type parameters not added as type I've started using PHP 7.1 nullable types and noticed, that Sami is not able to parse them. I saw the issue #264, but it does not fix the issue, at least not for parameters. For example `function setAvatar(?string $data)` will result in a type of `string`, and not `string|null` as expected. The PHP documentation for that element *is* `@param string|null $data`. This PR fixes this by adding the `null` type to the type array when resolving hints. Commits ------- ae635f6 Fix
2 parents dbbc169 + ae635f6 commit c71dcaf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sami/Parser/NodeVisitor.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,13 @@ protected function addMethod(ClassMethodNode $node)
180180
}
181181

182182
if (null !== $typeStr) {
183-
$parameter->setHint($this->resolveHint(array(array($typeStr, false))));
183+
$typeArr = array(array($typeStr, false));
184+
185+
if ($param->type instanceof NullableType) {
186+
$typeArr[] = array('null', false);
187+
}
188+
189+
$parameter->setHint($this->resolveHint($typeArr));
184190
}
185191

186192
$method->addParameter($parameter);

0 commit comments

Comments
 (0)