Skip to content

Commit c41a567

Browse files
committed
Mark most classes as readonly
Using `Rector\Php81\Rector\Property\ReadOnlyPropertyRector` and `Rector\Php82\Rector\Class_\ReadOnlyClassRector`. All controllers should be readonly. `Tags` and `Opml\Import` are an exception, for now, as they are doing weird stateful things. Ideally, spouts and helpers would be too but there are some backwards compatibility concerns.
1 parent 3f8317a commit c41a567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+75
-73
lines changed

src/controllers/About.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Controller for instance information API
1313
*/
14-
final class About {
14+
final readonly class About {
1515
public function __construct(
1616
private Authentication $authentication,
1717
private Configuration $configuration,

src/controllers/Authentication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Controller for user related tasks
1212
*/
13-
final class Authentication {
13+
final readonly class Authentication {
1414
public function __construct(
1515
private AuthenticationService $authenticationService,
1616
private View $view

src/controllers/Helpers/HashPassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Controller for user related tasks
1212
*/
13-
final class HashPassword {
13+
final readonly class HashPassword {
1414
public function __construct(
1515
private Authentication $authentication,
1616
private View $view

src/controllers/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @license GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
1919
* @author Tobias Zeising <tobias.zeising@aditu.de>
2020
*/
21-
final class Index {
21+
final readonly class Index {
2222
public function __construct(
2323
private Authentication $authentication,
2424
private \daos\Items $itemsDao,

src/controllers/Items.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @license GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
2020
* @author Tobias Zeising <tobias.zeising@aditu.de>
2121
*/
22-
final class Items {
22+
final readonly class Items {
2323
public function __construct(
2424
private Authentication $authentication,
2525
private \daos\Items $itemsDao,

src/controllers/Items/Stats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/**
1111
* Controller for viewing item statistics
1212
*/
13-
final class Stats {
13+
final readonly class Stats {
1414
public function __construct(
1515
private Authentication $authentication,
1616
private \daos\Items $itemsDao,

src/controllers/Items/Sync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Controller for synchronizing item statuses
1515
*/
16-
final class Sync {
16+
final readonly class Sync {
1717
public function __construct(
1818
private Authentication $authentication,
1919
private Configuration $configuration,

src/controllers/Opml/Export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @author Michael Moore <stuporglue@gmail.com>
1919
* @author Sean Rand <asanernd@gmail.com>
2020
*/
21-
final class Export {
21+
final readonly class Export {
2222
public function __construct(
2323
private Authentication $authentication,
2424
private Configuration $configuration,

src/controllers/Opml/Import.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
* @author Michael Moore <stuporglue@gmail.com>
1818
* @author Sean Rand <asanernd@gmail.com>
1919
*/
20+
// TODO: Make readonly.
2021
final class Import {
2122
/** @var array<string, array{id: int, tags: string[]}> Sources that have been imported from the OPML file */
2223
private array $imported = [];
2324

2425
public function __construct(
25-
private Authentication $authentication,
26-
private Logger $logger,
27-
private \daos\Sources $sourcesDao,
28-
private \daos\Tags $tagsDao,
29-
private View $view
26+
private readonly Authentication $authentication,
27+
private readonly Logger $logger,
28+
private readonly \daos\Sources $sourcesDao,
29+
private readonly \daos\Tags $tagsDao,
30+
private readonly View $view
3031
) {
3132
}
3233

src/controllers/Rss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @license GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
1818
* @author Tobias Zeising <tobias.zeising@aditu.de>
1919
*/
20-
final class Rss {
20+
final readonly class Rss {
2121
public function __construct(
2222
private Authentication $authentication,
2323
private Configuration $configuration,

0 commit comments

Comments
 (0)