Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add annotation with proper types for entity properties #394

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -30,19 +30,25 @@
class Comment
{
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var Post
*
* @ORM\ManyToOne(targetEntity="Post", inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $post;
/**
* @var string
*
* @ORM\Column(type="text")
* @Assert\NotBlank(message="comment.blank")
* @Assert\Length(
@@ -55,12 +61,16 @@ class Comment
private $content;
/**
* @var string
*
* @ORM\Column(type="string")
* @Assert\Email()
*/
private $authorEmail;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @Assert\DateTime()
*/
@@ -73,6 +83,8 @@ public function __construct()
/**
* @Assert\IsTrue(message = "comment.is_spam")
*
* @return bool
*/
public function isLegitComment()
{
@@ -81,42 +93,73 @@ public function isLegitComment()
return !$containsInvalidCharacters;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return string
*/
public function getAuthorEmail()
{
return $this->authorEmail;
}
/**
* @param string $authorEmail
*/
public function setAuthorEmail($authorEmail)
{
$this->authorEmail = $authorEmail;
}
/**
* @return \DateTime
*/
public function getPublishedAt()
{
return $this->publishedAt;
}
/**
* @param \DateTime $publishedAt

This comment has been minimized.

Copy link
@xabbuh

xabbuh Nov 4, 2016

Member

not needed as the type hint already provides this information

*/
public function setPublishedAt(\DateTime $publishedAt)
{
$this->publishedAt = $publishedAt;
}
/**
* @return Post
*/
public function getPost()
{
return $this->post;
}
/**
* @param Post $post
*/
public function setPost(Post $post)
{
$this->post = $post;
@@ -29,49 +29,65 @@ class Post
const NUM_ITEMS = 10;
/**
* @var int
*
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string
*
* @ORM\Column(type="string")
* @Assert\NotBlank()
*/
private $title;
/**
* @var string
*
* @ORM\Column(type="string")
*/
private $slug;
/**
* @var string
*
* @ORM\Column(type="string")
* @Assert\NotBlank(message="post.blank_summary")
*/
private $summary;
/**
* @var string
*
* @ORM\Column(type="text")
* @Assert\NotBlank(message="post.blank_content")
* @Assert\Length(min = "10", minMessage = "post.too_short_content")
*/
private $content;
/**
* @var string
*
* @ORM\Column(type="string")
* @Assert\Email()
*/
private $authorEmail;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime")
* @Assert\DateTime()
*/
private $publishedAt;
/**
* @var Comment[]|ArrayCollection
*
* @ORM\OneToMany(
* targetEntity="Comment",
* mappedBy="post",
@@ -87,46 +103,73 @@ public function __construct()
$this->comments = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* @param string $slug
*/
public function setSlug($slug)
{
$this->slug = $slug;
}
/**
* @return string
*/
public function getContent()
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
* @return string
*/
public function getAuthorEmail()
{
return $this->authorEmail;
}
/**
* @param string $authorEmail
*/
public function setAuthorEmail($authorEmail)
{
$this->authorEmail = $authorEmail;
@@ -144,37 +187,58 @@ public function isAuthor(User $user)
return $user->getEmail() === $this->getAuthorEmail();
}
/**
* @return \DateTime
*/
public function getPublishedAt()
{
return $this->publishedAt;
}
/**
* @param \DateTime $publishedAt
*/
public function setPublishedAt(\DateTime $publishedAt)
{
$this->publishedAt = $publishedAt;
}
/**
* @return Comment[]|ArrayCollection
*/
public function getComments()
{
return $this->comments;
}
/**
* @param Comment $comment
*/
public function addComment(Comment $comment)
{
$this->comments->add($comment);
$comment->setPost($this);
}
/**
* @param Comment $comment
*/
public function removeComment(Comment $comment)
{
$this->comments->removeElement($comment);
}
/**
* @return string
*/
public function getSummary()
{
return $this->summary;
}
/**
* @param string $summary
*/
public function setSummary($summary)
{
$this->summary = $summary;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.