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

Commit

Permalink
Merge branch 'feature/#62-allow-methodgenerator-set-return-type-when-…
Browse files Browse the repository at this point in the history
…rebuilding-from-array' into develop

Close #62
  • Loading branch information
Ocramius committed Sep 20, 2016
2 parents 3a9ec93 + 55dfafa commit da7ef15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Generator/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ public static function fromArray(array $array)
case 'visibility':
$method->setVisibility($value);
break;
case 'returntype':
$method->setReturnType($value);
break;
}
}

Expand Down Expand Up @@ -283,6 +286,14 @@ public function setReturnType($returnType = null)
return $this;
}

/**
* @return TypeGenerator|null
*/
public function getReturnType()
{
return $this->returnType;
}

/**
* @param bool $returnsReference
*
Expand Down
3 changes: 3 additions & 0 deletions test/Generator/MethodGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public function testCreateFromArray()
'final' => true,
'static' => true,
'visibility' => MethodGenerator::VISIBILITY_PROTECTED,
'returntype' => '\\SampleType',
]);

$this->assertEquals('SampleMethod', $methodGenerator->getName());
Expand All @@ -246,6 +247,8 @@ public function testCreateFromArray()
$this->assertTrue($methodGenerator->isFinal());
$this->assertTrue($methodGenerator->isStatic());
$this->assertEquals(MethodGenerator::VISIBILITY_PROTECTED, $methodGenerator->getVisibility());
$this->assertInstanceOf('Zend\Code\Generator\TypeGenerator', $methodGenerator->getReturnType());
$this->assertEquals('\\SampleType', $methodGenerator->getReturnType()->generate());
}

public function testCreateInterfaceMethodFromArray()
Expand Down

0 comments on commit da7ef15

Please sign in to comment.