X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fphpspec%2Fprophecy%2Fsrc%2FProphecy%2FDoubler%2FGenerator%2FNode%2FMethodNode.php;fp=vendor%2Fphpspec%2Fprophecy%2Fsrc%2FProphecy%2FDoubler%2FGenerator%2FNode%2FMethodNode.php;h=c74b48314d63ee0f0f3756c8ccd62995523c3f66;hp=71aabfa9401267ef3ac0d04e23e4d29abb414151;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/MethodNode.php b/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/MethodNode.php index 71aabfa94..c74b48314 100644 --- a/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/MethodNode.php +++ b/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/MethodNode.php @@ -11,6 +11,7 @@ namespace Prophecy\Doubler\Generator\Node; +use Prophecy\Doubler\Generator\TypeHintReference; use Prophecy\Exception\InvalidArgumentException; /** @@ -33,14 +34,20 @@ class MethodNode */ private $arguments = array(); + /** + * @var TypeHintReference + */ + private $typeHintReference; + /** * @param string $name * @param string $code */ - public function __construct($name, $code = null) + public function __construct($name, $code = null, TypeHintReference $typeHintReference = null) { $this->name = $name; $this->code = $code; + $this->typeHintReference = $typeHintReference ?: new TypeHintReference(); } public function getVisibility() @@ -112,38 +119,22 @@ class MethodNode */ public function setReturnType($type = null) { - switch ($type) { - case '': - $this->returnType = null; - break; - - case 'string'; - case 'float': - case 'int': - case 'bool': - case 'array': - case 'callable': - case 'iterable': - case 'void': - $this->returnType = $type; - break; - - case 'double': - case 'real': - $this->returnType = 'float'; - break; - - case 'boolean': - $this->returnType = 'bool'; - break; - - case 'integer': - $this->returnType = 'int'; - break; - - default: - $this->returnType = '\\' . ltrim($type, '\\'); + if ($type === '' || $type === null) { + $this->returnType = null; + return; + } + $typeMap = array( + 'double' => 'float', + 'real' => 'float', + 'boolean' => 'bool', + 'integer' => 'int', + ); + if (isset($typeMap[$type])) { + $type = $typeMap[$type]; } + $this->returnType = $this->typeHintReference->isBuiltInReturnTypeHint($type) ? + $type : + '\\' . ltrim($type, '\\'); } public function getReturnType()