Skip to content

Commit 1bf9dec

Browse files
committed
minor #394 Add annotation with proper types for entity properties (bocharsky-bw)
This PR was squashed before being merged into the master branch (closes #394). Discussion ---------- Add annotation with proper types for entity properties The most IDEs start showing returned types on getter calls after these changes. Commits ------- 052e309 Add annotation with proper types for entity properties
2 parents 0313e7a + 052e309 commit 1bf9dec

File tree

3 files changed

+78
-11
lines changed

3 files changed

+78
-11
lines changed

src/AppBundle/Entity/Comment.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,25 @@
3030
class Comment
3131
{
3232
/**
33+
* @var int
34+
*
3335
* @ORM\Id
3436
* @ORM\GeneratedValue
3537
* @ORM\Column(type="integer")
3638
*/
3739
private $id;
3840

3941
/**
42+
* @var Post
43+
*
4044
* @ORM\ManyToOne(targetEntity="Post", inversedBy="comments")
4145
* @ORM\JoinColumn(nullable=false)
4246
*/
4347
private $post;
4448

4549
/**
50+
* @var string
51+
*
4652
* @ORM\Column(type="text")
4753
* @Assert\NotBlank(message="comment.blank")
4854
* @Assert\Length(
@@ -55,12 +61,16 @@ class Comment
5561
private $content;
5662

5763
/**
64+
* @var string
65+
*
5866
* @ORM\Column(type="string")
5967
* @Assert\Email()
6068
*/
6169
private $authorEmail;
6270

6371
/**
72+
* @var \DateTime
73+
*
6474
* @ORM\Column(type="datetime")
6575
* @Assert\DateTime()
6676
*/
@@ -90,6 +100,10 @@ public function getContent()
90100
{
91101
return $this->content;
92102
}
103+
104+
/**
105+
* @param string $content
106+
*/
93107
public function setContent($content)
94108
{
95109
$this->content = $content;
@@ -99,6 +113,10 @@ public function getAuthorEmail()
99113
{
100114
return $this->authorEmail;
101115
}
116+
117+
/**
118+
* @param string $authorEmail
119+
*/
102120
public function setAuthorEmail($authorEmail)
103121
{
104122
$this->authorEmail = $authorEmail;
@@ -108,6 +126,7 @@ public function getPublishedAt()
108126
{
109127
return $this->publishedAt;
110128
}
129+
111130
public function setPublishedAt(\DateTime $publishedAt)
112131
{
113132
$this->publishedAt = $publishedAt;
@@ -117,6 +136,7 @@ public function getPost()
117136
{
118137
return $this->post;
119138
}
139+
120140
public function setPost(Post $post)
121141
{
122142
$this->post = $post;

src/AppBundle/Entity/Post.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,65 @@ class Post
2929
const NUM_ITEMS = 10;
3030

3131
/**
32+
* @var int
33+
*
3234
* @ORM\Id
3335
* @ORM\GeneratedValue
3436
* @ORM\Column(type="integer")
3537
*/
3638
private $id;
3739

3840
/**
41+
* @var string
42+
*
3943
* @ORM\Column(type="string")
4044
* @Assert\NotBlank()
4145
*/
4246
private $title;
4347

4448
/**
49+
* @var string
50+
*
4551
* @ORM\Column(type="string")
4652
*/
4753
private $slug;
4854

4955
/**
56+
* @var string
57+
*
5058
* @ORM\Column(type="string")
5159
* @Assert\NotBlank(message="post.blank_summary")
5260
*/
5361
private $summary;
5462

5563
/**
64+
* @var string
65+
*
5666
* @ORM\Column(type="text")
5767
* @Assert\NotBlank(message="post.blank_content")
5868
* @Assert\Length(min = "10", minMessage = "post.too_short_content")
5969
*/
6070
private $content;
6171

6272
/**
73+
* @var string
74+
*
6375
* @ORM\Column(type="string")
6476
* @Assert\Email()
6577
*/
6678
private $authorEmail;
6779

6880
/**
81+
* @var \DateTime
82+
*
6983
* @ORM\Column(type="datetime")
7084
* @Assert\DateTime()
7185
*/
7286
private $publishedAt;
7387

7488
/**
89+
* @var Comment[]|ArrayCollection
90+
*
7591
* @ORM\OneToMany(
7692
* targetEntity="Comment",
7793
* mappedBy="post",
@@ -97,6 +113,9 @@ public function getTitle()
97113
return $this->title;
98114
}
99115

116+
/**
117+
* @param string $title
118+
*/
100119
public function setTitle($title)
101120
{
102121
$this->title = $title;
@@ -107,6 +126,9 @@ public function getSlug()
107126
return $this->slug;
108127
}
109128

129+
/**
130+
* @param string $slug
131+
*/
110132
public function setSlug($slug)
111133
{
112134
$this->slug = $slug;
@@ -117,6 +139,9 @@ public function getContent()
117139
return $this->content;
118140
}
119141

142+
/**
143+
* @param string $content
144+
*/
120145
public function setContent($content)
121146
{
122147
$this->content = $content;
@@ -127,17 +152,16 @@ public function getAuthorEmail()
127152
return $this->authorEmail;
128153
}
129154

155+
/**
156+
* @param string $authorEmail
157+
*/
130158
public function setAuthorEmail($authorEmail)
131159
{
132160
$this->authorEmail = $authorEmail;
133161
}
134162

135163
/**
136164
* Is the given User the author of this Post?
137-
*
138-
* @param User $user
139-
*
140-
* @return bool
141165
*/
142166
public function isAuthor(User $user)
143167
{
@@ -175,6 +199,9 @@ public function getSummary()
175199
return $this->summary;
176200
}
177201

202+
/**
203+
* @param string $summary
204+
*/
178205
public function setSummary($summary)
179206
{
180207
$this->summary = $summary;

src/AppBundle/Entity/User.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,38 @@
2121
class User implements UserInterface
2222
{
2323
/**
24+
* @var int
25+
*
2426
* @ORM\Id
2527
* @ORM\GeneratedValue
2628
* @ORM\Column(type="integer")
2729
*/
2830
private $id;
2931

3032
/**
33+
* @var string
34+
*
3135
* @ORM\Column(type="string", unique=true)
3236
*/
3337
private $username;
3438

3539
/**
40+
* @var string
41+
*
3642
* @ORM\Column(type="string", unique=true)
3743
*/
3844
private $email;
3945

4046
/**
47+
* @var string
48+
*
4149
* @ORM\Column(type="string")
4250
*/
4351
private $password;
4452

4553
/**
54+
* @var array
55+
*
4656
* @ORM\Column(type="json_array")
4757
*/
4858
private $roles = [];
@@ -52,13 +62,14 @@ public function getId()
5262
return $this->id;
5363
}
5464

55-
/**
56-
* {@inheritdoc}
57-
*/
5865
public function getUsername()
5966
{
6067
return $this->username;
6168
}
69+
70+
/**
71+
* @param string $username
72+
*/
6273
public function setUsername($username)
6374
{
6475
$this->username = $username;
@@ -68,18 +79,23 @@ public function getEmail()
6879
{
6980
return $this->email;
7081
}
82+
83+
/**
84+
* @param string $email
85+
*/
7186
public function setEmail($email)
7287
{
7388
$this->email = $email;
7489
}
7590

76-
/**
77-
* {@inheritdoc}
78-
*/
7991
public function getPassword()
8092
{
8193
return $this->password;
8294
}
95+
96+
/**
97+
* @param string $password
98+
*/
8399
public function setPassword($password)
84100
{
85101
$this->password = $password;
@@ -107,18 +123,22 @@ public function setRoles(array $roles)
107123

108124
/**
109125
* Returns the salt that was originally used to encode the password.
126+
*
127+
* {@inheritdoc}
110128
*/
111129
public function getSalt()
112130
{
113131
// See "Do you need to use a Salt?" at http://symfony.com/doc/current/cookbook/security/entity_provider.html
114132
// we're using bcrypt in security.yml to encode the password, so
115133
// the salt value is built-in and you don't have to generate one
116134

117-
return;
135+
return null;
118136
}
119137

120138
/**
121139
* Removes sensitive data from the user.
140+
*
141+
* {@inheritdoc}
122142
*/
123143
public function eraseCredentials()
124144
{

0 commit comments

Comments
 (0)