Task #33142

Ignore Tags / Annotations in external libraries, find some good solution

Added by Christian Müller almost 10 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
Reflection
Start date:
2012-01-12
Due date:
% Done:

100%

Estimated time:
Sprint:
PHP Version:
Has patch:
No
Complexity:

Description

for now we have the ignore list of tags in Packages/Framework/TYPO3.FLOW3/Classes/Reflection/ReflectionService.php

For external libraries with lots of custom tags this is a problem, of course we can patch master specifically all the time, but maybe we should think about another solution. So a possible way would be to have a core ignore set and allow additions by configuration or just a globally configurable ignore list. Maybe there are other ideas?

#1

Updated by Adrian Föder almost 10 years ago

Well for now, we have afaik two possibilities how external libraries could get involved:
  1. if it's just a tiny helper library, it's intended to be stored in {PackageRoot}/Resources/PHP/{libraryName} and just included via require. is this suspected by the problem however?
  2. if the FLOW3 package mainly represents the foreing library at all, like it's the case in Imagine or Swift package, the library code is put below {PackageRoot}/Classes directly.

If this is considered common guideline, I suggest we should only allow customized annotation allowance for files below those two kind of directories.

So basically I agree with Christian making the "ignore" list of annotations just configurable via YAML configuration.
Additional idea could be to allow "mapping" of annotations; i.e.

@date
(which is not an official PhpDoc annotation) could get mapped to
@My\SooperdooperTool\Annotations\Date
or such.

#2

Updated by Peter Beernink almost 10 years ago

Adrian Föder wrote:

If this is considered common guideline, I suggest we should only allow customized annotation allowance for files below those two kind of directories.

So basically I agree with Christian making the "ignore" list of annotations just configurable via YAML configuration.
Additional idea could be to allow "mapping" of annotations; i.e.

@date

(which is not an official PhpDoc annotation) could get mapped to
@My\SooperdooperTool\Annotations\Date

or such.

This also make it possible to 'ignore' other tags, when an empty Annotation\Ignore is added.

#3

Updated by Karsten Dambekalns almost 10 years ago

  • Project changed from TYPO3 Flow Base Distribution to TYPO3.Flow
  • Status changed from New to Accepted
  • Assignee changed from Christian Müller to Karsten Dambekalns
#4

Updated by Karsten Dambekalns almost 10 years ago

  • Category set to Reflection
  • Target version set to 1.1
  • Has patch set to No
#5

Updated by Gerrit Code Review almost 10 years ago

  • Status changed from Accepted to Under Review

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7747

#6

Updated by Gerrit Code Review almost 10 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7747

#7

Updated by Peter Beernink almost 10 years ago

Karsten I haven't tested your code yet, but it looks like a good solution.
However, when I read the code it looks like one has to copy the default list to the Configuration/Settings.yaml in order to add additional tags.

Is this the intended behaviour?
I can imagine that you have multiple (3rd party) packages which all have one or two tags to exclude. You have to manually check each package on which tags should be excluded and compile a complete list in your base Settings.yaml.

Or am I completely wrong here and is the array merged with arrays defined in other packages?

#8

Updated by Bastian Waidelich almost 10 years ago

Peter Beernink wrote:

However, when I read the code it looks like one has to copy the default list
to the Configuration/Settings.yaml in order to add additional tags.

Good catch, this wouldn't be easily extensible by 3rd party unless we'd change the syntax to something like

ignoredTags:
  api: y
  package: y
  ...

if I'm correct..

Not very beautiful IMO.
What about adding an AnnotationInterface (that all annotations need to implement) and an (extensible) whitelist that gets all annontations added dynamically?

#9

Updated by Karsten Dambekalns almost 10 years ago

Check the configuration in the TYPO3.TcPdf package, it simply adds stuff. Worked for me, so unless I missed something, no need to replicate (which would be stupid).

#10

Updated by Gerrit Code Review over 9 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7747

#11

Updated by Christian Müller over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF