AbstractReaderTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <?php
  2. namespace Doctrine\Tests\Common\Annotations;
  3. use Doctrine\Common\Annotations\DoctrineReader;
  4. use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
  5. use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc;
  6. use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader;
  7. use Doctrine\Tests\Common\Annotations\DummyAnnotation;
  8. use Doctrine\Tests\Common\Annotations\Name;
  9. use Doctrine\Tests\Common\Annotations\DummyId;
  10. use Doctrine\Tests\Common\Annotations\DummyJoinTable;
  11. use Doctrine\Tests\Common\Annotations\DummyJoinColumn;
  12. use Doctrine\Tests\Common\Annotations\DummyColumn;
  13. use Doctrine\Tests\Common\Annotations\DummyGeneratedValue;
  14. require_once __DIR__ . '/TopLevelAnnotation.php';
  15. abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase
  16. {
  17. public function getReflectionClass()
  18. {
  19. $className = 'Doctrine\Tests\Common\Annotations\DummyClass';
  20. return new ReflectionClass($className);
  21. }
  22. public function testAnnotations()
  23. {
  24. $class = $this->getReflectionClass();
  25. $reader = $this->getReader();
  26. $this->assertEquals(1, count($reader->getClassAnnotations($class)));
  27. $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName));
  28. $this->assertEquals("hello", $annot->dummyValue);
  29. $field1Prop = $class->getProperty('field1');
  30. $propAnnots = $reader->getPropertyAnnotations($field1Prop);
  31. $this->assertEquals(1, count($propAnnots));
  32. $this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName));
  33. $this->assertEquals("fieldHello", $annot->dummyValue);
  34. $getField1Method = $class->getMethod('getField1');
  35. $methodAnnots = $reader->getMethodAnnotations($getField1Method);
  36. $this->assertEquals(1, count($methodAnnots));
  37. $this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName));
  38. $this->assertEquals(array(1, 2, "three"), $annot->value);
  39. $field2Prop = $class->getProperty('field2');
  40. $propAnnots = $reader->getPropertyAnnotations($field2Prop);
  41. $this->assertEquals(1, count($propAnnots));
  42. $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName));
  43. $this->assertEquals(1, count($joinTableAnnot->joinColumns));
  44. $this->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
  45. $this->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
  46. $this->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
  47. $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
  48. $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
  49. $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
  50. $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
  51. $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
  52. $this->assertEquals('', $dummyAnnot->dummyValue);
  53. $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value);
  54. $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
  55. $this->assertEquals('fieldHello', $dummyAnnot->dummyValue);
  56. $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation');
  57. $this->assertEquals('hello', $classAnnot->dummyValue);
  58. }
  59. public function testAnnotationsWithValidTargets()
  60. {
  61. $reader = $this->getReader();
  62. $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget');
  63. $this->assertEquals(1,count($reader->getClassAnnotations($class)));
  64. $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('foo'))));
  65. $this->assertEquals(1,count($reader->getMethodAnnotations($class->getMethod('someFunction'))));
  66. $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('nested'))));
  67. }
  68. public function testAnnotationsWithVarType()
  69. {
  70. $reader = $this->getReader();
  71. $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
  72. $this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))));
  73. $this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar'))));
  74. $this->assertInternalType('string', $fooAnnot[0]->string);
  75. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation);
  76. }
  77. /**
  78. * @expectedException Doctrine\Common\Annotations\AnnotationException
  79. * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetPropertyMethod is not allowed to be declared on class Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass. You may only use this annotation on these code elements: METHOD, PROPERTY
  80. */
  81. public function testClassWithInvalidAnnotationTargetAtClassDocBlock()
  82. {
  83. $reader = $this->getReader();
  84. $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'));
  85. }
  86. public function testClassWithWithInclude()
  87. {
  88. $reader = $this->getReader();
  89. $annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithRequire'));
  90. $this->assertCount(1, $annots);
  91. }
  92. /**
  93. * @expectedException Doctrine\Common\Annotations\AnnotationException
  94. * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$foo. You may only use this annotation on these code elements: CLASS
  95. */
  96. public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock()
  97. {
  98. $reader = $this->getReader();
  99. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'foo'));
  100. }
  101. /**
  102. * @expectedException Doctrine\Common\Annotations\AnnotationException
  103. * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetAnnotation is not allowed to be declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty::$bar. You may only use this annotation on these code elements: ANNOTATION
  104. */
  105. public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock()
  106. {
  107. $reader = $this->getReader();
  108. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'bar'));
  109. }
  110. /**
  111. * @expectedException Doctrine\Common\Annotations\AnnotationException
  112. * @expectedExceptionMessage [Semantical Error] Annotation @AnnotationTargetClass is not allowed to be declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod::functionName(). You may only use this annotation on these code elements: CLASS
  113. */
  114. public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
  115. {
  116. $reader = $this->getReader();
  117. $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod', 'functionName'));
  118. }
  119. /**
  120. * @expectedException Doctrine\Common\Annotations\AnnotationException
  121. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
  122. */
  123. public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock()
  124. {
  125. $reader = $this->getReader();
  126. $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError'));
  127. }
  128. /**
  129. * @expectedException Doctrine\Common\Annotations\AnnotationException
  130. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
  131. */
  132. public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock()
  133. {
  134. $reader = $this->getReader();
  135. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','foo'));
  136. }
  137. /**
  138. * @expectedException Doctrine\Common\Annotations\AnnotationException
  139. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
  140. */
  141. public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock()
  142. {
  143. $reader = $this->getReader();
  144. $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','bar'));
  145. }
  146. /**
  147. * @expectedException Doctrine\Common\Annotations\AnnotationException
  148. * @expectedExceptionMessage [Type Error] Attribute "string" of @AnnotationWithVarType declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::$invalidProperty expects a(n) string, but got integer.
  149. */
  150. public function testClassWithPropertyInvalidVarTypeError()
  151. {
  152. $reader = $this->getReader();
  153. $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
  154. $reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
  155. }
  156. /**
  157. * @expectedException Doctrine\Common\Annotations\AnnotationException
  158. * @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation.
  159. */
  160. public function testClassWithMethodInvalidVarTypeError()
  161. {
  162. $reader = $this->getReader();
  163. $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType');
  164. $reader->getMethodAnnotations($class->getMethod('invalidMethod'));
  165. }
  166. /**
  167. * @expectedException Doctrine\Common\Annotations\AnnotationException
  168. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in class Doctrine\Tests\Common\Annotations\DummyClassSyntaxError.
  169. */
  170. public function testClassSyntaxErrorContext()
  171. {
  172. $reader = $this->getReader();
  173. $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError'));
  174. }
  175. /**
  176. * @expectedException Doctrine\Common\Annotations\AnnotationException
  177. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in method Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError::foo().
  178. */
  179. public function testMethodSyntaxErrorContext()
  180. {
  181. $reader = $this->getReader();
  182. $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo'));
  183. }
  184. /**
  185. * @expectedException Doctrine\Common\Annotations\AnnotationException
  186. * @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 18 in property Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError::$foo.
  187. */
  188. public function testPropertySyntaxErrorContext()
  189. {
  190. $reader = $this->getReader();
  191. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo'));
  192. }
  193. /**
  194. * @group regression
  195. */
  196. public function testMultipleAnnotationsOnSameLine()
  197. {
  198. $reader = $this->getReader();
  199. $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id'));
  200. $this->assertEquals(3, count($annots));
  201. }
  202. public function testNonAnnotationProblem()
  203. {
  204. $reader = $this->getReader();
  205. $this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
  206. $this->assertInstanceOf($name, $annot);
  207. }
  208. public function testImportWithConcreteAnnotation()
  209. {
  210. $reader = $this->getReader();
  211. $property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field');
  212. $annotations = $reader->getPropertyAnnotations($property);
  213. $this->assertEquals(1, count($annotations));
  214. $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'));
  215. }
  216. public function testImportWithInheritance()
  217. {
  218. $reader = $this->getReader();
  219. $class = new TestParentClass();
  220. $ref = new \ReflectionClass($class);
  221. $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child'));
  222. $this->assertEquals(1, count($childAnnotations));
  223. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations));
  224. $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent'));
  225. $this->assertEquals(1, count($parentAnnotations));
  226. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations));
  227. }
  228. /**
  229. * @expectedException Doctrine\Common\Annotations\AnnotationException
  230. * @expectedExceptionMessage The annotation "@NameFoo" in property Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass::$field was never imported.
  231. */
  232. public function testImportDetectsNotImportedAnnotation()
  233. {
  234. $reader = $this->getReader();
  235. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field'));
  236. }
  237. /**
  238. * @expectedException Doctrine\Common\Annotations\AnnotationException
  239. * @expectedExceptionMessage The annotation "@Foo\Bar\Name" in property Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass::$field was never imported.
  240. */
  241. public function testImportDetectsNonExistentAnnotation()
  242. {
  243. $reader = $this->getReader();
  244. $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field'));
  245. }
  246. public function testTopLevelAnnotation()
  247. {
  248. $reader = $this->getReader();
  249. $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field'));
  250. $this->assertEquals(1, count($annotations));
  251. $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations));
  252. }
  253. public function testIgnoresAnnotationsNotPrefixedWithWhitespace()
  254. {
  255. $reader = $this->getReader();
  256. $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name');
  257. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation);
  258. }
  259. /**
  260. * @expectedException Doctrine\Common\Annotations\AnnotationException
  261. * @expectedExceptionMessage The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation". If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass.
  262. */
  263. public function testErrorWhenInvalidAnnotationIsUsed()
  264. {
  265. $reader = $this->getReader();
  266. $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass');
  267. $reader->getClassAnnotations($ref);
  268. }
  269. public function testInvalidAnnotationUsageButIgnoredClass()
  270. {
  271. $reader = $this->getReader();
  272. $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass');
  273. $annots = $reader->getClassAnnotations($ref);
  274. $this->assertEquals(2, count($annots));
  275. }
  276. /**
  277. * @group DDC-1660
  278. * @group regression
  279. */
  280. public function testInvalidAnnotationButIgnored()
  281. {
  282. $reader = $this->getReader();
  283. $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660');
  284. $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version'));
  285. $this->assertCount(0, $reader->getClassAnnotations($class));
  286. $this->assertCount(0, $reader->getMethodAnnotations($class->getMethod('bar')));
  287. $this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo')));
  288. }
  289. public function testAnnotationEnumeratorException()
  290. {
  291. $reader = $this->getReader();
  292. $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum');
  293. $this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar')));
  294. $this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo')));
  295. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]);
  296. $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]);
  297. try {
  298. $reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
  299. $this->fail();
  300. } catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
  301. $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage());
  302. }
  303. try {
  304. $reader->getMethodAnnotations($class->getMethod('invalidMethod'));
  305. $this->fail();
  306. } catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
  307. $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::invalidMethod() accept only [ONE, TWO, THREE], but got 5.', $exc->getMessage());
  308. }
  309. }
  310. /**
  311. * @group DCOM-106
  312. */
  313. public function testIgnoreFixMeAndUpperCaseToDo()
  314. {
  315. $reader = $this->getReader();
  316. $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106');
  317. $reader->getClassAnnotations($ref);
  318. }
  319. /**
  320. * @return AnnotationReader
  321. */
  322. abstract protected function getReader();
  323. }
  324. /**
  325. * @parseAnnotation("var")
  326. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  327. *
  328. */
  329. class TestParseAnnotationClass
  330. {
  331. /**
  332. * @var
  333. */
  334. private $field;
  335. }
  336. /**
  337. * @Name
  338. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  339. */
  340. class TestIgnoresNonAnnotationsClass
  341. {
  342. }
  343. class TestTopLevelAnnotationClass
  344. {
  345. /**
  346. * @\TopLevelAnnotation
  347. */
  348. private $field;
  349. }
  350. class TestNonExistentAnnotationClass
  351. {
  352. /**
  353. * @Foo\Bar\Name
  354. */
  355. private $field;
  356. }
  357. class TestAnnotationNotImportedClass
  358. {
  359. /**
  360. * @NameFoo
  361. */
  362. private $field;
  363. }
  364. class TestChildClass
  365. {
  366. /**
  367. * @\Doctrine\Tests\Common\Annotations\Foo\Name(name = "foo")
  368. */
  369. protected $child;
  370. }
  371. class TestParentClass extends TestChildClass
  372. {
  373. /**
  374. * @\Doctrine\Tests\Common\Annotations\Bar\Name(name = "bar")
  375. */
  376. private $parent;
  377. }
  378. class TestImportWithConcreteAnnotation
  379. {
  380. /**
  381. * @DummyAnnotation(dummyValue = "bar")
  382. */
  383. private $field;
  384. }
  385. /**
  386. * @ignoreAnnotation("var")
  387. */
  388. class DummyClass2 {
  389. /**
  390. * @DummyId @DummyColumn(type="integer") @DummyGeneratedValue
  391. * @var integer
  392. */
  393. private $id;
  394. }
  395. /** @Annotation */
  396. class DummyId extends \Doctrine\Common\Annotations\Annotation {}
  397. /** @Annotation */
  398. class DummyColumn extends \Doctrine\Common\Annotations\Annotation {
  399. public $type;
  400. }
  401. /** @Annotation */
  402. class DummyGeneratedValue extends \Doctrine\Common\Annotations\Annotation {}
  403. /** @Annotation */
  404. class DummyAnnotation extends \Doctrine\Common\Annotations\Annotation {
  405. public $dummyValue;
  406. }
  407. /**
  408. * @api
  409. * @Annotation
  410. */
  411. class DummyAnnotationWithIgnoredAnnotation extends \Doctrine\Common\Annotations\Annotation {
  412. public $dummyValue;
  413. }
  414. /** @Annotation */
  415. class DummyJoinColumn extends \Doctrine\Common\Annotations\Annotation {
  416. public $name;
  417. public $referencedColumnName;
  418. }
  419. /** @Annotation */
  420. class DummyJoinTable extends \Doctrine\Common\Annotations\Annotation {
  421. public $name;
  422. public $joinColumns;
  423. public $inverseJoinColumns;
  424. }
  425. /**
  426. * @DummyAnnotation(@)
  427. */
  428. class DummyClassSyntaxError
  429. {
  430. }
  431. class DummyClassMethodSyntaxError
  432. {
  433. /**
  434. * @DummyAnnotation(@)
  435. */
  436. public function foo()
  437. {
  438. }
  439. }
  440. class DummyClassPropertySyntaxError
  441. {
  442. /**
  443. * @DummyAnnotation(@)
  444. */
  445. public $foo;
  446. }
  447. /**
  448. * @ignoreAnnotation({"since", "var"})
  449. */
  450. class DummyClassNonAnnotationProblem
  451. {
  452. /**
  453. * @DummyAnnotation
  454. *
  455. * @var \Test
  456. * @since 0.1
  457. */
  458. public $foo;
  459. }
  460. /**
  461. * @DummyAnnotation Foo bar <foobar@1domain.com>
  462. */
  463. class DummyClassWithEmail
  464. {
  465. }
  466. /**
  467. * @fixme public
  468. * @TODO
  469. */
  470. class DCOM106
  471. {
  472. }
  473. namespace Doctrine\Tests\Common\Annotations\Foo;
  474. /** @Annotation */
  475. class Name extends \Doctrine\Common\Annotations\Annotation
  476. {
  477. public $name;
  478. }
  479. namespace Doctrine\Tests\Common\Annotations\Bar;
  480. /** @Annotation */
  481. class Name extends \Doctrine\Common\Annotations\Annotation
  482. {
  483. public $name;
  484. }