diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector.php b/app/code/Magento/Webapi/Model/Config/ClassReflector.php index 51878ad2d0940a8b991908c5e79457ee20a84972..e734ff1ef40ca4bc098f03d9525be3fad63f6cd8 100644 --- a/app/code/Magento/Webapi/Model/Config/ClassReflector.php +++ b/app/code/Magento/Webapi/Model/Config/ClassReflector.php @@ -6,6 +6,7 @@ namespace Magento\Webapi\Model\Config; use Zend\Server\Reflection; use Zend\Server\Reflection\ReflectionMethod; +use Zend\Code\Reflection\MethodReflection; /** * Class reflector. @@ -84,7 +85,7 @@ class ClassReflector */ public function extractMethodData(ReflectionMethod $method) { - $methodData = ['documentation' => $method->getDescription(), 'interface' => []]; + $methodData = ['documentation' => $this->extractMethodDescription($method), 'interface' => []]; $prototypes = $method->getPrototypes(); /** Take the fullest interface that also includes optional parameters. */ /** @var \Zend\Server\Reflection\Prototype $prototype */ @@ -111,4 +112,22 @@ class ClassReflector return $methodData; } + + /** + * Retrieve method full documentation description. + * + * @param ReflectionMethod $method + * @return string + */ + protected function extractMethodDescription(ReflectionMethod $method) + { + $methodReflection = new MethodReflection( + $method->getDeclaringClass()->getName(), + $method->getName() + ); + + $docBlock = $methodReflection->getDocBlock(); + + return $this->_typeProcessor->getDescription($docBlock); + } } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php index 30fdab7a8ccdc3841d89167a02f17f5838d08cff..498df37e372c3550fc957759b153d050ae2af8c0 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php @@ -66,7 +66,9 @@ class ClassReflectorTest extends \PHPUnit_Framework_TestCase protected function _getSampleReflectionData() { return [ - 'documentation' => 'Basic random string generator', + 'documentation' => + 'Basic random string generator. This line is short description '. + 'This line is long description. This is still the long description.', 'interface' => [ 'in' => [ 'parameters' => [ diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php index f3f25ccb5f4a0b586a75481da0acf7a6a43f5567..cce8322bdafeac9b3fb818537d96d7590ec096f2 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php @@ -7,7 +7,10 @@ namespace Magento\Webapi\Model\Config; class TestServiceForClassReflector { /** - * Basic random string generator + * Basic random string generator. This line is short description + * This line is long description. + * + * This is still the long description. * * @param int $length length of the random string * @return string random string diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index 901eded854db02ecca7352a62281b0c2f523de00..8756180f16b5b1a3250bb04b7acce6f496380d25 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -157,7 +157,7 @@ class TypeProcessor } $reflection = new ClassReflection($class); $docBlock = $reflection->getDocBlock(); - $this->_types[$typeName]['documentation'] = $docBlock ? $this->_getDescription($docBlock) : ''; + $this->_types[$typeName]['documentation'] = $docBlock ? $this->getDescription($docBlock) : ''; /** @var \Zend\Code\Reflection\MethodReflection $methodReflection */ foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodReflection) { if ($methodReflection->class === "Magento\Framework\Model\AbstractModel") { @@ -200,7 +200,7 @@ class TypeProcessor * @param \Zend\Code\Reflection\DocBlockReflection $doc * @return string */ - protected function _getDescription(\Zend\Code\Reflection\DocBlockReflection $doc) + public function getDescription(\Zend\Code\Reflection\DocBlockReflection $doc) { $shortDescription = $doc->getShortDescription(); $longDescription = $doc->getLongDescription();