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;
/**
* @return string|null
*/
public function getToken()
public function getToken(): ?string
{
return $this->token;
}
/**
* @param string|null $token
*
* @return Auth
*/
public function setToken(string $token = null): Auth
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
/**
* @return string|null
*/
public function getCsRfToken()
public function getCsRfToken(): ?string
{
return $this->csRfToken;
}
/**
* @param string $csRfToken
*
* @return Auth
*/
public function setCsRfToken(string $csRfToken = null)
public function setCsRfToken(?string $csRfToken): self
{
$this->csRfToken = $csRfToken;
return $this;
}
/**
* @return string|null
*/
public function getError()
public function getError(): ?string
{
return $this->error;
}
/**
* @param string|null $error
*
* @return Auth
*/
public function setError(string $error = null): Auth
public function setError(?string $error): self
{
$this->error = $error;

View file

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

View file

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

View file

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

View file

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