collections: V1.6.0 throws errors in Symfony context
Using API platform.
After the update to 1.6.0 cache:clear throws an error:
Script cache:clear returned with error code 1
!!
!! // Clearing the cache for the dev environment with debug
!! // true
!!
!!
!! In FileLoader.php line 166:
!!
!! [Semantical Error] The annotation "@template" in class Doctrine\Common\Coll
!! ections\Collection was never imported. Did you maybe forget to add a "use"
!! statement for this annotation? in . (which is being imported from "/srv/api
!! /config/routes/api_platform.yaml"). Make sure there is a loader supporting
!! the "api_platform" type.
!!
!!
!! In AnnotationException.php line 54:
!!
!! [Semantical Error] The annotation "@template" in class Doctrine\Common\Coll
!! ections\Collection was never imported. Did you maybe forget to add a "use"
!! statement for this annotation?
!!
!!
config/routes/api_platform.yml
api_platform:
resource: .
type: api_platform
Origin:
@template T
in https://github.com/doctrine/collections/commit/7ddac104668249f0f4803b128eb30d0564467a68#diff-6ecd3b230c9f7cef1a38ea4da84278f3R27
After manually fixing doctrine/collection in composer.json to 1.5.0 it works again.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 18 (16 by maintainers)
Commits related to this issue
- fix [CoreBundle]: Downgrade doctrine/collections to 1.5.*, because of https://github.com/doctrine/collections/issues/180 — committed to unite-cms/unite-cms by franzwilding 5 years ago
- fix [CoreBundle]: Downgrade doctrine/collections to 1.5.*, because of https://github.com/doctrine/collections/issues/180 — committed to unite-cms/CoreBundle by franzwilding 5 years ago
- fix [CoreBundle]: Downgrade doctrine/collections to 1.5.*, because of https://github.com/doctrine/collections/issues/180 — committed to franzwilding/test-split-repo by franzwilding 5 years ago
- Split test (#7) * fix #458 [CoreBundle]: For the moment allow auto field only for content and setting types and not any nested subfield * feature #468 [CoreBundle]: Add core integration for an api... — committed to unite-cms/CoreBundle by franzwilding 5 years ago
- Test sub tree split (#9) * fix #458 [CoreBundle]: For the moment allow auto field only for content and setting types and not any nested subfield * feature #468 [CoreBundle]: Add core integration f... — committed to unite-cms/CoreBundle by franzwilding 5 years ago
Handled and tested: preparing release.
As noted in https://github.com/doctrine/collections/pull/177#issuecomment-472467691, scavenging
vendor/
for annotations is not a good idea. This is an issue to be reported in APIPlatform.Well, multiple Symfony component needs to be able to read metadata (potentially using annotations) from arbitrary classes (Validator and Serializer are the one coming to my mind right now). And at least for these 2 components, it is very common to use them on object graphs involving Doctrine collections (as a common use case is to use them on your entities). Most of the time, you won’t need any metadata there, as you want to treat the collection with the standard handling of Traversable. But this does not mean that Symfony forbids defining a custom behavior, and so it still tries to find the metadata.
The fix for that would be to ignore the Psalm-specific tags in doctrine/annotations by default, as is done already for phpdoc tags.
Please note: you’ll need
doctrine/collections
1.6.1
along withdoctrine/annotations
1.6.1
.Yeah, currently patching
doctrine/annotations
, since-
is not a valid class identifier anyway