mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
fixed cs
This commit is contained in:
parent
185d0e588b
commit
9b94ae4b2c
@ -67,7 +67,7 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
'description' => $this->getDescription($input, $item->name),
|
'description' => $this->getDescription($input, $item->name),
|
||||||
'readonly' => $item->readOnly
|
'readonly' => $item->readOnly
|
||||||
);
|
);
|
||||||
|
|
||||||
//check for nested classes w/ JMS metadata
|
//check for nested classes w/ JMS metadata
|
||||||
if ($nestedInputClass = $this->getNestedClass($item->type)) {
|
if ($nestedInputClass = $this->getNestedClass($item->type)) {
|
||||||
$params[$name]['children'] = $this->parse($nestedInputClass);
|
$params[$name]['children'] = $this->parse($nestedInputClass);
|
||||||
@ -77,12 +77,12 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
|
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are various ways via JMS to declare arrays of objects, but that's an internal
|
* There are various ways via JMS to declare arrays of objects, but that's an internal
|
||||||
* implementation detail.
|
* implementation detail.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getNormalizedType($type)
|
protected function getNormalizedType($type)
|
||||||
@ -90,25 +90,27 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
if (in_array($type, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime'))) {
|
if (in_array($type, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime'))) {
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(false !== strpos($type, "array") || false !== strpos($type, "ArrayCollection")) {
|
if (false !== strpos($type, "array") || false !== strpos($type, "ArrayCollection")) {
|
||||||
if ($nested = $this->getNestedClassInArray($type)) {
|
if ($nested = $this->getNestedClassInArray($type)) {
|
||||||
$exp = explode("\\", $nested);
|
$exp = explode("\\", $nested);
|
||||||
|
|
||||||
return sprintf("array of objects (%s)", end($exp));
|
return sprintf("array of objects (%s)", end($exp));
|
||||||
} else {
|
} else {
|
||||||
return "array";
|
return "array";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$exp = explode("\\", $type);
|
$exp = explode("\\", $type);
|
||||||
|
|
||||||
return sprintf("object (%s)", end($exp));
|
return sprintf("object (%s)", end($exp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the various ways JMS describes custom classes in arrays, and
|
* Check the various ways JMS describes custom classes in arrays, and
|
||||||
* get the name of the class in the array, if available.
|
* get the name of the class in the array, if available.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
protected function getNestedClassInArray($type)
|
protected function getNestedClassInArray($type)
|
||||||
@ -118,18 +120,19 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
$regEx = "/\<([A-Za-z0-9\\\]*)(\,?\s?(.*))?\>/";
|
$regEx = "/\<([A-Za-z0-9\\\]*)(\,?\s?(.*))?\>/";
|
||||||
if (preg_match($regEx, $type, $matches)) {
|
if (preg_match($regEx, $type, $matches)) {
|
||||||
$matched = (!empty($matches[3])) ? $matches[3] : $matches[1];
|
$matched = (!empty($matches[3])) ? $matches[3] : $matches[1];
|
||||||
|
|
||||||
return in_array($matched, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime')) ? false : $matched;
|
return in_array($matched, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime')) ? false : $matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the JMS Serializer types for reference to a class.
|
* Scan the JMS Serializer types for reference to a class.
|
||||||
*
|
*
|
||||||
* http://jmsyst.com/bundles/JMSSerializerBundle/master/reference/annotations#type
|
* http://jmsyst.com/bundles/JMSSerializerBundle/master/reference/annotations#type
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
protected function getNestedClass($type)
|
protected function getNestedClass($type)
|
||||||
@ -137,12 +140,12 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
if (in_array($type, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime'))) {
|
if (in_array($type, array('boolean', 'integer', 'string', 'double', 'array', 'DateTime'))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//could be a nested object of some sort
|
//could be a nested object of some sort
|
||||||
if ($nested = $this->getNestedClassInArray($type)) {
|
if ($nested = $this->getNestedClassInArray($type)) {
|
||||||
return $nested;
|
return $nested;
|
||||||
}
|
}
|
||||||
|
|
||||||
//or could just be a class name (potentially)
|
//or could just be a class name (potentially)
|
||||||
return (null === $this->factory->getMetadataForClass($type)) ? false : $type;
|
return (null === $this->factory->getMetadataForClass($type)) ? false : $type;
|
||||||
}
|
}
|
||||||
@ -152,7 +155,6 @@ class JmsMetadataParser implements ParserInterface
|
|||||||
$description = "No description.";
|
$description = "No description.";
|
||||||
|
|
||||||
//TODO: abstract docblock parsing utility and implement here
|
//TODO: abstract docblock parsing utility and implement here
|
||||||
|
|
||||||
return $description;
|
return $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,5 +16,5 @@ class JmsNested
|
|||||||
* @JMS\Type("string");
|
* @JMS\Type("string");
|
||||||
*/
|
*/
|
||||||
public $bar;
|
public $bar;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ class JmsTest
|
|||||||
* @JMS\Type("array");
|
* @JMS\Type("array");
|
||||||
*/
|
*/
|
||||||
public $arr;
|
public $arr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @JMS\Type("Nelmio\ApiDocBundle\Tests\Fixtures\Model\JmsNested");
|
* @JMS\Type("Nelmio\ApiDocBundle\Tests\Fixtures\Model\JmsNested");
|
||||||
*/
|
*/
|
||||||
public $nested;
|
public $nested;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @JMS\Type("array<Nelmio\ApiDocBundle\Tests\Fixtures\Model\JmsNested>");
|
* @JMS\Type("array<Nelmio\ApiDocBundle\Tests\Fixtures\Model\JmsNested>");
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user