Skip to content

Commit c43d015

Browse files
authored
Merge pull request #31582 from nextcloud/refactor/carl/accesibility-app
Modernize accessibility app
2 parents 5e1a397 + 57bf348 commit c43d015

5 files changed

Lines changed: 35 additions & 94 deletions

File tree

apps/accessibility/lib/AccessibilityProvider.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,10 @@
3333

3434
class AccessibilityProvider {
3535

36-
/** @var string */
37-
protected $appName;
36+
protected string $appName;
37+
private IURLGenerator $urlGenerator;
38+
private IL10N $l;
3839

39-
/** @var IURLGenerator */
40-
private $urlGenerator;
41-
42-
/** @var IL10N */
43-
private $l;
44-
45-
/**
46-
* Account constructor.
47-
*
48-
* @param string $appName
49-
* @param IURLGenerator $urlGenerator
50-
* @param IL10N $l
51-
*/
5240
public function __construct(string $appName,
5341
IURLGenerator $urlGenerator,
5442
IL10N $l) {
@@ -57,7 +45,10 @@ public function __construct(string $appName,
5745
$this->l = $l;
5846
}
5947

60-
public function getThemes() {
48+
/**
49+
* @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
50+
*/
51+
public function getThemes(): array {
6152
return [
6253
[
6354
'id' => 'dark',
@@ -69,7 +60,10 @@ public function getThemes() {
6960
];
7061
}
7162

72-
public function getHighContrast() {
63+
/**
64+
* @psalm-return array{id: string, img: string, title: string, enableLabel: string, text: string}
65+
*/
66+
public function getHighContrast(): array {
7367
return [
7468
'id' => 'highcontrast',
7569
'img' => $this->urlGenerator->imagePath($this->appName, 'mode-highcontrast.jpg'),
@@ -79,7 +73,10 @@ public function getHighContrast() {
7973
];
8074
}
8175

82-
public function getFonts() {
76+
/**
77+
* @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
78+
*/
79+
public function getFonts(): array {
8380
return [
8481
[
8582
'id' => 'fontdyslexic',

apps/accessibility/lib/Controller/AccessibilityController.php

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,15 @@
4848

4949
class AccessibilityController extends Controller {
5050

51-
/** @var string */
52-
protected $appName;
53-
54-
/** @var string */
55-
protected $serverRoot;
56-
57-
/** @var IConfig */
58-
private $config;
59-
60-
/** @var LoggerInterface */
61-
private $logger;
62-
63-
/** @var ITimeFactory */
64-
protected $timeFactory;
65-
66-
/** @var IUserSession */
67-
private $userSession;
68-
69-
/** @var IconsCacher */
70-
protected $iconsCacher;
71-
72-
/** @var \OC_Defaults */
73-
private $defaults;
74-
75-
/** @var null|string */
76-
private $injectedVariables;
77-
78-
/** @var string */
79-
private $appRoot;
51+
protected string $serverRoot;
52+
private IConfig $config;
53+
private LoggerInterface $logger;
54+
protected ITimeFactory $timeFactory;
55+
private IUserSession $userSession;
56+
protected IconsCacher $iconsCacher;
57+
private \OC_Defaults $defaults;
58+
private ?string $injectedVariables = null;
59+
private string $appRoot;
8060

8161
public function __construct(string $appName,
8262
IRequest $request,
@@ -104,8 +84,6 @@ public function __construct(string $appName,
10484
* @PublicPage
10585
* @NoCSRFRequired
10686
* @NoSameSiteCookieRequired
107-
*
108-
* @return DataDisplayResponse
10987
*/
11088
public function getCss(): DataDisplayResponse {
11189
$css = '';
@@ -186,8 +164,6 @@ public function getCss(): DataDisplayResponse {
186164

187165
/**
188166
* Return an array with the user theme & font settings
189-
*
190-
* @return array
191167
*/
192168
private function getUserValues(): array {
193169
$userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
@@ -210,10 +186,6 @@ private function filterOutRule(string $rule, string $css): string {
210186

211187
/**
212188
* Add the correct uri prefix to make uri valid again
213-
*
214-
* @param string $css
215-
* @param string $webDir
216-
* @return string
217189
*/
218190
private function rebaseUrls(string $css, string $webDir): string {
219191
$re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
@@ -226,9 +198,8 @@ private function rebaseUrls(string $css, string $webDir): string {
226198
* Remove all matches from the $rule regex
227199
*
228200
* @param string $css string to parse
229-
* @return string
230201
*/
231-
private function invertSvgIconsColor(string $css) {
202+
private function invertSvgIconsColor(string $css): string {
232203
return str_replace(
233204
['color=000&', 'color=fff&', 'color=***&'],
234205
['color=***&', 'color=000&', 'color=fff&'],

apps/accessibility/lib/Controller/ConfigController.php

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,20 @@
4141

4242
class ConfigController extends OCSController {
4343

44-
/** @var string */
45-
protected $appName;
46-
47-
/** @var string */
48-
protected $userId;
49-
50-
/** @var string */
51-
protected $serverRoot;
52-
53-
/** @var IConfig */
54-
private $config;
55-
56-
/** @var IUserSession */
57-
private $userSession;
58-
59-
/** @var AccessibilityProvider */
60-
private $accessibilityProvider;
44+
protected string $userId;
45+
private IConfig $config;
46+
private IUserSession $userSession;
47+
private AccessibilityProvider $accessibilityProvider;
6148

6249
/**
6350
* Config constructor.
64-
*
65-
* @param string $appName
66-
* @param IRequest $request
67-
* @param IConfig $config
68-
* @param IUserSession $userSession
69-
* @param AccessibilityProvider $accessibilityProvider
7051
*/
7152
public function __construct(string $appName,
7253
IRequest $request,
7354
IConfig $config,
7455
IUserSession $userSession,
7556
AccessibilityProvider $accessibilityProvider) {
7657
parent::__construct($appName, $request);
77-
$this->appName = $appName;
7858
$this->config = $config;
7959
$this->userSession = $userSession;
8060
$this->accessibilityProvider = $accessibilityProvider;
@@ -102,7 +82,8 @@ public function getConfig(): DataResponse {
10282
*
10383
* Set theme or font config
10484
*
105-
* @param string $key theme or font
85+
* @param string $key the theme or font
86+
* @param string|false $value the value
10687
* @return DataResponse
10788
* @throws OCSBadRequestException|PreConditionNotMetException
10889
*/

apps/accessibility/lib/Migration/RepairUserConfig.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,11 @@
3535

3636
class RepairUserConfig implements IRepairStep {
3737

38-
/** @var IUserManager */
39-
protected $userManager;
40-
41-
/** @var IConfig */
42-
protected $config;
38+
protected IUserManager $userManager;
39+
protected IConfig $config;
4340

4441
/**
4542
* MigrateUserConfig constructor.
46-
*
47-
* @param IConfig $config
48-
* @param IUserManager $userManager
4943
*/
5044
public function __construct(IConfig $config,
5145
IUserManager $userManager) {

apps/accessibility/lib/Service/JSDataService.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
use OCP\IUserSession;
3232

3333
class JSDataService extends InitialStateProvider {
34-
/** @var IUserSession */
35-
private $userSession;
36-
/** @var IConfig */
37-
private $config;
34+
private IUserSession $userSession;
35+
private IConfig $config;
3836

3937
public function __construct(
4038
IUserSession $userSession,

0 commit comments

Comments
 (0)