From 0f17a8cf8ab9414fb692e29f09d0907f84b1b28d Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Tue, 8 Aug 2023 02:27:21 +0100 Subject: [PATCH] PHPStan level 3 --- phpstan-baseline.neon | 40 +++++++++---------- phpstan.neon | 5 ++- .../Controller/AnnotationRestController.php | 10 ++--- .../IgnoreOriginInstanceRuleController.php | 3 +- .../Controller/SiteCredentialController.php | 3 +- src/Wallabag/CoreBundle/Entity/Config.php | 13 +++--- src/Wallabag/CoreBundle/Entity/Entry.php | 30 +++++++------- .../StringToListTransformer.php | 2 +- .../Helper/PreparePagerForEntries.php | 5 ++- .../CoreBundle/Helper/RuleBasedTagger.php | 3 +- .../CoreBundle/Repository/EntryRepository.php | 2 +- .../Repository/SiteCredentialRepository.php | 2 +- .../CoreBundle/Twig/WallabagExtension.php | 2 +- .../ImportBundle/Import/AbstractImport.php | 2 +- .../ImportBundle/Import/BrowserImport.php | 12 +++--- .../ImportBundle/Import/DeliciousImport.php | 2 +- .../ImportBundle/Import/InstapaperImport.php | 2 +- .../ImportBundle/Import/PinboardImport.php | 2 +- .../ImportBundle/Import/PocketImport.php | 2 +- .../ImportBundle/Import/ReadabilityImport.php | 2 +- .../ImportBundle/Import/WallabagImport.php | 2 +- .../Controller/ManageController.php | 3 +- .../Controller/EntryControllerTest.php | 6 +-- .../CoreBundle/Helper/RedirectTest.php | 3 +- .../CoreBundle/WallabagCoreTestCase.php | 2 + 25 files changed, 86 insertions(+), 74 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a65463051..6ca99bef5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,10 +1,25 @@ parameters: ignoreErrors: + - + message: "#^Method Wallabag\\\\AnnotationBundle\\\\Controller\\\\WallabagAnnotationController\\:\\:postAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\\\.$#" + count: 1 + path: src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php + + - + message: "#^Method Wallabag\\\\AnnotationBundle\\\\Controller\\\\WallabagAnnotationController\\:\\:putAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\\\.$#" + count: 1 + path: src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php + - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Entity\\\\RuleInterface\\:\\:getConfig\\(\\)\\.$#" count: 1 path: src/Wallabag/CoreBundle/Controller/ConfigController.php + - + message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser\\(\\) invoked with 2 parameters, 1 required\\.$#" + count: 7 + path: src/Wallabag/CoreBundle/Controller/ConfigController.php + - message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#" count: 1 @@ -40,27 +55,12 @@ parameters: count: 2 path: src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php + - + message: "#^PHPDoc type Symfony\\\\Component\\\\Mailer\\\\MailerInterface of property Wallabag\\\\UserBundle\\\\Mailer\\\\UserMailer\\:\\:\\$mailer is not covariant with PHPDoc type Swift_Mailer of overridden property FOS\\\\UserBundle\\\\Mailer\\\\TwigSwiftMailer\\:\\:\\$mailer\\.$#" + count: 1 + path: src/Wallabag/UserBundle/Mailer/UserMailer.php + - message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#" count: 1 path: tests/Wallabag/CoreBundle/Controller/FeedControllerTest.php - - - - message: "#^Call to method generate\\(\\) on an unknown class PHPUnit_Framework_MockObject_MockObject\\.$#" - count: 2 - path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php - - - - message: "#^Property Tests\\\\Wallabag\\\\CoreBundle\\\\Helper\\\\RedirectTest\\:\\:\\$routerMock has unknown class PHPUnit_Framework_MockObject_MockObject as its type\\.$#" - count: 1 - path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php - - - - message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#" - count: 15 - path: src/* - - - - message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser()#" - count: 7 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php diff --git a/phpstan.neon b/phpstan.neon index adcdf7c17..6a4823c9b 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - phpstan-baseline.neon parameters: - level: 2 + level: 3 paths: - src - tests @@ -14,3 +14,6 @@ parameters: - vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php inferPrivatePropertyTypeFromConstructor: true + + ignoreErrors: + - "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#" diff --git a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php index 5ffd0eb2e..ef57f4851 100644 --- a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php +++ b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php @@ -4,8 +4,8 @@ namespace Wallabag\ApiBundle\Controller; use Nelmio\ApiDocBundle\Annotation\Operation; use OpenApi\Annotations as OA; -use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Wallabag\AnnotationBundle\Entity\Annotation; use Wallabag\CoreBundle\Entity\Entry; @@ -36,7 +36,7 @@ class AnnotationRestController extends WallabagRestController * * @Route("/api/annotations/{entry}.{_format}", methods={"GET"}, name="api_get_annotations", defaults={"_format": "json"}) * - * @return JsonResponse + * @return Response */ public function getAnnotationsAction(Entry $entry) { @@ -102,7 +102,7 @@ class AnnotationRestController extends WallabagRestController * * @Route("/api/annotations/{entry}.{_format}", methods={"POST"}, name="api_post_annotation", defaults={"_format": "json"}) * - * @return JsonResponse + * @return Response */ public function postAnnotationAction(Request $request, Entry $entry) { @@ -138,7 +138,7 @@ class AnnotationRestController extends WallabagRestController * * @Route("/api/annotations/{annotation}.{_format}", methods={"PUT"}, name="api_put_annotation", defaults={"_format": "json"}) * - * @return JsonResponse + * @return Response */ public function putAnnotationAction(int $annotation, Request $request) { @@ -174,7 +174,7 @@ class AnnotationRestController extends WallabagRestController * * @Route("/api/annotations/{annotation}.{_format}", methods={"DELETE"}, name="api_delete_annotation", defaults={"_format": "json"}) * - * @return JsonResponse + * @return Response */ public function deleteAnnotationAction(int $annotation) { diff --git a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php index 941fc9275..bc12bd2c3 100644 --- a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php +++ b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php @@ -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) { diff --git a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php index f55d11b4e..4a5a60f1d 100644 --- a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php +++ b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php @@ -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) { diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index 081d25027..fd176d36e 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -132,12 +132,16 @@ class Config private $user; /** + * @var ArrayCollection + * * @ORM\OneToMany(targetEntity="Wallabag\CoreBundle\Entity\TaggingRule", mappedBy="config", cascade={"remove"}) * @ORM\OrderBy({"id" = "ASC"}) */ private $taggingRules; /** + @var ArrayCollection + * @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; } diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 5a00c0dbe..437be6cde 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -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; diff --git a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php index 57dbc95ed..ba03188ed 100644 --- a/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php +++ b/src/Wallabag/CoreBundle/Form/DataTransformer/StringToListTransformer.php @@ -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)))); diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php index bb35066d3..69a727f04 100644 --- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php +++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php @@ -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); diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php index 4014c68e7..a37a0cd34 100644 --- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php +++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php @@ -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 + * @return ArrayCollection */ private function getRulesForUser(User $user) { diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 9dded5e57..3615b0c4b 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -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) { diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index 605e97e18..747a66902 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php @@ -42,7 +42,7 @@ class SiteCredentialRepository extends ServiceEntityRepository ->getOneOrNullResult(); if (null === $res) { - return; + return null; } // decrypt user & password before returning them diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index e94bf3603..0f588cf19 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -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()) diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index c07908915..880d6575b 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php @@ -107,7 +107,7 @@ abstract class AbstractImport implements ImportInterface /** * Parse one entry. * - * @return Entry + * @return Entry|null */ abstract public function parseEntry(array $importedEntry); diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 4d4dc9e23..94b5f18f1 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -81,28 +81,28 @@ abstract class BrowserImport extends AbstractImport if ($this->producer) { $this->parseEntriesForProducer($importedEntry); - return; + return null; } $this->parseEntries($importedEntry); - return; + return null; } if (\array_key_exists('children', $importedEntry)) { if ($this->producer) { $this->parseEntriesForProducer($importedEntry['children']); - return; + return null; } $this->parseEntries($importedEntry['children']); - return; + return null; } if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) { - return; + return null; } $url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; @@ -114,7 +114,7 @@ abstract class BrowserImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $data = $this->prepareEntry($importedEntry); diff --git a/src/Wallabag/ImportBundle/Import/DeliciousImport.php b/src/Wallabag/ImportBundle/Import/DeliciousImport.php index 9c991748f..455a64991 100644 --- a/src/Wallabag/ImportBundle/Import/DeliciousImport.php +++ b/src/Wallabag/ImportBundle/Import/DeliciousImport.php @@ -104,7 +104,7 @@ class DeliciousImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $data = [ diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php index fbab4f3ad..9dea9ed6e 100644 --- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php +++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php @@ -132,7 +132,7 @@ class InstapaperImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $entry = new Entry($this->user); diff --git a/src/Wallabag/ImportBundle/Import/PinboardImport.php b/src/Wallabag/ImportBundle/Import/PinboardImport.php index a8b7ced44..19093fb25 100644 --- a/src/Wallabag/ImportBundle/Import/PinboardImport.php +++ b/src/Wallabag/ImportBundle/Import/PinboardImport.php @@ -104,7 +104,7 @@ class PinboardImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $data = [ diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 5a0325759..4fa578695 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -186,7 +186,7 @@ class PocketImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $entry = new Entry($this->user); diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index 2b0829f77..0e98fb5db 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php @@ -104,7 +104,7 @@ class ReadabilityImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $data = [ diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index 7a03b9377..a13ede0a1 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php @@ -110,7 +110,7 @@ abstract class WallabagImport extends AbstractImport if (false !== $existingEntry) { ++$this->skippedEntries; - return; + return null; } $data = $this->prepareEntry($importedEntry); diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index fb7b5b2e5..aadd0ca55 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -13,6 +13,7 @@ use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\Form; +use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -184,7 +185,7 @@ class ManageController extends AbstractController * * @param User $user The User entity * - * @return Form The form + * @return FormInterface The form */ private function createDeleteForm(User $user) { diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index a6e0f395b..1a99286b0 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -673,7 +673,7 @@ class EntryControllerTest extends WallabagCoreTestCase ->getRepository(Entry::class) ->findOneById($entry->getId()); - $this->assertSame(1, $res->isStarred()); + $this->assertTrue($res->isStarred()); } public function testDelete() @@ -1748,14 +1748,14 @@ class EntryControllerTest extends WallabagCoreTestCase ->getRepository(Entry::class) ->find($entry1->getId()); - $this->assertSame(1, $res->isStarred()); + $this->assertTrue($res->isStarred()); $res = $client->getContainer() ->get(EntityManagerInterface::class) ->getRepository(Entry::class) ->find($entry2->getId()); - $this->assertSame(1, $res->isStarred()); + $this->assertTrue($res->isStarred()); // Mass actions : tag $client->request('POST', '/mass', [ diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php index 780eeddac..bdc1add47 100644 --- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php @@ -2,6 +2,7 @@ namespace Tests\Wallabag\CoreBundle\Helper; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Routing\Router; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; @@ -12,7 +13,7 @@ use Wallabag\UserBundle\Entity\User; class RedirectTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var Router&MockObject */ private $routerMock; /** @var Redirect */ diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php index c6246e41c..a6f34303e 100644 --- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php +++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php @@ -138,6 +138,8 @@ abstract class WallabagCoreTestCase extends WebTestCase $token = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken(); if (null !== $token) { + \assert($token->getUser() instanceof User); + return $token->getUser(); }