Class Phalcon\Annotations\Collection

implements Iterator, Traversable, Countable

Source on GitHub

Represents a collection of annotations. This class allows to traverse a group of annotations easily

  1. <?php
  2. //Traverse annotations
  3. foreach ($classAnnotations as $annotation) {
  4. echo "Name=", $annotation->getName(), PHP_EOL;
  5. }
  6. //Check if the annotations has a specific
  7. var_dump($classAnnotations->has("Cacheable"));
  8. //Get an specific annotation in the collection
  9. $annotation = $classAnnotations->get("Cacheable");

Methods

public __construct ([array $reflectionData])

Phalcon\Annotations\Collection constructor

public count ()

Returns the number of annotations in the collection

public rewind ()

Rewinds the internal iterator

public Phalcon\Annotations\Annotation current ()

Returns the current annotation in the iterator

public key ()

Returns the current position/key in the iterator

public next ()

Moves the internal iteration pointer to the next position

public valid ()

Check if the current annotation in the iterator is valid

public getAnnotations ()

Returns the internal annotations as an array

public get (mixed $name)

Returns the first annotation that match a name

public getAll (mixed $name)

Returns all the annotations that match a name

public has (mixed $name)

Check if an annotation exists in a collection