Skip to content

Commit

Permalink
Merge 3629dcb into be9bf28
Browse files Browse the repository at this point in the history
  • Loading branch information
afilina committed Feb 26, 2019
2 parents be9bf28 + 3629dcb commit 86db1d9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Mockery/Generator/Parameter.php
Expand Up @@ -48,7 +48,7 @@ public function getTypeHintAsString()
if ((version_compare(PHP_VERSION, '5.4.1') >= 0)) {
try {
if ($this->rfp->getClass()) {
return $this->getOptionalSign() . $this->rfp->getClass()->getName();
return $this->getOptionalSign() . '\\' . $this->rfp->getClass()->getName();
}
} catch (\ReflectionException $re) {
// noop
Expand Down
39 changes: 39 additions & 0 deletions tests/Mockery/Generator/ParameterTest.php
@@ -0,0 +1,39 @@
<?php

namespace Mockery\Generator;
{
class ParameterTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldReturnAbsoluteHintPathIfNamespaceProvided()
{
$rfp = new \ReflectionParameter(array('\TestSubjectNameSpace\TestSubject', 'foo'), 0);
$parameterGenerator = new Parameter($rfp);
$typeHint = $parameterGenerator->getTypeHintAsString();

$this->assertEquals('\TypeHintNameSpace\TypeHint', $typeHint);
}
}
}

namespace TypeHintNameSpace;
{
class TypeHint
{
}
}

namespace TestSubjectNameSpace;
use TypeHintNameSpace\TypeHint;
{
class TestSubject
{
public function foo(TypeHint $param)
{
}
}
}


0 comments on commit 86db1d9

Please sign in to comment.