New PHP 7.1 type hints for factories.

This commit is contained in:
Alexey Skobkin 2017-01-13 02:21:17 +03:00
parent 415efe9e6e
commit 5271fd5f59
4 changed files with 7 additions and 7 deletions

View file

@ -88,7 +88,7 @@ class CommentFactory
* *
* @throws InvalidResponseException * @throws InvalidResponseException
*/ */
private function validateData(array $data) private function validateData(array $data): void
{ {
if (!array_key_exists('author', $data)) { if (!array_key_exists('author', $data)) {
throw new InvalidResponseException('Comment author data not found in API response'); throw new InvalidResponseException('Comment author data not found in API response');

View file

@ -76,7 +76,7 @@ class FileFactory
* *
* @throws InvalidResponseException * @throws InvalidResponseException
*/ */
private function validateData($data) private function validateData($data): void
{ {
if (!is_string($data)) { if (!is_string($data)) {
// @todo Change exception // @todo Change exception

View file

@ -180,7 +180,7 @@ class PostFactory
* @param Post $post * @param Post $post
* @param string[] $tagsStrings * @param string[] $tagsStrings
*/ */
private function updatePostTags(Post $post, array $tagsStrings) private function updatePostTags(Post $post, array $tagsStrings): void
{ {
$tags = $this->tagFactory->createFromStringsArray($tagsStrings); $tags = $this->tagFactory->createFromStringsArray($tagsStrings);
@ -224,7 +224,7 @@ class PostFactory
* @param Post $post * @param Post $post
* @param array $urls * @param array $urls
*/ */
private function updatePostFiles(Post $post, array $urls) private function updatePostFiles(Post $post, array $urls): void
{ {
$files = $this->fileFactory->createFromUrlsArray($urls); $files = $this->fileFactory->createFromUrlsArray($urls);
@ -243,7 +243,7 @@ class PostFactory
} }
} }
private function validateMetaPost(MetaPost $post) private function validateMetaPost(MetaPost $post): bool
{ {
if (!$post->getPost()->getId()) { if (!$post->getPost()->getId()) {
$this->logger->error('Post DTO contains no id'); $this->logger->error('Post DTO contains no id');

View file

@ -85,7 +85,7 @@ class UserFactory
* *
* @throws InvalidResponseException * @throws InvalidResponseException
*/ */
private function validateArrayData(array $data) private function validateArrayData(array $data): void
{ {
if (!array_key_exists('id', $data) || !array_key_exists('login', $data) || !array_key_exists('name', $data) || !is_numeric($data['id'])) { if (!array_key_exists('id', $data) || !array_key_exists('login', $data) || !array_key_exists('name', $data) || !is_numeric($data['id'])) {
throw new InvalidResponseException('Invalid user data'); throw new InvalidResponseException('Invalid user data');
@ -97,7 +97,7 @@ class UserFactory
* *
* @throws InvalidResponseException * @throws InvalidResponseException
*/ */
private function validateDTOData(UserDTO $data) private function validateDTOData(UserDTO $data): void
{ {
if (!$data->getId() || !$data->getLogin()) { if (!$data->getId() || !$data->getLogin()) {
throw new InvalidUserDataException('User have no id or login', $data); throw new InvalidUserDataException('User have no id or login', $data);