Skip to content

Updated the DocBlocks of the Entities #527

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

Merged
merged 1 commit into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/AppBundle/Entity/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class Comment
*/
private $author;

/**
*
*/
public function __construct()
{
$this->publishedAt = new \DateTime();
Expand All @@ -91,11 +94,17 @@ public function isLegitComment()
return !$containsInvalidCharacters;
}

/**
* @return int
Copy link
Contributor

@bocharsky-bw bocharsky-bw Apr 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz Sorry, it's probably too late, but we don't need these @return statements for getters since we already have it on properties and PhpStorm could resolve them by itself: https://github.com/cafferata/symfony-demo/blob/e039e604a31754e371811b5dba2b0eb738af07fc/src/AppBundle/Entity/Comment.php#L33

But we need them for setters which do not have type hints though.

Some discussion about it here: #394

*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getContent()
{
return $this->content;
Expand All @@ -109,11 +118,17 @@ public function setContent($content)
$this->content = $content;
}

/**
* @return \DateTime
*/
public function getPublishedAt()
{
return $this->publishedAt;
}

/**
* @param \DateTime $publishedAt
*/
public function setPublishedAt(\DateTime $publishedAt)
{
$this->publishedAt = $publishedAt;
Expand All @@ -135,11 +150,17 @@ public function setAuthor(User $author)
$this->author = $author;
}

/**
* @return Post
*/
public function getPost()
{
return $this->post;
}

/**
* @param Post $post
*/
public function setPost(Post $post)
{
$this->post = $post;
Expand Down
42 changes: 42 additions & 0 deletions src/AppBundle/Entity/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,27 @@ class Post
*/
private $tags;

/**
*
*/
public function __construct()
{
$this->publishedAt = new \DateTime();
$this->comments = new ArrayCollection();
$this->tags = new ArrayCollection();
}

/**
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getTitle()
{
return $this->title;
Expand All @@ -144,6 +153,9 @@ public function setTitle($title)
$this->title = $title;
}

/**
* @return string
*/
public function getSlug()
{
return $this->slug;
Expand All @@ -157,6 +169,9 @@ public function setSlug($slug)
$this->slug = $slug;
}

/**
* @return string
*/
public function getContent()
{
return $this->content;
Expand All @@ -170,11 +185,17 @@ public function setContent($content)
$this->content = $content;
}

/**
* @return \DateTime
*/
public function getPublishedAt()
{
return $this->publishedAt;
}

/**
* @param \DateTime $publishedAt
*/
public function setPublishedAt(\DateTime $publishedAt)
{
$this->publishedAt = $publishedAt;
Expand All @@ -196,22 +217,34 @@ public function setAuthor(User $author)
$this->author = $author;
}

/**
* @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;
Expand All @@ -225,18 +258,27 @@ public function setSummary($summary)
$this->summary = $summary;
}

/**
* @param Tag $tag
*/
public function addTag(Tag $tag)
{
if (!$this->tags->contains($tag)) {
$this->tags->add($tag);
}
}

/**
* @param Tag $tag
*/
public function removeTag(Tag $tag)
{
$this->tags->removeElement($tag);
}

/**
* @return Tag[]|ArrayCollection
*/
public function getTags()
{
return $this->tags;
Expand Down
9 changes: 9 additions & 0 deletions src/AppBundle/Entity/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Tag implements \JsonSerializable
*/
private $name;

/**
* @return int
*/
public function getId()
{
return $this->id;
Expand All @@ -54,6 +57,9 @@ public function setName($name)
$this->name = $name;
}

/**
* @return string
*/
public function getName()
{
return $this->name;
Expand All @@ -71,6 +77,9 @@ public function jsonSerialize()
return $this->name;
}

/**
* @return string
*/
public function __toString()
{
return $this->name;
Expand Down
18 changes: 18 additions & 0 deletions src/AppBundle/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class User implements UserInterface
*/
private $roles = [];

/**
* @return int
*/
public function getId()
{
return $this->id;
Expand All @@ -86,11 +89,17 @@ public function setFullName($fullName)
$this->fullName = $fullName;
}

/**
* @return string
*/
public function getFullName()
{
return $this->fullName;
}

/**
* @return string
*/
public function getUsername()
{
return $this->username;
Expand All @@ -104,6 +113,9 @@ public function setUsername($username)
$this->username = $username;
}

/**
* @return string
*/
public function getEmail()
{
return $this->email;
Expand All @@ -117,6 +129,9 @@ public function setEmail($email)
$this->email = $email;
}

/**
* @return string
*/
public function getPassword()
{
return $this->password;
Expand Down Expand Up @@ -145,6 +160,9 @@ public function getRoles()
return array_unique($roles);
}

/**
* @param array $roles
*/
public function setRoles(array $roles)
{
$this->roles = $roles;
Expand Down