mirror of
https://github.com/wallabag/wallabag.git
synced 2025-04-23 10:24:12 +00:00
Clean PHPStan baseline
This commit is contained in:
parent
0d93add058
commit
e63d473032
17 changed files with 73 additions and 85 deletions
phpstan-baseline.neon
src
Controller
Event/Subscriber
Form/Type
Import
AbstractImport.phpBrowserImport.phpDeliciousImport.phpHtmlImport.phpImportInterface.phpInstapaperImport.phpOmnivoreImport.phpPinboardImport.phpReadabilityImport.phpWallabagImport.php
Mailer
tests/Controller
|
@ -1,66 +0,0 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: "#^Method Wallabag\\\\Controller\\\\AnnotationController\\:\\:postAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\<mixed\\>\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/AnnotationController.php
|
||||
|
||||
-
|
||||
message: "#^Method Wallabag\\\\Controller\\\\AnnotationController\\:\\:putAnnotationAction\\(\\) should return Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse but returns Symfony\\\\Component\\\\Form\\\\FormInterface\\<mixed\\>\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/AnnotationController.php
|
||||
|
||||
-
|
||||
message: "#^Method FOS\\\\UserBundle\\\\Model\\\\UserManagerInterface\\:\\:updateUser\\(\\) invoked with 2 parameters, 1 required\\.$#"
|
||||
count: 6
|
||||
path: src/Controller/ConfigController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/BrowserController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/BrowserController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/HtmlController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/HtmlController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/WallabagController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Wallabag\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Controller/Import/WallabagController.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Spiriit\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Event/Subscriber/CustomDoctrineORMSubscriber.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Spiriit\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpr\\(\\)\\.$#"
|
||||
count: 10
|
||||
path: src/Form/Type/EntryFilterType.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method Scheb\\\\TwoFactorBundle\\\\Model\\\\Email\\\\TwoFactorInterface\\:\\:getName\\(\\)\\.$#"
|
||||
count: 2
|
||||
path: src/Mailer/AuthCodeMailer.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method DOMNode\\:\\:getAttribute\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: tests/Controller/FeedControllerTest.php
|
|
@ -85,7 +85,7 @@ class AnnotationController extends AbstractFOSRestController
|
|||
return JsonResponse::fromJsonString($json);
|
||||
}
|
||||
|
||||
return $form;
|
||||
return new JsonResponse(status: 400);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ class AnnotationController extends AbstractFOSRestController
|
|||
return JsonResponse::fromJsonString($json);
|
||||
}
|
||||
|
||||
return $form;
|
||||
return new JsonResponse(status: 400);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new NotFoundHttpException($e);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,8 @@ class ConfigController extends AbstractController
|
|||
$message = 'flashes.config.notice.password_updated';
|
||||
|
||||
$user->setPlainPassword($pwdForm->get('new_password')->getData());
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('notice', $message);
|
||||
|
||||
|
@ -124,7 +125,8 @@ class ConfigController extends AbstractController
|
|||
$userForm->handleRequest($request);
|
||||
|
||||
if ($userForm->isSubmitted() && $userForm->isValid()) {
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
|
@ -277,7 +279,8 @@ class ConfigController extends AbstractController
|
|||
$user = $this->getUser();
|
||||
$user->setEmailTwoFactor(false);
|
||||
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
|
@ -305,7 +308,8 @@ class ConfigController extends AbstractController
|
|||
$user->setBackupCodes(null);
|
||||
$user->setEmailTwoFactor(true);
|
||||
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
|
@ -332,7 +336,8 @@ class ConfigController extends AbstractController
|
|||
$user->setGoogleAuthenticatorSecret('');
|
||||
$user->setBackupCodes(null);
|
||||
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
|
@ -370,7 +375,8 @@ class ConfigController extends AbstractController
|
|||
|
||||
$user->setBackupCodes($backupCodesHashed);
|
||||
|
||||
$this->userManager->updateUser($user, true);
|
||||
$this->userManager->updateUser($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash(
|
||||
'notice',
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Wallabag\Event\Subscriber;
|
|||
|
||||
use Spiriit\Bundle\FormFilterBundle\Event\GetFilterConditionEvent;
|
||||
use Spiriit\Bundle\FormFilterBundle\Event\Subscriber\DoctrineORMSubscriber;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
|
@ -14,7 +15,11 @@ class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements Event
|
|||
{
|
||||
public function filterDateRange(GetFilterConditionEvent $event)
|
||||
{
|
||||
$expr = $event->getFilterQuery()->getExpressionBuilder();
|
||||
$filterQuery = $event->getFilterQuery();
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$expr = $filterQuery->getExpressionBuilder();
|
||||
$values = $event->getValues();
|
||||
$value = $values['value'];
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Wallabag\Form\Type;
|
||||
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Doctrine\ORMQuery;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\FilterOperands;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
|
||||
use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
|
||||
|
@ -57,6 +58,8 @@ class EntryFilterType extends AbstractType
|
|||
return;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$min = (int) ($lower * $user->getConfig()->getReadingSpeed() / 200);
|
||||
$max = (int) ($upper * $user->getConfig()->getReadingSpeed() / 200);
|
||||
|
||||
|
@ -98,6 +101,9 @@ class EntryFilterType extends AbstractType
|
|||
if (empty($value) || \strlen($value) <= 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
|
@ -114,6 +120,8 @@ class EntryFilterType extends AbstractType
|
|||
return false;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$paramName = \sprintf('%s', str_replace('.', '_', $field));
|
||||
$expression = $filterQuery->getExpr()->eq($field, ':' . $paramName);
|
||||
$parameters = [$paramName => $value];
|
||||
|
@ -143,6 +151,8 @@ class EntryFilterType extends AbstractType
|
|||
return false;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$expression = $filterQuery->getExpr()->eq('e.isArchived', 'false');
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
|
@ -170,6 +180,8 @@ class EntryFilterType extends AbstractType
|
|||
return false;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
$expression = $filterQuery->getExpr()->isNotNull($field);
|
||||
|
||||
return $filterQuery->createCondition($expression);
|
||||
|
@ -182,6 +194,8 @@ class EntryFilterType extends AbstractType
|
|||
return false;
|
||||
}
|
||||
|
||||
\assert($filterQuery instanceof ORMQuery);
|
||||
|
||||
// is_public isn't a real field
|
||||
// we should use the "uid" field to determine if the entry has been made public
|
||||
$expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid');
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class AbstractImport implements ImportInterface
|
|||
*
|
||||
* @param bool $markAsRead
|
||||
*/
|
||||
public function setMarkAsRead($markAsRead)
|
||||
public function setMarkAsRead($markAsRead): static
|
||||
{
|
||||
$this->markAsRead = $markAsRead;
|
||||
|
||||
|
@ -101,6 +101,11 @@ abstract class AbstractImport implements ImportInterface
|
|||
];
|
||||
}
|
||||
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse one entry.
|
||||
*
|
||||
|
|
|
@ -53,7 +53,7 @@ abstract class BrowserImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class DeliciousImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ abstract class HtmlImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Wallabag\Import;
|
||||
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
interface ImportInterface extends LoggerAwareInterface
|
||||
{
|
||||
|
@ -42,4 +43,24 @@ interface ImportInterface extends LoggerAwareInterface
|
|||
* @return array
|
||||
*/
|
||||
public function getSummary();
|
||||
|
||||
/**
|
||||
* Set current user.
|
||||
* Could the current *connected* user or one retrieve by the consumer.
|
||||
*/
|
||||
public function setUser(User $user);
|
||||
|
||||
/**
|
||||
* Set file path to the json file.
|
||||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath): static;
|
||||
|
||||
/**
|
||||
* Set whether articles must be all marked as read.
|
||||
*
|
||||
* @param bool $markAsRead
|
||||
*/
|
||||
public function setMarkAsRead($markAsRead): static;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class InstapaperImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class OmnivoreImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class PinboardImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class ReadabilityImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ abstract class WallabagImport extends AbstractImport
|
|||
*
|
||||
* @param string $filepath
|
||||
*/
|
||||
public function setFilepath($filepath)
|
||||
public function setFilepath($filepath): static
|
||||
{
|
||||
$this->filepath = $filepath;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use Symfony\Component\Mailer\MailerInterface;
|
|||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Twig\Environment;
|
||||
use Wallabag\Entity\User;
|
||||
|
||||
/**
|
||||
* Custom mailer for TwoFactorBundle email.
|
||||
|
@ -69,6 +70,8 @@ class AuthCodeMailer implements AuthCodeMailerInterface
|
|||
*/
|
||||
public function sendAuthCode(TwoFactorInterface $user): void
|
||||
{
|
||||
\assert($user instanceof User);
|
||||
|
||||
$template = $this->twig->load('TwoFactor/email_auth_code.html.twig');
|
||||
|
||||
$subject = $template->renderBlock('subject', []);
|
||||
|
|
|
@ -45,7 +45,7 @@ class FeedControllerTest extends WallabagTestCase
|
|||
}
|
||||
|
||||
$this->assertSame(1, $xpath->query('/a:feed/a:link[@rel="self"]')->length);
|
||||
$this->assertStringContainsString($type, $xpath->query('/a:feed/a:link[@rel="self"]')->item(0)->getAttribute('href'));
|
||||
$this->assertStringContainsString($type, $xpath->query('/a:feed/a:link[@rel="self"]')->item(0)->attributes['href']->value);
|
||||
|
||||
$this->assertSame(1, $xpath->query('/a:feed/a:link[@rel="last"]')->length);
|
||||
|
||||
|
|
Loading…
Reference in a new issue