[DCOM-94] Support for constants on annotation reader Created: 06/Feb/12  Updated: 15/Mar/12  Resolved: 15/Mar/12

Status: Resolved
Project: Doctrine Common
Component/s: Annotations
Affects Version/s: None
Fix Version/s: 2.3

Type: New Feature Priority: Minor
Reporter: Fabio B. Silva Assignee: Fabio B. Silva
Resolution: Fixed Votes: 1
Labels: None


 Description   

Would be nice get support for constants on annotation reader.

Usage :

/**
* @SomeAnnotation(PHP_EOL)
* @SomeAnnotation(SomeClass::SOME_VALUE)
* @SomeAnnotation({SomeClass::VALUE1,SomeClass::VALUE2})
* @SomeAnnotation({SomeClass::SOME_KEY = SomeClass::SOME_VALUE})
*/


 Comments   
Comment by gabriel sancho [ 22/Feb/12 ]

file doctrine-2.2.0/Doctrine/Common/Lexer.php
line 214
@patch : para poder usar constantes

  • definidas con define como param de las anotaciones
  • las constantes deben empesar por '_' para evitar conflictos con 'false' y 'true'
  • esto solo soporta constantes en los valores de las anotaciones
  • ej:

define('_db_clase_05', '"test.Clase_05"');
...
/** @Table(name=_db_clase_05)
... */
class Clase_05

{ ... }

if(is_string($match[0]) && ($match[0][0] == '_') && defined($match[0]))

{ $aux_val = constant($match[0]); $match[0] = $aux_val; }
Comment by Fabio B. Silva [ 22/Feb/12 ]

hello gabriel,

I have a pull request opened : https://github.com/doctrine/common/pull/104

feel free to join us and comment ...
in inglesh please

Comment by Fabio B. Silva [ 15/Mar/12 ]

Fixed : https://github.com/doctrine/common/commit/970912eec0a1371e03de7010556d9280c26d8083

Generated at Sat Nov 01 04:52:47 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.