Skip to content

Commit 730b688

Browse files
committed
refactor: use the #[\Override] attribute
1 parent 69ee0ff commit 730b688

538 files changed

Lines changed: 2228 additions & 0 deletions

File tree

Some content is hidden

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

‎admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace Tests\Support\Database\Migrations;
44

55
use CodeIgniter\Database\Migration;
6+
use Override;
67

78
class ExampleMigration extends Migration
89
{
910
protected $DBGroup = 'tests';
1011

12+
#[Override]
1113
public function up(): void
1214
{
1315
$this->forge->addField('id');
@@ -30,6 +32,7 @@ public function up(): void
3032
$this->forge->createTable('factories');
3133
}
3234

35+
#[Override]
3336
public function down(): void
3437
{
3538
$this->forge->dropTable('factories');

‎admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace Tests\Support\Database\Seeds;
44

55
use CodeIgniter\Database\Seeder;
6+
use Override;
67

78
class ExampleSeeder extends Seeder
89
{
10+
#[Override]
911
public function run(): void
1012
{
1113
$factories = [

‎app/Controllers/BaseController.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use CodeIgniter\HTTP\IncomingRequest;
88
use CodeIgniter\HTTP\RequestInterface;
99
use CodeIgniter\HTTP\ResponseInterface;
10+
use Override;
1011
use Psr\Log\LoggerInterface;
1112

1213
/**
@@ -34,6 +35,7 @@ abstract class BaseController extends Controller
3435
*
3536
* @return void
3637
*/
38+
#[Override]
3739
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
3840
{
3941
// Load here all helpers you want to be available in your controllers that extend BaseController.

‎phpstan.dist.neon‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ parameters:
3535
identifier: trait.unused
3636
path: system/CLI/GeneratorTrait.php
3737
checkMissingCallableSignature: true
38+
checkMissingOverrideMethodAttribute: true
3839
treatPhpDocTypesAsCertain: false
3940
strictRules:
4041
allRules: false

‎rector.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
2929
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
3030
use Rector\Php83\Rector\ClassConst\AddTypeToConstRector;
31+
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\NoSetupWithParentCallOverrideRector;
3132
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
3233
use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector;
3334
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
@@ -86,6 +87,7 @@
8687

8788
YieldDataProviderRector::class,
8889
AddTypeToConstRector::class,
90+
NoSetupWithParentCallOverrideRector::class,
8991

9092
RemoveUnusedPrivateMethodRector::class => [
9193
// private method called via getPrivateMethodInvoker

‎system/API/BaseTransformer.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use CodeIgniter\HTTP\IncomingRequest;
1717
use InvalidArgumentException;
18+
use Override;
1819

1920
/**
2021
* Base class for transforming resources into arrays.
@@ -160,12 +161,14 @@ private function splitList(string $value): array
160161
*
161162
* @param mixed $resource The resource being transformed
162163
*/
164+
#[Override]
163165
abstract public function toArray(mixed $resource): array;
164166

165167
/**
166168
* Transforms the given resource into an array using
167169
* the $this->toArray().
168170
*/
171+
#[Override]
169172
public function transform(array|object|null $resource = null): array
170173
{
171174
// Store the resource so include methods can access it
@@ -190,6 +193,7 @@ public function transform(array|object|null $resource = null): array
190193
* If the request's 'fields' query variable is set, only those fields will be included
191194
* in the transformed output.
192195
*/
196+
#[Override]
193197
public function transformMany(array $resources): array
194198
{
195199
return array_map($this->transform(...), $resources);

‎system/Autoloader/FileLocator.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
namespace CodeIgniter\Autoloader;
1515

16+
use Override;
17+
1618
/**
1719
* Allows loading non-class files in a namespaced manner.
1820
* Works with Helpers, Views, etc.
@@ -53,6 +55,7 @@ public function __construct(Autoloader $autoloader)
5355
*
5456
* @return false|non-empty-string The path to the file, or false if not found.
5557
*/
58+
#[Override]
5659
public function locateFile(string $file, ?string $folder = null, string $ext = 'php')
5760
{
5861
$file = $this->ensureExt($file, $ext);
@@ -124,6 +127,7 @@ public function locateFile(string $file, ?string $folder = null, string $ext = '
124127
/**
125128
* Examines a file and returns the fully qualified class name.
126129
*/
130+
#[Override]
127131
public function getClassname(string $file): string
128132
{
129133
if (is_dir($file)) {
@@ -186,6 +190,7 @@ public function getClassname(string $file): string
186190
*
187191
* @return list<non-empty-string>
188192
*/
193+
#[Override]
189194
public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array
190195
{
191196
$path = $this->ensureExt($path, $ext);
@@ -265,6 +270,7 @@ protected function getNamespaces()
265270
return array_merge($namespaces, $system);
266271
}
267272

273+
#[Override]
268274
public function findQualifiedNameFromPath(string $path)
269275
{
270276
$resolvedPath = realpath($path);
@@ -318,6 +324,7 @@ public function findQualifiedNameFromPath(string $path)
318324
*
319325
* @return list<string> List of file paths
320326
*/
327+
#[Override]
321328
public function listFiles(string $path): array
322329
{
323330
if ($path === '') {
@@ -340,6 +347,7 @@ public function listFiles(string $path): array
340347
*
341348
* @return list<non-empty-string> List of file paths
342349
*/
350+
#[Override]
343351
public function listNamespaceFiles(string $prefix, string $path): array
344352
{
345353
if ($path === '' || $prefix === '') {

‎system/Autoloader/FileLocatorCached.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use CodeIgniter\Cache\CacheInterface;
1717
use CodeIgniter\Cache\FactoriesCache\FileVarExportHandler;
18+
use Override;
1819

1920
/**
2021
* FileLocator with Cache
@@ -87,6 +88,7 @@ public function deleteCache(): void
8788
$this->cacheHandler->delete($this->cacheKey);
8889
}
8990

91+
#[Override]
9092
public function findQualifiedNameFromPath(string $path): false|string
9193
{
9294
if (isset($this->cache['findQualifiedNameFromPath'][$path])) {
@@ -101,6 +103,7 @@ public function findQualifiedNameFromPath(string $path): false|string
101103
return $classname;
102104
}
103105

106+
#[Override]
104107
public function getClassname(string $file): string
105108
{
106109
if (isset($this->cache['getClassname'][$file])) {
@@ -118,6 +121,7 @@ public function getClassname(string $file): string
118121
/**
119122
* @return list<non-empty-string>
120123
*/
124+
#[Override]
121125
public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array
122126
{
123127
if (isset($this->cache['search'][$path][$ext][$prioritizeApp])) {
@@ -132,6 +136,7 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
132136
return $foundPaths;
133137
}
134138

139+
#[Override]
135140
public function listFiles(string $path): array
136141
{
137142
if (isset($this->cache['listFiles'][$path])) {
@@ -146,6 +151,7 @@ public function listFiles(string $path): array
146151
return $files;
147152
}
148153

154+
#[Override]
149155
public function listNamespaceFiles(string $prefix, string $path): array
150156
{
151157
if (isset($this->cache['listNamespaceFiles'][$prefix][$path])) {
@@ -160,6 +166,7 @@ public function listNamespaceFiles(string $prefix, string $path): array
160166
return $files;
161167
}
162168

169+
#[Override]
163170
public function locateFile(string $file, ?string $folder = null, string $ext = 'php'): false|string
164171
{
165172
$folderKey = $folder ?? '';

‎system/CLI/AbstractGeneratorCommand.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use CodeIgniter\CLI\Input\Option;
1919
use CodeIgniter\Exceptions\LogicException;
2020
use Config\Generators;
21+
use Override;
2122
use Throwable;
2223

2324
/**
@@ -74,6 +75,7 @@ public function __construct(Commands $commands)
7475
parent::__construct($commands);
7576
}
7677

78+
#[Override]
7779
protected function configure(): void
7880
{
7981
$this->addArgument(new Argument(
@@ -83,6 +85,7 @@ protected function configure(): void
8385
));
8486
}
8587

88+
#[Override]
8689
protected function provideDefaultOptions(): void
8790
{
8891
$this->provideGeneratorOptions();
@@ -127,11 +130,13 @@ final protected function addForceOption(): static
127130
));
128131
}
129132

133+
#[Override]
130134
protected function getArgumentPromptLabels(): array
131135
{
132136
return ['name' => lang($this->classNameLang)];
133137
}
134138

139+
#[Override]
135140
protected function execute(array $arguments, array $options): int
136141
{
137142
return $this->generateClass();

‎system/CLI/NullInputOutput.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313

1414
namespace CodeIgniter\CLI;
1515

16+
use Override;
17+
1618
/**
1719
* An InputOutput sink that discards all output and never reads input.
1820
*/
1921
final class NullInputOutput extends InputOutput
2022
{
23+
#[Override]
2124
public function fwrite($handle, string $string): void
2225
{
2326
}
2427

28+
#[Override]
2529
public function input(?string $prefix = null): string
2630
{
2731
return '';

0 commit comments

Comments
 (0)