Review main Abandoned

65840[FEATURE] Introduce PropertyDoctrineAnnotationMatcher

Alexander Schnitzler CR 0 V 0 Hard +334 −2 updated 01/06/22, 16:04

Commit message

This patch indroduces an extension scanner matcher which finds
class properties that are tagged with one or multiple doctrine
annotations.

This matcher is needed to deprecate doctrine annotations.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 7

Review log 1719

  1. Alexander Schnitzler uploaded patch set 1 09/23/20, 16:14

  2. Alexander Schnitzler commented on patch set 1 09/23/20, 16:17

    PropertyDoctrineAnnotationMatcher.php:102 Unresolved

    We should probably check isLineIgnored() here again for the specific line that is matched.
  3. TYPO3com voted on patch set 1 V -1 09/23/20, 16:32 Completed build in 16m 10s on Wed, 23 Sep, 04:32 PM Test Summary: 42 of 74188 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5883

  4. Alexander Schnitzler uploaded patch set 2 09/24/20, 12:07

  5. TYPO3com voted on patch set 2 V +1 09/24/20, 12:22 Completed build in 14m 09s on Thu, 24 Sep, 12:21 PM Test Summary: 73711 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5913

  6. Alexander Schnitzler commented on patch set 2 09/28/20, 14:10

    This change is ready for review.
  7. Alexander Schnitzler commented on patch set 2 10/06/20, 10:38

    ping
  8. Christian Kuhn commented on patch set 2 10/15/20, 11:32

    some questions. I don't really like the need to require the files. Isn't there any other way around that?

    PropertyDoctrineAnnotationMatcher.php:82

    This is risky: In case the class has a parse error, the extension scanner would fatal. This is not the case with any other matcher.

    PropertyDoctrineAnnotationMatcher.php:111

    I don't really understand why this is needed: We already have an annotation matcher for simple stuff like '@cascade'. This one does not need reflection either. Why is this needed in this case now?
  9. Christian Kuhn commented on patch set 2 CR -1 10/15/20, 11:33

    -1 for now. I hope we can find a less intrusive solution.
  10. Alexander Schnitzler commented on patch set 2 10/15/20, 13:42

    PropertyDoctrineAnnotationMatcher.php:82 Reply

    I know. Unfortunately doctrine/annotations only works with reflection which makes it necessary to load the file.

    PropertyDoctrineAnnotationMatcher.php:111 Reply

    See above. Back then when we only had @cascade, we could be very sure about finding @cascade with a simple strpos even. Now, with doctrine/annotations, we have actual classes that can be namespaced and aliased. That's why the dotrine/annotation parser needs reflection to understand the actually used class. Usually we have use TYPO3\Extbase\Annotation as Extbase; and then use @Extbase\Cascade. But we can also use FQCN: @TYPO3\Extbase\Annotation\Cascade. Or use TYPO3\Extbase\Annotation\Cascade with @Cascade; I know all this is ugly but I don't know a better way to search for annotation class usages with just nikic/parser.
  11. Alexander Schnitzler commented on patch set 2 10/15/20, 13:44

    PropertyDoctrineAnnotationMatcher.php:82 Reply Unresolved

    btw: The class can't have a parse error because it is parsed with nikic/parser before in \TYPO3\CMS\Install\Controller\UpgradeController::extensionScannerScanFileAction()
  12. Christian Kuhn commented on patch set 2 10/16/20, 13:44

    PropertyDoctrineAnnotationMatcher.php:111 Reply

    I see. nikic has a built in NameResolver, that we use, too. And option could be to gather all 'use' lines from the file, then for each annotation feed that to the phpParser to let it resolve names. What do you think?
  13. Alexander Schnitzler commented on patch set 2 10/16/20, 16:09

    PropertyDoctrineAnnotationMatcher.php:111 Reply

    I don't object here but I am too little into this parser thing to make the change myself. tbh, this parser stuff feels cumbersome to me all the time I get in contact with it. Here, with the scanner and even more so when trying to create new rules for rector. :/
  14. Christian Kuhn commented on patch set 2 10/17/20, 10:40

    PropertyDoctrineAnnotationMatcher.php:111 Reply Unresolved

    Agreed. Juggling in the node tree is ... exhausting. However, if that would free us from requiring the file and getting rid of the that context construct, I think it would be worth it.
  15. Benni Mack wrote 11/29/21, 10:04

    Change destination moved from master to main
  16. Benni Mack updated the commit message in patch set 3 11/29/21, 13:12

  17. Benni Mack commented on patch set 3 01/06/22, 14:32

    Ping. Should we continue here?
  18. Christian Kuhn commented on patch set 3 01/06/22, 16:03

    This matcher aims finding 'namespaced' annotations like '@Extbase\ORM\Lazy'. As pointed out, this isn't trivial to get right, the code has to jump through quite some hoops to achieve it and the approach should be improved further. It currently seems as if neither Alexander nor me are highly interested in finishing this patch. While the feature would be nice if we get it right, it's use is relatively limited, and it will take some time to finish. I hope it's ok to thus abandon the patch for now: It would be great if it's picked up again, and we can do that in a fresh patch if anyone decides to dedicate time on it.
  19. Christian Kuhn abandoned the change 01/06/22, 16:04