From 9dd70e7b99b050be7f083f39ccfa57e70776931b Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Mon, 6 Dec 2021 13:17:14 +0100 Subject: [PATCH] raise deps --- .github/workflows/build.yaml | 9 +------ composer.json | 2 +- src/Knp/Component/Pager/Event/AfterEvent.php | 2 +- src/Knp/Component/Pager/Event/BeforeEvent.php | 4 +-- src/Knp/Component/Pager/Event/ItemsEvent.php | 14 ++++------- .../Component/Pager/Event/PaginationEvent.php | 6 ++--- .../Doctrine/ORM/QuerySubscriber.php | 5 +--- .../Filtration/FiltrationSubscriber.php | 3 +-- .../Filtration/PropelQuerySubscriber.php | 5 +--- .../Paginate/Callback/CallbackPagination.php | 6 +---- .../Doctrine/DBALQueryBuilderSubscriber.php | 1 - .../Paginate/Doctrine/ORM/Query/Helper.php | 9 +------ .../Paginate/PaginationSubscriber.php | 3 +-- .../Subscriber/Sortable/ArraySubscriber.php | 14 +++-------- .../Doctrine/ODM/MongoDB/QuerySubscriber.php | 5 +--- .../Doctrine/ORM/Query/OrderByWalker.php | 7 +++--- .../Sortable/ElasticaQuerySubscriber.php | 5 +--- .../Sortable/PropelQuerySubscriber.php | 5 +--- .../Sortable/SolariumQuerySubscriber.php | 5 +--- .../Sortable/SortableSubscriber.php | 3 +-- .../PageNumberOutOfRangeException.php | 3 +-- .../Pager/Pagination/AbstractPagination.php | 12 ++++----- .../Pager/Pagination/SlidingPagination.php | 8 ++---- src/Knp/Component/Pager/Paginator.php | 14 +++-------- tests/Test/Fixture/Document/Article.php | 19 ++++++-------- tests/Test/Fixture/Document/Image.php | 13 +++++----- tests/Test/Fixture/Entity/Article.php | 12 ++++----- tests/Test/Fixture/Entity/Composite.php | 24 ++++++------------ tests/Test/Fixture/Entity/Shop/Product.php | 25 ++++++++++--------- tests/Test/Fixture/Entity/Shop/Tag.php | 6 ++--- tests/Test/Fixture/TestItem.php | 5 +--- .../Pagination/PaginationInterfaceTest.php | 2 +- tests/Test/Pager/Pagination/PaginatorTest.php | 6 ++--- tests/Test/Tool/BaseTestCaseMongoODM.php | 5 +--- tests/Test/Tool/BaseTestCaseORM.php | 10 ++------ tests/Test/Tool/BaseTestCasePHPCRODM.php | 5 +--- tests/Test/Tool/QueryAnalyzer.php | 12 +++------ 37 files changed, 100 insertions(+), 194 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1dde448e..2dc7089f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,21 +29,14 @@ jobs: strategy: fail-fast: false matrix: - php: - - '7.3' - - '7.4' - - '8.0' - - '8.1' include: - description: 'Lowest' - composer_option: '--prefer-lowest' - - description: '7.4' php: '7.4' + composer_option: '--prefer-lowest' - description: '8.0' php: '8.0' - description: '8.1' php: '8.1' - composer_option: '' name: PHP ${{ matrix.php }} tests (${{ matrix.description }}) steps: - name: Checkout diff --git a/composer.json b/composer.json index bd0589b6..47d1cb0d 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ } ], "require": { - "php": "^7.3 || ^8.0", + "php": "^7.4 || ^8.0", "symfony/event-dispatcher-contracts": "^2.0 || ^3.0", "symfony/http-foundation": "^4.4 || ^5.4 || ^6.0" }, diff --git a/src/Knp/Component/Pager/Event/AfterEvent.php b/src/Knp/Component/Pager/Event/AfterEvent.php index 2a22c007..56a68fec 100644 --- a/src/Knp/Component/Pager/Event/AfterEvent.php +++ b/src/Knp/Component/Pager/Event/AfterEvent.php @@ -10,7 +10,7 @@ */ final class AfterEvent extends Event { - private $pagination; + private PaginationInterface $pagination; public function __construct(PaginationInterface $paginationView) { diff --git a/src/Knp/Component/Pager/Event/BeforeEvent.php b/src/Knp/Component/Pager/Event/BeforeEvent.php index 97dd9daa..428796b1 100644 --- a/src/Knp/Component/Pager/Event/BeforeEvent.php +++ b/src/Knp/Component/Pager/Event/BeforeEvent.php @@ -11,9 +11,9 @@ */ final class BeforeEvent extends Event { - private $eventDispatcher; + private EventDispatcherInterface $eventDispatcher; - private $request; + private ?Request $request; public function __construct(EventDispatcherInterface $eventDispatcher, ?Request $request) { diff --git a/src/Knp/Component/Pager/Event/ItemsEvent.php b/src/Knp/Component/Pager/Event/ItemsEvent.php index 94835089..63e943d0 100644 --- a/src/Knp/Component/Pager/Event/ItemsEvent.php +++ b/src/Knp/Component/Pager/Event/ItemsEvent.php @@ -18,10 +18,8 @@ final class ItemsEvent extends Event /** * List of options - * - * @var array */ - public $options; + public array $options; /** * Items result @@ -32,14 +30,12 @@ final class ItemsEvent extends Event /** * Count result - * - * @var integer */ - public $count; + public int $count; - private $offset; - private $limit; - private $customPaginationParams = []; + private int $offset; + private int $limit; + private array $customPaginationParams = []; public function __construct(int $offset, int $limit) { diff --git a/src/Knp/Component/Pager/Event/PaginationEvent.php b/src/Knp/Component/Pager/Event/PaginationEvent.php index 808a290f..22a95622 100644 --- a/src/Knp/Component/Pager/Event/PaginationEvent.php +++ b/src/Knp/Component/Pager/Event/PaginationEvent.php @@ -19,12 +19,10 @@ final class PaginationEvent extends Event /** * List of options - * - * @var array */ - public $options; + public array $options; - private $pagination; + private PaginationInterface $pagination; public function setPagination(PaginationInterface $pagination): void { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/QuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/QuerySubscriber.php index 55cb0df0..770b1243 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/QuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Filtration/Doctrine/ORM/QuerySubscriber.php @@ -12,10 +12,7 @@ class QuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(?Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Filtration/FiltrationSubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Filtration/FiltrationSubscriber.php index 4b0dc93c..6faaa364 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Filtration/FiltrationSubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Filtration/FiltrationSubscriber.php @@ -9,9 +9,8 @@ class FiltrationSubscriber implements EventSubscriberInterface { /** * Lazy-load state tracker - * @var bool */ - private $isLoaded = false; + private bool $isLoaded = false; public function before(BeforeEvent $event): void { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Filtration/PropelQuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Filtration/PropelQuerySubscriber.php index f4a367ec..849cef21 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Filtration/PropelQuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Filtration/PropelQuerySubscriber.php @@ -9,10 +9,7 @@ class PropelQuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(?Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Callback/CallbackPagination.php b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Callback/CallbackPagination.php index d1146c9a..1734fdd2 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Callback/CallbackPagination.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Callback/CallbackPagination.php @@ -19,10 +19,6 @@ class CallbackPagination */ private $items; - /** - * @param callable $count - * @param callable $items - */ public function __construct(callable $count, callable $items) { $this->count = $count; @@ -36,6 +32,6 @@ public function getPaginationCount(): int public function getPaginationItems(int $offset, int $limit): array { - return call_user_func_array($this->items, [$offset, $limit]); + return call_user_func($this->items, $offset, $limit); } } diff --git a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/DBALQueryBuilderSubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/DBALQueryBuilderSubscriber.php index cce5143b..d7a040b9 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/DBALQueryBuilderSubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/DBALQueryBuilderSubscriber.php @@ -16,7 +16,6 @@ class DBALQueryBuilderSubscriber implements EventSubscriberInterface public function items(ItemsEvent $event): void { if ($event->target instanceof QueryBuilder) { - /** @var QueryBuilder $target */ $target = $event->target; // count results diff --git a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/Query/Helper.php b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/Query/Helper.php index 5919e4aa..e445e5e7 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/Query/Helper.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/Query/Helper.php @@ -13,9 +13,6 @@ class Helper /** * Clones the given $query and copies all used * parameters and hints - * - * @param Query $query - * @return Query */ public static function cloneQuery(Query $query): Query { @@ -33,10 +30,6 @@ public static function cloneQuery(Query $query): Query * Add a custom TreeWalker $walker class name to * be included in the CustomTreeWalker hint list * of the given $query - * - * @param Query $query - * @param string $walker - * @return void */ public static function addCustomTreeWalker(Query $query, string $walker): void { @@ -48,4 +41,4 @@ public static function addCustomTreeWalker(Query $query, string $walker): void } $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $customTreeWalkers); } -} \ No newline at end of file +} diff --git a/src/Knp/Component/Pager/Event/Subscriber/Paginate/PaginationSubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Paginate/PaginationSubscriber.php index 9f8918c1..efc526ee 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Paginate/PaginationSubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Paginate/PaginationSubscriber.php @@ -11,9 +11,8 @@ class PaginationSubscriber implements EventSubscriberInterface { /** * Lazy-load state tracker - * @var bool */ - private $isLoaded = false; + private bool $isLoaded = false; public function pagination(PaginationEvent $event): void { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php index 7f964ced..3abe4935 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php @@ -15,22 +15,16 @@ class ArraySubscriber implements EventSubscriberInterface /** * @var string the field used to sort current object array list */ - private $currentSortingField; + private string $currentSortingField; /** * @var string the sorting direction */ - private $sortDirection; + private string $sortDirection; - /** - * @var PropertyAccessorInterface|null - */ - private $propertyAccessor; + private ?PropertyAccessorInterface $propertyAccessor; - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(Request $request = null, PropertyAccessorInterface $accessor = null) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ODM/MongoDB/QuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ODM/MongoDB/QuerySubscriber.php index 460e1936..32f9935b 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ODM/MongoDB/QuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ODM/MongoDB/QuerySubscriber.php @@ -10,10 +10,7 @@ class QuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ORM/Query/OrderByWalker.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ORM/Query/OrderByWalker.php index 8d0b2bd3..3430b7a0 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ORM/Query/OrderByWalker.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/Doctrine/ORM/Query/OrderByWalker.php @@ -32,11 +32,8 @@ class OrderByWalker extends TreeWalkerAdapter /** * Walks down a SelectStatement AST node, modifying it to * sort the query like requested by url - * - * @param SelectStatement $AST - * @return void|string */ - public function walkSelectStatement(SelectStatement $AST) + public function walkSelectStatement(SelectStatement $AST): string { $query = $this->_getQuery(); $fields = (array)$query->getHint(self::HINT_PAGINATOR_SORT_FIELD); @@ -92,5 +89,7 @@ public function walkSelectStatement(SelectStatement $AST) $AST->orderByClause = new OrderByClause([$orderByItem]); } } + + return ''; } } diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ElasticaQuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ElasticaQuerySubscriber.php index eb1fd5e2..6f25f748 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ElasticaQuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ElasticaQuerySubscriber.php @@ -11,10 +11,7 @@ class ElasticaQuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/PropelQuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/PropelQuerySubscriber.php index 169668cf..372d2001 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/PropelQuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/PropelQuerySubscriber.php @@ -9,10 +9,7 @@ class PropelQuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/SolariumQuerySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/SolariumQuerySubscriber.php index 2a303fbe..12ae6c6d 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/SolariumQuerySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/SolariumQuerySubscriber.php @@ -14,10 +14,7 @@ */ class SolariumQuerySubscriber implements EventSubscriberInterface { - /** - * @var Request - */ - private $request; + private Request $request; public function __construct(Request $request) { diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/SortableSubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/SortableSubscriber.php index 53d9a0b2..7cf73f50 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/SortableSubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/SortableSubscriber.php @@ -9,9 +9,8 @@ class SortableSubscriber implements EventSubscriberInterface { /** * Lazy-load state tracker - * @var bool */ - private $isLoaded = false; + private bool $isLoaded = false; public function before(BeforeEvent $event): void { diff --git a/src/Knp/Component/Pager/Exception/PageNumberOutOfRangeException.php b/src/Knp/Component/Pager/Exception/PageNumberOutOfRangeException.php index 58ff3e3e..e2aac841 100644 --- a/src/Knp/Component/Pager/Exception/PageNumberOutOfRangeException.php +++ b/src/Knp/Component/Pager/Exception/PageNumberOutOfRangeException.php @@ -7,8 +7,7 @@ class PageNumberOutOfRangeException extends OutOfRangeException { - /** @var int */ - private $maxPageNumber; + private int $maxPageNumber; public function __construct(?string $message, int $maxPageNumber, ?Throwable $previousException = null) { diff --git a/src/Knp/Component/Pager/Pagination/AbstractPagination.php b/src/Knp/Component/Pager/Pagination/AbstractPagination.php index 83ae89f4..d2c6a0e5 100644 --- a/src/Knp/Component/Pager/Pagination/AbstractPagination.php +++ b/src/Knp/Component/Pager/Pagination/AbstractPagination.php @@ -6,12 +6,12 @@ abstract class AbstractPagination implements Iterator, PaginationInterface { - protected $currentPageNumber; - protected $numItemsPerPage; - protected $items = []; - protected $totalCount; - protected $paginatorOptions; - protected $customParameters; + protected ?int $currentPageNumber = null; + protected ?int $numItemsPerPage = null; + protected iterable $items = []; + protected ?int $totalCount = null; + protected ?array $paginatorOptions = null; + protected ?array $customParameters = null; public function rewind(): void { diff --git a/src/Knp/Component/Pager/Pagination/SlidingPagination.php b/src/Knp/Component/Pager/Pagination/SlidingPagination.php index d4b7ee94..e2999818 100644 --- a/src/Knp/Component/Pager/Pagination/SlidingPagination.php +++ b/src/Knp/Component/Pager/Pagination/SlidingPagination.php @@ -13,17 +13,13 @@ final class SlidingPagination extends AbstractPagination { /** * Pagination page range - * - * @var int */ - private $range = 5; + private int $range = 5; /** * Closure which is executed to render pagination - * - * @var Closure */ - public $renderer; + public ?Closure $renderer = null; public function setPageRange(int $range): void { diff --git a/src/Knp/Component/Pager/Paginator.php b/src/Knp/Component/Pager/Paginator.php index c0dd977b..c715bebc 100644 --- a/src/Knp/Component/Pager/Paginator.php +++ b/src/Knp/Component/Pager/Paginator.php @@ -16,17 +16,14 @@ */ final class Paginator implements PaginatorInterface { - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; + private EventDispatcherInterface $eventDispatcher; /** * Default options of paginator * - * @var array + * @var array */ - private $defaultOptions = [ + private array $defaultOptions = [ self::PAGE_PARAMETER_NAME => 'page', self::SORT_FIELD_PARAMETER_NAME => 'sort', self::SORT_DIRECTION_PARAMETER_NAME => 'direction', @@ -37,10 +34,7 @@ final class Paginator implements PaginatorInterface self::DEFAULT_LIMIT => self::DEFAULT_LIMIT_VALUE, ]; - /** - * @var RequestStack|null - */ - private $requestStack; + private ?RequestStack $requestStack; public function __construct(EventDispatcherInterface $eventDispatcher, RequestStack $requestStack = null) { diff --git a/tests/Test/Fixture/Document/Article.php b/tests/Test/Fixture/Document/Article.php index f680f586..d97a8a3f 100644 --- a/tests/Test/Fixture/Document/Article.php +++ b/tests/Test/Fixture/Document/Article.php @@ -17,52 +17,49 @@ final class Article /** * @ODM\Field(type="string") */ - private $title; + private ?string $title = null; /** * @ODM\Field(type="bool", name="status") */ - private $status; + private bool $status = false; /** * @ODM\Field(type="date", name="created_at") */ - private $createdAt; + private ?\DateTime $createdAt = null; public function getId() { return $this->id; } - public function setTitle($title): void + public function setTitle(?string $title): void { $this->title = $title; } - public function getTitle() + public function getTitle(): ?string { return $this->title; } - public function getStatus() + public function getStatus(): bool { return $this->status; } - public function setStatus($status): void + public function setStatus(bool $status): void { $this->status = $status; } - /** - * @param \DateTime $createdAt - */ public function setCreatedAt(\DateTime $createdAt): void { $this->createdAt = $createdAt; } - public function getCreatedAt() + public function getCreatedAt(): ?\DateTime { return $this->createdAt; } diff --git a/tests/Test/Fixture/Document/Image.php b/tests/Test/Fixture/Document/Image.php index 14c9b296..c3828062 100644 --- a/tests/Test/Fixture/Document/Image.php +++ b/tests/Test/Fixture/Document/Image.php @@ -17,10 +17,11 @@ final class Image /** * @ODM\Field */ - private $title; + private ?string $title = null; /** * @ODM\File + * @var int|string */ private $file; @@ -28,18 +29,18 @@ final class Image * Set file. * * @param int|string $file - * @return Image */ - public function setFile($file) + public function setFile($file): self { $this->file = $file; + return $this; } /** * Get file. * - * @return integer + * @return int|string */ public function getFile() { @@ -51,12 +52,12 @@ public function getId() return $this->id; } - public function setTitle($title): void + public function setTitle(?string $title): void { $this->title = $title; } - public function getTitle() + public function getTitle(): ?string { return $this->title; } diff --git a/tests/Test/Fixture/Entity/Article.php b/tests/Test/Fixture/Entity/Article.php index f998bb16..c95e95cb 100644 --- a/tests/Test/Fixture/Entity/Article.php +++ b/tests/Test/Fixture/Entity/Article.php @@ -19,34 +19,34 @@ class Article /** * @ORM\Column(length=64) */ - private $title; + private ?string $title = null; /** * @ORM\Column(type="boolean") */ - private $enabled = true; + private bool $enabled = true; public function getId() { return $this->id; } - public function setTitle($title): void + public function setTitle(?string $title): void { $this->title = $title; } - public function getTitle() + public function getTitle(): ?string { return $this->title; } - public function setEnabled($enabled): void + public function setEnabled(bool $enabled): void { $this->enabled = $enabled; } - public function isEnabled() + public function isEnabled(): bool { return $this->enabled; } diff --git a/tests/Test/Fixture/Entity/Composite.php b/tests/Test/Fixture/Entity/Composite.php index c583a1b7..76579db2 100644 --- a/tests/Test/Fixture/Entity/Composite.php +++ b/tests/Test/Fixture/Entity/Composite.php @@ -18,60 +18,52 @@ class Composite /** * @ORM\Column(length=64) */ - private $title; + private ?string $title = null; /** * @ORM\Id * @ORM\Column(type="string") */ - private $uid; + private ?string $uid = null; /** * Sets uid. - * - * @param mixed $uid */ - public function setUid($uid): void + public function setUid(?string $uid): void { $this->uid = $uid; } /** * Returns uid. - * - * @return mixed */ - public function getUid() + public function getUid(): ?string { return $this->uid; } /** * Sets Id. - * - * @param integer $id */ - public function setId($id): void + public function setId(?int $id): void { $this->id = $id; } /** * Returns Id. - * - * @return integer */ - public function getId() + public function getId(): ?int { return $this->id; } - public function setTitle($title): void + public function setTitle(?string $title): void { $this->title = $title; } - public function getTitle() + public function getTitle(): ?string { return $this->title; } diff --git a/tests/Test/Fixture/Entity/Shop/Product.php b/tests/Test/Fixture/Entity/Shop/Product.php index 8170e676..6abf4214 100644 --- a/tests/Test/Fixture/Entity/Shop/Product.php +++ b/tests/Test/Fixture/Entity/Shop/Product.php @@ -3,6 +3,7 @@ namespace Test\Fixture\Entity\Shop; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** @@ -20,27 +21,27 @@ class Product /** * @ORM\Column(length=64) */ - private $title; + private ?string $title = null; /** * @ORM\Column(length=255, nullable=true) */ - private $description; + private ?string $description = null; /** * @ORM\Column(type="float", nullable=false) */ - private $price; + private ?float $price = null; /** * @ORM\ManyToMany(targetEntity="Tag") */ - private $tags; + private Collection $tags; /** * @ORM\Column(type="integer") */ - private $numTags = 0; + private int $numTags = 0; public function __construct() { @@ -52,32 +53,32 @@ public function getId() return $this->id; } - public function setTitle($title): void + public function setTitle(?string $title): void { $this->title = $title; } - public function getTitle() + public function getTitle(): ?string { return $this->title; } - public function setDescription($description): void + public function setDescription(?string $description): void { $this->description = $description; } - public function getDescription() + public function getDescription(): ?string { return $this->description; } - public function setPrice($price): void + public function setPrice(?float $price): void { $this->price = $price; } - public function getPrice() + public function getPrice(): ?float { return $this->price; } @@ -88,7 +89,7 @@ public function addTag(Tag $tag): void $this->tags[] = $tag; } - public function getTags() + public function getTags(): Collection { return $this->tags; } diff --git a/tests/Test/Fixture/Entity/Shop/Tag.php b/tests/Test/Fixture/Entity/Shop/Tag.php index 44a680e0..ff03718f 100644 --- a/tests/Test/Fixture/Entity/Shop/Tag.php +++ b/tests/Test/Fixture/Entity/Shop/Tag.php @@ -19,19 +19,19 @@ class Tag /** * @ORM\Column(length=64) */ - private $name; + private ?string $name = null; public function getId() { return $this->id; } - public function setName($name): void + public function setName(?string $name): void { $this->name = $name; } - public function getName() + public function getName(): ?string { return $this->name; } diff --git a/tests/Test/Fixture/TestItem.php b/tests/Test/Fixture/TestItem.php index 0090dfe3..fda24f7a 100644 --- a/tests/Test/Fixture/TestItem.php +++ b/tests/Test/Fixture/TestItem.php @@ -4,10 +4,7 @@ class TestItem { - /** - * @var int - */ - private $sortProperty; + private int $sortProperty; public function __construct(int $sortProperty) { diff --git a/tests/Test/Pager/Pagination/PaginationInterfaceTest.php b/tests/Test/Pager/Pagination/PaginationInterfaceTest.php index 249a30a8..36b7fcf1 100644 --- a/tests/Test/Pager/Pagination/PaginationInterfaceTest.php +++ b/tests/Test/Pager/Pagination/PaginationInterfaceTest.php @@ -7,7 +7,7 @@ final class PaginationInterfaceTest extends BaseTestCase { - private $reflection; + private ?\ReflectionClass $reflection = null; protected function setUp(): void { diff --git a/tests/Test/Pager/Pagination/PaginatorTest.php b/tests/Test/Pager/Pagination/PaginatorTest.php index 9f809b47..08ca3483 100644 --- a/tests/Test/Pager/Pagination/PaginatorTest.php +++ b/tests/Test/Pager/Pagination/PaginatorTest.php @@ -11,13 +11,13 @@ final class PaginatorTest extends BaseTestCase */ public function shouldThrowExceptionOnInvalidPageAndLimitArgs(): void { - $exceptionTrown = false; + $exceptionThrown = false; try { $paginator = $this->getPaginatorInstance(); $paginator->paginate(['a', 'b'], -1, 0); } catch (\LogicException $e) { - $exceptionTrown = true; + $exceptionThrown = true; } - $this->assertTrue($exceptionTrown); + $this->assertTrue($exceptionThrown); } } diff --git a/tests/Test/Tool/BaseTestCaseMongoODM.php b/tests/Test/Tool/BaseTestCaseMongoODM.php index a4d5411a..b999950e 100644 --- a/tests/Test/Tool/BaseTestCaseMongoODM.php +++ b/tests/Test/Tool/BaseTestCaseMongoODM.php @@ -14,10 +14,7 @@ */ abstract class BaseTestCaseMongoODM extends BaseTestCase { - /** - * @var DocumentManager - */ - protected $dm; + protected ?DocumentManager $dm = null; protected function setUp(): void { diff --git a/tests/Test/Tool/BaseTestCaseORM.php b/tests/Test/Tool/BaseTestCaseORM.php index cb1594ff..0efc7c62 100644 --- a/tests/Test/Tool/BaseTestCaseORM.php +++ b/tests/Test/Tool/BaseTestCaseORM.php @@ -28,15 +28,9 @@ */ abstract class BaseTestCaseORM extends BaseTestCase { - /** - * @var EntityManager|null - */ - protected $em; + protected ?EntityManager $em = null; - /** - * @var QueryAnalyzer|null - */ - protected $queryAnalyzer; + protected ?QueryAnalyzer $queryAnalyzer = null; protected function setUp(): void { diff --git a/tests/Test/Tool/BaseTestCasePHPCRODM.php b/tests/Test/Tool/BaseTestCasePHPCRODM.php index 8c96b970..a88760c8 100644 --- a/tests/Test/Tool/BaseTestCasePHPCRODM.php +++ b/tests/Test/Tool/BaseTestCasePHPCRODM.php @@ -16,10 +16,7 @@ */ abstract class BaseTestCasePHPCRODM extends BaseTestCase { - /** - * @var DocumentManager|null - */ - protected $dm; + protected ?DocumentManager $dm = null; protected function setUp(): void { diff --git a/tests/Test/Tool/QueryAnalyzer.php b/tests/Test/Tool/QueryAnalyzer.php index 6da48a57..a410f1b9 100644 --- a/tests/Test/Tool/QueryAnalyzer.php +++ b/tests/Test/Tool/QueryAnalyzer.php @@ -17,10 +17,8 @@ final class QueryAnalyzer implements SQLLogger { /** * Used database platform - * - * @var AbstractPlatform */ - protected $platform; + protected AbstractPlatform $platform; /** * Start time of currently executed query @@ -38,18 +36,14 @@ final class QueryAnalyzer implements SQLLogger /** * List of queries executed - * - * @var array */ - private $queries = []; + private array $queries = []; /** * Query execution times indexed * in same order as queries - * - * @var array */ - private $queryExecutionTimes = []; + private array $queryExecutionTimes = []; /** * Initialize log listener with database