File tree Expand file tree Collapse file tree
tests/Rector/ReplaceFetchAllMethodCallRector Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace OCP \AppFramework ;
4+
5+ use OCP \IDBConnection ;
6+ use PDO ;
7+
8+ class SomeClass
9+ {
10+ public function __construct (IDBConnection $ connection ) {
11+ $ qb = $ connection ->getQueryBuilder ();
12+ $ result = $ qb ->select ('* ' )
13+ ->from ('pages ' )
14+ ->executeQuery ();
15+
16+ $ result ->fetchAll ();
17+ $ result ->fetchAll (PDO ::FETCH_COLUMN );
18+ $ result ->fetchAll (PDO ::FETCH_ASSOC );
19+ $ result ->fetchAll (PDO ::FETCH_NUM );
20+
21+ $ result ->fetch (PDO ::FETCH_COLUMN );
22+ $ result ->fetch (PDO ::FETCH_ASSOC );
23+ $ result ->fetch ();
24+ $ result ->fetch (PDO ::FETCH_NUM );
25+ }
26+ }
27+
28+ ?>
29+ -----
30+ <?php
31+
32+ namespace OCP \AppFramework ;
33+
34+ use OCP \IDBConnection ;
35+ use PDO ;
36+
37+ class SomeClass
38+ {
39+ public function __construct (IDBConnection $ connection ) {
40+ $ qb = $ connection ->getQueryBuilder ();
41+ $ result = $ qb ->select ('* ' )
42+ ->from ('pages ' )
43+ ->executeQuery ();
44+
45+ $ result ->fetchAllAssociative ();
46+ $ result ->fetchFirstColumn ();
47+ $ result ->fetchAllAssociative ();
48+ $ result ->fetchAllNumeric ();
49+
50+ $ result ->fetchOne ();
51+ $ result ->fetchAssociative ();
52+ $ result ->fetchAssociative ();
53+ $ result ->fetchNumeric ();
54+ }
55+ }
56+
57+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /*
6+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+ * SPDX-License-Identifier: AGPL-3.0-or-later
8+ */
9+
10+ namespace Nextcloud \Rector \Test \Rector \ReplaceFetchAllMethodCallRector ;
11+
12+ use Iterator ;
13+ use PHPUnit \Framework \Attributes \DataProvider ;
14+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
15+
16+ final class ReplaceFetchAllMethodCallRectorTest extends AbstractRectorTestCase
17+ {
18+ #[DataProvider('provideData ' )]
19+ public function test (string $ filePath ): void
20+ {
21+ $ this ->doTestFile ($ filePath );
22+ }
23+
24+ public static function provideData (): Iterator
25+ {
26+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
27+ }
28+
29+ public function provideConfigFilePath (): string
30+ {
31+ return __DIR__ . '/config/config.php ' ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Nextcloud \Rector \Rector \RenameParameterRector ;
6+ use Nextcloud \Rector \Rector \ReplaceFetchAllMethodCallRector ;
7+ use Nextcloud \Rector \ValueObject \RenameParameter ;
8+ use Rector \Config \RectorConfig ;
9+
10+ return RectorConfig::configure ()
11+ ->withRules ([
12+ ReplaceFetchAllMethodCallRector::class,
13+ ]);
You can’t perform that action at this time.
0 commit comments