PHPStan level 3

This commit is contained in:
Yassine Guedidi
2023-08-08 02:27:21 +01:00
parent 85065b509f
commit 0f17a8cf8a
25 changed files with 86 additions and 74 deletions

View File

@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -138,7 +139,7 @@ class IgnoreOriginInstanceRuleController extends AbstractController
*
* @param IgnoreOriginInstanceRule $ignoreOriginInstanceRule The ignore origin instance rule entity
*
* @return Form The form
* @return FormInterface The form
*/
private function createDeleteForm(IgnoreOriginInstanceRule $ignoreOriginInstanceRule)
{

View File

@ -6,6 +6,7 @@ use Craue\ConfigBundle\Util\Config;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ -173,7 +174,7 @@ class SiteCredentialController extends AbstractController
*
* @param SiteCredential $siteCredential The site credential entity
*
* @return Form The form
* @return FormInterface The form
*/
private function createDeleteForm(SiteCredential $siteCredential)
{

View File

@ -132,12 +132,16 @@ class Config
private $user;
/**
* @var ArrayCollection<TaggingRule>
*
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"})
* @ORM\OrderBy({"id" = "ASC"})
*/
private $taggingRules;
/**
@var ArrayCollection<IgnoreOriginUserRule>
* @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\IgnoreOriginUserRule", mappedBy="config", cascade={"remove"})
* @ORM\OrderBy({"id" = "ASC"})
*/
@ -371,12 +375,9 @@ class Config
return $this;
}
/**
* @return bool
*/
public function getDisplayThumbnails(): ?bool
public function getDisplayThumbnails(): bool
{
return $this->displayThumbnails;
return (bool) $this->displayThumbnails;
}
/**
@ -384,7 +385,7 @@ class Config
*/
public function setDisplayThumbnails(bool $displayThumbnails)
{
$this->displayThumbnails = $displayThumbnails;
$this->displayThumbnails = $displayThumbnails ? 1 : 0;
return $this;
}

View File

@ -55,7 +55,7 @@ class Entry
private $id;
/**
* @var string
* @var string|null
*
* @ORM\Column(name="uid", type="string", length=23, nullable=true)
*
@ -132,7 +132,7 @@ class Entry
private $isArchived = false;
/**
* @var \DateTime
* @var \DateTimeInterface
*
* @ORM\Column(name="archived_at", type="datetime", nullable=true)
*
@ -161,7 +161,7 @@ class Entry
private $content;
/**
* @var \DateTime
* @var \DateTimeInterface
*
* @ORM\Column(name="created_at", type="datetime")
*
@ -170,7 +170,7 @@ class Entry
private $createdAt;
/**
* @var \DateTime
* @var \DateTimeInterface
*
* @ORM\Column(name="updated_at", type="datetime")
*
@ -179,7 +179,7 @@ class Entry
private $updatedAt;
/**
* @var \DateTime
* @var \DateTimeInterface
*
* @ORM\Column(name="published_at", type="datetime", nullable=true)
*
@ -197,7 +197,7 @@ class Entry
private $publishedBy;
/**
* @var \DateTime
* @var \DateTimeInterface
*
* @ORM\Column(name="starred_at", type="datetime", nullable=true)
*
@ -400,7 +400,7 @@ class Entry
}
/**
* @return \DateTime|null
* @return \DateTimeInterface|null
*/
public function getArchivedAt()
{
@ -408,7 +408,7 @@ class Entry
}
/**
* @param \DateTime|null $archivedAt
* @param \DateTimeInterface|null $archivedAt
*
* @return Entry
*/
@ -482,7 +482,7 @@ class Entry
public function toggleStar()
{
$this->isStarred = $this->isStarred() ^ 1;
$this->isStarred = !$this->isStarred();
return $this;
}
@ -560,7 +560,7 @@ class Entry
}
/**
* @return \DateTime
* @return \DateTimeInterface
*/
public function getCreatedAt()
{
@ -568,7 +568,7 @@ class Entry
}
/**
* @return \DateTime
* @return \DateTimeInterface
*/
public function getUpdatedAt()
{
@ -576,7 +576,7 @@ class Entry
}
/**
* @return \DateTime|null
* @return \DateTimeInterface|null
*/
public function getStarredAt()
{
@ -584,7 +584,7 @@ class Entry
}
/**
* @param \DateTime|null $starredAt
* @param \DateTimeInterface|null $starredAt
*
* @return Entry
*/
@ -881,7 +881,7 @@ class Entry
}
/**
* @return \DateTime
* @return \DateTimeInterface
*/
public function getPublishedAt()
{
@ -891,7 +891,7 @@ class Entry
/**
* @return Entry
*/
public function setPublishedAt(\DateTime $publishedAt)
public function setPublishedAt(\DateTimeInterface $publishedAt)
{
$this->publishedAt = $publishedAt;

View File

@ -49,7 +49,7 @@ class StringToListTransformer implements DataTransformerInterface
public function reverseTransform($string)
{
if (null === $string) {
return;
return null;
}
return array_values(array_filter(array_map('trim', explode($this->separator, $string))));

View File

@ -3,6 +3,7 @@
namespace Wallabag\CoreBundle\Helper;
use Pagerfanta\Adapter\AdapterInterface;
use Pagerfanta\Adapter\NullAdapter;
use Pagerfanta\Pagerfanta;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Wallabag\UserBundle\Entity\User;
@ -19,7 +20,7 @@ class PreparePagerForEntries
/**
* @param User $user If user isn't logged in, we can force it (like for feed)
*
* @return Pagerfanta|null
* @return Pagerfanta
*/
public function prepare(AdapterInterface $adapter, User $user = null)
{
@ -28,7 +29,7 @@ class PreparePagerForEntries
}
if (!$user instanceof User) {
return;
return new Pagerfanta(new NullAdapter());
}
$entries = new Pagerfanta($adapter);

View File

@ -2,6 +2,7 @@
namespace Wallabag\CoreBundle\Helper;
use Doctrine\Common\Collections\ArrayCollection;
use Psr\Log\LoggerInterface;
use RulerZ\RulerZ;
use Wallabag\CoreBundle\Entity\Entry;
@ -120,7 +121,7 @@ class RuleBasedTagger
/**
* Retrieves the tagging rules for a given user.
*
* @return array<TaggingRule>
* @return ArrayCollection<TaggingRule>
*/
private function getRulesForUser(User $user)
{

View File

@ -429,7 +429,7 @@ class EntryRepository extends ServiceEntityRepository
/**
* Find all entries which have an empty value for hash.
*
* @return Entry|false
* @return Entry[]
*/
public function findByEmptyHashedUrlAndUserId(int $userId)
{

View File

@ -42,7 +42,7 @@ class SiteCredentialRepository extends ServiceEntityRepository
->getOneOrNullResult();
if (null === $res) {
return;
return null;
}
// decrypt user & password before returning them

View File

@ -145,7 +145,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (!$user instanceof User) {
return 0;
return '';
}
$query = $this->entryRepository->getBuilderForArchiveByUser($user->getId())