diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c280d3a3d..10a4c15d4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,836 +1,96 @@ parameters: - ignoreErrors: - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findAnnotationsByPageId\\(\\)\\.$#" - count: 1 - path: src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findByUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/DeveloperController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findByUserIdAndBatchHashedUrls\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/EntryRestController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByLabel\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/EntryRestController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 2 - path: src/Wallabag/ApiBundle/Controller/EntryRestController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:removeTag\\(\\)\\.$#" - count: 2 - path: src/Wallabag/ApiBundle/Controller/TagRestController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:removeTags\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/TagRestController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findAllTags\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/TagRestController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findByLabelsAndUser\\(\\)\\.$#" - count: 3 - path: src/Wallabag/ApiBundle/Controller/TagRestController.php - - - - message: "#^Call to an undefined method FOS\\\\UserBundle\\\\Model\\\\UserInterface\\:\\:addClient\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/UserRestController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Controller/UserRestController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 3 - path: src/Wallabag/ApiBundle/Controller/WallabagRestController.php - - - - message: "#^Cannot call method getId\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 2 - path: src/Wallabag/ApiBundle/Controller/WallabagRestController.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\AccessToken\\:\\:\\$client has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\ClientInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/AccessToken.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\AccessToken\\:\\:\\$user has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\UserInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/AccessToken.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\AuthCode\\:\\:\\$client has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\ClientInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/AuthCode.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\AuthCode\\:\\:\\$user has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\UserInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/AuthCode.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\RefreshToken\\:\\:\\$client has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\ClientInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/RefreshToken.php - - - - message: "#^Property Wallabag\\\\ApiBundle\\\\Entity\\\\RefreshToken\\:\\:\\$user has unknown class FOS\\\\OAuthServerBundle\\\\Entity\\\\UserInterface as its type\\.$#" - count: 1 - path: src/Wallabag/ApiBundle/Entity/RefreshToken.php - - - - message: "#^Service \"wallabag_core\\.entry\\.download_images\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/CleanDownloadedImagesCommand.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/CleanDownloadedImagesCommand.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ExportCommand.php - - - - message: "#^Service \"wallabag_core\\.helper\\.entries_export\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ExportCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ExportCommand.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getConnection\\(\\)\\.$#" - count: 5 - path: src/Wallabag/CoreBundle/Command/InstallCommand.php - - - - message: "#^Method Wallabag\\\\CoreBundle\\\\Command\\\\InstallCommand\\:\\:execute\\(\\) should return int\\|null but return statement is missing\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/InstallCommand.php - - - - message: "#^Service \"fos_user\\.user_manager\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/InstallCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Command/ListUserCommand.php - - - - message: "#^Service \"wallabag_core\\.content_proxy\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ReloadEntryCommand.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ReloadEntryCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ReloadEntryCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/ShowUserCommand.php - - - - message: "#^Service \"wallabag_core\\.rule_based_tagger\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/TagAllCommand.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Command/TagAllCommand.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findAllArchivedEntriesByUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:removeAllByUserId\\(\\)\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Entity\\\\RuleInterface\\:\\:getConfig\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method getConfig\\(\\) on an unknown class WallabagCoreBundle\\:IgnoreOriginUserRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method getConfig\\(\\) on an unknown class WallabagCoreBundle\\:TaggingRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method getId\\(\\) on an unknown class WallabagCoreBundle\\:IgnoreOriginUserRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method getId\\(\\) on an unknown class WallabagCoreBundle\\:TaggingRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method setConfig\\(\\) on an unknown class WallabagCoreBundle\\:IgnoreOriginUserRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to method setConfig\\(\\) on an unknown class WallabagCoreBundle\\:TaggingRule\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Service \"fos_user\\.user_manager\" is private\\.$#" - count: 7 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Service \"liip_theme\\.active_theme\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 3 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Service \"wallabag_core\\.tag_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Service \"wallabag_user\\.user_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/ConfigController.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\EntryRepository\\:\\:findById\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Service \"logger\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Service \"wallabag_core\\.content_proxy\" is private\\.$#" - count: 3 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 6 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.prepare_pager_for_entries\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.redirect\" is private\\.$#" - count: 4 - path: src/Wallabag/CoreBundle/Controller/EntryController.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\TagRepository\\:\\:findOneBySlug\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ExportController.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ExportController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.entries_export\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/ExportController.php - - - - message: "#^Service \"wallabag_core\\.tag_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/ExportController.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/FeedController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.prepare_pager_for_entries\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/FeedController.php - - - - message: "#^Service \"wallabag_core\\.ignore_origin_instance_rule_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\SiteCredentialRepository\\:\\:findByUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/SiteCredentialController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.crypto_proxy\" is private\\.$#" - count: 4 - path: src/Wallabag/CoreBundle/Controller/SiteCredentialController.php - - - - message: "#^Service \"wallabag_core\\.site_credential_repository\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/SiteCredentialController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/StaticController.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\TagRepository\\:\\:findOneByLabel\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.entry_repository\" is private\\.$#" - count: 5 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.prepare_pager_for_entries\" is private\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.redirect\" is private\\.$#" - count: 4 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.tag_repository\" is private\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.tags_assigner\" is private\\.$#" - count: 3 - path: src/Wallabag/CoreBundle/Controller/TagController.php - - - - message: "#^Service \"wallabag_core\\.helper\\.crypto_proxy\" is private\\.$#" - count: 4 - path: src/Wallabag/CoreBundle/DataFixtures/SiteCredentialFixtures.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/DependencyInjection/Configuration.php - - - - message: "#^Cannot call method getConfig\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php - - - - message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\:\\:findDistinctLanguageByUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php - - - - message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpr\\(\\)\\.$#" - count: 10 - path: src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php - - - - message: "#^Cannot call method getConfig\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php - - - - message: "#^Cannot call method getId\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php - - - - message: "#^Cannot call method getConfig\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Helper/EntriesExport.php - - - - message: "#^PHPDoc tag @var has invalid value \\(\\[\\\\GuzzleHttp\\\\Event\\\\SubscriberInterface\\]\\)\\: Unexpected token \"\\[\", expected type at offset 9$#" - count: 1 - path: src/Wallabag/CoreBundle/Helper/HttpClientFactory.php - - - - message: "#^Call to an undefined method Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\:\\:getConfig\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php - - - - message: "#^Call to an undefined method Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\:\\:getConfig\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Helper/Redirect.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\TagRepository\\:\\:findOneByLabel\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php - - - - message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Repository\\\\TagRepository\\:\\:findOneByLabel\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/Helper/TagsAssigner.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUsernameAndFeedtoken\\(\\)\\.$#" - count: 1 - path: src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php - - - - message: "#^Call to an undefined method Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\:\\:getConfig\\(\\)\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Twig/WallabagExtension.php - - - - message: "#^Call to an undefined method Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\:\\:getCreatedAt\\(\\)\\.$#" - count: 2 - path: src/Wallabag/CoreBundle/Twig/WallabagExtension.php - - - - message: "#^Call to an undefined method Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\:\\:getId\\(\\)\\.$#" - count: 7 - path: src/Wallabag/CoreBundle/Twig/WallabagExtension.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneById\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUsername\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getConnection\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Method Wallabag\\\\ImportBundle\\\\Command\\\\ImportCommand\\:\\:execute\\(\\) should return int\\|null but return statement is missing\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.chrome\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.delicious\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.firefox\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.instapaper\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.pinboard\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.readability\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.wallabag_v1\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Service \"wallabag_import\\.wallabag_v2\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/ImportCommand.php - - - - message: "#^Method Wallabag\\\\ImportBundle\\\\Command\\\\RedisWorkerCommand\\:\\:execute\\(\\) should return int\\|null but return statement is missing\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php - - - - message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/BrowserController.php - - - - message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/BrowserController.php - - - - message: "#^Service \"wallabag_import\\.chrome\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ChromeController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.chrome\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ChromeController.php - - - - message: "#^Service \"wallabag_import\\.delicious\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/DeliciousController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.delicious\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/DeliciousController.php - - - - message: "#^Service \"wallabag_import\\.elcurator\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ElcuratorController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.elcurator\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ElcuratorController.php - - - - message: "#^Service \"wallabag_import\\.firefox\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/FirefoxController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.firefox\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/FirefoxController.php - - - - message: "#^Service \"wallabag_core\\.redis\\.client\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ImportController.php - - - - message: "#^Service \"wallabag_import\\.chain\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ImportController.php - - - - message: "#^Service \"wallabag_import\\.instapaper\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/InstapaperController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.instapaper\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/InstapaperController.php - - - - message: "#^Service \"wallabag_import\\.pinboard\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/PinboardController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.pinboard\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/PinboardController.php - - - - message: "#^Service \"wallabag_import\\.pocket\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/PocketController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.pocket\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/PocketController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.readability\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ReadabilityController.php - - - - message: "#^Service \"wallabag_import\\.readability\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/ReadabilityController.php - - - - message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagController.php - - - - message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagController.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.wallabag_v1\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php - - - - message: "#^Service \"wallabag_import\\.wallabag_v1\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php - - - - message: "#^Service \"wallabag_import\\.producer\\.redis\\.wallabag_v2\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php - - - - message: "#^Service \"wallabag_import\\.wallabag_v2\\.import\" is private\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" - count: 1 - path: src/Wallabag/ImportBundle/DependencyInjection/Configuration.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:getQueryBuilderForSearch\\(\\)\\.$#" - count: 1 - path: src/Wallabag/UserBundle/Controller/ManageController.php - - - - message: "#^Service \"fos_user\\.user_manager\" is private\\.$#" - count: 2 - path: src/Wallabag/UserBundle/Controller/ManageController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 1 - path: src/Wallabag/UserBundle/Controller/RegistrationController.php - - - - message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" - count: 1 - path: src/Wallabag/UserBundle/Controller/SecurityController.php - - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" - count: 1 - path: src/Wallabag/UserBundle/DependencyInjection/Configuration.php - - - - message: "#^Call to an undefined method Scheb\\\\TwoFactorBundle\\\\Model\\\\Email\\\\TwoFactorInterface\\:\\:getName\\(\\)\\.$#" - count: 2 - path: src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findAnnotationById\\(\\)\\.$#" - count: 1 - path: tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findLastAnnotationByPageId\\(\\)\\.$#" - count: 1 - path: tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneById\\(\\)\\.$#" - count: 2 - path: tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUsernameAndNotArchived\\(\\)\\.$#" - count: 7 - path: tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUserName\\(\\)\\.$#" - count: 3 - path: tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php - - - - message: "#^PHPDoc tag @var has invalid value \\(\\$loginManager \\\\FOS\\\\UserBundle\\\\Security\\\\LoginManager\\)\\: Unexpected token \"\\$loginManager\", expected type at offset 9$#" - count: 1 - path: tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php - - - - message: "#^PHPDoc tag @var has invalid value \\(\\$userManager \\\\FOS\\\\UserBundle\\\\Doctrine\\\\UserManager\\)\\: Unexpected token \"\\$userManager\", expected type at offset 9$#" - count: 1 - path: tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findByUrlAndUserId\\(\\)\\.$#" - count: 3 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUser\\(\\)\\.$#" - count: 7 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneWithTags\\(\\)\\.$#" - count: 2 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getId\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 10 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getOriginUrl\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 1 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getTags\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 3 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getTitle\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 4 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getUrl\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 3 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getUserEmail\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 1 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getUserId\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 1 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to method getUserName\\(\\) on an unknown class WallabagCoreBundle\\:Entry\\.$#" - count: 1 - path: tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findAllByTagId\\(\\)\\.$#" - count: 4 - path: tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneWithTags\\(\\)\\.$#" - count: 3 - path: tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByLabel\\(\\)\\.$#" - count: 2 - path: tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php - - - - message: "#^Call to an undefined method Doctrine\\\\ORM\\\\EntityRepository\\\\:\\:findOneByUserName\\(\\)\\.$#" - count: 1 - path: tests/Wallabag/ApiBundle/WallabagApiTestCase.php - - - - message: "#^PHPDoc tag @var has invalid value \\(\\$loginManager \\\\FOS\\\\UserBundle\\\\Security\\\\LoginManager\\)\\: Unexpected token \"\\$loginManager\", expected type at offset 9$#" - count: 1 - path: tests/Wallabag/ApiBundle/WallabagApiTestCase.php - - - - message: "#^PHPDoc tag @var has invalid value \\(\\$userManager \\\\FOS\\\\UserBundle\\\\Doctrine\\\\UserManager\\)\\: Unexpected token \"\\$userManager\", expected type at offset 9$#" - count: 1 - path: tests/Wallabag/ApiBundle/WallabagApiTestCase.php - - - - message: "#^Cannot call method getId\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 9 - path: tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.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: "#^Cannot call method getConfig\\(\\) on string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\.$#" - count: 3 - 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 + ignoreErrors: + - + message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" + count: 2 + path: src/Wallabag/ApiBundle/Controller/EntryRestController.php + + - + message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ApiBundle/Controller/UserRestController.php + + - + message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" + count: 3 + path: src/Wallabag/ApiBundle/Controller/WallabagRestController.php + + - + message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getConnection\\(\\)\\.$#" + count: 5 + path: src/Wallabag/CoreBundle/Command/InstallCommand.php + + - + message: "#^Call to an undefined method Wallabag\\\\CoreBundle\\\\Entity\\\\RuleInterface\\:\\:getConfig\\(\\)\\.$#" + count: 1 + path: src/Wallabag/CoreBundle/Controller/ConfigController.php + + - + message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:getParameter\\(\\)\\.$#" + count: 1 + path: src/Wallabag/CoreBundle/Controller/StaticController.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" + count: 1 + path: src/Wallabag/CoreBundle/DependencyInjection/Configuration.php + + - + message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpressionBuilder\\(\\)\\.$#" + count: 1 + path: src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php + + - + message: "#^Call to an undefined method Lexik\\\\Bundle\\\\FormFilterBundle\\\\Filter\\\\Query\\\\QueryInterface\\:\\:getExpr\\(\\)\\.$#" + count: 10 + path: src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php + + - + message: "#^Call to an undefined method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getConnection\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/Command/ImportCommand.php + + - + message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/Controller/BrowserController.php + + - + message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/Controller/BrowserController.php + + - + message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setFilepath\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/Controller/WallabagController.php + + - + message: "#^Call to an undefined method Wallabag\\\\ImportBundle\\\\Import\\\\ImportInterface\\:\\:setUser\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/Controller/WallabagController.php + + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" + count: 1 + path: src/Wallabag/ImportBundle/DependencyInjection/Configuration.php + + - + message: "#^Call to an undefined method Scheb\\\\TwoFactorBundle\\\\Model\\\\Email\\\\TwoFactorInterface\\:\\:getName\\(\\)\\.$#" + count: 2 + path: src/Wallabag/UserBundle/Mailer/AuthCodeMailer.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 diff --git a/phpstan.neon b/phpstan.neon index 28c7e8fa5..1edbd234d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ includes: - - phpstan-baseline.neon + - phpstan-baseline.neon parameters: level: 2 @@ -14,3 +14,6 @@ parameters: - vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php inferPrivatePropertyTypeFromConstructor: true + + ignoreErrors: + - '#^Service ".+" is private\.?#' diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php index 0f2cc1e09..20c34f55d 100644 --- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php +++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php @@ -52,7 +52,7 @@ class WallabagAnnotationController extends AbstractFOSRestController { $data = json_decode($request->getContent(), true); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $annotation = new Annotation($this->getUser()); $annotation->setEntry($entry); @@ -95,7 +95,7 @@ class WallabagAnnotationController extends AbstractFOSRestController $form->submit($data); if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($annotation); $em->flush(); @@ -119,7 +119,7 @@ class WallabagAnnotationController extends AbstractFOSRestController */ public function deleteAnnotationAction(Annotation $annotation) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($annotation); $em->flush(); diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php index 59c17e447..8987b263a 100644 --- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php +++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php @@ -9,6 +9,8 @@ use Wallabag\AnnotationBundle\Entity\Annotation; /** * AnnotationRepository. + * + * @method Annotation|null findOneById(int $id) */ class AnnotationRepository extends ServiceEntityRepository { diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php index 179285d40..c15c57678 100644 --- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php +++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php @@ -23,7 +23,7 @@ class DeveloperController extends Controller */ public function indexAction() { - $clients = $this->getDoctrine()->getRepository(Client::class)->findByUser($this->getUser()->getId()); + $clients = $this->get('doctrine')->getRepository(Client::class)->findByUser($this->getUser()->getId()); return $this->render('@WallabagCore/Developer/index.html.twig', [ 'clients' => $clients, @@ -39,7 +39,7 @@ class DeveloperController extends Controller */ public function createClientAction(Request $request) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $client = new Client($this->getUser()); $clientForm = $this->createForm(ClientType::class, $client); $clientForm->handleRequest($request); @@ -79,7 +79,7 @@ class DeveloperController extends Controller throw $this->createAccessDeniedException('You can not access this client.'); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($client); $em->flush(); diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 98f11b52a..3d17d0296 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -88,7 +88,7 @@ class EntryRestController extends WallabagRestController public function getEntriesExistsAction(Request $request) { $this->validateAuthentication(); - $repo = $this->getDoctrine()->getRepository(Entry::class); + $repo = $this->get('doctrine')->getRepository(Entry::class); $returnId = (null === $request->query->get('return_id')) ? false : (bool) $request->query->get('return_id'); @@ -464,7 +464,7 @@ class EntryRestController extends WallabagRestController // entry deleted, dispatch event about it! $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($entry); $em->flush(); } @@ -532,7 +532,7 @@ class EntryRestController extends WallabagRestController $this->get(ContentProxy::class)->updateEntry($entry, $url); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -755,7 +755,7 @@ class EntryRestController extends WallabagRestController $this->get(ContentProxy::class)->setDefaultEntryTitle($entry); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -971,7 +971,7 @@ class EntryRestController extends WallabagRestController $this->get(ContentProxy::class)->setDefaultEntryTitle($entry); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -1027,7 +1027,7 @@ class EntryRestController extends WallabagRestController return new JsonResponse([], 304); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -1085,7 +1085,7 @@ class EntryRestController extends WallabagRestController // entry deleted, dispatch event about it! $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($entry); $em->flush(); @@ -1168,7 +1168,7 @@ class EntryRestController extends WallabagRestController $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -1213,7 +1213,7 @@ class EntryRestController extends WallabagRestController $this->validateUserAccess($entry->getUser()->getId()); $entry->removeTag($tag); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -1272,7 +1272,7 @@ class EntryRestController extends WallabagRestController foreach ($tags as $label) { $label = trim($label); - $tag = $this->getDoctrine() + $tag = $this->get('doctrine') ->getRepository(Tag::class) ->findOneByLabel($label); @@ -1281,7 +1281,7 @@ class EntryRestController extends WallabagRestController } } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); } @@ -1340,7 +1340,7 @@ class EntryRestController extends WallabagRestController if (false !== $entry && !(empty($tags))) { $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); } diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index 3cc623909..7e943be55 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php @@ -33,7 +33,7 @@ class TagRestController extends WallabagRestController { $this->validateAuthentication(); - $tags = $this->getDoctrine() + $tags = $this->get('doctrine') ->getRepository(Tag::class) ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); @@ -71,7 +71,7 @@ class TagRestController extends WallabagRestController $this->validateAuthentication(); $label = $request->get('tag', ''); - $tags = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser([$label], $this->getUser()->getId()); + $tags = $this->get('doctrine')->getRepository(Tag::class)->findByLabelsAndUser([$label], $this->getUser()->getId()); if (empty($tags)) { throw $this->createNotFoundException('Tag not found'); @@ -79,7 +79,7 @@ class TagRestController extends WallabagRestController $tag = $tags[0]; - $this->getDoctrine() + $this->get('doctrine') ->getRepository(Entry::class) ->removeTag($this->getUser()->getId(), $tag); @@ -122,13 +122,13 @@ class TagRestController extends WallabagRestController $tagsLabels = $request->get('tags', ''); - $tags = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser(explode(',', $tagsLabels), $this->getUser()->getId()); + $tags = $this->get('doctrine')->getRepository(Tag::class)->findByLabelsAndUser(explode(',', $tagsLabels), $this->getUser()->getId()); if (empty($tags)) { throw $this->createNotFoundException('Tags not found'); } - $this->getDoctrine() + $this->get('doctrine') ->getRepository(Entry::class) ->removeTags($this->getUser()->getId(), $tags); @@ -167,13 +167,13 @@ class TagRestController extends WallabagRestController { $this->validateAuthentication(); - $tagFromDb = $this->getDoctrine()->getRepository(Tag::class)->findByLabelsAndUser([$tag->getLabel()], $this->getUser()->getId()); + $tagFromDb = $this->get('doctrine')->getRepository(Tag::class)->findByLabelsAndUser([$tag->getLabel()], $this->getUser()->getId()); if (empty($tagFromDb)) { throw $this->createNotFoundException('Tag not found'); } - $this->getDoctrine() + $this->get('doctrine') ->getRepository(Entry::class) ->removeTag($this->getUser()->getId(), $tag); @@ -195,7 +195,7 @@ class TagRestController extends WallabagRestController $tags = [$tags]; } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); foreach ($tags as $tag) { if (0 === \count($tag->getEntries())) { diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php index 348536d32..182e659e6 100644 --- a/src/Wallabag/ApiBundle/Controller/UserRestController.php +++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php @@ -102,6 +102,7 @@ class UserRestController extends WallabagRestController $userManager = $this->get(UserManagerInterface::class); $user = $userManager->createUser(); + \assert($user instanceof User); // user will be disabled BY DEFAULT to avoid spamming account to be enabled $user->setEnabled(false); @@ -150,7 +151,7 @@ class UserRestController extends WallabagRestController $client = new Client($user); $client->setName($request->request->get('client_name', 'Default client')); - $this->getDoctrine()->getManager()->persist($client); + $this->get('doctrine')->getManager()->persist($client); $user->addClient($client); diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index fedc3910c..4716addd6 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -12,6 +12,7 @@ use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Wallabag\UserBundle\Entity\User; class WallabagRestController extends AbstractFOSRestController { @@ -84,6 +85,7 @@ class WallabagRestController extends AbstractFOSRestController protected function validateUserAccess($requestUserId) { $user = $this->get(TokenStorageInterface::class)->getToken()->getUser(); + \assert($user instanceof User); if ($requestUserId !== $user->getId()) { throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId()); } diff --git a/src/Wallabag/ApiBundle/Entity/AccessToken.php b/src/Wallabag/ApiBundle/Entity/AccessToken.php index 98e0af3e1..49e21bef4 100644 --- a/src/Wallabag/ApiBundle/Entity/AccessToken.php +++ b/src/Wallabag/ApiBundle/Entity/AccessToken.php @@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken; +use FOS\OAuthServerBundle\Model\ClientInterface; +use FOS\UserBundle\Model\UserInterface; /** * @ORM\Table("oauth2_access_tokens") @@ -37,12 +39,16 @@ class AccessToken extends BaseAccessToken /** * @ORM\ManyToOne(targetEntity="Client", inversedBy="accessTokens") * @ORM\JoinColumn(nullable=false) + * + * @var ClientInterface */ protected $client; /** * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") + * + * @var UserInterface */ protected $user; } diff --git a/src/Wallabag/ApiBundle/Entity/AuthCode.php b/src/Wallabag/ApiBundle/Entity/AuthCode.php index 7c9c85396..33b4c94bb 100644 --- a/src/Wallabag/ApiBundle/Entity/AuthCode.php +++ b/src/Wallabag/ApiBundle/Entity/AuthCode.php @@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode; +use FOS\OAuthServerBundle\Model\ClientInterface; +use FOS\UserBundle\Model\UserInterface; /** * @ORM\Table("oauth2_auth_codes") @@ -37,12 +39,16 @@ class AuthCode extends BaseAuthCode /** * @ORM\ManyToOne(targetEntity="Client") * @ORM\JoinColumn(nullable=false) + * + * @var ClientInterface */ protected $client; /** * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") + * + * @var UserInterface */ protected $user; } diff --git a/src/Wallabag/ApiBundle/Entity/RefreshToken.php b/src/Wallabag/ApiBundle/Entity/RefreshToken.php index 55a507e13..b013f0254 100644 --- a/src/Wallabag/ApiBundle/Entity/RefreshToken.php +++ b/src/Wallabag/ApiBundle/Entity/RefreshToken.php @@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken; +use FOS\OAuthServerBundle\Model\ClientInterface; +use FOS\UserBundle\Model\UserInterface; /** * @ORM\Table("oauth2_refresh_tokens") @@ -37,12 +39,16 @@ class RefreshToken extends BaseRefreshToken /** * @ORM\ManyToOne(targetEntity="Client", inversedBy="refreshTokens") * @ORM\JoinColumn(nullable=false) + * + * @var ClientInterface */ protected $client; /** * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") + * + * @var UserInterface */ protected $user; } diff --git a/src/Wallabag/ApiBundle/Repository/ClientRepository.php b/src/Wallabag/ApiBundle/Repository/ClientRepository.php index 1c00e1645..0c0b79786 100644 --- a/src/Wallabag/ApiBundle/Repository/ClientRepository.php +++ b/src/Wallabag/ApiBundle/Repository/ClientRepository.php @@ -6,6 +6,9 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; use Wallabag\ApiBundle\Entity\Client; +/** + * @method Client[] findByUser(int $userId) + */ class ClientRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php index 1d0fa3031..4637b4126 100644 --- a/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php +++ b/src/Wallabag/CoreBundle/Command/GenerateUrlHashesCommand.php @@ -43,7 +43,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand return 1; } } else { - $users = $this->getDoctrine()->getRepository(User::class)->findAll(); + $users = $this->getContainer()->get('doctrine')->getRepository(User::class)->findAll(); $output->writeln(sprintf('Generating hashed urls for "%d" users', \count($users))); @@ -60,7 +60,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand private function generateHashedUrls(User $user) { $em = $this->getContainer()->get(EntityManagerInterface::class); - $repo = $this->getDoctrine()->getRepository(Entry::class); + $repo = $this->getContainer()->get('doctrine')->getRepository(Entry::class); $entries = $repo->findByEmptyHashedUrlAndUserId($user->getId()); @@ -89,7 +89,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand */ private function getUser($username) { - return $this->getDoctrine()->getRepository(User::class)->findOneByUserName($username); + return $this->getContainer()->get('doctrine')->getRepository(User::class)->findOneByUserName($username); } private function getDoctrine() diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 1dafde40d..bc3e61d14 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -20,6 +20,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule; use Wallabag\CoreBundle\Entity\InternalSetting; +use Wallabag\UserBundle\Entity\User; class InstallCommand extends ContainerAwareCommand { @@ -79,6 +80,8 @@ class InstallCommand extends ContainerAwareCommand $this->io->success('wallabag has been successfully installed.'); $this->io->success('You can now configure your web server, see https://doc.wallabag.org'); + + return 0; } private function checkRequirements() @@ -261,6 +264,7 @@ class InstallCommand extends ContainerAwareCommand $userManager = $this->getContainer()->get(UserManagerInterface::class); $user = $userManager->createUser(); + \assert($user instanceof User); $user->setUsername($this->io->ask('Username', 'wallabag')); diff --git a/src/Wallabag/CoreBundle/Command/TagAllCommand.php b/src/Wallabag/CoreBundle/Command/TagAllCommand.php index 66eb2a36a..7ca7279f2 100644 --- a/src/Wallabag/CoreBundle/Command/TagAllCommand.php +++ b/src/Wallabag/CoreBundle/Command/TagAllCommand.php @@ -47,7 +47,7 @@ class TagAllCommand extends ContainerAwareCommand $io->text('Persist ' . \count($entries) . ' entries... '); - $em = $this->getDoctrine()->getManager(); + $em = $this->getContainer()->get('doctrine')->getManager(); foreach ($entries as $entry) { $em->persist($entry); } diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 18c7a2798..bc650c57b 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -44,7 +44,7 @@ class ConfigController extends Controller */ public function indexAction(Request $request) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $config = $this->getConfig(); $userManager = $this->container->get(UserManagerInterface::class); $user = $this->getUser(); @@ -125,7 +125,7 @@ class ConfigController extends Controller $action = $this->generateUrl('config') . '#set5'; if ($request->query->has('tagging-rule')) { - $taggingRule = $this->getDoctrine() + $taggingRule = $this->get('doctrine') ->getRepository(TaggingRule::class) ->find($request->query->get('tagging-rule')); @@ -188,7 +188,7 @@ class ConfigController extends Controller $action = $this->generateUrl('config') . '#set6'; if ($request->query->has('ignore-origin-user-rule')) { - $ignoreOriginUserRule = $this->getDoctrine() + $ignoreOriginUserRule = $this->get('doctrine') ->getRepository(IgnoreOriginUserRule::class) ->find($request->query->get('ignore-origin-user-rule')); @@ -414,7 +414,7 @@ class ConfigController extends Controller $config = $this->getConfig(); $config->setFeedToken(Utils::generateToken()); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($config); $em->flush(); @@ -440,7 +440,7 @@ class ConfigController extends Controller $config = $this->getConfig(); $config->setFeedToken(null); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($config); $em->flush(); @@ -467,7 +467,7 @@ class ConfigController extends Controller { $this->validateRuleAction($rule); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($rule); $em->flush(); @@ -504,7 +504,7 @@ class ConfigController extends Controller { $this->validateRuleAction($rule); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($rule); $em->flush(); @@ -541,7 +541,7 @@ class ConfigController extends Controller { switch ($type) { case 'annotations': - $this->getDoctrine() + $this->get('doctrine') ->getRepository(Annotation::class) ->removeAllByUserId($this->getUser()->getId()); break; @@ -552,7 +552,7 @@ class ConfigController extends Controller // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff // otherwise they won't be removed ... if ($this->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { - $this->getDoctrine()->getRepository(Annotation::class)->removeAllByUserId($this->getUser()->getId()); + $this->get('doctrine')->getRepository(Annotation::class)->removeAllByUserId($this->getUser()->getId()); } // manually remove tags to avoid orphan tag @@ -622,7 +622,7 @@ class ConfigController extends Controller $user = $this->getUser(); $user->getConfig()->setListMode(!$user->getConfig()->getListMode()); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($user); $em->flush(); @@ -691,7 +691,7 @@ class ConfigController extends Controller ->removeTags($userId, $tags); // cleanup orphan tags - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); foreach ($tags as $tag) { if (0 === \count($tag->getEntries())) { @@ -726,9 +726,9 @@ class ConfigController extends Controller private function removeAnnotationsForArchivedByUserId($userId) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); - $archivedEntriesAnnotations = $this->getDoctrine() + $archivedEntriesAnnotations = $this->get('doctrine') ->getRepository(Annotation::class) ->findAllArchivedEntriesByUser($userId); @@ -757,7 +757,7 @@ class ConfigController extends Controller */ private function getConfig() { - $config = $this->getDoctrine() + $config = $this->get('doctrine') ->getRepository(ConfigEntity::class) ->findOneByUser($this->getUser()); diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 964e1e3e7..6f66a021c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -40,7 +40,7 @@ class EntryController extends Controller */ public function massAction(Request $request) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $values = $request->request->all(); $tagsToAdd = []; @@ -173,7 +173,7 @@ class EntryController extends Controller $this->updateEntry($entry); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -201,7 +201,7 @@ class EntryController extends Controller if (false === $this->checkIfEntryAlreadyExists($entry)) { $this->updateEntry($entry); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -238,7 +238,7 @@ class EntryController extends Controller $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -409,7 +409,7 @@ class EntryController extends Controller return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); } - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -431,7 +431,7 @@ class EntryController extends Controller $this->checkUserAction($entry); $entry->toggleArchive(); - $this->getDoctrine()->getManager()->flush(); + $this->get('doctrine')->getManager()->flush(); $message = 'flashes.entry.notice.entry_unarchived'; if ($entry->isArchived()) { @@ -461,7 +461,7 @@ class EntryController extends Controller $entry->toggleStar(); $entry->updateStar($entry->isStarred()); - $this->getDoctrine()->getManager()->flush(); + $this->get('doctrine')->getManager()->flush(); $message = 'flashes.entry.notice.entry_unstarred'; if ($entry->isStarred()) { @@ -500,7 +500,7 @@ class EntryController extends Controller // entry deleted, dispatch event about it! $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($entry); $em->flush(); @@ -532,7 +532,7 @@ class EntryController extends Controller if (null === $entry->getUid()) { $entry->generateUid(); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); } @@ -555,7 +555,7 @@ class EntryController extends Controller $entry->cleanUid(); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); diff --git a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php index 22fbf5fa0..1414de8c1 100644 --- a/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php +++ b/src/Wallabag/CoreBundle/Controller/IgnoreOriginInstanceRuleController.php @@ -50,7 +50,7 @@ class IgnoreOriginInstanceRuleController extends Controller $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($ignoreOriginInstanceRule); $em->flush(); @@ -82,7 +82,7 @@ class IgnoreOriginInstanceRuleController extends Controller $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($ignoreOriginInstanceRule); $em->flush(); @@ -119,7 +119,7 @@ class IgnoreOriginInstanceRuleController extends Controller $this->get(TranslatorInterface::class)->trans('flashes.ignore_origin_instance_rule.notice.deleted') ); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($ignoreOriginInstanceRule); $em->flush(); } diff --git a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php index 67b262947..e2b44e3eb 100644 --- a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php +++ b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php @@ -60,7 +60,7 @@ class SiteCredentialController extends Controller $credential->setUsername($this->get(CryptoProxy::class)->crypt($credential->getUsername())); $credential->setPassword($this->get(CryptoProxy::class)->crypt($credential->getPassword())); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($credential); $em->flush(); @@ -99,7 +99,7 @@ class SiteCredentialController extends Controller $siteCredential->setUsername($this->get(CryptoProxy::class)->crypt($siteCredential->getUsername())); $siteCredential->setPassword($this->get(CryptoProxy::class)->crypt($siteCredential->getPassword())); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($siteCredential); $em->flush(); @@ -140,7 +140,7 @@ class SiteCredentialController extends Controller $this->get(TranslatorInterface::class)->trans('flashes.site_credential.notice.deleted', ['%host%' => $siteCredential->getHost()]) ); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($siteCredential); $em->flush(); } diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index b32f3ad31..53ce07c98 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -39,7 +39,7 @@ class TagController extends Controller $form->get('label')->getData() ); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->persist($entry); $em->flush(); @@ -67,7 +67,7 @@ class TagController extends Controller public function removeTagFromEntry(Request $request, Entry $entry, Tag $tag) { $entry->removeTag($tag); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->flush(); // remove orphan tag in case no entries are associated to it @@ -188,7 +188,7 @@ class TagController extends Controller $entry->removeTag($tag); } - $this->getDoctrine()->getManager()->flush(); + $this->get('doctrine')->getManager()->flush(); $this->get(SessionInterface::class)->getFlashBag()->add( 'notice', @@ -212,7 +212,7 @@ class TagController extends Controller /** @var QueryBuilder $qb */ $qb = $this->get(EntryRepository::class)->getBuilderForSearchByUser($this->getUser()->getId(), $filter, $currentRoute); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $entries = $qb->getQuery()->getResult(); @@ -246,7 +246,7 @@ class TagController extends Controller // remove orphan tag in case no entries are associated to it if (0 === \count($tag->getEntries())) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($tag); $em->flush(); } diff --git a/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php index 9372a3639..dcaa32186 100644 --- a/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php +++ b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Event\Listener; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; +use Wallabag\UserBundle\Entity\User; /** * Stores the locale of the user in the session after the login. @@ -25,6 +26,7 @@ class UserLocaleListener public function onInteractiveLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); + \assert($user instanceof User); if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) { $this->session->set('_locale', $user->getConfig()->getLanguage()); diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 44448bfb7..6581a99fc 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -15,11 +15,12 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Wallabag\CoreBundle\Repository\EntryRepository; +use Wallabag\UserBundle\Entity\User; class EntryFilterType extends AbstractType { - private $user; private $repository; + private $tokenStorage; /** * Repository & user are used to get a list of language entries for this user. @@ -27,16 +28,15 @@ class EntryFilterType extends AbstractType public function __construct(EntryRepository $entryRepository, TokenStorageInterface $tokenStorage) { $this->repository = $entryRepository; - - $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; - - if (null === $this->user || !\is_object($this->user)) { - return; - } + $this->tokenStorage = $tokenStorage; } public function buildForm(FormBuilderInterface $builder, array $options) { + $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; + + \assert($user instanceof User); + $builder ->add('readingTime', NumberRangeFilterType::class, [ 'left_number_options' => [ @@ -47,17 +47,19 @@ class EntryFilterType extends AbstractType 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL, 'attr' => ['min' => 0], ], - 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) use ($user) { $lower = $values['value']['left_number'][0]; $upper = $values['value']['right_number'][0]; - $min = (int) ($lower * $this->user->getConfig()->getReadingSpeed() / 200); - $max = (int) ($upper * $this->user->getConfig()->getReadingSpeed() / 200); - if (null === $lower && null === $upper) { // no value? no filter return; - } elseif (null === $lower && null !== $upper) { + } + + $min = (int) ($lower * $user->getConfig()->getReadingSpeed() / 200); + $max = (int) ($upper * $user->getConfig()->getReadingSpeed() / 200); + + if (null === $lower && null !== $upper) { // only lower value is defined: query all entries with reading LOWER THAN this value $expression = $filterQuery->getExpr()->lte($field, $max); } elseif (null !== $lower && null === $upper) { @@ -176,7 +178,7 @@ class EntryFilterType extends AbstractType 'label' => 'entry.filters.is_public_label', ]) ->add('language', ChoiceFilterType::class, [ - 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), + 'choices' => array_flip($this->repository->findDistinctLanguageByUser($user->getId())), 'label' => 'entry.filters.language_label', ]) ; diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 30727ba1f..b39fcf257 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -21,11 +21,11 @@ class EntriesExport private $wallabagUrl; private $logoPath; private $translator; + private $tokenStorage; private $title = ''; private $entries = []; private $author = 'wallabag'; private $language = ''; - private $user; /** * @param TranslatorInterface $translator Translator service @@ -38,13 +38,7 @@ class EntriesExport $this->translator = $translator; $this->wallabagUrl = $wallabagUrl; $this->logoPath = $logoPath; - - /* @var User $user */ - $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; - - if (null === $this->user || !\is_object($this->user)) { - return; - } + $this->tokenStorage = $tokenStorage; } /** @@ -140,6 +134,9 @@ class EntriesExport */ private function produceEpub() { + $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; + \assert($user instanceof User); + /* * Start and End of the book */ @@ -213,7 +210,7 @@ class EntriesExport $publishedDate = $entry->getPublishedAt()->format('Y-m-d'); } - $readingTime = $entry->getReadingTime() / $this->user->getConfig()->getReadingSpeed() * 200; + $readingTime = $entry->getReadingTime() / $user->getConfig()->getReadingSpeed() * 200; $titlepage = $content_start . '

