New PHP 7.1 type hints for DTO.

This commit is contained in:
Alexey Skobkin 2017-01-13 02:13:44 +03:00
parent 39bfe4c9bf
commit d21d18f50a
5 changed files with 41 additions and 132 deletions

View file

@ -34,60 +34,37 @@ class Auth
*/ */
private $error; private $error;
/**
* @return string|null public function getToken(): ?string
*/
public function getToken()
{ {
return $this->token; return $this->token;
} }
/** public function setToken(?string $token): self
* @param string|null $token
*
* @return Auth
*/
public function setToken(string $token = null): Auth
{ {
$this->token = $token; $this->token = $token;
return $this; return $this;
} }
/** public function getCsRfToken(): ?string
* @return string|null
*/
public function getCsRfToken()
{ {
return $this->csRfToken; return $this->csRfToken;
} }
/** public function setCsRfToken(?string $csRfToken): self
* @param string $csRfToken
*
* @return Auth
*/
public function setCsRfToken(string $csRfToken = null)
{ {
$this->csRfToken = $csRfToken; $this->csRfToken = $csRfToken;
return $this; return $this;
} }
/** public function getError(): ?string
* @return string|null
*/
public function getError()
{ {
return $this->error; return $this->error;
} }
/** public function setError(?string $error): self
* @param string|null $error
*
* @return Auth
*/
public function setError(string $error = null): Auth
{ {
$this->error = $error; $this->error = $error;

View file

@ -23,18 +23,15 @@ class MetaPost
/** /**
* @return Post * @return Post
*/ */
public function getPost() public function getPost(): ?Post
{ {
return $this->post; return $this->post;
} }
/** public function setPost(Post $post): self
* @param Post $post
* @return MetaPost
*/
public function setPost(Post $post)
{ {
$this->post = $post; $this->post = $post;
return $this; return $this;
} }
} }

View file

@ -76,37 +76,27 @@ class Post
private $private; private $private;
/** public function getId(): ?string
* @return string
*/
public function getId()
{ {
return $this->id; return $this->id;
} }
/** public function setId(?string $id): self
* @param string $id
* @return Post
*/
public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
/** /**
* @return string[] * @return string[]
*/ */
public function getTags() public function getTags(): ?array
{ {
return $this->tags; return $this->tags;
} }
/** public function setTags(?array $tags): self
* @param string[] $tags
* @return Post
*/
public function setTags($tags)
{ {
$this->tags = $tags; $this->tags = $tags;
return $this; return $this;
@ -115,7 +105,7 @@ class Post
/** /**
* @return string[] * @return string[]
*/ */
public function getFiles() public function getFiles(): ?array
{ {
return $this->files; return $this->files;
} }
@ -125,106 +115,71 @@ class Post
* *
* @return Post * @return Post
*/ */
public function setFiles($files) public function setFiles(?array $files): self
{ {
$this->files = $files; $this->files = $files;
return $this; return $this;
} }
/** public function getAuthor(): ?User
* @return User
*/
public function getAuthor()
{ {
return $this->author; return $this->author;
} }
/** public function setAuthor(?User $author): self
* @param User $author
* @return Post
*/
public function setAuthor(User $author)
{ {
$this->author = $author; $this->author = $author;
return $this; return $this;
} }
/** public function getText(): ?string
* @return string
*/
public function getText()
{ {
return $this->text; return $this->text;
} }
/** public function setText(?string $text): self
* @param string $text
* @return Post
*/
public function setText($text)
{ {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
/** public function getCreated(): ?string
* @return string
*/
public function getCreated()
{ {
return $this->created; return $this->created;
} }
/** public function setCreated(?string $created): self
* @param string $created
* @return Post
*/
public function setCreated($created)
{ {
$this->created = $created; $this->created = $created;
return $this; return $this;
} }
/** public function getType(): ?string
* @return string
*/
public function getType()
{ {
return $this->type; return $this->type;
} }
/** public function setType(?string $type): self
* @param string $type
* @return Post
*/
public function setType($type)
{ {
$this->type = $type; $this->type = $type;
return $this; return $this;
} }
/** public function getPrivate(): ?bool
* @return boolean
*/
public function getPrivate()
{ {
return $this->private; return $this->private;
} }
/** public function isPrivate(): ?bool
* @return boolean
*/
public function isPrivate()
{ {
return $this->private; return $this->private;
} }
/** public function setPrivate(?bool $private): self
* @param boolean $private
* @return Post
*/
public function setPrivate($private)
{ {
$this->private = $private; $this->private = $private;
return $this; return $this;

View file

@ -22,7 +22,7 @@ class PostsPage
/** /**
* @return MetaPost[] * @return MetaPost[]
*/ */
public function getPosts() public function getPosts(): ?array
{ {
return $this->posts; return $this->posts;
} }
@ -33,9 +33,10 @@ class PostsPage
* @param MetaPost[] $posts * @param MetaPost[] $posts
* @return PostsPage * @return PostsPage
*/ */
public function setPosts($posts) public function setPosts(?array $posts): self
{ {
$this->posts = $posts; $this->posts = $posts;
return $this; return $this;
} }

View file

@ -35,55 +35,34 @@ class User
private $name; private $name;
/** public function getId(): ?string
* @return string
*/
public function getId()
{ {
return $this->id; return $this->id;
} }
/** public function setId(?string $id): self
* @param string $id
* @return User
*/
public function setId($id)
{ {
$this->id = $id; $this->id = $id;
return $this; return $this;
} }
/** public function getLogin(): ?string
* @return string
*/
public function getLogin()
{ {
return $this->login; return $this->login;
} }
/** public function setLogin(?string $login): self
* @param string $login
* @return User
*/
public function setLogin($login)
{ {
$this->login = $login; $this->login = $login;
return $this; return $this;
} }
/** public function getName(): ?string
* @return string
*/
public function getName()
{ {
return $this->name; return $this->name;
} }
/** public function setName(?string $name): self
* @param string $name
* @return User
*/
public function setName($name)
{ {
$this->name = $name; $this->name = $name;
return $this; return $this;