Skip to content

Loading…

[WIP][Server] Rewrite Reflection API to reuse code from Zend\Code\Reflection API #2868

Closed
wants to merge 2 commits into from

2 participants

@Maks3w
Zend Framework member

No description provided.

@Maks3w Maks3w commented on an outdated diff
library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php
@@ -47,16 +47,16 @@ public function getName()
public function initialize($tagDocBlockLine)
{
$matches = array();
- preg_match('#([\w|\\\]+)(?:\s+(\$\S+)){0,1}(?:\s+(.*))?#s', $tagDocBlockLine, $matches);
+ preg_match('#([\w|\\\]+(\[\])*)(?:\s+(\$\S+)){0,1}(?:\s+(.*))?#s', $tagDocBlockLine, $matches);
@Maks3w Zend Framework member
Maks3w added a note

Add support for typed arrays like string[] or Object[][]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/Soap/AutoDiscoverTest.php
@@ -685,7 +685,7 @@ public function testNoReturnIsOneWayCallInSetClass()
$wsdl = $autodiscover->toXml();
$this->assertContains(
- '<operation name="pushOneWay"><documentation>@param string $message</documentation><input message="tns:pushOneWayIn"/></operation>',
+ '<operation name="pushOneWay"><documentation>pushOneWay</documentation><input message="tns:pushOneWayIn"/></operation>',
@Maks3w Zend Framework member
Maks3w added a note

If not description is present in the docblock then return the name of the function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney added a commit that referenced this pull request
@weierophinney weierophinney [#2868] Fix some libxml test failures
- XmlRpc needed testing as it relies on Zend\Server\Reflection. Changes
  in recent versions of PHPUnit have made it more greedy with regards to
  warnings, which led to new test failures. The changes introduced make
  the component more resilient.
28b11a7
@Maks3w
Zend Framework member

@weierophinney Why not merge this to master too? I tried to preserve the BC

@weierophinney
Zend Framework member
@ghost Unknown pushed a commit that referenced this pull request
@weierophinney weierophinney [#2868] Fix some libxml test failures
- XmlRpc needed testing as it relies on Zend\Server\Reflection. Changes
  in recent versions of PHPUnit have made it more greedy with regards to
  warnings, which led to new test failures. The changes introduced make
  the component more resilient.
f71bee5
@ghost Unknown pushed a commit that referenced this pull request
@weierophinney weierophinney Merge branch 'feature/server-refactor' into develop
Close #2868
8acefa7
@weierophinney weierophinney referenced this pull request
Commit has since been removed from the repository and is no longer available.
@weierophinney weierophinney added a commit to zendframework/zend-xmlrpc that referenced this pull request
@weierophinney weierophinney [zendframework/zf2#2868] Fix some libxml test failures
- XmlRpc needed testing as it relies on Zend\Server\Reflection. Changes
  in recent versions of PHPUnit have made it more greedy with regards to
  warnings, which led to new test failures. The changes introduced make
  the component more resilient.
59cea2b
@weierophinney weierophinney added a commit to zendframework/zend-xmlrpc that referenced this pull request
@weierophinney weierophinney Merge branch 'feature/server-refactor' into develop ef8261e
@weierophinney weierophinney added a commit to zendframework/zend-server that referenced this pull request
@weierophinney weierophinney [zendframework/zf2#2868] Fix some libxml test failures
- XmlRpc needed testing as it relies on Zend\Server\Reflection. Changes
  in recent versions of PHPUnit have made it more greedy with regards to
  warnings, which led to new test failures. The changes introduced make
  the component more resilient.
3b4ff4d
@weierophinney weierophinney added a commit to zendframework/zend-server that referenced this pull request
@weierophinney weierophinney Merge branch 'feature/server-refactor' into develop 9fd25c9
@weierophinney weierophinney added a commit to zendframework/zend-soap that referenced this pull request
@weierophinney weierophinney Merge branch 'feature/server-refactor' into develop 5f406b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2012
  1. @Maks3w
  2. @Maks3w

    [Server] Reuse code from Zend\Code

    Maks3w committed
    Also remove underscore preffix from methods name
This page is out of date. Refresh to see the latest.
View
22 library/Zend/Code/Reflection/DocBlock/Tag/MethodTag.php
@@ -14,14 +14,14 @@
* @category Zend
* @package Zend_Reflection
*/
-class MethodTag implements TagInterface
+class MethodTag implements TagInterface, PhpDocTypedTagInterface
{
/**
* Return value type
*
- * @var string
+ * @var array
*/
- protected $returnType = null;
+ protected $types = array();
/**
* Method name
@@ -67,7 +67,7 @@ public function initialize($tagDocblockLine)
}
if ($match[2] !== '') {
- $this->returnType = rtrim($match[2]);
+ $this->types = explode('|', rtrim($match[2]));
}
$this->methodName = $match[3];
@@ -81,11 +81,21 @@ public function initialize($tagDocblockLine)
/**
* Get return value type
*
- * @return string
+ * @return null|string
+ * @deprecated 2.0.4 use getTypes instead
*/
public function getReturnType()
{
- return $this->returnType;
+ if (empty($this->types)) {
+ return null;
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
}
/**
View
22 library/Zend/Code/Reflection/DocBlock/Tag/ParamTag.php
@@ -14,12 +14,12 @@
* @category Zend
* @package Zend_Reflection
*/
-class ParamTag implements TagInterface
+class ParamTag implements TagInterface, PhpDocTypedTagInterface
{
/**
- * @var string
+ * @var array
*/
- protected $type = null;
+ protected $types = array();
/**
* @var string
@@ -47,9 +47,9 @@ public function getName()
public function initialize($tagDocBlockLine)
{
$matches = array();
- preg_match('#([\w|\\\]+)(?:\s+(\$\S+)){0,1}(?:\s+(.*))?#s', $tagDocBlockLine, $matches);
+ preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocBlockLine, $matches);
- $this->type = $matches[1];
+ $this->types = explode('|', $matches[1]);
if (isset($matches[2])) {
$this->variableName = $matches[2];
@@ -64,10 +64,20 @@ public function initialize($tagDocBlockLine)
* Get parameter variable type
*
* @return string
+ * @deprecated 2.0.4 use getTypes instead
*/
public function getType()
{
- return $this->type;
+ if (empty($this->types)) {
+ return '';
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
}
/**
View
21 library/Zend/Code/Reflection/DocBlock/Tag/PhpDocTypedTagInterface.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Code
+ */
+
+namespace Zend\Code\Reflection\DocBlock\Tag;
+
+interface PhpDocTypedTagInterface
+{
+ /**
+ * Return all types supported by the tag definition
+ *
+ * @return string[]
+ */
+ public function getTypes();
+}
View
20 library/Zend/Code/Reflection/DocBlock/Tag/PropertyTag.php
@@ -14,12 +14,12 @@
* @category Zend
* @package Zend_Reflection
*/
-class PropertyTag implements TagInterface
+class PropertyTag implements TagInterface, PhpDocTypedTagInterface
{
/**
- * @var string
+ * @var array
*/
- protected $type = null;
+ protected $types = array();
/**
* @var string
@@ -48,7 +48,7 @@ public function initialize($tagDocblockLine)
{
if (preg_match('#^(.+)?(\$[\S]+)[\s]*(.*)$#m', $tagDocblockLine, $match)) {
if ($match[1] !== '') {
- $this->type = rtrim($match[1]);
+ $this->types = explode('|', rtrim($match[1]));
}
if ($match[2] !== '') {
@@ -65,10 +65,20 @@ public function initialize($tagDocblockLine)
* Get property variable type
*
* @return null|string
+ * @deprecated 2.0.4 use getTypes instead
*/
public function getType()
{
- return $this->type;
+ if (empty($this->types)) {
+ return null;
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
}
/**
View
24 library/Zend/Code/Reflection/DocBlock/Tag/ReturnTag.php
@@ -14,12 +14,12 @@
* @category Zend
* @package Zend_Reflection
*/
-class ReturnTag implements TagInterface
+class ReturnTag implements TagInterface, PhpDocTypedTagInterface
{
/**
- * @var string
+ * @var array
*/
- protected $type = null;
+ protected $types = array();
/**
* @var string
@@ -41,12 +41,12 @@ public function getName()
public function initialize($tagDocBlockLine)
{
$matches = array();
- preg_match('#([\w|\\\]+)(?:\s+(.*))?#', $tagDocBlockLine, $matches);
+ preg_match('#((?:[\w|\\\]+(?:\[\])*\|?)+)(?:\s+(.*))?#s', $tagDocBlockLine, $matches);
- $this->type = $matches[1];
+ $this->types = explode('|', $matches[1]);
if (isset($matches[2])) {
- $this->description = $matches[2];
+ $this->description = trim(preg_replace('#\s+#', ' ', $matches[2]));
}
}
@@ -54,10 +54,20 @@ public function initialize($tagDocBlockLine)
* Get return variable type
*
* @return string
+ * @deprecated 2.0.4 use getTypes instead
*/
public function getType()
{
- return $this->type;
+ if (empty($this->types)) {
+ return '';
+ }
+
+ return $this->types[0];
+ }
+
+ public function getTypes()
+ {
+ return $this->types;
}
public function getDescription()
View
73 library/Zend/Code/Reflection/DocBlock/Tag/ThrowsTag.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Code
+ */
+
+namespace Zend\Code\Reflection\DocBlock\Tag;
+
+/**
+ * @category Zend
+ * @package Zend_Reflection
+ */
+class ThrowsTag implements TagInterface, PhpDocTypedTagInterface
+{
+ /**
+ * @var string
+ */
+ protected $type = null;
+
+ /**
+ * @var string
+ */
+ protected $description = null;
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return 'throws';
+ }
+
+ /**
+ * @param string $tagDocBlockLine
+ * @return void
+ */
+ public function initialize($tagDocBlockLine)
+ {
+ $matches = array();
+ preg_match('#([\w|\\\]+)(?:\s+(.*))?#', $tagDocBlockLine, $matches);
+
+ $this->type = $matches[1];
+
+ if (isset($matches[2])) {
+ $this->description = $matches[2];
+ }
+ }
+
+ /**
+ * Get return variable type
+ *
+ * @return string
+ * @deprecated 2.0.4 use getTypes instead
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function getTypes()
+ {
+ return array($this->type);
+ }
+
+ public function getDescription()
+ {
+ return $this->description;
+ }
+}
View
1 library/Zend/Code/Reflection/DocBlock/TagManager.php
@@ -37,6 +37,7 @@ public function useDefaultPrototypes()
$this->addTagPrototype(new Tag\ReturnTag());
$this->addTagPrototype(new Tag\MethodTag());
$this->addTagPrototype(new Tag\PropertyTag());
+ $this->addTagPrototype(new Tag\ThrowsTag());
$this->addTagPrototype(new Tag\GenericTag());
}
View
156 library/Zend/Server/Reflection/AbstractFunction.php
@@ -10,6 +10,9 @@
namespace Zend\Server\Reflection;
+use ReflectionFunctionAbstract;
+use Zend\Code\Reflection\DocBlockReflection;
+
/**
* Function/Method Reflection
*
@@ -79,22 +82,14 @@
/**
* Constructor
*
- * @param \Reflector $r
+ * @param ReflectionFunctionAbstract $r
* @param null|string $namespace
* @param null|array $argv
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
- public function __construct(\Reflector $r, $namespace = null, $argv = array())
+ public function __construct(ReflectionFunctionAbstract $r, $namespace = null, $argv = array())
{
- // In PHP 5.1.x, ReflectionMethod extends ReflectionFunction. In 5.2.x,
- // both extend ReflectionFunctionAbstract. So, we can't do normal type
- // hinting in the prototype, but instead need to do some explicit
- // testing here.
- if ((!$r instanceof \ReflectionFunction)
- && (!$r instanceof \ReflectionMethod)) {
- throw new Exception\InvalidArgumentException('Invalid reflection class');
- }
$this->reflection = $r;
// Determine namespace
@@ -113,7 +108,7 @@ public function __construct(\Reflector $r, $namespace = null, $argv = array())
}
// Perform some introspection
- $this->_reflect();
+ $this->reflect();
}
/**
@@ -127,7 +122,7 @@ public function __construct(\Reflector $r, $namespace = null, $argv = array())
* @param int $level
* @return void
*/
- protected function _addTree(Node $parent, $level = 0)
+ protected function addTree(Node $parent, $level = 0)
{
if ($level >= $this->sigParamsDepth) {
return;
@@ -136,7 +131,7 @@ protected function _addTree(Node $parent, $level = 0)
foreach ($this->sigParams[$level] as $value) {
$node = new Node($value, $parent);
if ((null !== $value) && ($this->sigParamsDepth > $level + 1)) {
- $this->_addTree($node, $level + 1);
+ $this->addTree($node, $level + 1);
}
}
}
@@ -150,12 +145,12 @@ protected function _addTree(Node $parent, $level = 0)
*
* @return array
*/
- protected function _buildTree()
+ protected function buildTree()
{
$returnTree = array();
- foreach ((array) $this->return as $value) {
+ foreach ($this->return as $value) {
$node = new Node($value);
- $this->_addTree($node);
+ $this->addTree($node);
$returnTree[] = $node;
}
@@ -174,15 +169,15 @@ protected function _buildTree()
* @param array $paramDesc Array of parameter descriptions
* @return array
*/
- protected function _buildSignatures($return, $returnDesc, $paramTypes, $paramDesc)
+ protected function buildSignatures($return, $returnDesc, $paramTypes, $paramDesc)
{
$this->return = $return;
$this->returnDesc = $returnDesc;
$this->paramDesc = $paramDesc;
$this->sigParams = $paramTypes;
$this->sigParamsDepth = count($paramTypes);
- $signatureTrees = $this->_buildTree();
- $signatures = array();
+ $signatureTrees = $this->buildTree();
+ $signatures = array();
$endPoints = array();
foreach ($signatureTrees as $root) {
@@ -233,93 +228,61 @@ protected function _buildSignatures($return, $returnDesc, $paramTypes, $paramDes
* @throws Exception\RuntimeException
* @return array
*/
- protected function _reflect()
+ protected function reflect()
{
- $function = $this->reflection;
- $helpText = '';
- $signatures = array();
- $returnDesc = '';
- $paramCount = $function->getNumberOfParameters();
- $paramCountRequired = $function->getNumberOfRequiredParameters();
- $parameters = $function->getParameters();
- $docBlock = $function->getDocComment();
-
- if (!empty($docBlock)) {
- // Get help text
- if (preg_match(':/\*\*\s*\r?\n\s*\*\s(.*?)\r?\n\s*\*(\s@|/):s', $docBlock, $matches)) {
- $helpText = $matches[1];
- $helpText = preg_replace('/(^\s*\*\s)/m', '', $helpText);
- $helpText = preg_replace('/\r?\n\s*\*\s*(\r?\n)*/s', "\n", $helpText);
- $helpText = trim($helpText);
+ $function = $this->reflection;
+ $paramCount = $function->getNumberOfParameters();
+ $parameters = $function->getParameters();
+ $scanner = new DocBlockReflection(($function->getDocComment()) ? : '/***/');
+ $helpText = $scanner->getLongDescription();
+ /* @var \Zend\Code\Reflection\DocBlock\Tag\ParamTag[] $paramTags */
+ $paramTags = $scanner->getTags('param');
+ /* @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnTag */
+ $returnTag = $scanner->getTag('return');
+
+ if (empty($helpText)) {
+ $helpText = $scanner->getShortDescription();
+ if (empty($helpText)) {
+ $helpText = $function->getName();
}
+ }
+ $this->setDescription($helpText);
- // Get return type(s) and description
- $return = 'void';
- if (preg_match('/@return\s+(\S+)/', $docBlock, $matches)) {
- $return = explode('|', $matches[1]);
- if (preg_match('/@return\s+\S+\s+(.*?)(@|\*\/)/s', $docBlock, $matches)) {
- $value = $matches[1];
- $value = preg_replace('/\s?\*\s/m', '', $value);
- $value = preg_replace('/\s{2,}/', ' ', $value);
- $returnDesc = trim($value);
- }
+ if ($returnTag) {
+ $return = array();
+ $returnDesc = $returnTag->getDescription();
+ foreach ($returnTag->getTypes() as $type) {
+ $return[] = $type;
}
+ } else {
+ $return = array('void');
+ $returnDesc = '';
+ }
- // Get param types and description
- if (preg_match_all('/@param\s+([^\s]+)/m', $docBlock, $matches)) {
- $paramTypesTmp = $matches[1];
- if (preg_match_all('/@param\s+\S+\s+(\$\S+)\s+(.*?)(?=@|\*\/)/s', $docBlock, $matches)) {
- $paramDesc = $matches[2];
- foreach ($paramDesc as $key => $value) {
- $value = preg_replace('/\s?\*\s/m', '', $value);
- $value = preg_replace('/\s{2,}/', ' ', $value);
- $paramDesc[$key] = trim($value);
- }
- }
+ $paramTypesTmp = array();
+ $paramDesc = array();
+ if (empty($paramTags)) {
+ foreach ($parameters as $param) {
+ $paramTypesTmp[] = array(($param->isArray()) ? 'array' : 'mixed');
+ $paramDesc[] = '';
}
} else {
- $helpText = $function->getName();
- $return = 'void';
-
- // Try and auto-determine type, based on reflection
- $paramTypesTmp = array();
- foreach ($parameters as $i => $param) {
- $paramType = 'mixed';
- if ($param->isArray()) {
- $paramType = 'array';
- }
- $paramTypesTmp[$i] = $paramType;
+ $paramDesc = array();
+ foreach ($paramTags as $paramTag) {
+ $paramTypesTmp[] = $paramTag->getTypes();
+ $paramDesc[] = ($paramTag->getDescription()) ? : '';
}
}
- // Set method description
- $this->setDescription($helpText);
-
// Get all param types as arrays
- if (!isset($paramTypesTmp) && (0 < $paramCount)) {
- $paramTypesTmp = array_fill(0, $paramCount, 'mixed');
- } elseif (!isset($paramTypesTmp)) {
- $paramTypesTmp = array();
- } elseif (count($paramTypesTmp) < $paramCount) {
- $start = $paramCount - count($paramTypesTmp);
- for ($i = $start; $i < $paramCount; ++$i) {
- $paramTypesTmp[$i] = 'mixed';
- }
- }
-
- // Get all param descriptions as arrays
- if (!isset($paramDesc) && (0 < $paramCount)) {
- $paramDesc = array_fill(0, $paramCount, '');
- } elseif (!isset($paramDesc)) {
- $paramDesc = array();
- } elseif (count($paramDesc) < $paramCount) {
- $start = $paramCount - count($paramDesc);
+ $nParamTypesTmp = count($paramTypesTmp);
+ if ($nParamTypesTmp < $paramCount) {
+ $start = $paramCount - $nParamTypesTmp;
for ($i = $start; $i < $paramCount; ++$i) {
- $paramDesc[$i] = '';
+ $paramTypesTmp[$i] = array('mixed');
+ $paramDesc[$i] = '';
}
- }
-
- if (count($paramTypesTmp) != $paramCount) {
+ } elseif ($nParamTypesTmp != $paramCount) {
throw new Exception\RuntimeException(
'Variable number of arguments is not supported for services (except optional parameters). '
. 'Number of function arguments must correspond to actual number of arguments described in a docblock.');
@@ -327,14 +290,13 @@ protected function _reflect()
$paramTypes = array();
foreach ($paramTypesTmp as $i => $param) {
- $tmp = explode('|', $param);
if ($parameters[$i]->isOptional()) {
- array_unshift($tmp, null);
+ array_unshift($param, null);
}
- $paramTypes[] = $tmp;
+ $paramTypes[] = $param;
}
- $this->_buildSignatures($return, $returnDesc, $paramTypes, $paramDesc);
+ $this->buildSignatures($return, $returnDesc, $paramTypes, $paramDesc);
}
View
2 library/Zend/Server/Reflection/ReflectionMethod.php
@@ -62,7 +62,7 @@ public function __construct(ReflectionClass $class, \ReflectionMethod $r, $names
$this->class = $class->getName();
// Perform some introspection
- $this->_reflect();
+ $this->reflect();
}
/**
View
3 library/Zend/Server/composer.json
@@ -14,6 +14,7 @@
"target-dir": "Zend/Server",
"require": {
"php": ">=5.3.3",
- "zendframework/zend-stdlib": "self.version"
+ "zendframework/zend-stdlib": "self.version",
+ "zendframework/zend-code": "self.version"
}
}
View
3 tests/ZendTest/Code/Reflection/DocBlock/Tag/MethodTagTest.php
@@ -35,11 +35,12 @@ public function testParseName()
public function testParseNameAndType()
{
$tag = new MethodTag();
- $tag->initialize('string test()');
+ $tag->initialize('string|null test()');
$this->assertEquals('method', $tag->getName());
$this->assertEquals('test()', $tag->getMethodName());
$this->assertFalse($tag->isStatic());
$this->assertEquals('string', $tag->getReturnType());
+ $this->assertEquals(array('string', 'null'), $tag->getTypes());
$this->assertNull($tag->getDescription());
}
View
3 tests/ZendTest/Code/Reflection/DocBlock/Tag/PropertyTagTest.php
@@ -34,10 +34,11 @@ public function testParseName()
public function testParseTypeAndName()
{
$tag = new PropertyTag();
- $tag->initialize('string $test');
+ $tag->initialize('string|null $test');
$this->assertEquals('$test', $tag->getPropertyName());
$this->assertNull($tag->getDescription());
$this->assertEquals('string', $tag->getType());
+ $this->assertEquals(array('string', 'null'), $tag->getTypes());
}
public function testParseNameAndDescription()
View
49 tests/ZendTest/Code/Reflection/DocBlockReflectionTest.php
@@ -11,6 +11,7 @@
namespace ZendTest\Code\Reflection;
use Zend\Code\Reflection\ClassReflection;
+use Zend\Code\Reflection\DocBlockReflection;
/**
* @category Zend
@@ -120,4 +121,52 @@ public function testToString()
$this->assertEquals($expectedString, (string)$classDocBlock);
}
+
+ public function testFunctionDocBlockTags()
+ {
+ $docblock = '
+ /**
+ * Method ShortDescription
+ *
+ * @param int $one Description for one
+ * @param int[] Description for two
+ * @param string|null $three Description for three
+ * which spans multiple lines
+ * @return int[]|null Description
+ * @throws Exception
+ */
+';
+
+ $docblockReflection = new DocBlockReflection($docblock);
+
+ $paramTags = $docblockReflection->getTags('param');
+
+ $this->assertEquals(5, count($docblockReflection->getTags()));
+ $this->assertEquals(3, count($paramTags));
+ $this->assertEquals(1, count($docblockReflection->getTags('return')));
+ $this->assertEquals(1, count($docblockReflection->getTags('throws')));
+
+ $returnTag = $docblockReflection->getTag('return');
+ $this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\ReturnTag', $returnTag);
+ $this->assertEquals('int[]', $returnTag->getType());
+ $this->assertEquals(array('int[]', 'null'), $returnTag->getTypes());
+ $this->assertEquals('Description', $returnTag->getDescription());
+
+ $throwsTag = $docblockReflection->getTag('throws');
+ $this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\ThrowsTag', $throwsTag);
+ $this->assertEquals('Exception', $throwsTag->getType());
+
+ $paramTag = $paramTags[0];
+ $this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\ParamTag', $paramTag);
+ $this->assertEquals('int', $paramTag->getType());
+
+ $paramTag = $paramTags[1];
+ $this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\ParamTag', $paramTag);
+ $this->assertEquals('int[]', $paramTag->getType());
+
+ $paramTag = $paramTags[2];
+ $this->assertInstanceOf('Zend\Code\Reflection\DocBlock\Tag\ParamTag', $paramTag);
+ $this->assertEquals('string', $paramTag->getType());
+ $this->assertEquals(array('string', 'null'), $paramTag->getTypes());
+ }
}
View
13 tests/ZendTest/Server/Reflection/ReflectionFunctionTest.php
@@ -41,16 +41,6 @@ public function test__construct()
$this->assertTrue(0 < count($prototypes));
}
- public function testConstructorThrowsExceptionOnNonFunction()
- {
- $function = new \ReflectionFunction('\ZendTest\Server\Reflection\function1');
- $r = new Reflection\ReflectionFunction($function);
- $params = $r->getParameters();
-
- $this->setExpectedException('Zend\Server\Reflection\Exception\InvalidArgumentException', 'Invalid reflection class');
- $r = new Reflection\ReflectionFunction($params[0]);
- }
-
public function test__getSet()
{
$function = new \ReflectionFunction('\ZendTest\Server\Reflection\function1');
@@ -85,8 +75,7 @@ public function testGetPrototypes()
$r = new Reflection\ReflectionFunction($function);
$prototypes = $r->getPrototypes();
- $this->assertTrue(is_array($prototypes));
- $this->assertTrue(0 < count($prototypes));
+ $this->assertInternalType('array', $prototypes);
$this->assertEquals(8, count($prototypes));
foreach ($prototypes as $p) {
View
4 tests/ZendTest/Soap/AutoDiscoverTest.php
@@ -685,7 +685,7 @@ public function testNoReturnIsOneWayCallInSetClass()
$wsdl = $autodiscover->toXml();
$this->assertContains(
- '<operation name="pushOneWay"><documentation>@param string $message</documentation><input message="tns:pushOneWayIn"/></operation>',
+ '<operation name="pushOneWay"><documentation>pushOneWay</documentation><input message="tns:pushOneWayIn"/></operation>',
@Maks3w Zend Framework member
Maks3w added a note

If not description is present in the docblock then return the name of the function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
$wsdl
);
}
@@ -701,7 +701,7 @@ public function testNoReturnIsOneWayCallInAddFunction()
$wsdl = $autodiscover->toXml();
$this->assertContains(
- '<operation name="OneWay"><documentation>@param string $message</documentation><input message="tns:OneWayIn"/></operation>',
+ '<operation name="OneWay"><documentation>ZendTest\Soap\TestAsset\OneWay</documentation><input message="tns:OneWayIn"/></operation>',
$wsdl
);
}
Something went wrong with that request. Please try again.