From d21d18f50a66de02ceb6f9596463c72ec70015da Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Fri, 13 Jan 2017 02:13:44 +0300 Subject: [PATCH] New PHP 7.1 type hints for DTO. --- .../Bundle/PointToolsBundle/DTO/Api/Auth.php | 37 ++------ .../DTO/Api/Crawler/MetaPost.php | 9 +- .../PointToolsBundle/DTO/Api/Crawler/Post.php | 87 +++++-------------- .../DTO/Api/Crawler/PostsPage.php | 5 +- .../PointToolsBundle/DTO/Api/Crawler/User.php | 35 ++------ 5 files changed, 41 insertions(+), 132 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Auth.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Auth.php index 51bf3e6..e43a83e 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Auth.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Auth.php @@ -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; diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/MetaPost.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/MetaPost.php index 2b1c383..fd266e1 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/MetaPost.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/MetaPost.php @@ -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; } } \ No newline at end of file diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/Post.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/Post.php index d93926f..2f2a832 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/Post.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/Post.php @@ -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; diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/PostsPage.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/PostsPage.php index 6913e1c..1e18b0a 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/PostsPage.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/PostsPage.php @@ -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; } diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/User.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/User.php index fdb0c0f..829e4f1 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/User.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/Crawler/User.php @@ -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;