Annotations are more than phpdoc comments, they're a fully-featured way of including additional information alongside your code. We might have rejected an RFC to add support into the PHP core, but the community has embraced this tool anyway! This session shows you who is doing what with annotations, and will give you some ideas on how to use the existing tools in your own projects to keep life simple. Developers, architects and anyone responsible for the technical direction of an application should attend this session.
37. subject
-- In English --
An annotation is a note that is made while
reading any form of text.
38. -- In Code Speak --
“An annotation is metadata attached to your
code, that can be read at runtime.”
“Annotations do not directly affect program
semantics”
39. -- In Code Speak --
“An annotation is metadata attached to your
code, that can be read at runtime.”
effects
53. annotations
Annotations in the wild
C#
attributes
54. @Entity
@Table(name = people)
class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
annotations
Annotations in the wild
C#
attributes
55. @Entity
@Table(name = people)
class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
annotations
Annotations in the wild
public class Customer
C#
{
[Required]
[StringLength(50)]
public string Prename { get; set; }
[Column(TypeName = image)]
public byte[] Image { get; set; }
attributes
56. @Entity
@Table(name = people)
class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
annotations after
57. v1.5
Annotations in the wild
public class Customer
C#
{
[Required]
[StringLength(50)]
public string Prename { get; set; }
[Column(TypeName = image)]
public byte[] Image { get; set; }
attributes
58. @Entity
@Table(name = people)
class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
annotations after
59. v1.5
Annotations in the wild
public class Customer
C#
{
[Required]
[StringLength(50)]
public string Prename { get; set; }
[Column(TypeName = image)]
public byte[] Image { get; set; }
attributes
since
522. use
use DoctrineORMMapping as ORM;
use SymfonyComponentValidator
Constraints as Assert;
/**
* @ORMColumn(‘string’)
* @AssertNotBlank()
“metadata” */
new ORMColumn(‘string’)
new AssertNotBlank()
How
530. use
use DoctrineORMMapping as ORM;
use SymfonyComponentValidator
Constraints as Assert;
/**
* @ORMColumn(‘string’)
* @AssertNotBlank()
“metadata” */
new ORMColumn(‘string’)
new AssertNotBlank()
Walker
590. annotation
/**
* {@inheritDoc}
*/
public function getDefaultOption()
{
return 'allowed';
}
}
DMSFilterRulesRule:
public function __construct($options = null)