annotating with annotations - dpc uncon
DESCRIPTION
What exactly are annotations? How can they change the way you code and make life simpler? Annotations allow you to implement new functionality into code using "notes" this allows you to easily maintain your own architecture but benefit from external tools. Let's look at how annotations are used today in PHP and how we can develop our own solutions based on the existing libraries.TRANSCRIPT
![Page 1: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/1.jpg)
A����������� ������������������ look����������� ������������������ into����������� ������������������ Annotations����������� ������������������ in����������� ������������������ PHP
Rafael����������� ������������������ Dohms
*����������� ������������������ Dutch����������� ������������������ PHP����������� ������������������ Conference����������� ������������������ 2012����������� ������������������ -����������� ������������������ UnCon
Annotating����������� ������������������ with����������� ������������������ Annotations
@rdohmson����������� ������������������ twitter
![Page 2: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/2.jpg)
A����������� ������������������ look����������� ������������������ into����������� ������������������ Annotations����������� ������������������ in����������� ������������������ PHP
Rafael����������� ������������������ Dohms
*����������� ������������������ Forum����������� ������������������ PHP����������� ������������������ Paris����������� ������������������ 2012
Annotating����������� ������������������ with����������� ������������������ Annotations
@rdohmson����������� ������������������ twitter
![Page 3: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/3.jpg)
phot
o cr
edit:
Eli W
hite
Evangelist, Speaker and Contributor.
Podcaster, User Group Leader.
Developer at WEBclusive.
Rafael Dohms@rdohms
![Page 4: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/4.jpg)
What? Why? Where?
How?
a����������� ������������������ little����������� ������������������ history
show����������� ������������������ me����������� ������������������ the����������� ������������������ code!
existing����������� ������������������ uses
Implementing����������� ������������������ custom����������� ������������������ annotations
based����������� ������������������ on����������� ������������������ DMS\Filter
![Page 5: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/5.jpg)
what?What����������� ������������������ ar
e����������� ������������������ annotation
s?
http://ecdesignrebels.blogspot.com
![Page 6: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/6.jpg)
-- In English --"An annotation is a note that is made while
reading any form of text."
![Page 7: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/7.jpg)
-- In English --"An annotation is a note that is made while
reading any form of text."
something����������� ������������������ that����������� ������������������ describes����������� ������������������ an����������� ������������������ aspect����������� ������������������ of����������� ������������������ the����������� ������������������ subject
![Page 8: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/8.jpg)
“An annotation describes behavior of code and affects your application in runtime.”
“Annotations do not directly affect program semantics”
-- In Code Speak --
![Page 9: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/9.jpg)
“An annotation describes behavior of code and affects your application in runtime.”
“Annotations do not directly affect program semantics”
-- In Code Speak --
just����������� ������������������ like����������� ������������������ your����������� ������������������ notes
![Page 10: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/10.jpg)
![Page 11: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/11.jpg)
In����������� ������������������ 2004:����������� ������������������ Metadata����������� ������������������ or����������� ������������������ “General����������� ������������������ purpose����������� ������������������ Annotations”
![Page 12: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/12.jpg)
In����������� ������������������ 2004:����������� ������������������ Metadata����������� ������������������ or����������� ������������������ “General����������� ������������������ purpose����������� ������������������ Annotations”
available����������� ������������������ at����������� ������������������ Runtime����������� ������������������ using����������� ������������������ Reflection
![Page 13: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/13.jpg)
In����������� ������������������ 2004:����������� ������������������ Metadata����������� ������������������ or����������� ������������������ “General����������� ������������������ purpose����������� ������������������ Annotations”
available����������� ������������������ at����������� ������������������ Runtime����������� ������������������ using����������� ������������������ Reflection
@Entity @Table(name = "people") class Person implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; @Column(length = 32) private String name;
![Page 14: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/14.jpg)
In����������� ������������������ 2004:����������� ������������������ Metadata����������� ������������������ or����������� ������������������ “General����������� ������������������ purpose����������� ������������������ Annotations”
available����������� ������������������ at����������� ������������������ Runtime����������� ������������������ using����������� ������������������ Reflection
@Entity @Table(name = "people") class Person implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; @Column(length = 32) private String name;
specific����������� ������������������ syntax
![Page 15: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/15.jpg)
![Page 16: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/16.jpg)
No����������� ������������������ core����������� ������������������ annotation����������� ������������������ support
![Page 17: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/17.jpg)
Questions?
![Page 18: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/18.jpg)
Questions?
I’m����������� ������������������ kidding!
![Page 19: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/19.jpg)
![Page 20: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/20.jpg)
![Page 21: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/21.jpg)
phpDoc
~2000
![Page 22: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/22.jpg)
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005
![Page 23: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/23.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005
![Page 24: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/24.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
![Page 25: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/25.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
![Page 26: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/26.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
2010
RFC:����������� ������������������ Annotations����������� ������������������ in����������� ������������������ core����������� ������������������ w/����������� ������������������ custom����������� ������������������
syntax
![Page 27: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/27.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
2010
RFC:����������� ������������������ Annotations����������� ������������������ in����������� ������������������ core����������� ������������������ w/����������� ������������������ custom����������� ������������������
syntaxREJECTED
![Page 28: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/28.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
2010
RFC:����������� ������������������ Annotations����������� ������������������ in����������� ������������������ core����������� ������������������ w/����������� ������������������ custom����������� ������������������
syntax
2011
RFC:����������� ������������������ DocBlock����������� ������������������ Annotations
“in����������� ������������������ discussion”
REJECTED
![Page 29: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/29.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
2010
RFC:����������� ������������������ Annotations����������� ������������������ in����������� ������������������ core����������� ������������������ w/����������� ������������������ custom����������� ������������������
syntax
2011
RFC:����������� ������������������ DocBlock����������� ������������������ Annotations
“in����������� ������������������ discussion”
REJECTED
?
![Page 30: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/30.jpg)
First����������� ������������������ Annotation
����������� ������������������ Engines����������� ������������������ in����������� ������������������ PHP
phpDoc
PHP����������� ������������������ 5.1Reflection����������� ������������������ supports����������� ������������������ getDocComments()
~2000 2005 2008
Doctrine����������� ������������������ 2����������� ������������������ Annotation����������� ������������������ Engine
2010
RFC:����������� ������������������ Annotations����������� ������������������ in����������� ������������������ core����������� ������������������ w/����������� ������������������ custom����������� ������������������
syntax
2011
RFC:����������� ������������������ DocBlock����������� ������������������ Annotations
“in����������� ������������������ discussion”
REJECTED
?
/** * Caas\Bundle\FundingBundle\Entity\Reward * * @ORM\Table("reward") * @ORM\Entity(repositoryClass="Caas\Bundle\FundingBundle\Entity\RewardRepository") */ class Reward { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string $title * * @ORM\Column(name="title", type="string", length=150, nullable=true) * * @Assert\MaxLength(150) */ protected $title;
![Page 31: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/31.jpg)
Note:
![Page 32: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/32.jpg)
Note:
//����������� ������������������ This����������� ������������������ is����������� ������������������ a����������� ������������������ comment
/*����������� ������������������ This����������� ������������������ is����������� ������������������ a����������� ������������������ multiline����������� ������������������ comment����������� ������������������ */T_COMMENT
![Page 33: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/33.jpg)
Note:
//����������� ������������������ This����������� ������������������ is����������� ������������������ a����������� ������������������ comment
/*����������� ������������������ This����������� ������������������ is����������� ������������������ a����������� ������������������ multiline����������� ������������������ comment����������� ������������������ */
/**����������� ������������������ ����������� ������������������ *����������� ������������������ This����������� ������������������ is����������� ������������������ a����������� ������������������ doc����������� ������������������ block����������� ������������������ */
T_COMMENT
T_DOC_COMMENT
![Page 34: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/34.jpg)
/** * @deprecated * * @ORM\Column(‘string’, length=255) */public function method()
![Page 35: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/35.jpg)
/** * @deprecated * * @ORM\Column(‘string’, length=255) */public function method()
marker
![Page 36: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/36.jpg)
/** * @deprecated * * @ORM\Column(‘string’, length=255) */public function method()
markerparameterized
![Page 37: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/37.jpg)
Why?Why����������� ������������������ sho
uld����������� ������������������ I����������� ������������������ use����������� ������������������ ann
otations?
http://ecdesignrebels.blogspot.com
what����������� ������������������ are����������� ������������������ the����������� ������������������
pros/cons?
![Page 38: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/38.jpg)
-
![Page 39: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/39.jpg)
Harder����������� ������������������ to����������� ������������������ debug����������� ������������������ (dynamic����������� ������������������ code)
-
![Page 40: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/40.jpg)
Harder����������� ������������������ to����������� ������������������ debug����������� ������������������ (dynamic����������� ������������������ code)
- Performance����������� ������������������ hit����������� ������������������ (non-native����������� ������������������ code)
![Page 41: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/41.jpg)
Harder����������� ������������������ to����������� ������������������ debug����������� ������������������ (dynamic����������� ������������������ code)
Its����������� ������������������ implemented����������� ������������������ in����������� ������������������ comments����������� ������������������ docblocks!
- Performance����������� ������������������ hit����������� ������������������ (non-native����������� ������������������ code)
![Page 42: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/42.jpg)
+
![Page 43: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/43.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
+
![Page 44: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/44.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
+
Doctrine����������� ������������������ 1����������� ������������������ vs����������� ������������������ Doctrine����������� ������������������ 2
![Page 45: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/45.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
Contextualizes����������� ������������������ behavior/config����������� ������������������ in����������� ������������������ the����������� ������������������ object+
Doctrine����������� ������������������ 1����������� ������������������ vs����������� ������������������ Doctrine����������� ������������������ 2
![Page 46: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/46.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
Contextualizes����������� ������������������ behavior/config����������� ������������������ in����������� ������������������ the����������� ������������������ object+
Doctrine����������� ������������������ 1����������� ������������������ vs����������� ������������������ Doctrine����������� ������������������ 2
In����������� ������������������ object����������� ������������������ vs.����������� ������������������ external����������� ������������������ configuration����������� ������������������ file
![Page 47: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/47.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
Contextualizes����������� ������������������ behavior/config����������� ������������������ in����������� ������������������ the����������� ������������������ object+
Doctrine����������� ������������������ 1����������� ������������������ vs����������� ������������������ Doctrine����������� ������������������ 2
In����������� ������������������ object����������� ������������������ vs.����������� ������������������ external����������� ������������������ configuration����������� ������������������ file
Its����������� ������������������ documented/stored����������� ������������������ by����������� ������������������ phpDocumentor
![Page 48: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/48.jpg)
Easier����������� ������������������ to����������� ������������������ inject����������� ������������������ behavior����������� ������������������ without����������� ������������������ extending
Contextualizes����������� ������������������ behavior/config����������� ������������������ in����������� ������������������ the����������� ������������������ object+
Doctrine����������� ������������������ 1����������� ������������������ vs����������� ������������������ Doctrine����������� ������������������ 2
In����������� ������������������ object����������� ������������������ vs.����������� ������������������ external����������� ������������������ configuration����������� ������������������ file
Its����������� ������������������ documented/stored����������� ������������������ by����������� ������������������ phpDocumentorIts����������� ������������������ in����������� ������������������ docblocks,����������� ������������������ so����������� ������������������ its����������� ������������������ parsed
![Page 49: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/49.jpg)
<?php
class User{
protected $name
...
}
![Page 50: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/50.jpg)
<?php
class User{
protected $name
...
}
-����������� ������������������ persist����������� ������������������ as����������� ������������������ varchar
-����������� ������������������ length����������� ������������������ should����������� ������������������ not����������� ������������������ be����������� ������������������
more����������� ������������������ then����������� ������������������ 255
-����������� ������������������ should����������� ������������������ not����������� ������������������ be����������� ������������������ blank
-����������� ������������������ only����������� ������������������ letters
![Page 51: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/51.jpg)
<?php
class User{
protected $name
...
}
-����������� ������������������ persist����������� ������������������ as����������� ������������������ varchar
-����������� ������������������ length����������� ������������������ should����������� ������������������ not����������� ������������������ be����������� ������������������
more����������� ������������������ then����������� ������������������ 255
-����������� ������������������ should����������� ������������������ not����������� ������������������ be����������� ������������������ blank
-����������� ������������������ only����������� ������������������ letters
Acme\BlogBundle\Entity\Author: properties: name: - NotBlank: ~ - MaxLength: 255
Doctrine\Tests\ORM\Mapping\User: type: entity table: cms_users id: id: type: integer generator: strategy: AUTO fields: name: type: string length: 255
Acme\BlogBundle\Entity\Author: filters: name: - alpha
Validation
filter
persistence
![Page 52: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/52.jpg)
/** * @ORM\Column(‘string’, length=255) * @Assert\NotBlank() * @Assert\MaxLength(255) * @Filter\Alpha() */
class User{
protected $name
...
}
<?phpValidation
persistence
filter
![Page 53: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/53.jpg)
Where?Where����������� ������������������ a
re����������� ������������������ annotatio
ns����������� ������������������ used?
http://ecdesignrebels.blogspot.com
![Page 54: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/54.jpg)
![Page 55: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/55.jpg)
class DataTest extends PHPUnit_Framework_TestCase { /** * @dataProvider provider * * @expectedException InvalidArgumentException * @expectedExceptionMessage Right Message */ public function testAdd($a, $b, $c) { /* Test code */ } public function provider() { return array( array(0, 0, 0), ); } }
expectations
repetition
![Page 56: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/56.jpg)
/** * @ORM\Table("myentity") * @ORM\Entity(repositoryClass="MyEntityRepository") */ class MyEntity { /** * @var integer $id * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @var string $title * * @ORM\Column(name="title", type="string", length=255) * @Assert\MaxLength(255) * @Assert\NotBlank() */ protected $title; /** * @var \Doctrine\Common\Collections\ArrayCollection $users * * @ORM\OneToMany(targetEntity="OtherEntity", mappedBy="myEntity", cascade={"persist","remove"}) */ protected $otherEntities; }
persistance
association
![Page 57: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/57.jpg)
/** * @Route("/myaction/{id}", name="myaction") * @Method("POST") * * @Template("MyBundle:MyController:my.html.twig") * * @param int $id * @return array */ public function myAction($id) { /* Controller Logic */ return array('data' => $data); }
class MyEntity { /** * @var string $title * * @ORM\Column(name="title", type="string", length=255) * @Assert\MaxLength(255) * @Assert\NotBlank() */ protected $title; }
routing
Validation
templating
![Page 58: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/58.jpg)
/** * @FLOW3\Aspect */ class LoggingAspect { /** * @FLOW3\Inject * @var \Examples\Forum\Logger\ApplicationLoggerInterface */ protected $applicationLogger; /** * Log a message if a post is deleted * * @param \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint * @FLOW3\Before("method(Examples\Forum\Domain\Model\Forum->deletePost())") * @return void */ public function logDeletePost(\TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint) { $post = $joinPoint->getMethodArgument('post'); $this->applicationLogger->log('Removing post ' . $post->getTitle(), LOG_INFO); } }
Dependency����������� ������������������ Injection
AOP
![Page 59: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/59.jpg)
How?How����������� ������������������ can����������� ������������������ i����������� ������������������
write����������� ������������������ my����������� ������������������ own����������� ������������������
annotations?
http://ecdesignrebels.blogspot.com
![Page 60: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/60.jpg)
Annotations
My����������� ������������������ Project
![Page 61: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/61.jpg)
Annotations
My����������� ������������������ Project
Annotation����������� ������������������ Engine
![Page 62: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/62.jpg)
![Page 63: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/63.jpg)
/** * @tag parameters */public function method()
Code
![Page 64: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/64.jpg)
/** * @tag parameters */public function method()
Code
ReflectionClass->getDocComment()
![Page 65: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/65.jpg)
DOCBlock
/** * @tag parameters */
/** * @tag parameters */public function method()
Code
ReflectionClass->getDocComment()
![Page 66: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/66.jpg)
DOCBlock
/** * @tag parameters */
/** * @tag parameters */public function method()
Code
ReflectionClass->getDocComment()
![Page 67: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/67.jpg)
DOCBlock
/** * @tag parameters */
Tag() + parameters
Annotation����������� ������������������ Instances
/** * @tag parameters */public function method()
Code
ReflectionClass->getDocComment()
![Page 68: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/68.jpg)
Doctrine����������� ������������������ Commons
ZF2����������� ������������������ Annotations
phpDocumentor����������� ������������������ 2
php-annotationsaddendumStubble
abandoned?
Notoj
Annotation Engines
![Page 69: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/69.jpg)
Annotation Engines
Notoj
2.3 2.0����������� ������������������ -����������� ������������������ alpha ?
Parameterized marker parameterized
very����������� ������������������ mature maturing new
![Page 70: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/70.jpg)
Annotation Engines
Notoj
2.3 2.0����������� ������������������ -����������� ������������������ alpha ?
Parameterized marker parameterized
very����������� ������������������ mature maturing new
![Page 71: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/71.jpg)
How����������� ������������������ it����������� ������������������ Works
<?php
/** * @ORM\Column(‘string’) * @Assert\NotBlank() */
use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\ Constraints as Assert;
![Page 72: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/72.jpg)
How����������� ������������������ it����������� ������������������ Works
<?php
/** * @ORM\Column(‘string’) * @Assert\NotBlank() */
use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\ Constraints as Assert;
Declare����������� ������������������ which����������� ������������������ Annotations����������� ������������������ you����������� ������������������ will����������� ������������������ use
![Page 73: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/73.jpg)
How����������� ������������������ it����������� ������������������ Works
AnnotationReader<?php
/** * @ORM\Column(‘string’) * @Assert\NotBlank() */
use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\ Constraints as Assert;
Declare����������� ������������������ which����������� ������������������ Annotations����������� ������������������ you����������� ������������������ will����������� ������������������ use
![Page 74: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/74.jpg)
How����������� ������������������ it����������� ������������������ Works
AnnotationReader<?php
/** * @ORM\Column(‘string’) * @Assert\NotBlank() */
new ORM\Column(‘string’)new Assert\NotBlank()
“metadata”
use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\ Constraints as Assert;
Declare����������� ������������������ which����������� ������������������ Annotations����������� ������������������ you����������� ������������������ will����������� ������������������ use
![Page 75: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/75.jpg)
How����������� ������������������ it����������� ������������������ Works
AnnotationReader<?php
/** * @ORM\Column(‘string’) * @Assert\NotBlank() */
new ORM\Column(‘string’)new Assert\NotBlank()
Cache
“metadata”
Walker����������� ������������������ /����������� ������������������ code
use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\ Constraints as Assert;
Declare����������� ������������������ which����������� ������������������ Annotations����������� ������������������ you����������� ������������������ will����������� ������������������ use
![Page 76: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/76.jpg)
DMS\Filterhttps://github.com/rdohms/DMS
![Page 77: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/77.jpg)
The����������� ������������������ Gears
![Page 78: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/78.jpg)
The����������� ������������������ Gears
Doctrine\CommonsYourApp
![Page 79: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/79.jpg)
The����������� ������������������ Gears
Reader
Doctrine\CommonsYourApp
![Page 80: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/80.jpg)
The����������� ������������������ Gears
Parsing
Reader
Doctrine\CommonsYourApp
![Page 81: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/81.jpg)
The����������� ������������������ Gears
Parsing
ReaderFilter
Doctrine\CommonsYourApp
![Page 82: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/82.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
ReaderFilter
Doctrine\CommonsYourApp
![Page 83: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/83.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
Doctrine\CommonsYourApp
![Page 84: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/84.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
Doctrine\CommonsYourApp
MyAnnotation
![Page 85: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/85.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
filter()
Doctrine\CommonsYourApp
MyAnnotation
![Page 86: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/86.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
getMethodAnnotation()filter()
Doctrine\CommonsYourApp
MyAnnotation
![Page 87: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/87.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
getMethodAnnotation()filter()
Doctrine\CommonsYourApp
MyAnnotation
![Page 88: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/88.jpg)
The����������� ������������������ Gears
Parsing“Enforcing”
Reader
AnnotatedObject
Filter
getMethodAnnotation()filter()
filtered value
Doctrine\CommonsYourApp
MyAnnotation
![Page 89: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/89.jpg)
namespace Filter\Rule; /** * @Annotation */ class NoDogs { public function __construct($options) { /* no options */ } public function filter($value) { return str_replace("dogs", "", (string) $value); } }
Usage:����������� ������������������ @Filter\NoDogs()
![Page 90: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/90.jpg)
namespace Filter\Rule; /** * @Annotation */ class NoDogs { public function __construct($options) { /* no options */ } public function filter($value) { return str_replace("dogs", "", (string) $value); } }
tell����������� ������������������ doctrine����������� ������������������ this����������� ������������������ is����������� ������������������ an����������� ������������������ annotation
Usage:����������� ������������������ @Filter\NoDogs()
![Page 91: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/91.jpg)
namespace Filter\Rule; /** * @Annotation */ class NoDogs { public function __construct($options) { /* no options */ } public function filter($value) { return str_replace("dogs", "", (string) $value); } }
tell����������� ������������������ doctrine����������� ������������������ this����������� ������������������ is����������� ������������������ an����������� ������������������ annotation
Usage:����������� ������������������ @Filter\NoDogs()
array����������� ������������������ of����������� ������������������ the����������� ������������������ parameters
![Page 92: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/92.jpg)
namespace Filter\Rule; /** * @Annotation */ class NoDogs { public function __construct($options) { /* no options */ } public function filter($value) { return str_replace("dogs", "", (string) $value); } }
tell����������� ������������������ doctrine����������� ������������������ this����������� ������������������ is����������� ������������������ an����������� ������������������ annotation
Usage:����������� ������������������ @Filter\NoDogs()
array����������� ������������������ of����������� ������������������ the����������� ������������������ parameters
this����������� ������������������ is����������� ������������������ the����������� ������������������ effect����������� ������������������ of����������� ������������������ our����������� ������������������ annotation
![Page 93: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/93.jpg)
namespace Filter; class Filter { private $reader; public function __construct(Doctrine\Common\Annotations\Reader $reader) { $this->reader = $reader; } public function filter($object) { $reflectionObject = new \ReflectionObject($object); foreach ($reflectionObject->getProperties() as $reflectionProperty) { $this->filterProperty($object, $reflectionProperty); } } public function filterProperty($object, $reflectionProperty) { // fetch the @NoDog annotation from the annotation reader $annotation = $this->reader->getMethodAnnotation(
$reflectionProperty, 'Filter\Rule\NoDog'); if (null !== $annotation) { return; } $reflectionProperty->setAccessible(true); $value = $reflectionProperty->getValue($object); $filteredValue = $annotation->filter($value); $reflectionProperty->setValue( $filteredValue ); } }
![Page 94: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/94.jpg)
namespace Filter; class Filter { private $reader; public function __construct(Doctrine\Common\Annotations\Reader $reader) { $this->reader = $reader; } public function filter($object) { $reflectionObject = new \ReflectionObject($object); foreach ($reflectionObject->getProperties() as $reflectionProperty) { $this->filterProperty($object, $reflectionProperty); } } public function filterProperty($object, $reflectionProperty) { // fetch the @NoDog annotation from the annotation reader $annotation = $this->reader->getMethodAnnotation(
$reflectionProperty, 'Filter\Rule\NoDog'); if (null !== $annotation) { return; } $reflectionProperty->setAccessible(true); $value = $reflectionProperty->getValue($object); $filteredValue = $annotation->filter($value); $reflectionProperty->setValue( $filteredValue ); } }
Get����������� ������������������ only����������� ������������������ our����������� ������������������ annotation
![Page 95: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/95.jpg)
namespace Filter; class Filter { private $reader; public function __construct(Doctrine\Common\Annotations\Reader $reader) { $this->reader = $reader; } public function filter($object) { $reflectionObject = new \ReflectionObject($object); foreach ($reflectionObject->getProperties() as $reflectionProperty) { $this->filterProperty($object, $reflectionProperty); } } public function filterProperty($object, $reflectionProperty) { // fetch the @NoDog annotation from the annotation reader $annotation = $this->reader->getMethodAnnotation(
$reflectionProperty, 'Filter\Rule\NoDog'); if (null !== $annotation) { return; } $reflectionProperty->setAccessible(true); $value = $reflectionProperty->getValue($object); $filteredValue = $annotation->filter($value); $reflectionProperty->setValue( $filteredValue ); } }
Get����������� ������������������ only����������� ������������������ our����������� ������������������ annotation
Make����������� ������������������ Annotation����������� ������������������ affect����������� ������������������ application
![Page 96: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/96.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
![Page 97: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/97.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Reader
Filter
![Page 98: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/98.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Reader
Loader
Walker
Filter
![Page 99: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/99.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
Filter
![Page 100: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/100.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
Filters����������� ������������������ Annotations
Filter
![Page 101: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/101.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
Filters����������� ������������������ Annotationsnavigates����������� ������������������ object,����������� ������������������
reflects����������� ������������������ and����������� ������������������ filters
Filter
![Page 102: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/102.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
Filters����������� ������������������ Annotationsnavigates����������� ������������������ object,����������� ������������������
reflects����������� ������������������ and����������� ������������������ filters
Filter
![Page 103: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/103.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
annotations
Filters����������� ������������������ Annotationsnavigates����������� ������������������ object,����������� ������������������
reflects����������� ������������������ and����������� ������������������ filters
Filter
![Page 104: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/104.jpg)
Taking����������� ������������������ it����������� ������������������ up����������� ������������������ a����������� ������������������ notch
Parsing
Loading
Using/Walking
Reader
Loader
Walker
annotations metadata
Filters����������� ������������������ Annotationsnavigates����������� ������������������ object,����������� ������������������
reflects����������� ������������������ and����������� ������������������ filters
Filter
![Page 105: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/105.jpg)
/** * @My\Annotation(“name”, nullable=true) */
![Page 106: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/106.jpg)
/** * @My\Annotation(“name”, nullable=true) */
defaultProperty
![Page 107: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/107.jpg)
/** * @My\Annotation(“name”, nullable=true) */
new My\Annotation($options);
defaultProperty
![Page 108: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/108.jpg)
/** * @My\Annotation(“name”, nullable=true) */
new My\Annotation($options);
array:����������� ������������������ key����������� ������������������ =>����������� ������������������ valueor
string:����������� ������������������ value
defaultProperty
![Page 109: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/109.jpg)
/** * @My\Annotation(“name”, nullable=true) */
new My\Annotation($options);
array:����������� ������������������ key����������� ������������������ =>����������� ������������������ valueor
string:����������� ������������������ value
defaultProperty
or
![Page 110: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/110.jpg)
/** * @My\Annotation(“name”, nullable=true) */
new My\Annotation($options);
$a = new My\Annotation();$a->nullable = true;$a->{$a->getDefaultProperty()} = “name”;
array:����������� ������������������ key����������� ������������������ =>����������� ������������������ valueor
string:����������� ������������������ value
defaultProperty
or
![Page 111: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/111.jpg)
DMS\Filterhttps://github.com/rdohms/DMS
/** * Filter\Alpha(true) */protected $name;
Alpha->filter($name);
Rafael����������� ������������������ Dohms23
Rafael����������� ������������������ Dohms
![Page 112: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/112.jpg)
What? Why? Where?
How?
![Page 113: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/113.jpg)
Questions?
http://doh.mshttp://slides.doh.ms
@rdohms
Rate����������� ������������������ this����������� ������������������ talk����������� ������������������ on����������� ������������������ Joind.in!
https://joind.in/6681
on����������� ������������������ twitter these����������� ������������������ slides����������� ������������������ will����������� ������������������ be����������� ������������������ here
please!
![Page 114: Annotating with Annotations - DPC UnCon](https://reader034.vdocuments.us/reader034/viewer/2022052410/554bc2eeb4c90530298b525a/html5/thumbnails/114.jpg)
Questions?