' . $entry->getTitle() . '

' . @@ -306,6 +303,9 @@ class EntriesExport */ private function producePdf() { + $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; + \assert($user instanceof User); + $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); /* @@ -331,7 +331,7 @@ class EntriesExport $authors = implode(',', $publishedBy); } - $readingTime = $entry->getReadingTime() / $this->user->getConfig()->getReadingSpeed() * 200; + $readingTime = $entry->getReadingTime() / $user->getConfig()->getReadingSpeed() * 200; $pdf->addPage(); $html = '

' . $entry->getTitle() . '

' . diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php index 48194c234..05241d67e 100644 --- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface; */ class HttpClientFactory implements ClientFactory { - /** @var [\GuzzleHttp\Event\SubscriberInterface] */ + /** @var SubscriberInterface[] */ private $subscribers = []; /** @var CookieJar */ diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php index fd946fd73..bb35066d3 100644 --- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php +++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php @@ -27,7 +27,7 @@ class PreparePagerForEntries $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; } - if (null === $user || !\is_object($user)) { + if (!$user instanceof User) { return; } diff --git a/src/Wallabag/CoreBundle/Helper/Redirect.php b/src/Wallabag/CoreBundle/Helper/Redirect.php index 8add7aa50..99bc192a6 100644 --- a/src/Wallabag/CoreBundle/Helper/Redirect.php +++ b/src/Wallabag/CoreBundle/Helper/Redirect.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Helper; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Wallabag\CoreBundle\Entity\Config; +use Wallabag\UserBundle\Entity\User; /** * Manage redirections to avoid redirecting to empty routes. @@ -31,7 +32,7 @@ class Redirect { $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; - if (null === $user || !\is_object($user)) { + if (!$user instanceof User) { return $url; } diff --git a/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php b/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php index b74881b91..28ca892ab 100644 --- a/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php +++ b/src/Wallabag/CoreBundle/ParamConverter/UsernameFeedTokenConverter.php @@ -8,6 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInte use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Wallabag\UserBundle\Entity\User; +use Wallabag\UserBundle\Repository\UserRepository; /** * ParamConverter used in the Feed controller to retrieve the right user according to @@ -76,6 +77,7 @@ class UsernameFeedTokenConverter implements ParamConverterInterface // Get actual entity manager for class $em = $this->registry->getManagerForClass($configuration->getClass()); + /** @var UserRepository $userRepository */ $userRepository = $em->getRepository($configuration->getClass()); // Try to find user by its username and config feed_token diff --git a/src/Wallabag/CoreBundle/Repository/ConfigRepository.php b/src/Wallabag/CoreBundle/Repository/ConfigRepository.php index c09aabd19..d438311bd 100644 --- a/src/Wallabag/CoreBundle/Repository/ConfigRepository.php +++ b/src/Wallabag/CoreBundle/Repository/ConfigRepository.php @@ -6,6 +6,9 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; use Wallabag\CoreBundle\Entity\Config; +/** + * @method Config|null findOneByUser(int $userId) + */ class ConfigRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 7cadb091a..a5d5fed5a 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -12,6 +12,10 @@ use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Helper\UrlHasher; +/** + * @method Entry[] findById(int $id) + * @method Entry|null findOneByUser(int $userId) + */ class EntryRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index 0c2ad6fb5..605e97e18 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php @@ -9,6 +9,8 @@ use Wallabag\CoreBundle\Helper\CryptoProxy; /** * SiteCredentialRepository. + * + * @method SiteCredential[] findByUser(int $userId) */ class SiteCredentialRepository extends ServiceEntityRepository { diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index ffa2c0b36..3e17e2e88 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -7,6 +7,10 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; use Wallabag\CoreBundle\Entity\Tag; +/** + * @method Tag|null findOneByLabel(string $label) + * @method Tag|null findOneBySlug(string $slug) + */ class TagRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index 26635fba0..ca0cc9a55 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -10,6 +10,7 @@ use Twig\TwigFilter; use Twig\TwigFunction; use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\TagRepository; +use Wallabag\UserBundle\Entity\User; class WallabagExtension extends AbstractExtension implements GlobalsInterface { @@ -81,7 +82,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface { $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; - if (null === $user || !\is_object($user)) { + if (!$user instanceof User) { return 0; } @@ -127,7 +128,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface { $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; - if (null === $user || !\is_object($user)) { + if (!$user instanceof User) { return 0; } @@ -143,7 +144,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface { $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; - if (null === $user || !\is_object($user)) { + if (!$user instanceof User) { return 0; } diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php index 198ab6a72..8413a3c6c 100644 --- a/src/Wallabag/ImportBundle/Command/ImportCommand.php +++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php @@ -112,5 +112,7 @@ class ImportCommand extends ContainerAwareCommand $em->clear(); $output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---'); + + return 0; } } diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php index 015824f99..d5f9d3338 100644 --- a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php +++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php @@ -40,5 +40,7 @@ class RedisWorkerCommand extends ContainerAwareCommand ); $worker->start(); + + return 0; } } diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index 1d2bcbb40..72922b4eb 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -37,6 +37,7 @@ class ManageController extends Controller $userManager = $this->container->get(UserManagerInterface::class); $user = $userManager->createUser(); + \assert($user instanceof User); // enable created user by default $user->setEnabled(true); @@ -127,7 +128,7 @@ class ManageController extends Controller $this->get(TranslatorInterface::class)->trans('flashes.user.notice.deleted', ['%username%' => $user->getUsername()]) ); - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $em->remove($user); $em->flush(); } @@ -147,7 +148,7 @@ class ManageController extends Controller */ public function searchFormAction(Request $request, $page = 1) { - $em = $this->getDoctrine()->getManager(); + $em = $this->get('doctrine')->getManager(); $qb = $em->getRepository(User::class)->createQueryBuilder('u'); $form = $this->createForm(SearchUserType::class); diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index b4333b993..9cafe5c55 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -7,6 +7,9 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; use Wallabag\UserBundle\Entity\User; +/** + * @method User|null findOneById(int $id) + */ class UserRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) diff --git a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php index 0e8585754..dd6b768a1 100644 --- a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php +++ b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php @@ -3,6 +3,8 @@ namespace Tests\Wallabag\AnnotationBundle; use FOS\UserBundle\Model\UserInterface; +use FOS\UserBundle\Model\UserManager; +use FOS\UserBundle\Security\LoginManager; use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Cookie; @@ -47,9 +49,9 @@ abstract class WallabagAnnotationTestCase extends WebTestCase $client = static::createClient(); $container = $client->getContainer(); - /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ + /** @var UserManager $userManager */ $userManager = $container->get('fos_user.user_manager.test'); - /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ + /** @var LoginManager $loginManager */ $loginManager = $container->get('fos_user.security.login_manager.test'); $firewallName = $container->getParameter('fos_user.firewall_name'); diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index ae567a52e..92594e41f 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -4,6 +4,8 @@ namespace Tests\Wallabag\ApiBundle; use Doctrine\ORM\EntityManagerInterface; use FOS\UserBundle\Model\UserInterface; +use FOS\UserBundle\Model\UserManager; +use FOS\UserBundle\Security\LoginManager; use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Cookie; @@ -37,9 +39,9 @@ abstract class WallabagApiTestCase extends WebTestCase $client = static::createClient(); $container = $client->getContainer(); - /** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ + /** @var UserManager $userManager */ $userManager = $container->get('fos_user.user_manager.test'); - /** @var $loginManager \FOS\UserBundle\Security\LoginManager */ + /** @var LoginManager $loginManager */ $loginManager = $container->get('fos_user.security.login_manager.test'); $firewallName = $container->getParameter('fos_user.firewall_name'); diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 3a5450148..f56f6916d 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -895,6 +895,8 @@ class ConfigControllerTest extends WallabagCoreTestCase $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); + \assert($user instanceof User); + $tag = new Tag(); $tag->setLabel('super'); $em->persist($tag); @@ -980,6 +982,8 @@ class ConfigControllerTest extends WallabagCoreTestCase $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); + \assert($user instanceof User); + $tag = new Tag(); $tag->setLabel('super'); $em->persist($tag); @@ -1056,6 +1060,8 @@ class ConfigControllerTest extends WallabagCoreTestCase $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); + \assert($user instanceof User); + $tag = new Tag(); $tag->setLabel('super'); $em->persist($tag); diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php index 22b9480d0..780eeddac 100644 --- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php +++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php @@ -18,6 +18,9 @@ class RedirectTest extends TestCase /** @var Redirect */ private $redirect; + /** @var User */ + private $user; + /** @var UsernamePasswordToken */ private $token; @@ -32,24 +35,24 @@ class RedirectTest extends TestCase ->with('homepage') ->willReturn('homepage'); - $user = new User(); - $user->setName('youpi'); - $user->setEmail('youpi@youpi.org'); - $user->setUsername('youpi'); - $user->setPlainPassword('youpi'); - $user->setEnabled(true); - $user->addRole('ROLE_SUPER_ADMIN'); + $this->user = new User(); + $this->user->setName('youpi'); + $this->user->setEmail('youpi@youpi.org'); + $this->user->setUsername('youpi'); + $this->user->setPlainPassword('youpi'); + $this->user->setEnabled(true); + $this->user->addRole('ROLE_SUPER_ADMIN'); - $config = new Config($user); + $config = new Config($this->user); $config->setItemsPerPage(30); $config->setReadingSpeed(200); $config->setLanguage('en'); $config->setPocketConsumerKey('xxxxx'); $config->setActionMarkAsRead(Config::REDIRECT_TO_CURRENT_PAGE); - $user->setConfig($config); + $this->user->setConfig($config); - $this->token = new UsernamePasswordToken($user, 'password', 'key'); + $this->token = new UsernamePasswordToken($this->user, 'password', 'key'); $tokenStorage = new TokenStorage(); $tokenStorage->setToken($this->token); @@ -87,7 +90,7 @@ class RedirectTest extends TestCase public function testUserForRedirectToHomepage() { - $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); + $this->user->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); $redirectUrl = $this->redirect->to('/unread/list'); @@ -96,7 +99,7 @@ class RedirectTest extends TestCase public function testUserForRedirectWithIgnoreActionMarkAsRead() { - $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); + $this->user->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); $redirectUrl = $this->redirect->to('/unread/list', '', true); @@ -105,7 +108,7 @@ class RedirectTest extends TestCase public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead() { - $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); + $this->user->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE); $redirectUrl = $this->redirect->to(null, 'fallback', true);