diff --git a/.gitignore b/.gitignore index 0d330a8..c49a5d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -vendor/ -composer.lock \ No newline at end of file +vendor/ +composer.lock +phpunit.xml diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index e87c88c..1d69036 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -40,7 +40,7 @@ class ApiDoc { if (isset($data['formType'])) { $this->formType = $data['formType']; - } else if (isset($data['filters'])) { + } elseif (isset($data['filters'])) { foreach ($data['filters'] as $filter) { if (!isset($filter['name'])) { throw new \InvalidArgumentException('A "filter" element has to contain a "name" attribute'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index b932eae..e88d4e8 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\DependencyInjection; -use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index a4b02af..abd761b 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -28,7 +28,7 @@ class ApiDocExtractor private $container; /** - * @var \ymfony\Component\Routing\RouterInterface + * @var \Symfony\Component\Routing\RouterInterface */ private $router; @@ -116,7 +116,7 @@ class ApiDocExtractor * Returns the ReflectionMethod for the given controller string * * @param string $controller - * @return ReflectionMethod|null + * @return \ReflectionMethod|null */ public function getReflectionMethod($controller) { @@ -150,7 +150,7 @@ class ApiDocExtractor * - route * * @param string $controller - * @param Route $route + * @param Route $route * @return array|null */ public function get($controller, $route) @@ -172,9 +172,9 @@ class ApiDocExtractor * - annotation * - route * - * @param ApiDoc $annotation - * @param Route $route - * @param ReflectionMethod $method + * @param ApiDoc $annotation + * @param Route $route + * @param \ReflectionMethod $method * @return array */ protected function getData(ApiDoc $annotation, Route $route, \ReflectionMethod $method) diff --git a/Formatter/AbstractFormatter.php b/Formatter/AbstractFormatter.php index 107ddb3..bb05506 100644 --- a/Formatter/AbstractFormatter.php +++ b/Formatter/AbstractFormatter.php @@ -56,22 +56,22 @@ abstract class AbstractFormatter implements FormatterInterface /** * Format a single array of data * - * @param array $data + * @param array $data * @return string|array */ - protected abstract function renderOne(array $data); + abstract protected function renderOne(array $data); /** * Format a set of resource sections. * - * @param array $collection + * @param array $collection * @return string|array */ - protected abstract function render(array $collection); + abstract protected function render(array $collection); /** - * @param ApiDoc $apiDoc - * @param Route $route + * @param ApiDoc $apiDoc + * @param Route $route * @return array */ protected function getData(ApiDoc $apiDoc, Route $route) diff --git a/Formatter/FormatterInterface.php b/Formatter/FormatterInterface.php index a51a947..878a8a0 100644 --- a/Formatter/FormatterInterface.php +++ b/Formatter/FormatterInterface.php @@ -19,17 +19,17 @@ interface FormatterInterface /** * Format a collection of documentation data. * - * @param array $collection + * @param array $collection * @return string|array */ - function format(array $collection); + public function format(array $collection); /** * Format documentation data for one route. * * @param ApiDoc $apiDoc - * @param Route $route + * @param Route $route * return string|array */ - function formatOne(ApiDoc $apiDoc, Route $route); + public function formatOne(ApiDoc $apiDoc, Route $route); } diff --git a/Formatter/HtmlFormatter.php b/Formatter/HtmlFormatter.php index cdcfd21..170004c 100644 --- a/Formatter/HtmlFormatter.php +++ b/Formatter/HtmlFormatter.php @@ -11,8 +11,6 @@ namespace Nelmio\ApiDocBundle\Formatter; -use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Symfony\Component\Routing\Route; use Symfony\Component\Templating\EngineInterface; class HtmlFormatter extends AbstractFormatter diff --git a/Parser/FormTypeParser.php b/Parser/FormTypeParser.php index dadc16b..e044d5b 100644 --- a/Parser/FormTypeParser.php +++ b/Parser/FormTypeParser.php @@ -47,7 +47,7 @@ class FormTypeParser * - required * - description * - * @param AbstractType $type + * @param AbstractType $type * @return array */ public function parse(AbstractType $type) @@ -56,7 +56,11 @@ class FormTypeParser $parameters = array(); foreach ($builder->all() as $name => $child) { - $childBuilder = $builder->create($name, $child['type'] ?: 'text', $child['options']); + if ($child instanceof FormBuilder) { + $childBuilder = $child; + } else { + $childBuilder = $builder->create($name, $child['type'] ?: 'text', $child['options']); + } $bestType = ''; foreach ($childBuilder->getTypes() as $type) { diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php index 0314e64..def145b 100644 --- a/Tests/Fixtures/Controller/TestController.php +++ b/Tests/Fixtures/Controller/TestController.php @@ -58,7 +58,7 @@ class TestController * * @ApiDoc() * - * @param int $id A nice comment + * @param int $id A nice comment * @param int $page */ public function myCommentedAction() diff --git a/Tests/Fixtures/Controller/TestServiceController.php b/Tests/Fixtures/Controller/TestServiceController.php index a4033c5..c6c4ec6 100644 --- a/Tests/Fixtures/Controller/TestServiceController.php +++ b/Tests/Fixtures/Controller/TestServiceController.php @@ -11,9 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller; -use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Symfony\Component\HttpFoundation\Response; - class TestServiceController extends TestController { } diff --git a/Tests/Fixtures/Form/TestType.php b/Tests/Fixtures/Form/TestType.php index a6a1b08..004e4e9 100644 --- a/Tests/Fixtures/Form/TestType.php +++ b/Tests/Fixtures/Form/TestType.php @@ -23,6 +23,7 @@ class TestType extends AbstractType { $builder->add('a', null, array('description' => 'A nice description')); $builder->add('b'); + $builder->add($builder->create('c', 'checkbox')); } /** diff --git a/Tests/Fixtures/Model/Test.php b/Tests/Fixtures/Model/Test.php index 96992b8..4ee1dfd 100644 --- a/Tests/Fixtures/Model/Test.php +++ b/Tests/Fixtures/Model/Test.php @@ -24,4 +24,6 @@ class Test * @Assert\Type("DateTime"); */ public $b; + + public $c; } diff --git a/Tests/Fixtures/NelmioApiDocTestBundle.php b/Tests/Fixtures/NelmioApiDocTestBundle.php index 6664ed8..c7141f6 100644 --- a/Tests/Fixtures/NelmioApiDocTestBundle.php +++ b/Tests/Fixtures/NelmioApiDocTestBundle.php @@ -1,18 +1,18 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Nelmio\ApiDocBundle\Tests\Fixtures; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class NelmioApiDocTestBundle extends Bundle -{ -} + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Nelmio\ApiDocBundle\Tests\Fixtures; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class NelmioApiDocTestBundle extends Bundle +{ +} diff --git a/Tests/Fixtures/app/AppKernel.php b/Tests/Fixtures/app/AppKernel.php index 1d08af4..b8c28b7 100644 --- a/Tests/Fixtures/app/AppKernel.php +++ b/Tests/Fixtures/app/AppKernel.php @@ -31,7 +31,6 @@ while ($dir !== $lastDir) { } use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; /** diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index 33b3157..a2ae4f3 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -75,6 +75,11 @@ b: * type: string * required: true +c: + + * type: boolean + * required: true + ### `POST` /tests ### @@ -93,6 +98,11 @@ b: * type: string * required: true +c: + + * type: boolean + * required: true + # others # diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php index 0780255..73d4ffa 100644 --- a/Tests/Formatter/SimpleFormatterTest.php +++ b/Tests/Formatter/SimpleFormatterTest.php @@ -97,6 +97,12 @@ class SimpleFormatterTest extends WebTestCase 'required' => true, 'description' => '', ), + 'c' => + array( + 'dataType' => 'boolean', + 'required' => true, + 'description' => '', + ), ), 'description' => 'create test', ), @@ -121,6 +127,12 @@ class SimpleFormatterTest extends WebTestCase 'required' => true, 'description' => '', ), + 'c' => + array( + 'dataType' => 'boolean', + 'required' => true, + 'description' => '', + ), ), 'description' => 'create test', ), diff --git a/Tests/WebTestCase.php b/Tests/WebTestCase.php index b3e12d1..dba3f87 100644 --- a/Tests/WebTestCase.php +++ b/Tests/WebTestCase.php @@ -37,14 +37,14 @@ abstract class WebTestCase extends BaseWebTestCase return static::$kernel->getContainer(); } - static protected function getKernelClass() + protected static function getKernelClass() { require_once __DIR__.'/Fixtures/app/AppKernel.php'; return 'Nelmio\ApiDocBundle\Tests\Functional\AppKernel'; } - static protected function createKernel(array $options = array()) + protected static function createKernel(array $options = array()) { $class = self::getKernelClass(); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 54345bb..0204cd7 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -1,13 +1,14 @@ -