codestyle fixes

This commit is contained in:
kopaygorodsky 2017-09-15 21:43:20 +03:00
parent 6e41a20e40
commit b405b33ea2
5 changed files with 18 additions and 20 deletions

View File

@ -20,9 +20,6 @@ trait ModelRegistryAwareTrait
*/
private $modelRegistry;
/**
* @param ModelRegistry $modelRegistry
*/
public function setModelRegistry(ModelRegistry $modelRegistry)
{
$this->modelRegistry = $modelRegistry;

View File

@ -116,11 +116,8 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
break;
}
if (
($formType = $type->getInnerType()) &&
($formClass = get_class($formType)) &&
!$this->isBuiltinType($formClass) //don't check builtin types in Form component.
) {
if ($type->getInnerType() && ($formClass = get_class($type->getInnerType())) && !$this->isBuiltinType($formClass)) {
//if form type is not builtin in Form component.
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $formClass));
$property->setRef($this->modelRegistry->register($model));
break;
@ -136,13 +133,8 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
}
}
/**
* @param string $type
*
* @return bool
*/
private function isBuiltinType(string $type) : bool
private function isBuiltinType(string $type): bool
{
return strpos($type, 'Symfony\Component\Form\Extension\Core\Type') !== false;
return 0 === strpos($type, 'Symfony\Component\Form\Extension\Core\Type');
}
}

View File

@ -18,9 +18,9 @@ use Nelmio\ApiDocBundle\Annotation\Operation;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
use Nelmio\ApiDocBundle\Tests\Functional\Form\DummyType;
use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Swagger\Annotations as SWG;
use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
/**
* @Route("/api")

View File

@ -1,11 +1,20 @@
<?php
/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
class UserType extends AbstractType
{
@ -17,7 +26,7 @@ class UserType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class
'data_class' => User::class,
]);
}
}
}

View File

@ -179,7 +179,7 @@ class FunctionalTest extends WebTestCase
$this->assertEquals([
'type' => 'object',
'properties' => [
'dummy' => ['$ref' => '#/definitions/DummyType']
'dummy' => ['$ref' => '#/definitions/DummyType'],
],
'required' => ['dummy'],
], $this->getModel('UserType')->toArray());