Problem/Motivation
Method "Doctrine\Common\Annotations\Reader::getClassAnnotations()" will return "array" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Method "Doctrine\Common\Annotations\Reader::getMethodAnnotations()" will return "array" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Method "Doctrine\Common\Annotations\Reader::getPropertyAnnotations()" will return "array" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Method "Doctrine\Common\Annotations\Reader::getClassAnnotation()" will return "?T" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Method "Doctrine\Common\Annotations\Reader::getMethodAnnotation()" will return "?T" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Method "Doctrine\Common\Annotations\Reader::getPropertyAnnotation()" will return "?T" as of its next major version. Doing the same in implementation "Drupal\Component\Annotation\Doctrine\SimpleAnnotationReader" will be required when upgrading.
Steps to reproduce
Proposed resolution
Add the type hints.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3231693-2.patch | 3.01 KB | daffie |
Comments
Comment #2
daffie commentedIn core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php on line #144-145 we have the code:
I have taken that as the return value for the 3 methods that get the type hint:
?T.Comment #3
longwaveI am not sure this is right. I guess this is the Symfony debug class loader reading the docblock for the Doctrine classes and making an assumption that because there are @return with class declarations, a return type will be added - but has Doctrine actually announced this?
Comment #4
catchComment #6
longwaveMarking as postponed, as I believe this is a false positive caused by the over-eager DebugClassLoader reading docblocks in third party code and assuming they mean that typehints will be added.
Comment #7
gábor hojtsyThis was postponed on #3232131: [Symfony 5] Symfony's DebugClassLoader triggers deprecation messages for missing return type hints, where there is no deprecation I believe which landed. So unpostponing.
Comment #8
longwaveI still think this is a false positive and hence should be won't fix. There is no guarantee that:
Comment #9
catchAgreed, let's mark this as duplicate of #3232131: [Symfony 5] Symfony's DebugClassLoader triggers deprecation messages for missing return type hints, where there is no deprecation since we came up with a solution there. We may also do #3252386: Use PHP attributes instead of doctrine annotations.