Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PropertyInfo] TypeError caused by PropertyInfoExtractor in v4.2.2 #29851

Closed
nem75 opened this issue Jan 11, 2019 · 2 comments
Closed

[PropertyInfo] TypeError caused by PropertyInfoExtractor in v4.2.2 #29851

nem75 opened this issue Jan 11, 2019 · 2 comments

Comments

@nem75
Copy link

nem75 commented Jan 11, 2019

Symfony version(s) affected: 4.2.2

Description
We use Symfony in conjunction with nelmio/api-doc-bundle. When upgrading everything to v4.2.2 this Exception is thrown when trying to access the generated API documentation via browser:

TypeError:
Argument 1 passed to Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor::__construct() must implement interface Doctrine\Common\Persistence\Mapping\ClassMetadataFactory, instance of Doctrine\ORM\EntityManager given, called in /app/var/cache/dev/Container8xam11G/getDoctrine_Orm_DefaultEntityManager_PropertyInfoExtractorService.php on line 9

  at vendor/symfony/doctrine-bridge/PropertyInfo/DoctrineExtractor.php:32
  at Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor->__construct(object(EntityManager))
     (var/cache/dev/Container8xam11G/getDoctrine_Orm_DefaultEntityManager_PropertyInfoExtractorService.php:9)
  at require('/app/var/cache/dev/Container8xam11G/getDoctrine_Orm_DefaultEntityManager_PropertyInfoExtractorService.php')
     (var/cache/dev/Container8xam11G/srcApp_KernelDevDebugContainer.php:158)
  at Container8xam11G\srcApp_KernelDevDebugContainer->load('getDoctrine_Orm_DefaultEntityManager_PropertyInfoExtractorService.php')
     (var/cache/dev/Container8xam11G/getPropertyInfoService.php:14)
  at Container8xam11G\srcApp_KernelDevDebugContainer->{closure}()
     (vendor/symfony/property-info/PropertyInfoExtractor.php:108)
  at Symfony\Component\PropertyInfo\PropertyInfoExtractor->extract(object(RewindableGenerator), 'getTypes', array('App\\Entity\\SomeResourceEntity', 'id', array()))
     (vendor/symfony/property-info/PropertyInfoExtractor.php:74)
  at Symfony\Component\PropertyInfo\PropertyInfoExtractor->getTypes('App\\Entity\\SomeResourceEntity', 'id')
     (vendor/nelmio/api-doc-bundle/ModelDescriber/ObjectModelDescriber.php:80)
  at Nelmio\ApiDocBundle\ModelDescriber\ObjectModelDescriber->describe(object(Model), object(Schema))
     (vendor/nelmio/api-doc-bundle/Model/ModelRegistry.php:95)
  at Nelmio\ApiDocBundle\Model\ModelRegistry->registerDefinitions()
     (vendor/nelmio/api-doc-bundle/ApiDocGenerator.php:72)
  at Nelmio\ApiDocBundle\ApiDocGenerator->generate()
     (vendor/nelmio/api-doc-bundle/Controller/SwaggerUiController.php:53)
  at Nelmio\ApiDocBundle\Controller\SwaggerUiController->__invoke(object(Request), 'default')
     (vendor/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:67)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:37)

How to reproduce

Example phpdoc processed by the api doc bundle:

    /**
     * @Route(
     *     path="/api/recources",
     *     name="api_list_resources",
     *     methods={"GET"}
     * )
     *
     * @SWG\Response(
     *     response="200",
     *     description="A list of recources",
     *     @SWG\Schema(
     *         type="array",
     *         @Model(type=App\Entity\SomeResourceEntity::class, groups={"api"})
     *     )
     * )
     *
     * @param Request $request
     * @return JsonResponse
     */

SomeResourceEntity in this case is your run of the mill Doctrine Entity object with a numeric id field, nothing fancy.

I won't completely rule out that this might be a problem in nelmio/api-doc-bundle, but downgrading symfony/property-info to ~4.1 definitely gets rid of the problem; which is not satisfactory of course. Please advise.

@xabbuh
Copy link
Member

xabbuh commented Jan 11, 2019

Which version of the DoctrineBundle do you use?

@xabbuh
Copy link
Member

xabbuh commented Jan 11, 2019

Ah, I see. The service is registered by DoctrineBundle (see doctrine/DoctrineBundle#883) and will be fixed in doctrine/DoctrineBundle#884. Closing here as there is nothing we can do about that in Symfony.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants