Skip to content

Commit 55a7a7e

Browse files
Merge pull request #81 from nextcloud-libraries/bugfix/noid/samples
test(iappconfig): Add more tests with IAppConfig already imported
2 parents acb470c + cc109f3 commit 55a7a7e

3 files changed

Lines changed: 124 additions & 5 deletions

File tree

src/Rector/ReplaceIConfigWithIAppConfigRector.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,9 @@ function (Node $subNode) use ($propertyNames, $deprecatedMethods, &$calls): ?Nod
191191
if (!$this->isName($propertyFetch->var, 'this')) {
192192
return null;
193193
}
194-
foreach ($propertyNames as $propertyName) {
195-
if ($this->isName($propertyFetch->name, $propertyName)) {
196-
$calls[] = $subNode;
197194

198-
break;
199-
}
195+
if ($this->isNames($propertyFetch->name, $propertyNames)) {
196+
$calls[] = $subNode;
200197
}
201198

202199
return null;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
8+
namespace Nextcloud\Rector\Test\Rector\ReplaceIConfigWithIAppConfigRector\Fixture;
9+
10+
use OCP\IAppConfig;
11+
use OCP\IConfig;
12+
13+
class SomeClass
14+
{
15+
public function __construct(private IConfig $config, private IAppConfig $appConfig)
16+
{
17+
}
18+
19+
public function run(): void
20+
{
21+
$this->config->getAppValue('myapp', 'mykey');
22+
$this->config->getAppValue('myapp', 'mykey', 'default');
23+
$this->config->getAppKeys('myapp');
24+
$this->config->setAppValue('myapp', 'mykey', 'value');
25+
$this->config->deleteAppValue('myapp', 'mykey');
26+
$this->config->deleteAppValues('myapp');
27+
}
28+
}
29+
30+
?>
31+
-----
32+
<?php
33+
34+
/*
35+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
36+
* SPDX-License-Identifier: AGPL-3.0-or-later
37+
*/
38+
39+
namespace Nextcloud\Rector\Test\Rector\ReplaceIConfigWithIAppConfigRector\Fixture;
40+
41+
use OCP\IAppConfig;
42+
use OCP\IConfig;
43+
44+
class SomeClass
45+
{
46+
public function __construct(private IConfig $config, private IAppConfig $appConfig)
47+
{
48+
}
49+
50+
public function run(): void
51+
{
52+
$this->appConfig->getValue('myapp', 'mykey');
53+
$this->appConfig->getValue('myapp', 'mykey', 'default');
54+
$this->appConfig->getKeys('myapp');
55+
$this->appConfig->setValue('myapp', 'mykey', 'value');
56+
$this->appConfig->deleteKey('myapp', 'mykey');
57+
$this->appConfig->deleteApp('myapp');
58+
}
59+
}
60+
61+
?>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
5+
* SPDX-License-Identifier: AGPL-3.0-or-later
6+
*/
7+
8+
namespace Nextcloud\Rector\Test\Rector\ReplaceIConfigWithIAppConfigRector\Fixture;
9+
10+
use OCP\AppFramework\Services\IAppConfig;
11+
use OCP\IConfig;
12+
13+
class SomeClass
14+
{
15+
public function __construct(private IConfig $config, private IAppConfig $appConfig)
16+
{
17+
}
18+
19+
public function run(): void
20+
{
21+
$this->config->getAppValue('myapp', 'mykey');
22+
$this->config->getAppValue('myapp', 'mykey', 'default');
23+
$this->config->getAppKeys('myapp');
24+
$this->config->setAppValue('myapp', 'mykey', 'value');
25+
$this->config->deleteAppValue('myapp', 'mykey');
26+
$this->config->deleteAppValues('myapp');
27+
}
28+
}
29+
30+
?>
31+
-----
32+
<?php
33+
34+
/*
35+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
36+
* SPDX-License-Identifier: AGPL-3.0-or-later
37+
*/
38+
39+
namespace Nextcloud\Rector\Test\Rector\ReplaceIConfigWithIAppConfigRector\Fixture;
40+
41+
use OCP\AppFramework\Services\IAppConfig;
42+
use OCP\IConfig;
43+
44+
class SomeClass
45+
{
46+
public function __construct(private IConfig $config, private IAppConfig $appConfig, private \OCP\IAppConfig $appConfig2)
47+
{
48+
}
49+
50+
public function run(): void
51+
{
52+
$this->appConfig2->getValue('myapp', 'mykey');
53+
$this->appConfig2->getValue('myapp', 'mykey', 'default');
54+
$this->appConfig2->getKeys('myapp');
55+
$this->appConfig2->setValue('myapp', 'mykey', 'value');
56+
$this->appConfig2->deleteKey('myapp', 'mykey');
57+
$this->appConfig2->deleteApp('myapp');
58+
}
59+
}
60+
61+
?>

0 commit comments

Comments
 (0)