Review main Merged

32714[FEATURE] Add methods to get class tag values via reflection

Frank Nägler CR +2 V +2 Normal +100 −9 updated 10/26/14, 17:15

Commit message

This patch adds ReflectionService::getClassTagsValues($className) and
ReflectionService::getClassTagValues($className, $tag) to get class
tag values via reflection.

Also the unit test changed to test the new methods.

Review

  • Code review CR +2
    • Markus Klein +2
    • Alexander Opitz +1
  • Verified V +2
    • Markus Klein +2
    • Alexander Opitz +1

Issues 1

Files 3

Review log 39

Show 14 earlier messages
  1. Frank Nägler uploaded patch set 1 09/10/14, 20:33

  2. Frank Nägler uploaded patch set 2 09/10/14, 20:36

  3. Mathias Brodala voted on patch set 2 CR +1 09/11/14, 07:04

  4. Tymoteusz Motylewski commented on patch set 2 09/11/14, 07:15

    What these methods are useful for?
    duplicated issue (the same issue in resolved and related)
  5. Frank Nägler commented on patch set 2 09/11/14, 07:30

    you can tag classes like methods and properties, but you can't get these information by the ReflectionService. With these methods it is now possible. The core or extbase currently not need at the moment, but it is a utility class which can be used by everyone. An example could be to get informations if the class is deprecated or who was the author. I think there are a lot of cases, where these method are useful.
  6. Tymoteusz Motylewski updated the commit message in patch set 3 09/12/14, 13:36

  7. Anja Leichsenring uploaded patch set 4 09/13/14, 21:39

  8. Anja Leichsenring commented on patch set 4 CR -1 V +1 09/13/14, 21:40

    improved and corrected the unit tests. Please add a documentation entry at typo3/sysext/core/Documentation/master. -1 because it is missing. Codewise fine
  9. Mathias Brodala voted on patch set 4 CR +1 09/14/14, 07:08

  10. Frank Nägler uploaded patch set 5 09/14/14, 11:27

  11. Frank Nägler commented on patch set 5 09/14/14, 11:27

    added the documentation file
  12. Anja Leichsenring voted on patch set 5 CR +1 V +1 09/14/14, 11:34

  13. Alexander Opitz commented on patch set 5 V +1 CR +1 09/15/14, 12:01

    Verified by running the tests.
  14. Christian Kuhn uploaded patch set 6 10/02/14, 15:30

  1. Christian Kuhn commented on patch set 5 10/02/14, 15:39

    ReflectionService.php:207

    This is redundant with the if (!isset()) above. return $this->classTagsValues[$className] would fit here.

    ReflectionService.php:225

    Hmm. What I don't really like about this method: The return value is always an empty error, both if there is an annotation without value, and also if the annotation itself is not set at all. I'm not sure if that is what we want here? BTW: What happens if the same annotation is given twice? I'd at least like to have a unit test for these cases: Two same named annotations, and no annotation at all. And I'd like to have a second opinion what to do if we ask for an annotation that is not set at all here. If the result is identical to "no value", this method can not be used to find out whether an annotation is set at all: /** * @foo */ Currently, asking for 'foo' gives the same result as asking for (not existing) 'bar'. To find out if an annotation is set, one would have to do a getClassTagsValues together() and an isset on the resulting array then. Possible changes: a) throw exception if given annotation is not there, b) return NULL instead of array(), c) keep like it is. What do you think?
  2. Christian Kuhn commented on patch set 6 CR -1 10/02/14, 15:40

    -1 until we discussed my concerns from patch set 5.
  3. Mathias Brodala commented on patch set 5 10/06/14, 08:57

    ReflectionService.php:225 Reply

    While you might be right here, we should be consistent to the existing methods which seem to build on the principle of lowest surprise. Thus you can rely on the return value to always be an array and process it as such. If you are using tags which may or may not have values, you have to perform separate checks anyways.
  4. Frank Nägler commented on patch set 5 10/10/14, 14:54

    ReflectionService.php:225 Reply

    In general I agree with your concerns. Both new methods has the same logic like the others of this class. Sure, this must not be a reason, but I think the behavior should of all these kind of methods should be identical.
  5. Christian Kuhn commented on patch set 6 CR 0 10/13/14, 20:43

    ok, i was not aware that the other methods work in a similar way. so it is probably better to stay consistent here. removed my -1.
  6. Alexander Opitz commented on patch set 6 V +1 CR +1 10/14/14, 07:51

    Reattach votes as only .rst file was changed
  7. Markus Klein commented on patch set 6 10/14/14, 08:22

    ReflectionService.php:215

    Maybe a dumb question, but can a tag have multiple values? If not, the array type seems wrong here. If it can have, please add unit tests for this case.
  8. Mathias Brodala commented on patch set 6 10/14/14, 08:45

    ReflectionService.php:215 Reply

    A tag can appear multiple times which results in all values being gathered in an array.
  9. Markus Klein updated the commit message in patch set 7 10/14/14, 08:55

  10. Markus Klein voted on patch set 7 CR +1 V +1 10/14/14, 08:55

  11. Mathias Brodala commented on patch set 7 10/14/14, 09:02

    ReflectionServiceTest.php:19

    Maybe add @test at least twice to test for all values being extracted?
  12. Markus Klein commented on patch set 7 10/14/14, 09:04

    I would even rename the @test to something else, because you easily mix that with the @test annotation for phpunit.
  13. Markus Klein uploaded patch set 8 10/14/14, 09:08

  14. Markus Klein voted on patch set 8 CR +1 V +1 10/14/14, 09:08

  15. Stefan Froemken commented on patch set 8 10/14/14, 09:44

    ReflectionService.php:197

    containing...what?

    ReflectionService.php:198

    if

    ReflectionService.php:200

    This is public. So what about @api annotation?
  16. Alexander Opitz commented on patch set 8 10/14/14, 10:37

    ReflectionService.php:200 Reply

    @api is defined for the whole class.
  17. Stefan Froemken commented on patch set 8 10/14/14, 14:40

    ReflectionService.php:200 Reply

    OK...in that case it should be removed from the other method, too.
  18. Alexander Opitz commented on patch set 8 10/14/14, 15:34

    The complete class is marked with @api but also some of the public functions are marked with @api. It seams we need a schema how we like to do it.

    ReflectionService.php:200 Reply

    Ahh ok. :)
  19. Frank Nägler commented on patch set 8 10/14/14, 20:25

    ok, what should/can I change now? remove @api from all methods, because the class has @api ?
  20. Frank Nägler uploaded patch set 9 10/26/14, 12:37

  21. Frank Nägler commented on patch set 9 10/26/14, 12:37

    changed the phpDoc comments only
  22. Markus Klein voted on patch set 9 CR +1 V +1 10/26/14, 13:45

  23. Alexander Opitz voted on patch set 9 V +1 CR +1 10/26/14, 17:12

  24. Markus Klein voted on patch set 9 CR +2 V +2 10/26/14, 17:14

  25. Markus Klein merged patch set 9 10/26/14, 17:15