Merge pull request #6098 from wallabag/fix/upgrade-phpstan

Upgrade PHPStan and move to level 2 with baseline
This commit is contained in:
Jérémy Benoist 2022-11-23 17:10:19 +01:00 committed by GitHub
commit e2e769bacc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 457 additions and 285 deletions

View file

@ -31,9 +31,6 @@ updates:
- dependency-name: friendsofsymfony/user-bundle - dependency-name: friendsofsymfony/user-bundle
versions: versions:
- "> 2.0.2" - "> 2.0.2"
- dependency-name: nelmio/api-doc-bundle
versions:
- "> 2.13.4"
- package-ecosystem: github-actions - package-ecosystem: github-actions
directory: "/" directory: "/"
schedule: schedule:

View file

@ -127,10 +127,10 @@
"m6web/redis-mock": "^5.0", "m6web/redis-mock": "^5.0",
"php-http/mock-client": "^1.0", "php-http/mock-client": "^1.0",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12", "phpstan/phpstan": "^1.8",
"phpstan/phpstan-doctrine": "^0.12", "phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-symfony": "^0.12", "phpstan/phpstan-symfony": "^1.2",
"symfony/maker-bundle": "^1.18", "symfony/maker-bundle": "^1.18",
"symfony/phpunit-bridge": "~6.0" "symfony/phpunit-bridge": "~6.0"
}, },

