final class Target

Annotation that can be used to signal to the parser to check the annotation target during the parsing process.

@author Fabio B. Silva <fabio.bat.silva@gmail.com>

Hierarchy

  • class \Doctrine\Common\Annotations\Annotation\Target

Expanded class hierarchy of Target

4 files declare their use of Target
AnnotationReader.php in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/AnnotationReader.php
DocParser.php in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/DocParser.php
DocParserTest.php in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
SimpleAnnotationReader.php in drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php
2 string references to 'Target'
FieldPluginBase::buildOptionsForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php
Default options form that provides the label widget that all fields should have.
views.data_types.schema.yml in drupal/core/modules/views/config/schema/views.data_types.schema.yml
drupal/core/modules/views/config/schema/views.data_types.schema.yml
13 classes are annotated with Target
AnnotationTargetAll in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetAll.php
Plugin annotation @Target("ALL");
AnnotationTargetAnnotation in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetAnnotation.php
Plugin annotation @Target({ "ANNOTATION" })
AnnotationTargetClass in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetClass.php
Plugin annotation @Target("CLASS");
AnnotationTargetMethod in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetMethod.php
Plugin annotation @Target("METHOD");
AnnotationTargetPropertyMethod in drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationTargetPropertyMethod.php
Plugin annotation @Target({ "METHOD", "PROPERTY" })

... See full list

File

drupal/core/vendor/doctrine/common/lib/Doctrine/Common/Annotations/Annotation/Target.php, line 31

Namespace

Doctrine\Common\Annotations\Annotation
View source
final class Target {
  const TARGET_CLASS = 1;
  const TARGET_METHOD = 2;
  const TARGET_PROPERTY = 4;
  const TARGET_ANNOTATION = 8;
  const TARGET_ALL = 15;

  /**
   * @var array
   */
  private static $map = array(
    'ALL' => self::TARGET_ALL,
    'CLASS' => self::TARGET_CLASS,
    'METHOD' => self::TARGET_METHOD,
    'PROPERTY' => self::TARGET_PROPERTY,
    'ANNOTATION' => self::TARGET_ANNOTATION,
  );

  /**
   * @var array
   */
  public $value;

  /**
   * Targets as bitmask.
   *
   * @var integer
   */
  public $targets;

  /**
   * Literal target declaration.
   *
   * @var integer
   */
  public $literal;

  /**
   * Annotation construct
   *
   * @param array $values
   *
   * @throws \InvalidArgumentException
   */
  public function __construct(array $values) {
    if (!isset($values['value'])) {
      $values['value'] = null;
    }
    if (is_string($values['value'])) {
      $values['value'] = array(
        $values['value'],
      );
    }
    if (!is_array($values['value'])) {
      throw new \InvalidArgumentException(sprintf('@Target expects either a string value, or an array of strings, "%s" given.', is_object($values['value']) ? get_class($values['value']) : gettype($values['value'])));
    }
    $bitmask = 0;
    foreach ($values['value'] as $literal) {
      if (!isset(self::$map[$literal])) {
        throw new \InvalidArgumentException(sprintf('Invalid Target "%s". Available targets: [%s]', $literal, implode(', ', array_keys(self::$map))));
      }
      $bitmask += self::$map[$literal];
    }
    $this->targets = $bitmask;
    $this->value = $values['value'];
    $this->literal = implode(', ', $this->value);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Target::$literal public property Literal target declaration.
Target::$map private static property
Target::$targets public property Targets as bitmask.
Target::$value public property
Target::TARGET_ALL constant
Target::TARGET_ANNOTATION constant
Target::TARGET_CLASS constant
Target::TARGET_METHOD constant
Target::TARGET_PROPERTY constant
Target::__construct public function Annotation construct