Skip to content

Commit cb3225e

Browse files
committed
refactor: remove redundant property declarations in BaseController
1 parent 61ed3ac commit cb3225e

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

app/Controllers/BaseController.php

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,43 @@
33
namespace App\Controllers;
44

55
use CodeIgniter\Controller;
6-
use CodeIgniter\HTTP\CLIRequest;
7-
use CodeIgniter\HTTP\IncomingRequest;
86
use CodeIgniter\HTTP\RequestInterface;
97
use CodeIgniter\HTTP\ResponseInterface;
108
use Psr\Log\LoggerInterface;
119

1210
/**
13-
* Class BaseController
14-
*
1511
* BaseController provides a convenient place for loading components
1612
* and performing functions that are needed by all your controllers.
13+
*
1714
* Extend this class in any new controllers:
15+
* ```
1816
* class Home extends BaseController
17+
* ```
1918
*
20-
* For security be sure to declare any new methods as protected or private.
19+
* For security, be sure to declare any new methods as protected or private.
2120
*/
2221
abstract class BaseController extends Controller
2322
{
24-
/**
25-
* Instance of the main Request object.
26-
*
27-
* @var CLIRequest|IncomingRequest
28-
*/
29-
protected $request;
30-
31-
/**
32-
* An array of helpers to be loaded automatically upon
33-
* class instantiation. These helpers will be available
34-
* to all other controllers that extend BaseController.
35-
*
36-
* @var list<string>
37-
*/
38-
protected $helpers = [];
39-
4023
/**
4124
* Be sure to declare properties for any property fetch you initialized.
4225
* The creation of dynamic property is deprecated in PHP 8.2.
4326
*/
27+
4428
// protected $session;
4529

4630
/**
4731
* @return void
4832
*/
4933
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
5034
{
51-
// Do Not Edit This Line
35+
// Load here all helpers you want to be available in your controllers that extend BaseController.
36+
// Caution: Do not put the this below the parent::initController() call below.
37+
// $this->helpers = ['form', 'url'];
38+
39+
// Caution: Do not edit this line.
5240
parent::initController($request, $response, $logger);
5341

5442
// Preload any models, libraries, etc, here.
55-
56-
// E.g.: $this->session = service('session');
43+
// $this->session = service('session');
5744
}
5845
}

system/Controller.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
use Psr\Log\LoggerInterface;
2626

2727
/**
28-
* Class Controller
29-
*
3028
* @see \CodeIgniter\ControllerTest
3129
*/
3230
class Controller

0 commit comments

Comments
 (0)