325
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a2a09b8c7c80d9411cb07680b46952a5", "content-hash": "7e2e98057e24124078e082fe4b4a7702",
"packages": [ "packages": [
{ {
"name": "babdev/pagerfanta-bundle", "name": "babdev/pagerfanta-bundle",
@ -7601,16 +7601,16 @@
}, },
{ {
"name": "phpstan/phpdoc-parser", "name": "phpstan/phpdoc-parser",
"version": "1.13.0", "version": "1.13.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git", "url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "33aefcdab42900e36366d0feab6206e2dd68f947" "reference": "aac44118344d197e6d5f7c6cee91885f0a89acdd"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/33aefcdab42900e36366d0feab6206e2dd68f947", "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/aac44118344d197e6d5f7c6cee91885f0a89acdd",
"reference": "33aefcdab42900e36366d0feab6206e2dd68f947", "reference": "aac44118344d197e6d5f7c6cee91885f0a89acdd",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -7640,9 +7640,9 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types", "description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": { "support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues", "issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.13.0" "source": "https://github.com/phpstan/phpdoc-parser/tree/1.13.1"
}, },
"time": "2022-10-21T09:57:39+00:00" "time": "2022-11-20T08:52:26+00:00"
}, },
{ {
"name": "phpzip/phpzip", "name": "phpzip/phpzip",
@ -9511,16 +9511,16 @@
}, },
{ {
"name": "symfony/polyfill-apcu", "name": "symfony/polyfill-apcu",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-apcu.git", "url": "https://github.com/symfony/polyfill-apcu.git",
"reference": "43273a33c46f9d5a08dac76859f63d6814242e81" "reference": "6e7f6ed2168779a2b3927e606a9768860a8bdfa0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/43273a33c46f9d5a08dac76859f63d6814242e81", "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/6e7f6ed2168779a2b3927e606a9768860a8bdfa0",
"reference": "43273a33c46f9d5a08dac76859f63d6814242e81", "reference": "6e7f6ed2168779a2b3927e606a9768860a8bdfa0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9529,7 +9529,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9568,7 +9568,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-apcu/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-apcu/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -9584,20 +9584,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" "reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", "reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9612,7 +9612,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9650,7 +9650,7 @@
"portable" "portable"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -9666,20 +9666,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-iconv", "name": "symfony/polyfill-iconv",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git", "url": "https://github.com/symfony/polyfill-iconv.git",
"reference": "143f1881e655bebca1312722af8068de235ae5dc" "reference": "927013f3aac555983a5059aada98e1907d842695"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/143f1881e655bebca1312722af8068de235ae5dc", "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/927013f3aac555983a5059aada98e1907d842695",
"reference": "143f1881e655bebca1312722af8068de235ae5dc", "reference": "927013f3aac555983a5059aada98e1907d842695",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9694,7 +9694,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9733,7 +9733,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-iconv/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-iconv/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -9749,20 +9749,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-icu", "name": "symfony/polyfill-intl-icu",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-icu.git", "url": "https://github.com/symfony/polyfill-intl-icu.git",
"reference": "e407643d610e5f2c8a4b14189150f68934bf5e48" "reference": "a3d9148e2c363588e05abbdd4ee4f971f0a5330c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/e407643d610e5f2c8a4b14189150f68934bf5e48", "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/a3d9148e2c363588e05abbdd4ee4f971f0a5330c",
"reference": "e407643d610e5f2c8a4b14189150f68934bf5e48", "reference": "a3d9148e2c363588e05abbdd4ee4f971f0a5330c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9774,7 +9774,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9820,7 +9820,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -9836,20 +9836,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-idn", "name": "symfony/polyfill-intl-idn",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git", "url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8" "reference": "639084e360537a19f9ee352433b84ce831f3d2da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/59a8d271f00dd0e4c2e518104cc7963f655a1aa8", "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/639084e360537a19f9ee352433b84ce831f3d2da",
"reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8", "reference": "639084e360537a19f9ee352433b84ce831f3d2da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9863,7 +9863,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9907,7 +9907,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -9923,20 +9923,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-intl-normalizer", "name": "symfony/polyfill-intl-normalizer",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "219aa369ceff116e673852dce47c3a41794c14bd" "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6",
"reference": "219aa369ceff116e673852dce47c3a41794c14bd", "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -9948,7 +9948,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -9991,7 +9991,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10007,20 +10007,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -10035,7 +10035,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -10074,7 +10074,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10090,7 +10090,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-php56", "name": "symfony/polyfill-php56",
@ -10230,16 +10230,16 @@
}, },
{ {
"name": "symfony/polyfill-php72", "name": "symfony/polyfill-php72",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php72.git", "url": "https://github.com/symfony/polyfill-php72.git",
"reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2" "reference": "869329b1e9894268a8a61dabb69153029b7a8c97"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2", "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97",
"reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2", "reference": "869329b1e9894268a8a61dabb69153029b7a8c97",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -10248,7 +10248,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -10286,7 +10286,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10302,20 +10302,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-php73", "name": "symfony/polyfill-php73",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php73.git", "url": "https://github.com/symfony/polyfill-php73.git",
"reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -10324,7 +10324,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -10365,7 +10365,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10381,20 +10381,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-php80", "name": "symfony/polyfill-php80",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -10403,7 +10403,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -10448,7 +10448,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10464,20 +10464,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-10T07:21:04+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/polyfill-uuid", "name": "symfony/polyfill-uuid",
"version": "v1.26.0", "version": "v1.27.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-uuid.git", "url": "https://github.com/symfony/polyfill-uuid.git",
"reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23" "reference": "f3cf1a645c2734236ed1e2e671e273eeb3586166"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/a41886c1c81dc075a09c71fe6db5b9d68c79de23", "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/f3cf1a645c2734236ed1e2e671e273eeb3586166",
"reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23", "reference": "f3cf1a645c2734236ed1e2e671e273eeb3586166",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -10492,7 +10492,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-main": "1.26-dev" "dev-main": "1.27-dev"
}, },
"thanks": { "thanks": {
"name": "symfony/polyfill", "name": "symfony/polyfill",
@ -10530,7 +10530,7 @@
"uuid" "uuid"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-uuid/tree/v1.26.0" "source": "https://github.com/symfony/polyfill-uuid/tree/v1.27.0"
}, },
"funding": [ "funding": [
{ {
@ -10546,7 +10546,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-05-24T11:49:31+00:00" "time": "2022-11-03T14:55:06+00:00"
}, },
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",
@ -12465,16 +12465,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.15.1", "version": "v4.15.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc",
"reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "reference": "f59bbe44bf7d96f24f3e2b4ddc21cd52c1d2adbc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -12515,9 +12515,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.2"
}, },
"time": "2022-09-04T07:30:47+00:00" "time": "2022-11-12T15:38:23+00:00"
}, },
{ {
"name": "php-cs-fixer/diff", "name": "php-cs-fixer/diff",
@ -12645,28 +12645,27 @@
}, },
{ {
"name": "phpstan/extension-installer", "name": "phpstan/extension-installer",
"version": "1.1.0", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/extension-installer.git", "url": "https://github.com/phpstan/extension-installer.git",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051" "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/extension-installer/zipball/66c7adc9dfa38b6b5838a9fb728b68a7d8348051", "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"reference": "66c7adc9dfa38b6b5838a9fb728b68a7d8348051", "reference": "f06dbb052ddc394e7896fcd1cfcd533f9f6ace40",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer-plugin-api": "^1.1 || ^2.0", "composer-plugin-api": "^2.0",
"php": "^7.1 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": ">=0.11.6" "phpstan/phpstan": "^1.8.0"
}, },
"require-dev": { "require-dev": {
"composer/composer": "^1.8", "composer/composer": "^2.0",
"phing/phing": "^2.16.3",
"php-parallel-lint/php-parallel-lint": "^1.2.0", "php-parallel-lint/php-parallel-lint": "^1.2.0",
"phpstan/phpstan-strict-rules": "^0.11 || ^0.12" "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0"
}, },
"type": "composer-plugin", "type": "composer-plugin",
"extra": { "extra": {
@ -12684,26 +12683,26 @@
"description": "Composer plugin for automatic installation of PHPStan extensions", "description": "Composer plugin for automatic installation of PHPStan extensions",
"support": { "support": {
"issues": "https://github.com/phpstan/extension-installer/issues", "issues": "https://github.com/phpstan/extension-installer/issues",
"source": "https://github.com/phpstan/extension-installer/tree/1.1.0" "source": "https://github.com/phpstan/extension-installer/tree/1.2.0"
}, },
"time": "2020-12-13T13:06:13+00:00" "time": "2022-10-17T12:59:16+00:00"
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "0.12.100", "version": "1.9.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "48236ddf823547081b2b153d1cd2994b784328c3" "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/48236ddf823547081b2b153d1cd2994b784328c3", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa",
"reference": "48236ddf823547081b2b153d1cd2994b784328c3", "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1|^8.0" "php": "^7.2|^8.0"
}, },
"conflict": { "conflict": {
"phpstan/phpstan-shim": "*" "phpstan/phpstan-shim": "*"
@ -12713,11 +12712,6 @@
"phpstan.phar" "phpstan.phar"
], ],
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.12-dev"
}
},
"autoload": { "autoload": {
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
@ -12728,9 +12722,13 @@
"MIT" "MIT"
], ],
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan/issues", "issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.100" "source": "https://github.com/phpstan/phpstan/tree/1.9.2"
}, },
"funding": [ "funding": [
{ {
@ -12746,25 +12744,25 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-11-01T09:52:08+00:00" "time": "2022-11-10T09:56:11+00:00"
}, },
{ {
"name": "phpstan/phpstan-doctrine", "name": "phpstan/phpstan-doctrine",
"version": "0.12.44", "version": "1.3.23",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-doctrine.git", "url": "https://github.com/phpstan/phpstan-doctrine.git",
"reference": "5fe9a9b15707d9bc5178fa7cf0899e904d112ccd" "reference": "964caf844c89134e5c2f19e97cbf8b5d12193779"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/5fe9a9b15707d9bc5178fa7cf0899e904d112ccd", "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/964caf844c89134e5c2f19e97cbf8b5d12193779",
"reference": "5fe9a9b15707d9bc5178fa7cf0899e904d112ccd", "reference": "964caf844c89134e5c2f19e97cbf8b5d12193779",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": "^0.12.85" "phpstan/phpstan": "^1.8.11"
}, },
"conflict": { "conflict": {
"doctrine/collections": "<1.0", "doctrine/collections": "<1.0",
@ -12777,22 +12775,23 @@
"doctrine/annotations": "^1.11.0", "doctrine/annotations": "^1.11.0",
"doctrine/collections": "^1.6", "doctrine/collections": "^1.6",
"doctrine/common": "^2.7 || ^3.0", "doctrine/common": "^2.7 || ^3.0",
"doctrine/dbal": "^2.13.1", "doctrine/dbal": "^2.13.8 || ^3.3.3",
"doctrine/lexer": "^1.2.1",
"doctrine/mongodb-odm": "^1.3 || ^2.1", "doctrine/mongodb-odm": "^1.3 || ^2.1",
"doctrine/orm": "^2.9.1", "doctrine/orm": "^2.11.0",
"doctrine/persistence": "^1.1 || ^2.0", "doctrine/persistence": "^1.3.8 || ^2.2.1",
"gedmo/doctrine-extensions": "^3.8",
"nesbot/carbon": "^2.49", "nesbot/carbon": "^2.49",
"nikic/php-parser": "^4.13.2",
"php-parallel-lint/php-parallel-lint": "^1.2", "php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^0.12.16", "phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^0.12.5", "phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5.10",
"ramsey/uuid-doctrine": "^1.5.0" "ramsey/uuid-doctrine": "^1.5.0",
"symfony/cache": "^4.4.35"
}, },
"type": "phpstan-extension", "type": "phpstan-extension",
"extra": { "extra": {
"branch-alias": {
"dev-master": "0.12-dev"
},
"phpstan": { "phpstan": {
"includes": [ "includes": [
"extension.neon", "extension.neon",
@ -12812,41 +12811,39 @@
"description": "Doctrine extensions for PHPStan", "description": "Doctrine extensions for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-doctrine/issues", "issues": "https://github.com/phpstan/phpstan-doctrine/issues",
"source": "https://github.com/phpstan/phpstan-doctrine/tree/0.12.44" "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.3.23"
}, },
"time": "2021-09-01T06:46:16+00:00" "time": "2022-11-14T07:46:16+00:00"
}, },
{ {
"name": "phpstan/phpstan-phpunit", "name": "phpstan/phpstan-phpunit",
"version": "0.12.22", "version": "1.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git", "url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc" "reference": "dea1f87344c6964c607d9076dee42d891f3923f0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/dea1f87344c6964c607d9076dee42d891f3923f0",
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc", "reference": "dea1f87344c6964c607d9076dee42d891f3923f0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": "^0.12.92" "phpstan/phpstan": "^1.8.11"
}, },
"conflict": { "conflict": {
"phpunit/phpunit": "<7.0" "phpunit/phpunit": "<7.0"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2", "php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-strict-rules": "^0.12.6", "phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5"
}, },
"type": "phpstan-extension", "type": "phpstan-extension",
"extra": { "extra": {
"branch-alias": {
"dev-master": "0.12-dev"
},
"phpstan": { "phpstan": {
"includes": [ "includes": [
"extension.neon", "extension.neon",
@ -12866,49 +12863,51 @@
"description": "PHPUnit extensions and rules for PHPStan", "description": "PHPUnit extensions and rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues", "issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/0.12.22" "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.2.2"
}, },
"time": "2021-08-12T10:53:43+00:00" "time": "2022-10-28T10:23:07+00:00"
}, },
{ {
"name": "phpstan/phpstan-symfony", "name": "phpstan/phpstan-symfony",
"version": "0.12.44", "version": "1.2.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-symfony.git", "url": "https://github.com/phpstan/phpstan-symfony.git",
"reference": "c1627fce5b505b3f53d9d4fbd4d7963603305f98" "reference": "d6ea16206b1b645ded5b43736d8ef5ae1168eb55"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/c1627fce5b505b3f53d9d4fbd4d7963603305f98", "url": "https://api.github.com/repos/phpstan/phpstan-symfony/zipball/d6ea16206b1b645ded5b43736d8ef5ae1168eb55",
"reference": "c1627fce5b505b3f53d9d4fbd4d7963603305f98", "reference": "d6ea16206b1b645ded5b43736d8ef5ae1168eb55",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-simplexml": "*", "ext-simplexml": "*",
"php": "^7.1 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpstan": "^0.12.98" "phpstan/phpstan": "^1.9.1"
}, },
"conflict": { "conflict": {
"symfony/framework-bundle": "<3.0" "symfony/framework-bundle": "<3.0"
}, },
"require-dev": { "require-dev": {
"nikic/php-parser": "^4.13.0",
"php-parallel-lint/php-parallel-lint": "^1.2", "php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^0.12.16", "phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^0.12.5", "phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"symfony/config": "^4.2 || ^5.0", "psr/container": "1.0 || 1.1.1",
"symfony/console": "^4.0 || ^5.0", "symfony/config": "^5.4 || ^6.1",
"symfony/framework-bundle": "^4.4 || ^5.0", "symfony/console": "^5.4 || ^6.1",
"symfony/http-foundation": "^4.0 || ^5.0", "symfony/dependency-injection": "^5.4 || ^6.1",
"symfony/messenger": "^4.2 || ^5.0", "symfony/form": "^5.4 || ^6.1",
"symfony/serializer": "^4.0 || ^5.0" "symfony/framework-bundle": "^5.4 || ^6.1",
"symfony/http-foundation": "^5.4 || ^6.1",
"symfony/messenger": "^5.4",
"symfony/polyfill-php80": "^1.24",
"symfony/serializer": "^5.4"
}, },
"type": "phpstan-extension", "type": "phpstan-extension",
"extra": { "extra": {
"branch-alias": {
"dev-master": "0.12-dev"
},
"phpstan": { "phpstan": {
"includes": [ "includes": [
"extension.neon", "extension.neon",
@ -12935,9 +12934,9 @@
"description": "Symfony Framework extensions and rules for PHPStan", "description": "Symfony Framework extensions and rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-symfony/issues", "issues": "https://github.com/phpstan/phpstan-symfony/issues",
"source": "https://github.com/phpstan/phpstan-symfony/tree/0.12.44" "source": "https://github.com/phpstan/phpstan-symfony/tree/1.2.16"
}, },
"time": "2021-09-02T12:14:11+00:00" "time": "2022-11-04T13:16:15+00:00"
}, },
{ {
"name": "symfony/maker-bundle", "name": "symfony/maker-bundle",

96
phpstan-baseline.neon Normal file
View file

@ -0,0 +1,96 @@
parameters:
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

View file

@ -1,5 +1,8 @@
includes:
- phpstan-baseline.neon
parameters: parameters:
level: 1 level: 2
paths: paths:
- src - src
- tests - tests
@ -11,3 +14,6 @@ parameters:
- vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php - vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php
inferPrivatePropertyTypeFromConstructor: true inferPrivatePropertyTypeFromConstructor: true
ignoreErrors:
- '#^Service ".+" is private\.?#'

View file

@ -52,7 +52,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
{ {
$data = json_decode($request->getContent(), true); $data = json_decode($request->getContent(), true);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$annotation = new Annotation($this->getUser()); $annotation = new Annotation($this->getUser());
$annotation->setEntry($entry); $annotation->setEntry($entry);
@ -95,7 +95,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
$form->submit($data); $form->submit($data);
if ($form->isValid()) { if ($form->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($annotation); $em->persist($annotation);
$em->flush(); $em->flush();
@ -119,7 +119,7 @@ class WallabagAnnotationController extends AbstractFOSRestController
*/ */
public function deleteAnnotationAction(Annotation $annotation) public function deleteAnnotationAction(Annotation $annotation)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($annotation); $em->remove($annotation);
$em->flush(); $em->flush();

View file

@ -9,6 +9,8 @@ use Wallabag\AnnotationBundle\Entity\Annotation;
/** /**
* AnnotationRepository. * AnnotationRepository.
*
* @method Annotation|null findOneById(int $id)
*/ */
class AnnotationRepository extends ServiceEntityRepository class AnnotationRepository extends ServiceEntityRepository
{ {

View file

@ -23,7 +23,7 @@ class DeveloperController extends Controller
*/ */
public function indexAction() 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', [ return $this->render('@WallabagCore/Developer/index.html.twig', [
'clients' => $clients, 'clients' => $clients,
@ -39,7 +39,7 @@ class DeveloperController extends Controller
*/ */
public function createClientAction(Request $request) public function createClientAction(Request $request)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$client = new Client($this->getUser()); $client = new Client($this->getUser());
$clientForm = $this->createForm(ClientType::class, $client); $clientForm = $this->createForm(ClientType::class, $client);
$clientForm->handleRequest($request); $clientForm->handleRequest($request);
@ -79,7 +79,7 @@ class DeveloperController extends Controller
throw $this->createAccessDeniedException('You can not access this client.'); throw $this->createAccessDeniedException('You can not access this client.');
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($client); $em->remove($client);
$em->flush(); $em->flush();

View file

@ -88,7 +88,7 @@ class EntryRestController extends WallabagRestController
public function getEntriesExistsAction(Request $request) public function getEntriesExistsAction(Request $request)
{ {
$this->validateAuthentication(); $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'); $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! // entry deleted, dispatch event about it!
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($entry); $em->remove($entry);
$em->flush(); $em->flush();
} }
@ -532,7 +532,7 @@ class EntryRestController extends WallabagRestController
$this->get(ContentProxy::class)->updateEntry($entry, $url); $this->get(ContentProxy::class)->updateEntry($entry, $url);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -755,7 +755,7 @@ class EntryRestController extends WallabagRestController
$this->get(ContentProxy::class)->setDefaultEntryTitle($entry); $this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -971,7 +971,7 @@ class EntryRestController extends WallabagRestController
$this->get(ContentProxy::class)->setDefaultEntryTitle($entry); $this->get(ContentProxy::class)->setDefaultEntryTitle($entry);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -1027,7 +1027,7 @@ class EntryRestController extends WallabagRestController
return new JsonResponse([], 304); return new JsonResponse([], 304);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -1085,7 +1085,7 @@ class EntryRestController extends WallabagRestController
// entry deleted, dispatch event about it! // entry deleted, dispatch event about it!
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($entry); $em->remove($entry);
$em->flush(); $em->flush();
@ -1168,7 +1168,7 @@ class EntryRestController extends WallabagRestController
$this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags);
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -1213,7 +1213,7 @@ class EntryRestController extends WallabagRestController
$this->validateUserAccess($entry->getUser()->getId()); $this->validateUserAccess($entry->getUser()->getId());
$entry->removeTag($tag); $entry->removeTag($tag);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -1272,7 +1272,7 @@ class EntryRestController extends WallabagRestController
foreach ($tags as $label) { foreach ($tags as $label) {
$label = trim($label); $label = trim($label);
$tag = $this->getDoctrine() $tag = $this->get('doctrine')
->getRepository(Tag::class) ->getRepository(Tag::class)
->findOneByLabel($label); ->findOneByLabel($label);
@ -1281,7 +1281,7 @@ class EntryRestController extends WallabagRestController
} }
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
} }
@ -1340,7 +1340,7 @@ class EntryRestController extends WallabagRestController
if (false !== $entry && !(empty($tags))) { if (false !== $entry && !(empty($tags))) {
$this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags); $this->get(TagsAssigner::class)->assignTagsToEntry($entry, $tags);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
} }

View file

@ -33,7 +33,7 @@ class TagRestController extends WallabagRestController
{ {
$this->validateAuthentication(); $this->validateAuthentication();
$tags = $this->getDoctrine() $tags = $this->get('doctrine')
->getRepository(Tag::class) ->getRepository(Tag::class)
->findAllFlatTagsWithNbEntries($this->getUser()->getId()); ->findAllFlatTagsWithNbEntries($this->getUser()->getId());
@ -71,7 +71,7 @@ class TagRestController extends WallabagRestController
$this->validateAuthentication(); $this->validateAuthentication();
$label = $request->get('tag', ''); $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)) { if (empty($tags)) {
throw $this->createNotFoundException('Tag not found'); throw $this->createNotFoundException('Tag not found');
@ -79,7 +79,7 @@ class TagRestController extends WallabagRestController
$tag = $tags[0]; $tag = $tags[0];
$this->getDoctrine() $this->get('doctrine')
->getRepository(Entry::class) ->getRepository(Entry::class)
->removeTag($this->getUser()->getId(), $tag); ->removeTag($this->getUser()->getId(), $tag);
@ -122,13 +122,13 @@ class TagRestController extends WallabagRestController
$tagsLabels = $request->get('tags', ''); $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)) { if (empty($tags)) {
throw $this->createNotFoundException('Tags not found'); throw $this->createNotFoundException('Tags not found');
} }
$this->getDoctrine() $this->get('doctrine')
->getRepository(Entry::class) ->getRepository(Entry::class)
->removeTags($this->getUser()->getId(), $tags); ->removeTags($this->getUser()->getId(), $tags);
@ -167,13 +167,13 @@ class TagRestController extends WallabagRestController
{ {
$this->validateAuthentication(); $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)) { if (empty($tagFromDb)) {
throw $this->createNotFoundException('Tag not found'); throw $this->createNotFoundException('Tag not found');
} }
$this->getDoctrine() $this->get('doctrine')
->getRepository(Entry::class) ->getRepository(Entry::class)
->removeTag($this->getUser()->getId(), $tag); ->removeTag($this->getUser()->getId(), $tag);
@ -195,7 +195,7 @@ class TagRestController extends WallabagRestController
$tags = [$tags]; $tags = [$tags];
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (0 === \count($tag->getEntries())) { if (0 === \count($tag->getEntries())) {

View file

@ -102,6 +102,7 @@ class UserRestController extends WallabagRestController
$userManager = $this->get(UserManagerInterface::class); $userManager = $this->get(UserManagerInterface::class);
$user = $userManager->createUser(); $user = $userManager->createUser();
\assert($user instanceof User);
// user will be disabled BY DEFAULT to avoid spamming account to be enabled // user will be disabled BY DEFAULT to avoid spamming account to be enabled
$user->setEnabled(false); $user->setEnabled(false);
@ -150,7 +151,7 @@ class UserRestController extends WallabagRestController
$client = new Client($user); $client = new Client($user);
$client->setName($request->request->get('client_name', 'Default client')); $client->setName($request->request->get('client_name', 'Default client'));
$this->getDoctrine()->getManager()->persist($client); $this->get('doctrine')->getManager()->persist($client);
$user->addClient($client); $user->addClient($client);

View file

@ -12,6 +12,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Wallabag\UserBundle\Entity\User;
class WallabagRestController extends AbstractFOSRestController class WallabagRestController extends AbstractFOSRestController
{ {
@ -84,6 +85,7 @@ class WallabagRestController extends AbstractFOSRestController
protected function validateUserAccess($requestUserId) protected function validateUserAccess($requestUserId)
{ {
$user = $this->get(TokenStorageInterface::class)->getToken()->getUser(); $user = $this->get(TokenStorageInterface::class)->getToken()->getUser();
\assert($user instanceof User);
if ($requestUserId !== $user->getId()) { if ($requestUserId !== $user->getId()) {
throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId()); throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
} }

View file

@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken; use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken;
use FOS\OAuthServerBundle\Model\ClientInterface;
use FOS\UserBundle\Model\UserInterface;
/** /**
* @ORM\Table("oauth2_access_tokens") * @ORM\Table("oauth2_access_tokens")
@ -37,12 +39,16 @@ class AccessToken extends BaseAccessToken
/** /**
* @ORM\ManyToOne(targetEntity="Client", inversedBy="accessTokens") * @ORM\ManyToOne(targetEntity="Client", inversedBy="accessTokens")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*
* @var ClientInterface
*/ */
protected $client; protected $client;
/** /**
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*
* @var UserInterface
*/ */
protected $user; protected $user;
} }

View file

@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode; use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode;
use FOS\OAuthServerBundle\Model\ClientInterface;
use FOS\UserBundle\Model\UserInterface;
/** /**
* @ORM\Table("oauth2_auth_codes") * @ORM\Table("oauth2_auth_codes")
@ -37,12 +39,16 @@ class AuthCode extends BaseAuthCode
/** /**
* @ORM\ManyToOne(targetEntity="Client") * @ORM\ManyToOne(targetEntity="Client")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*
* @var ClientInterface
*/ */
protected $client; protected $client;
/** /**
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*
* @var UserInterface
*/ */
protected $user; protected $user;
} }

View file

@ -4,6 +4,8 @@ namespace Wallabag\ApiBundle\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken; use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken;
use FOS\OAuthServerBundle\Model\ClientInterface;
use FOS\UserBundle\Model\UserInterface;
/** /**
* @ORM\Table("oauth2_refresh_tokens") * @ORM\Table("oauth2_refresh_tokens")
@ -37,12 +39,16 @@ class RefreshToken extends BaseRefreshToken
/** /**
* @ORM\ManyToOne(targetEntity="Client", inversedBy="refreshTokens") * @ORM\ManyToOne(targetEntity="Client", inversedBy="refreshTokens")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*
* @var ClientInterface
*/ */
protected $client; protected $client;
/** /**
* @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User") * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE") * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*
* @var UserInterface
*/ */
protected $user; protected $user;
} }

View file

@ -6,6 +6,9 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Wallabag\ApiBundle\Entity\Client; use Wallabag\ApiBundle\Entity\Client;
/**
* @method Client[] findByUser(int $userId)
*/
class ClientRepository extends ServiceEntityRepository class ClientRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)

View file

@ -43,7 +43,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
return 1; return 1;
} }
} else { } 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))); $output->writeln(sprintf('Generating hashed urls for "%d" users', \count($users)));
@ -60,7 +60,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
private function generateHashedUrls(User $user) private function generateHashedUrls(User $user)
{ {
$em = $this->getContainer()->get(EntityManagerInterface::class); $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()); $entries = $repo->findByEmptyHashedUrlAndUserId($user->getId());
@ -89,7 +89,7 @@ class GenerateUrlHashesCommand extends ContainerAwareCommand
*/ */
private function getUser($username) 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() private function getDoctrine()

View file

@ -20,6 +20,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule; use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
use Wallabag\CoreBundle\Entity\InternalSetting; use Wallabag\CoreBundle\Entity\InternalSetting;
use Wallabag\UserBundle\Entity\User;
class InstallCommand extends ContainerAwareCommand class InstallCommand extends ContainerAwareCommand
{ {
@ -79,6 +80,8 @@ class InstallCommand extends ContainerAwareCommand
$this->io->success('wallabag has been successfully installed.'); $this->io->success('wallabag has been successfully installed.');
$this->io->success('You can now configure your web server, see https://doc.wallabag.org'); $this->io->success('You can now configure your web server, see https://doc.wallabag.org');
return 0;
} }
private function checkRequirements() private function checkRequirements()
@ -261,6 +264,7 @@ class InstallCommand extends ContainerAwareCommand
$userManager = $this->getContainer()->get(UserManagerInterface::class); $userManager = $this->getContainer()->get(UserManagerInterface::class);
$user = $userManager->createUser(); $user = $userManager->createUser();
\assert($user instanceof User);
$user->setUsername($this->io->ask('Username', 'wallabag')); $user->setUsername($this->io->ask('Username', 'wallabag'));

View file

@ -47,7 +47,7 @@ class TagAllCommand extends ContainerAwareCommand
$io->text('Persist ' . \count($entries) . ' entries... '); $io->text('Persist ' . \count($entries) . ' entries... ');
$em = $this->getDoctrine()->getManager(); $em = $this->getContainer()->get('doctrine')->getManager();
foreach ($entries as $entry) { foreach ($entries as $entry) {
$em->persist($entry); $em->persist($entry);
} }

View file

@ -44,7 +44,7 @@ class ConfigController extends Controller
*/ */
public function indexAction(Request $request) public function indexAction(Request $request)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$config = $this->getConfig(); $config = $this->getConfig();
$userManager = $this->container->get(UserManagerInterface::class); $userManager = $this->container->get(UserManagerInterface::class);
$user = $this->getUser(); $user = $this->getUser();
@ -125,7 +125,7 @@ class ConfigController extends Controller
$action = $this->generateUrl('config') . '#set5'; $action = $this->generateUrl('config') . '#set5';
if ($request->query->has('tagging-rule')) { if ($request->query->has('tagging-rule')) {
$taggingRule = $this->getDoctrine() $taggingRule = $this->get('doctrine')
->getRepository(TaggingRule::class) ->getRepository(TaggingRule::class)
->find($request->query->get('tagging-rule')); ->find($request->query->get('tagging-rule'));
@ -188,7 +188,7 @@ class ConfigController extends Controller
$action = $this->generateUrl('config') . '#set6'; $action = $this->generateUrl('config') . '#set6';
if ($request->query->has('ignore-origin-user-rule')) { if ($request->query->has('ignore-origin-user-rule')) {
$ignoreOriginUserRule = $this->getDoctrine() $ignoreOriginUserRule = $this->get('doctrine')
->getRepository(IgnoreOriginUserRule::class) ->getRepository(IgnoreOriginUserRule::class)
->find($request->query->get('ignore-origin-user-rule')); ->find($request->query->get('ignore-origin-user-rule'));
@ -414,7 +414,7 @@ class ConfigController extends Controller
$config = $this->getConfig(); $config = $this->getConfig();
$config->setFeedToken(Utils::generateToken()); $config->setFeedToken(Utils::generateToken());
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($config); $em->persist($config);
$em->flush(); $em->flush();
@ -440,7 +440,7 @@ class ConfigController extends Controller
$config = $this->getConfig(); $config = $this->getConfig();
$config->setFeedToken(null); $config->setFeedToken(null);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($config); $em->persist($config);
$em->flush(); $em->flush();
@ -467,7 +467,7 @@ class ConfigController extends Controller
{ {
$this->validateRuleAction($rule); $this->validateRuleAction($rule);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($rule); $em->remove($rule);
$em->flush(); $em->flush();
@ -504,7 +504,7 @@ class ConfigController extends Controller
{ {
$this->validateRuleAction($rule); $this->validateRuleAction($rule);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($rule); $em->remove($rule);
$em->flush(); $em->flush();
@ -541,7 +541,7 @@ class ConfigController extends Controller
{ {
switch ($type) { switch ($type) {
case 'annotations': case 'annotations':
$this->getDoctrine() $this->get('doctrine')
->getRepository(Annotation::class) ->getRepository(Annotation::class)
->removeAllByUserId($this->getUser()->getId()); ->removeAllByUserId($this->getUser()->getId());
break; break;
@ -552,7 +552,7 @@ class ConfigController extends Controller
// SQLite doesn't care about cascading remove, so we need to manually remove associated stuff // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
// otherwise they won't be removed ... // otherwise they won't be removed ...
if ($this->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) { 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 // manually remove tags to avoid orphan tag
@ -622,7 +622,7 @@ class ConfigController extends Controller
$user = $this->getUser(); $user = $this->getUser();
$user->getConfig()->setListMode(!$user->getConfig()->getListMode()); $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
@ -691,7 +691,7 @@ class ConfigController extends Controller
->removeTags($userId, $tags); ->removeTags($userId, $tags);
// cleanup orphan tags // cleanup orphan tags
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (0 === \count($tag->getEntries())) { if (0 === \count($tag->getEntries())) {
@ -726,9 +726,9 @@ class ConfigController extends Controller
private function removeAnnotationsForArchivedByUserId($userId) private function removeAnnotationsForArchivedByUserId($userId)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$archivedEntriesAnnotations = $this->getDoctrine() $archivedEntriesAnnotations = $this->get('doctrine')
->getRepository(Annotation::class) ->getRepository(Annotation::class)
->findAllArchivedEntriesByUser($userId); ->findAllArchivedEntriesByUser($userId);
@ -757,7 +757,7 @@ class ConfigController extends Controller
*/ */
private function getConfig() private function getConfig()
{ {
$config = $this->getDoctrine() $config = $this->get('doctrine')
->getRepository(ConfigEntity::class) ->getRepository(ConfigEntity::class)
->findOneByUser($this->getUser()); ->findOneByUser($this->getUser());

View file

@ -40,7 +40,7 @@ class EntryController extends Controller
*/ */
public function massAction(Request $request) public function massAction(Request $request)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$values = $request->request->all(); $values = $request->request->all();
$tagsToAdd = []; $tagsToAdd = [];
@ -173,7 +173,7 @@ class EntryController extends Controller
$this->updateEntry($entry); $this->updateEntry($entry);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -201,7 +201,7 @@ class EntryController extends Controller
if (false === $this->checkIfEntryAlreadyExists($entry)) { if (false === $this->checkIfEntryAlreadyExists($entry)) {
$this->updateEntry($entry); $this->updateEntry($entry);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -238,7 +238,7 @@ class EntryController extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -409,7 +409,7 @@ class EntryController extends Controller
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
} }
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -431,7 +431,7 @@ class EntryController extends Controller
$this->checkUserAction($entry); $this->checkUserAction($entry);
$entry->toggleArchive(); $entry->toggleArchive();
$this->getDoctrine()->getManager()->flush(); $this->get('doctrine')->getManager()->flush();
$message = 'flashes.entry.notice.entry_unarchived'; $message = 'flashes.entry.notice.entry_unarchived';
if ($entry->isArchived()) { if ($entry->isArchived()) {
@ -461,7 +461,7 @@ class EntryController extends Controller
$entry->toggleStar(); $entry->toggleStar();
$entry->updateStar($entry->isStarred()); $entry->updateStar($entry->isStarred());
$this->getDoctrine()->getManager()->flush(); $this->get('doctrine')->getManager()->flush();
$message = 'flashes.entry.notice.entry_unstarred'; $message = 'flashes.entry.notice.entry_unstarred';
if ($entry->isStarred()) { if ($entry->isStarred()) {
@ -500,7 +500,7 @@ class EntryController extends Controller
// entry deleted, dispatch event about it! // entry deleted, dispatch event about it!
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry)); $this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($entry); $em->remove($entry);
$em->flush(); $em->flush();
@ -532,7 +532,7 @@ class EntryController extends Controller
if (null === $entry->getUid()) { if (null === $entry->getUid()) {
$entry->generateUid(); $entry->generateUid();
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
} }
@ -555,7 +555,7 @@ class EntryController extends Controller
$entry->cleanUid(); $entry->cleanUid();
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();

View file

@ -50,7 +50,7 @@ class IgnoreOriginInstanceRuleController extends Controller
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($ignoreOriginInstanceRule); $em->persist($ignoreOriginInstanceRule);
$em->flush(); $em->flush();
@ -82,7 +82,7 @@ class IgnoreOriginInstanceRuleController extends Controller
$editForm->handleRequest($request); $editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) { if ($editForm->isSubmitted() && $editForm->isValid()) {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($ignoreOriginInstanceRule); $em->persist($ignoreOriginInstanceRule);
$em->flush(); $em->flush();
@ -119,7 +119,7 @@ class IgnoreOriginInstanceRuleController extends Controller
$this->get(TranslatorInterface::class)->trans('flashes.ignore_origin_instance_rule.notice.deleted') $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->remove($ignoreOriginInstanceRule);
$em->flush(); $em->flush();
} }

View file

@ -60,7 +60,7 @@ class SiteCredentialController extends Controller
$credential->setUsername($this->get(CryptoProxy::class)->crypt($credential->getUsername())); $credential->setUsername($this->get(CryptoProxy::class)->crypt($credential->getUsername()));
$credential->setPassword($this->get(CryptoProxy::class)->crypt($credential->getPassword())); $credential->setPassword($this->get(CryptoProxy::class)->crypt($credential->getPassword()));
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($credential); $em->persist($credential);
$em->flush(); $em->flush();
@ -99,7 +99,7 @@ class SiteCredentialController extends Controller
$siteCredential->setUsername($this->get(CryptoProxy::class)->crypt($siteCredential->getUsername())); $siteCredential->setUsername($this->get(CryptoProxy::class)->crypt($siteCredential->getUsername()));
$siteCredential->setPassword($this->get(CryptoProxy::class)->crypt($siteCredential->getPassword())); $siteCredential->setPassword($this->get(CryptoProxy::class)->crypt($siteCredential->getPassword()));
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($siteCredential); $em->persist($siteCredential);
$em->flush(); $em->flush();
@ -140,7 +140,7 @@ class SiteCredentialController extends Controller
$this->get(TranslatorInterface::class)->trans('flashes.site_credential.notice.deleted', ['%host%' => $siteCredential->getHost()]) $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->remove($siteCredential);
$em->flush(); $em->flush();
} }

View file

@ -39,7 +39,7 @@ class TagController extends Controller
$form->get('label')->getData() $form->get('label')->getData()
); );
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->persist($entry); $em->persist($entry);
$em->flush(); $em->flush();
@ -67,7 +67,7 @@ class TagController extends Controller
public function removeTagFromEntry(Request $request, Entry $entry, Tag $tag) public function removeTagFromEntry(Request $request, Entry $entry, Tag $tag)
{ {
$entry->removeTag($tag); $entry->removeTag($tag);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->flush(); $em->flush();
// remove orphan tag in case no entries are associated to it // remove orphan tag in case no entries are associated to it
@ -188,7 +188,7 @@ class TagController extends Controller
$entry->removeTag($tag); $entry->removeTag($tag);
} }
$this->getDoctrine()->getManager()->flush(); $this->get('doctrine')->getManager()->flush();
$this->get(SessionInterface::class)->getFlashBag()->add( $this->get(SessionInterface::class)->getFlashBag()->add(
'notice', 'notice',
@ -212,7 +212,7 @@ class TagController extends Controller
/** @var QueryBuilder $qb */ /** @var QueryBuilder $qb */
$qb = $this->get(EntryRepository::class)->getBuilderForSearchByUser($this->getUser()->getId(), $filter, $currentRoute); $qb = $this->get(EntryRepository::class)->getBuilderForSearchByUser($this->getUser()->getId(), $filter, $currentRoute);
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$entries = $qb->getQuery()->getResult(); $entries = $qb->getQuery()->getResult();
@ -246,7 +246,7 @@ class TagController extends Controller
// remove orphan tag in case no entries are associated to it // remove orphan tag in case no entries are associated to it
if (0 === \count($tag->getEntries())) { if (0 === \count($tag->getEntries())) {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$em->remove($tag); $em->remove($tag);
$em->flush(); $em->flush();
} }

View file

@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Event\Listener;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Wallabag\UserBundle\Entity\User;
/** /**
* Stores the locale of the user in the session after the login. * Stores the locale of the user in the session after the login.
@ -25,6 +26,7 @@ class UserLocaleListener
public function onInteractiveLogin(InteractiveLoginEvent $event) public function onInteractiveLogin(InteractiveLoginEvent $event)
{ {
$user = $event->getAuthenticationToken()->getUser(); $user = $event->getAuthenticationToken()->getUser();
\assert($user instanceof User);
if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) { if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) {
$this->session->set('_locale', $user->getConfig()->getLanguage()); $this->session->set('_locale', $user->getConfig()->getLanguage());

View file

@ -15,11 +15,12 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\UserBundle\Entity\User;
class EntryFilterType extends AbstractType class EntryFilterType extends AbstractType
{ {
private $user;
private $repository; private $repository;
private $tokenStorage;
/** /**
* Repository & user are used to get a list of language entries for this user. * 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) public function __construct(EntryRepository $entryRepository, TokenStorageInterface $tokenStorage)
{ {
$this->repository = $entryRepository; $this->repository = $entryRepository;
$this->tokenStorage = $tokenStorage;
$this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
if (null === $this->user || !\is_object($this->user)) {
return;
}
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
\assert($user instanceof User);
$builder $builder
->add('readingTime', NumberRangeFilterType::class, [ ->add('readingTime', NumberRangeFilterType::class, [
'left_number_options' => [ 'left_number_options' => [
@ -47,17 +47,19 @@ class EntryFilterType extends AbstractType
'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL, 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL,
'attr' => ['min' => 0], '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]; $lower = $values['value']['left_number'][0];
$upper = $values['value']['right_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) { if (null === $lower && null === $upper) {
// no value? no filter // no value? no filter
return; 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 // only lower value is defined: query all entries with reading LOWER THAN this value
$expression = $filterQuery->getExpr()->lte($field, $max); $expression = $filterQuery->getExpr()->lte($field, $max);
} elseif (null !== $lower && null === $upper) { } elseif (null !== $lower && null === $upper) {
@ -176,7 +178,7 @@ class EntryFilterType extends AbstractType
'label' => 'entry.filters.is_public_label', 'label' => 'entry.filters.is_public_label',
]) ])
->add('language', ChoiceFilterType::class, [ ->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', 'label' => 'entry.filters.language_label',
]) ])
; ;

View file

@ -21,11 +21,11 @@ class EntriesExport
private $wallabagUrl; private $wallabagUrl;
private $logoPath; private $logoPath;
private $translator; private $translator;
private $tokenStorage;
private $title = ''; private $title = '';
private $entries = []; private $entries = [];
private $author = 'wallabag'; private $author = 'wallabag';
private $language = ''; private $language = '';
private $user;
/** /**
* @param TranslatorInterface $translator Translator service * @param TranslatorInterface $translator Translator service
@ -38,13 +38,7 @@ class EntriesExport
$this->translator = $translator; $this->translator = $translator;
$this->wallabagUrl = $wallabagUrl; $this->wallabagUrl = $wallabagUrl;
$this->logoPath = $logoPath; $this->logoPath = $logoPath;
$this->tokenStorage = $tokenStorage;
/* @var User $user */
$this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
if (null === $this->user || !\is_object($this->user)) {
return;
}
} }
/** /**
@ -140,6 +134,9 @@ class EntriesExport
*/ */
private function produceEpub() private function produceEpub()
{ {
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
\assert($user instanceof User);
/* /*
* Start and End of the book * Start and End of the book
*/ */
@ -213,7 +210,7 @@ class EntriesExport
$publishedDate = $entry->getPublishedAt()->format('Y-m-d'); $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 . $titlepage = $content_start .
'<h1>' . $entry->getTitle() . '</h1>' . '<h1>' . $entry->getTitle() . '</h1>' .
@ -306,6 +303,9 @@ class EntriesExport
*/ */
private function producePdf() 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); $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
/* /*
@ -331,7 +331,7 @@ class EntriesExport
$authors = implode(',', $publishedBy); $authors = implode(',', $publishedBy);
} }
$readingTime = $entry->getReadingTime() / $this->user->getConfig()->getReadingSpeed() * 200; $readingTime = $entry->getReadingTime() / $user->getConfig()->getReadingSpeed() * 200;
$pdf->addPage(); $pdf->addPage();
$html = '<h1>' . $entry->getTitle() . '</h1>' . $html = '<h1>' . $entry->getTitle() . '</h1>' .

View file

@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface;
*/ */
class HttpClientFactory implements ClientFactory class HttpClientFactory implements ClientFactory
{ {
/** @var [\GuzzleHttp\Event\SubscriberInterface] */ /** @var SubscriberInterface[] */
private $subscribers = []; private $subscribers = [];
/** @var CookieJar */ /** @var CookieJar */

View file

@ -27,7 +27,7 @@ class PreparePagerForEntries
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
} }
if (null === $user || !\is_object($user)) { if (!$user instanceof User) {
return; return;
} }

View file

@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Helper;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Config;
use Wallabag\UserBundle\Entity\User;
/** /**
* Manage redirections to avoid redirecting to empty routes. * Manage redirections to avoid redirecting to empty routes.
@ -31,7 +32,7 @@ class Redirect
{ {
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (null === $user || !\is_object($user)) { if (!$user instanceof User) {
return $url; return $url;
} }

View file

@ -8,6 +8,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInte
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
use Wallabag\UserBundle\Repository\UserRepository;
/** /**
* ParamConverter used in the Feed controller to retrieve the right user according to * 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 // Get actual entity manager for class
$em = $this->registry->getManagerForClass($configuration->getClass()); $em = $this->registry->getManagerForClass($configuration->getClass());
/** @var UserRepository $userRepository */
$userRepository = $em->getRepository($configuration->getClass()); $userRepository = $em->getRepository($configuration->getClass());
// Try to find user by its username and config feed_token // Try to find user by its username and config feed_token

View file

@ -6,6 +6,9 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Config;
/**
* @method Config|null findOneByUser(int $userId)
*/
class ConfigRepository extends ServiceEntityRepository class ConfigRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)

View file

@ -12,6 +12,10 @@ use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\UrlHasher; use Wallabag\CoreBundle\Helper\UrlHasher;
/**
* @method Entry[] findById(int $id)
* @method Entry|null findOneByUser(int $userId)
*/
class EntryRepository extends ServiceEntityRepository class EntryRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)

View file

@ -9,6 +9,8 @@ use Wallabag\CoreBundle\Helper\CryptoProxy;
/** /**
* SiteCredentialRepository. * SiteCredentialRepository.
*
* @method SiteCredential[] findByUser(int $userId)
*/ */
class SiteCredentialRepository extends ServiceEntityRepository class SiteCredentialRepository extends ServiceEntityRepository
{ {

View file

@ -7,6 +7,10 @@ use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
/**
* @method Tag|null findOneByLabel(string $label)
* @method Tag|null findOneBySlug(string $slug)
*/
class TagRepository extends ServiceEntityRepository class TagRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)

View file

@ -10,6 +10,7 @@ use Twig\TwigFilter;
use Twig\TwigFunction; use Twig\TwigFunction;
use Wallabag\CoreBundle\Repository\EntryRepository; use Wallabag\CoreBundle\Repository\EntryRepository;
use Wallabag\CoreBundle\Repository\TagRepository; use Wallabag\CoreBundle\Repository\TagRepository;
use Wallabag\UserBundle\Entity\User;
class WallabagExtension extends AbstractExtension implements GlobalsInterface 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; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (null === $user || !\is_object($user)) { if (!$user instanceof User) {
return 0; return 0;
} }
@ -127,7 +128,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
{ {
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (null === $user || !\is_object($user)) { if (!$user instanceof User) {
return 0; return 0;
} }
@ -143,7 +144,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
{ {
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
if (null === $user || !\is_object($user)) { if (!$user instanceof User) {
return 0; return 0;
} }

View file

@ -112,5 +112,7 @@ class ImportCommand extends ContainerAwareCommand
$em->clear(); $em->clear();
$output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---'); $output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
return 0;
} }
} }

View file

@ -40,5 +40,7 @@ class RedisWorkerCommand extends ContainerAwareCommand
); );
$worker->start(); $worker->start();
return 0;
} }
} }

View file

@ -37,6 +37,7 @@ class ManageController extends Controller
$userManager = $this->container->get(UserManagerInterface::class); $userManager = $this->container->get(UserManagerInterface::class);
$user = $userManager->createUser(); $user = $userManager->createUser();
\assert($user instanceof User);
// enable created user by default // enable created user by default
$user->setEnabled(true); $user->setEnabled(true);
@ -127,7 +128,7 @@ class ManageController extends Controller
$this->get(TranslatorInterface::class)->trans('flashes.user.notice.deleted', ['%username%' => $user->getUsername()]) $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->remove($user);
$em->flush(); $em->flush();
} }
@ -147,7 +148,7 @@ class ManageController extends Controller
*/ */
public function searchFormAction(Request $request, $page = 1) public function searchFormAction(Request $request, $page = 1)
{ {
$em = $this->getDoctrine()->getManager(); $em = $this->get('doctrine')->getManager();
$qb = $em->getRepository(User::class)->createQueryBuilder('u'); $qb = $em->getRepository(User::class)->createQueryBuilder('u');
$form = $this->createForm(SearchUserType::class); $form = $this->createForm(SearchUserType::class);

View file

@ -7,6 +7,9 @@ use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
use Wallabag\UserBundle\Entity\User; use Wallabag\UserBundle\Entity\User;
/**
* @method User|null findOneById(int $id)
*/
class UserRepository extends ServiceEntityRepository class UserRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)

View file

@ -3,6 +3,8 @@
namespace Tests\Wallabag\AnnotationBundle; namespace Tests\Wallabag\AnnotationBundle;
use FOS\UserBundle\Model\UserInterface; use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManager;
use FOS\UserBundle\Security\LoginManager;
use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\Cookie;
@ -23,6 +25,7 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$this->client = $this->createAuthorizedClient(); $this->client = $this->createAuthorizedClient();
} }
@ -46,9 +49,9 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
$client = static::createClient(); $client = static::createClient();
$container = $client->getContainer(); $container = $client->getContainer();
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ /** @var UserManager $userManager */
$userManager = $container->get('fos_user.user_manager.test'); $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'); $loginManager = $container->get('fos_user.security.login_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name'); $firewallName = $container->getParameter('fos_user.firewall_name');

View file

@ -4,6 +4,8 @@ namespace Tests\Wallabag\ApiBundle;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserInterface; use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Model\UserManager;
use FOS\UserBundle\Security\LoginManager;
use Symfony\Bundle\FrameworkBundle\Client; use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\BrowserKit\Cookie; use Symfony\Component\BrowserKit\Cookie;
@ -25,6 +27,7 @@ abstract class WallabagApiTestCase extends WebTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp();
$this->client = $this->createAuthorizedClient(); $this->client = $this->createAuthorizedClient();
} }
@ -36,9 +39,9 @@ abstract class WallabagApiTestCase extends WebTestCase
$client = static::createClient(); $client = static::createClient();
$container = $client->getContainer(); $container = $client->getContainer();
/** @var $userManager \FOS\UserBundle\Doctrine\UserManager */ /** @var UserManager $userManager */
$userManager = $container->get('fos_user.user_manager.test'); $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'); $loginManager = $container->get('fos_user.security.login_manager.test');
$firewallName = $container->getParameter('fos_user.firewall_name'); $firewallName = $container->getParameter('fos_user.firewall_name');

View file

@ -895,6 +895,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
$user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser();
\assert($user instanceof User);
$tag = new Tag(); $tag = new Tag();
$tag->setLabel('super'); $tag->setLabel('super');
$em->persist($tag); $em->persist($tag);
@ -980,6 +982,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
$user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser();
\assert($user instanceof User);
$tag = new Tag(); $tag = new Tag();
$tag->setLabel('super'); $tag->setLabel('super');
$em->persist($tag); $em->persist($tag);
@ -1056,6 +1060,8 @@ class ConfigControllerTest extends WallabagCoreTestCase
$user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser();
\assert($user instanceof User);
$tag = new Tag(); $tag = new Tag();
$tag->setLabel('super'); $tag->setLabel('super');
$em->persist($tag); $em->persist($tag);

View file

@ -18,6 +18,9 @@ class RedirectTest extends TestCase
/** @var Redirect */ /** @var Redirect */
private $redirect; private $redirect;
/** @var User */
private $user;
/** @var UsernamePasswordToken */ /** @var UsernamePasswordToken */
private $token; private $token;
@ -32,24 +35,24 @@ class RedirectTest extends TestCase
->with('homepage') ->with('homepage')
->willReturn('homepage'); ->willReturn('homepage');
$user = new User(); $this->user = new User();
$user->setName('youpi'); $this->user->setName('youpi');
$user->setEmail('youpi@youpi.org'); $this->user->setEmail('youpi@youpi.org');
$user->setUsername('youpi'); $this->user->setUsername('youpi');
$user->setPlainPassword('youpi'); $this->user->setPlainPassword('youpi');
$user->setEnabled(true); $this->user->setEnabled(true);
$user->addRole('ROLE_SUPER_ADMIN'); $this->user->addRole('ROLE_SUPER_ADMIN');
$config = new Config($user); $config = new Config($this->user);
$config->setItemsPerPage(30); $config->setItemsPerPage(30);
$config->setReadingSpeed(200); $config->setReadingSpeed(200);
$config->setLanguage('en'); $config->setLanguage('en');
$config->setPocketConsumerKey('xxxxx'); $config->setPocketConsumerKey('xxxxx');
$config->setActionMarkAsRead(Config::REDIRECT_TO_CURRENT_PAGE); $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 = new TokenStorage();
$tokenStorage->setToken($this->token); $tokenStorage->setToken($this->token);
@ -87,7 +90,7 @@ class RedirectTest extends TestCase
public function testUserForRedirectToHomepage() 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'); $redirectUrl = $this->redirect->to('/unread/list');
@ -96,7 +99,7 @@ class RedirectTest extends TestCase
public function testUserForRedirectWithIgnoreActionMarkAsRead() 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); $redirectUrl = $this->redirect->to('/unread/list', '', true);
@ -105,7 +108,7 @@ class RedirectTest extends TestCase
public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead() 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); $redirectUrl = $this->redirect->to(null, 'fallback', true);