WIP: Symfony 6 project remake #2

Draft
skobkin wants to merge 103 commits from symfony6_remake into master
8 changed files with 111 additions and 288 deletions
Showing only changes of commit 441fdc06b3 - Show all commits

View file

@ -1,56 +0,0 @@
<?php
namespace src\PointToolsBundle\DTO\Api;
use src\PointToolsBundle\DTO\Api\Comment;
use src\PointToolsBundle\DTO\Api\Post;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
class MetaPost implements ValidableInterface
{
/**
* @var Post|null
*/
private $post;
/**
* @var Comment[]|null
*/
private $comments;
public function getPost(): ?Post
{
return $this->post;
}
public function setPost(?Post $post): void
{
$this->post = $post;
}
/**
* @return Comment[]|null
*/
public function getComments(): ?array
{
return $this->comments;
}
/**
* @param Comment[]|null $comments
*/
public function setComments(?array $comments): void
{
$this->comments = $comments;
}
public function isValid(): bool
{
if (null !== $this->post && $this->post->isValid()) {
return true;
}
return false;
}
}

View file

@ -1,26 +1,14 @@
<?php <?php
declare(strict_types=1);
namespace src\PointToolsBundle\DTO\Api; namespace App\DTO\Api;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
/** TODO: Refactor to public readonly */
class Auth implements ValidableInterface class Auth implements ValidableInterface
{ {
/** private ?string $token;
* @var string|null private ?string $csRfToken;
*/ private ?string $error;
private $token;
/**
* @var string|null
*/
private $csRfToken;
/**
* @var string|null
*/
private $error;
public function getToken(): ?string public function getToken(): ?string
{ {
@ -54,10 +42,6 @@ class Auth implements ValidableInterface
public function isValid(): bool public function isValid(): bool
{ {
if (null !== $this->token && null !== $this->csRfToken && null === $this->error) { return null !== $this->token && null !== $this->csRfToken && null === $this->error;
return true;
}
return false;
} }
} }

View file

@ -1,46 +1,18 @@
<?php <?php
declare(strict_types=1);
namespace src\PointToolsBundle\DTO\Api; namespace App\DTO\Api;
use src\PointToolsBundle\DTO\Api\User;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
/** TODO: Refactor to public readonly */
class Comment implements ValidableInterface class Comment implements ValidableInterface
{ {
/** private ?string $postId;
* @var string|null private ?int $number;
*/ private ?int $toCommentId;
private $postId; private ?string $created;
private ?string $text;
/** private ?User $author;
* @var int|null private ?bool $isRec;
*/
private $number;
/**
* @var int|null
*/
private $toCommentId;
/**
* @var string|null
*/
private $created;
/**
* @var string|null
*/
private $text;
/**
* @var User|null
*/
private $author;
/**
* @var bool|null
*/
private $isRec;
public function getPostId(): ?string public function getPostId(): ?string
@ -120,10 +92,6 @@ class Comment implements ValidableInterface
public function isValid(): bool public function isValid(): bool
{ {
if (null !== $this->postId && null !== $this->number && null !== $this->author && null !== $this->text) { return null !== $this->postId && null !== $this->number && null !== $this->author && null !== $this->text;
return true;
}
return false;
} }
} }

40
src/DTO/Api/MetaPost.php Normal file
View file

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\DTO\Api;
/** TODO: Refactor to public readonly */
class MetaPost implements ValidableInterface
{
private ?Post $post;
/** @var Comment[]|null */
private ?array $comments;
public function getPost(): ?Post
{
return $this->post;
}
public function setPost(?Post $post): void
{
$this->post = $post;
}
/** @return Comment[]|null */
public function getComments(): ?array
{
return $this->comments;
}
/** @param Comment[]|null $comments */
public function setComments(?array $comments): void
{
$this->comments = $comments;
}
public function isValid(): bool
{
return null !== $this->post && $this->post->isValid();
}
}

View file

@ -1,52 +1,21 @@
<?php <?php
declare(strict_types=1);
namespace src\PointToolsBundle\DTO\Api; namespace App\DTO\Api;
use src\PointToolsBundle\DTO\Api\User;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
/** TODO: Refactor to public readonly */
class Post implements ValidableInterface class Post implements ValidableInterface
{ {
/** private ?string $id;
* @var string|null /** @var string[]|null */
*/ private ?array $tags;
private $id; /** @var string[]|null */
private ?array $files;
/** private ?User $author;
* @var string[]|null private ?string $text;
*/ private ?string $created;
private $tags; private ?string $type;
private ?bool $private;
/**
* @var string[]|null
*/
private $files;
/**
* @var User|null
*/
private $author;
/**
* @var string|null
*/
private $text;
/**
* @var string|null
*/
private $created;
/**
* @var string|null
*/
private $type;
/**
* @var bool|null
*/
private $private;
public function getId(): ?string public function getId(): ?string
{ {
@ -58,9 +27,7 @@ class Post implements ValidableInterface
$this->id = $id; $this->id = $id;
} }
/** /** @return string[]|null */
* @return string[]|null
*/
public function getTags(): ?array public function getTags(): ?array
{ {
return $this->tags; return $this->tags;
@ -71,9 +38,7 @@ class Post implements ValidableInterface
$this->tags = $tags; $this->tags = $tags;
} }
/** /** @return string[]|null */
* @return string[]|null
*/
public function getFiles(): ?array public function getFiles(): ?array
{ {
return $this->files; return $this->files;
@ -144,18 +109,13 @@ class Post implements ValidableInterface
public function isValid(): bool public function isValid(): bool
{ {
if ( return null !== $this->id &&
null !== $this->id &&
null !== $this->author && null !== $this->author &&
$this->author->isValid() && $this->author->isValid() &&
null !== $this->text && null !== $this->text &&
null !== $this->created// && null !== $this->created
// @todo check type existence in incoming data // @todo check type existence in incoming data
//null !== $this->type //null !== $this->type
) { ;
return true;
}
return false;
} }
} }

View file

@ -1,33 +1,22 @@
<?php <?php
declare(strict_types=1);
namespace src\PointToolsBundle\DTO\Api; namespace App\DTO\Api;
use src\PointToolsBundle\DTO\Api\MetaPost;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
/** TODO: Refactor to public readonly */
class PostsPage implements ValidableInterface class PostsPage implements ValidableInterface
{ {
/** /** @var MetaPost[]|null */
* @var MetaPost[]|null private ?array $posts;
*/ private ?bool $hasNext;
private $posts;
/** /** @return MetaPost[]|null */
* @var bool|null
*/
private $hasNext;
/**
* @return MetaPost[]|null
*/
public function getPosts(): ?array public function getPosts(): ?array
{ {
return $this->posts; return $this->posts;
} }
/** /** @param MetaPost[]|null $posts */
* @param MetaPost[]|null $posts
*/
public function setPosts(?array $posts): void public function setPosts(?array $posts): void
{ {
$this->posts = $posts; $this->posts = $posts;
@ -45,10 +34,6 @@ class PostsPage implements ValidableInterface
public function isValid(): bool public function isValid(): bool
{ {
if (null !== $this->posts) { return null !== $this->posts;
return true;
}
return false;
} }
} }

View file

@ -1,81 +1,25 @@
<?php <?php
declare(strict_types=1);
namespace src\PointToolsBundle\DTO\Api; namespace App\DTO\Api;
use src\PointToolsBundle\DTO\Api\ValidableInterface;
/** TODO: Refactor to public readonly */
class User implements ValidableInterface class User implements ValidableInterface
{ {
/** private ?string $id;
* @var string|null private ?string $login;
*/ private ?string $name;
private $id; private ?string $about;
private ?string $xmpp;
/** private ?string $created;
* @var string|null private ?bool $gender;
*/ private ?bool $denyAnonymous;
private $login; private ?bool $private;
private ?string $birthDate;
/** private ?string $homepage;
* @var string|null private ?string $email;
*/ private ?string $location;
private $name; private ?string $error;
/**
* @var string|null
*/
private $about;
/**
* @var string|null
*/
private $xmpp;
/**
* @var string|null
*/
private $created;
/**
* @var bool|null
*/
private $gender;
/**
* @var bool|null
*/
private $denyAnonymous;
/**
* @var bool|null
*/
private $private;
/**
* @var string|null
*/
private $birthDate;
/**
* @var string|null
*/
private $homepage;
/**
* @var string|null
*/
private $email;
/**
* @var string|null
*/
private $location;
/**
* @var string|null
*/
private $error;
public function getId(): ?string public function getId(): ?string
{ {
@ -219,10 +163,6 @@ class User implements ValidableInterface
public function isValid(): bool public function isValid(): bool
{ {
if (null === $this->error && null !== $this->id && null !== $this->login) { return null === $this->error && null !== $this->id && null !== $this->login;
return true;
}
return false;
} }
} }

View file

@ -1,7 +1,9 @@
<?php <?php
namespace src\PointToolsBundle\DTO\Api; declare(strict_types=1);
namespace App\DTO\Api;
interface ValidableInterface interface ValidableInterface
{ {
public function isValid(): bool; public function isValid(): bool;
} }