From 8c7f5c15caf0a03f8dfcacbd3101910a45fc463e Mon Sep 17 00:00:00 2001 From: objecttothis Date: Thu, 26 Jan 2023 17:36:54 +0400 Subject: [PATCH] CI4 4.3.1 upgrade - add missing files - overwrite changed files - merge code changes - Matched .htaccess file in /public/ to CI4 - Corrected naming of Error language file to Errors - Refactored references to Error language file --- app/Config/Encryption.php | 44 ++++++++++++++--------- app/Config/Events.php | 1 + app/Config/Exceptions.php | 41 ++++++++++++++------- app/Config/Feature.php | 4 +-- app/Config/Filters.php | 16 +++------ app/Config/Format.php | 6 ++-- app/Config/Generators.php | 2 +- app/Config/Honeypot.php | 27 +++++++------- app/Config/Images.php | 10 ++---- app/Config/Kint.php | 22 ++++++------ app/Config/Logger.php | 27 +++++++------- app/Config/Migrations.php | 20 +++++------ app/Config/Mimes.php | 8 ++--- app/Config/Modules.php | 23 ++++++++++++ app/Config/Pager.php | 6 ++-- app/Config/Paths.php | 20 +++-------- app/Config/Routes.php | 8 +---- app/Config/Security.php | 34 +++++------------- app/Config/Toolbar.php | 20 ++++------- app/Config/UserAgents.php | 8 ++--- app/Config/Validation.php | 14 ++++---- app/Controllers/BaseController.php | 6 ++++ app/Language/en-US/Error.php | 5 --- app/Language/en-US/Errors.php | 9 +++++ app/Models/Module.php | 4 +-- app/Views/errors/html/error_404.php | 6 ++-- app/Views/errors/html/error_exception.php | 4 +-- app/Views/errors/html/production.php | 8 ++--- app/Views/no_access.php | 2 +- 29 files changed, 201 insertions(+), 204 deletions(-) delete mode 100644 app/Language/en-US/Error.php create mode 100644 app/Language/en-US/Errors.php diff --git a/app/Config/Encryption.php b/app/Config/Encryption.php index ee4cb56aa..e37b4e2a1 100644 --- a/app/Config/Encryption.php +++ b/app/Config/Encryption.php @@ -20,10 +20,8 @@ class Encryption extends BaseConfig * If you use the Encryption class you must set an encryption key (seed). * You need to ensure it is long enough for the cipher and mode you plan to use. * See the user guide for more info. - * - * @var string */ - public $key; //Set in the constructor + public string $key = ''; /** * -------------------------------------------------------------------------- @@ -35,10 +33,8 @@ class Encryption extends BaseConfig * Available drivers: * - OpenSSL * - Sodium - * - * @var string */ - public $driver = 'OpenSSL'; + public string $driver = 'OpenSSL'; /** * -------------------------------------------------------------------------- @@ -49,10 +45,8 @@ class Encryption extends BaseConfig * before it is encrypted. This value should be greater than zero. * * See the user guide for more information on padding. - * - * @var int */ - public $blockSize = 16; + public int $blockSize = 16; /** * -------------------------------------------------------------------------- @@ -60,14 +54,30 @@ class Encryption extends BaseConfig * -------------------------------------------------------------------------- * * HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'. - * - * @var string */ - public $digest = 'SHA512'; + public string $digest = 'SHA512'; - function __construct() - { - parent::__construct(); - $this->key = getenv('ENCRYPTION_KEY') !== FALSE ? getenv('ENCRYPTION_KEY') : ''; - } + /** + * Whether the cipher-text should be raw. If set to false, then it will be base64 encoded. + * This setting is only used by OpenSSLHandler. + * + * Set to false for CI3 Encryption compatibility. + */ + public bool $rawData = true; + + /** + * Encryption key info. + * This setting is only used by OpenSSLHandler. + * + * Set to 'encryption' for CI3 Encryption compatibility. + */ + public string $encryptKeyInfo = ''; + + /** + * Authentication key info. + * This setting is only used by OpenSSLHandler. + * + * Set to 'authentication' for CI3 Encryption compatibility. + */ + public string $authKeyInfo = ''; } diff --git a/app/Config/Events.php b/app/Config/Events.php index 19793140a..3f9fd3b10 100644 --- a/app/Config/Events.php +++ b/app/Config/Events.php @@ -7,6 +7,7 @@ use App\Events\Load_config; use App\Events\Method; use CodeIgniter\Events\Events; use CodeIgniter\Exceptions\FrameworkException; + /* * -------------------------------------------------------------------- * Application Events diff --git a/app/Config/Exceptions.php b/app/Config/Exceptions.php index 7cbc78a88..bf3a1b964 100644 --- a/app/Config/Exceptions.php +++ b/app/Config/Exceptions.php @@ -3,6 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; +use Psr\Log\LogLevel; /** * Setup how the exception handler works. @@ -17,10 +18,8 @@ class Exceptions extends BaseConfig * through Services::Log. * * Default: true - * - * @var bool */ - public $log = true; + public bool $log = true; /** * -------------------------------------------------------------------------- @@ -28,10 +27,8 @@ class Exceptions extends BaseConfig * -------------------------------------------------------------------------- * Any status codes here will NOT be logged if logging is turned on. * By default, only 404 (Page Not Found) exceptions are ignored. - * - * @var array */ - public $ignoreCodes = [404]; + public array $ignoreCodes = [404]; /** * -------------------------------------------------------------------------- @@ -41,10 +38,8 @@ class Exceptions extends BaseConfig * directories that hold the views used to generate errors. * * Default: APPPATH.'Views/errors' - * - * @var string */ - public $errorViewPath = APPPATH . 'Views/errors'; + public string $errorViewPath = APPPATH . 'Views/errors'; /** * -------------------------------------------------------------------------- @@ -53,8 +48,30 @@ class Exceptions extends BaseConfig * Any data that you would like to hide from the debug trace. * In order to specify 2 levels, use "/" to separate. * ex. ['server', 'setup/password', 'secret_token'] - * - * @var array */ - public $sensitiveDataInTrace = []; + public array $sensitiveDataInTrace = []; + + /** + * -------------------------------------------------------------------------- + * LOG DEPRECATIONS INSTEAD OF THROWING? + * -------------------------------------------------------------------------- + * By default, CodeIgniter converts deprecations into exceptions. Also, + * starting in PHP 8.1 will cause a lot of deprecated usage warnings. + * Use this option to temporarily cease the warnings and instead log those. + * This option also works for user deprecations. + */ + public bool $logDeprecations = true; + + /** + * -------------------------------------------------------------------------- + * LOG LEVEL THRESHOLD FOR DEPRECATIONS + * -------------------------------------------------------------------------- + * If `$logDeprecations` is set to `true`, this sets the log level + * to which the deprecation will be logged. This should be one of the log + * levels recognized by PSR-3. + * + * The related `Config\Logger::$threshold` should be adjusted, if needed, + * to capture logging the deprecations. + */ + public string $deprecationLogLevel = LogLevel::WARNING; } diff --git a/app/Config/Feature.php b/app/Config/Feature.php index 480697b61..a43239442 100644 --- a/app/Config/Feature.php +++ b/app/Config/Feature.php @@ -20,10 +20,8 @@ class Feature extends BaseConfig * - CodeIgniter\Router\Router::handle() uses: * - property $filtersInfo, instead of $filterInfo * - CodeIgniter\Router\RouteCollection::getFiltersForRoute(), instead of getFilterForRoute() - * - * @var bool */ - public $multipleFilters = false; + public bool $multipleFilters = false; /** * Use improved new auto routing instead of the default legacy version. diff --git a/app/Config/Filters.php b/app/Config/Filters.php index 969570615..9bdc9ec86 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -14,10 +14,8 @@ class Filters extends BaseConfig /** * Configures aliases for Filter classes to * make reading things nicer and simpler. - * - * @var array */ - public $aliases = [ + public array $aliases = [ 'csrf' => CSRF::class, 'toolbar' => DebugToolbar::class, 'honeypot' => Honeypot::class, @@ -28,10 +26,8 @@ class Filters extends BaseConfig /** * List of filter aliases that are always * applied before and after every request. - * - * @var array */ - public $globals = [ + public array $globals = [ 'before' => [ 'honeypot', 'csrf' => ['except' => 'login'], @@ -54,10 +50,8 @@ class Filters extends BaseConfig * If you use this, you should disable auto-routing because auto-routing * permits any HTTP method to access a controller. Accessing the controller * with a method you don’t expect could bypass the filter. - * - * @var array */ - public $methods = []; + public array $methods = []; /** * List of filter aliases that should run on any @@ -65,8 +59,6 @@ class Filters extends BaseConfig * * Example: * 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']] - * - * @var array */ - public $filters = []; + public array $filters = []; } diff --git a/app/Config/Format.php b/app/Config/Format.php index d89e40842..749da3e5f 100644 --- a/app/Config/Format.php +++ b/app/Config/Format.php @@ -24,7 +24,7 @@ class Format extends BaseConfig * * @var string[] */ - public $supportedResponseFormats = [ + public array $supportedResponseFormats = [ 'application/json', 'application/xml', // machine-readable XML 'text/xml', // human-readable XML @@ -41,7 +41,7 @@ class Format extends BaseConfig * * @var array */ - public $formatters = [ + public array $formatters = [ 'application/json' => JSONFormatter::class, 'application/xml' => XMLFormatter::class, 'text/xml' => XMLFormatter::class, @@ -57,7 +57,7 @@ class Format extends BaseConfig * * @var array */ - public $formatterOptions = [ + public array $formatterOptions = [ 'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, 'application/xml' => 0, 'text/xml' => 0, diff --git a/app/Config/Generators.php b/app/Config/Generators.php index 11214fdc6..01b1ef2b2 100644 --- a/app/Config/Generators.php +++ b/app/Config/Generators.php @@ -25,7 +25,7 @@ class Generators extends BaseConfig * * @var array */ - public $views = [ + public array $views = [ 'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php', 'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php', 'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php', diff --git a/app/Config/Honeypot.php b/app/Config/Honeypot.php index 42b5a0dc8..67ebcb0ee 100644 --- a/app/Config/Honeypot.php +++ b/app/Config/Honeypot.php @@ -8,36 +8,35 @@ class Honeypot extends BaseConfig { /** * Makes Honeypot visible or not to human - * - * @var bool */ - public $hidden = true; + public bool $hidden = true; /** * Honeypot Label Content - * - * @var string */ - public $label = 'Fill This Field'; + public string $label = 'Fill This Field'; /** * Honeypot Field Name - * - * @var string */ - public $name = 'honeypot'; + public string $name = 'honeypot'; /** * Honeypot HTML Template - * - * @var string */ - public $template = ''; + public string $template = ''; /** * Honeypot container * - * @var string + * If you enabled CSP, you can remove `style="display:none"`. */ - public $container = '
{template}
'; + public string $container = '
{template}
'; + + /** + * The id attribute for Honeypot container tag + * + * Used when CSP is enabled. + */ + public string $containerId = 'hpc'; } diff --git a/app/Config/Images.php b/app/Config/Images.php index 1c15d8151..a33ddadb9 100644 --- a/app/Config/Images.php +++ b/app/Config/Images.php @@ -10,25 +10,21 @@ class Images extends BaseConfig { /** * Default handler used if no other handler is specified. - * - * @var string */ - public $defaultHandler = 'gd'; + public string $defaultHandler = 'gd'; /** * The path to the image library. * Required for ImageMagick, GraphicsMagick, or NetPBM. - * - * @var string */ - public $libraryPath = '/usr/local/bin/convert'; + public string $libraryPath = '/usr/local/bin/convert'; /** * The available handler classes. * * @var array */ - public $handlers = [ + public array $handlers = [ 'gd' => GDHandler::class, 'imagick' => ImageMagickHandler::class, ]; diff --git a/app/Config/Kint.php b/app/Config/Kint.php index b1016ed57..7e0a0157c 100644 --- a/app/Config/Kint.php +++ b/app/Config/Kint.php @@ -3,7 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; -use Kint\Renderer\Renderer; +use Kint\Renderer\AbstractRenderer; /** * -------------------------------------------------------------------------- @@ -24,18 +24,18 @@ class Kint extends BaseConfig */ public $plugins; - public $maxDepth = 6; - public $displayCalledFrom = true; - public $expanded = false; + public int $maxDepth = 6; + public bool $displayCalledFrom = true; + public bool $expanded = false; /* |-------------------------------------------------------------------------- | RichRenderer Settings |-------------------------------------------------------------------------- */ - public $richTheme = 'aante-light.css'; - public $richFolder = false; - public $richSort = Renderer::SORT_FULL; + public string $richTheme = 'aante-light.css'; + public bool $richFolder = false; + public int $richSort = AbstractRenderer::SORT_FULL; public $richObjectPlugins; public $richTabPlugins; @@ -44,8 +44,8 @@ class Kint extends BaseConfig | CLI Settings |-------------------------------------------------------------------------- */ - public $cliColors = true; - public $cliForceUTF8 = false; - public $cliDetectWidth = true; - public $cliMinWidth = 40; + public bool $cliColors = true; + public bool $cliForceUTF8 = false; + public bool $cliDetectWidth = true; + public int $cliMinWidth = 40; } diff --git a/app/Config/Logger.php b/app/Config/Logger.php index d0fb6f97b..de6644fd9 100644 --- a/app/Config/Logger.php +++ b/app/Config/Logger.php @@ -3,6 +3,7 @@ namespace Config; use CodeIgniter\Config\BaseConfig; +use CodeIgniter\Log\Handlers\FileHandler; class Logger extends BaseConfig { @@ -37,7 +38,7 @@ class Logger extends BaseConfig * * @var array|int */ - public $threshold = 4; + public $threshold = (ENVIRONMENT === 'production') ? 4 : 9; /** * -------------------------------------------------------------------------- @@ -46,10 +47,8 @@ class Logger extends BaseConfig * * Each item that is logged has an associated date. You can use PHP date * codes to set your own date formatting - * - * @var string */ - public $dateFormat = 'Y-m-d H:i:s'; + public string $dateFormat = 'Y-m-d H:i:s'; /** * -------------------------------------------------------------------------- @@ -59,7 +58,7 @@ class Logger extends BaseConfig * The logging system supports multiple actions to be taken when something * is logged. This is done by allowing for multiple Handlers, special classes * designed to write the log to their chosen destinations, whether that is - * a file on the server, a cloud-based service, or even taking actions such + * a file on the getServer, a cloud-based service, or even taking actions such * as emailing the dev team. * * Each handler is defined by the class name used for that handler, and it @@ -73,10 +72,8 @@ class Logger extends BaseConfig * * Handlers are executed in the order defined in this array, starting with * the handler on top and continuing down. - * - * @var array */ - public $handlers = [ + public array $handlers = [ /* * -------------------------------------------------------------------- @@ -140,14 +137,14 @@ class Logger extends BaseConfig * Uncomment this block to use it. */ // 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [ - // /* The log levels this handler can handle. */ - // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'], + // /* The log levels this handler can handle. */ + // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'], // - // /* - // * The message type where the error should go. Can be 0 or 4, or use the - // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4) - // */ - // 'messageType' => 0, + // /* + // * The message type where the error should go. Can be 0 or 4, or use the + // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4) + // */ + // 'messageType' => 0, // ], ]; } diff --git a/app/Config/Migrations.php b/app/Config/Migrations.php index 3170e3892..638fb6ec1 100644 --- a/app/Config/Migrations.php +++ b/app/Config/Migrations.php @@ -15,10 +15,8 @@ class Migrations extends BaseConfig * * You should enable migrations whenever you intend to do a schema migration * and disable it back when you're done. - * - * @var bool */ - public $enabled = true; + public bool $enabled = true; /** * -------------------------------------------------------------------------- @@ -30,10 +28,8 @@ class Migrations extends BaseConfig * level the system is at. It then compares the migration level in this * table to the $config['migration_version'] if they are not the same it * will migrate up. This must be set. - * - * @var string */ - public $table = 'migrations'; + public string $table = 'migrations'; /** * -------------------------------------------------------------------------- @@ -42,13 +38,15 @@ class Migrations extends BaseConfig * * This is the format that will be used when creating new migrations * using the CLI command: - * > php spark migrate:create + * > php spark make:migration * - * Typical formats: + * Note: if you set an unsupported format, migration runner will not find + * your migration files. + * + * Supported formats: * - YmdHis_ * - Y-m-d-His_ * - Y_m_d_His_ - * - * @var string */ - public $timestampFormat = 'YmdHis_';} + public string $timestampFormat = 'YmdHis_'; +} diff --git a/app/Config/Mimes.php b/app/Config/Mimes.php index 4a1134cfd..6b06c4e3a 100644 --- a/app/Config/Mimes.php +++ b/app/Config/Mimes.php @@ -20,10 +20,8 @@ class Mimes { /** * Map of extensions to mime types. - * - * @var array */ - public static $mimes = [ + public static array $mimes = [ 'hqx' => [ 'application/mac-binhex40', 'application/mac-binhex', @@ -527,6 +525,6 @@ class Mimes } } - return null; - } + return null; + } } diff --git a/app/Config/Modules.php b/app/Config/Modules.php index bde4079f7..5b6a639b3 100644 --- a/app/Config/Modules.php +++ b/app/Config/Modules.php @@ -31,6 +31,29 @@ class Modules extends BaseModules */ public $discoverInComposer = true; + /** + * The Composer package list for Auto-Discovery + * This setting is optional. + * + * E.g.: + * [ + * 'only' => [ + * // List up all packages to auto-discover + * 'codeigniter4/shield', + * ], + * ] + * or + * [ + * 'exclude' => [ + * // List up packages to exclude. + * 'pestphp/pest', + * ], + * ] + * + * @var array + */ + public $composerPackages = []; + /** * -------------------------------------------------------------------------- * Auto-Discovery Rules diff --git a/app/Config/Pager.php b/app/Config/Pager.php index 2eb5e87d1..19e526c47 100644 --- a/app/Config/Pager.php +++ b/app/Config/Pager.php @@ -20,7 +20,7 @@ class Pager extends BaseConfig * * @var array */ - public $templates = [ + public array $templates = [ 'default_full' => 'CodeIgniter\Pager\Views\default_full', 'default_simple' => 'CodeIgniter\Pager\Views\default_simple', 'default_head' => 'CodeIgniter\Pager\Views\default_head', @@ -32,10 +32,8 @@ class Pager extends BaseConfig * -------------------------------------------------------------------------- * * The default number of results shown in a single page. - * - * @var int */ - public $perPage = 20; + public int $perPage = 20; /** * -------------------------------------------------------------------------- diff --git a/app/Config/Paths.php b/app/Config/Paths.php index 3ff97302b..d0035fbcf 100644 --- a/app/Config/Paths.php +++ b/app/Config/Paths.php @@ -22,10 +22,8 @@ class Paths * * This must contain the name of your "system" folder. Include * the path if the folder is not in the same directory as this file. - * - * @var string */ - public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; + public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; /** * --------------------------------------------------------------- @@ -38,10 +36,8 @@ class Paths * you do, use a full server path. * * @see http://codeigniter.com/user_guide/general/managing_apps.html - * - * @var string */ - public $appDirectory = __DIR__ . '/..'; + public string $appDirectory = __DIR__ . '/..'; /** * --------------------------------------------------------------- @@ -53,10 +49,8 @@ class Paths * need write permission to a single place that can be tucked away * for maximum security, keeping it out of the app and/or * system directories. - * - * @var string */ - public $writableDirectory = __DIR__ . '/../../writable'; + public string $writableDirectory = __DIR__ . '/../../writable'; /** * --------------------------------------------------------------- @@ -64,10 +58,8 @@ class Paths * --------------------------------------------------------------- * * This variable must contain the name of your "tests" directory. - * - * @var string */ - public $testsDirectory = __DIR__ . '/../../tests'; + public string $testsDirectory = __DIR__ . '/../../tests'; /** * --------------------------------------------------------------- @@ -78,8 +70,6 @@ class Paths * contains the view files used by your application. By * default this is in `app/Views`. This value * is used when no value is provided to `Services::renderer()`. - * - * @var string */ - public $viewDirectory = __DIR__ . '/../Views'; + public string $viewDirectory = __DIR__ . '/../Views'; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 025a0ae55..05d7048e9 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -5,12 +5,6 @@ namespace Config; // Create a new instance of our RouteCollection class. $routes = Services::routes(); -// Load the system's routing file first, so that the app and ENVIRONMENT -// can override as needed. -if (is_file(SYSTEMPATH . 'Config/Routes.php')) { - require SYSTEMPATH . 'Config/Routes.php'; -} - /* * -------------------------------------------------------------------- * Router Setup @@ -25,7 +19,7 @@ $routes->set404Override(); // where controller filters or CSRF protection are bypassed. // If you don't want to define all routes, please use the Auto Routing (Improved). // Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true. -$routes->setAutoRoute(true); +// $routes->setAutoRoute(false); /* * -------------------------------------------------------------------- diff --git a/app/Config/Security.php b/app/Config/Security.php index f583e74bd..7dc01a348 100644 --- a/app/Config/Security.php +++ b/app/Config/Security.php @@ -15,7 +15,7 @@ class Security extends BaseConfig * * @var string 'cookie' or 'session' */ - public $csrfProtection = 'cookie'; + public string $csrfProtection = 'cookie'; /** * -------------------------------------------------------------------------- @@ -23,10 +23,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Randomize the CSRF Token for added security. - * - * @var bool */ - public $tokenRandomize = false; + public bool $tokenRandomize = false; /** * -------------------------------------------------------------------------- @@ -34,10 +32,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Token name for Cross Site Request Forgery protection. - * - * @var string */ - public $tokenName = 'csrf_ospos_v4'; + public string $tokenName = 'csrf_ospos_v4'; /** * -------------------------------------------------------------------------- @@ -45,10 +41,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Header name for Cross Site Request Forgery protection. - * - * @var string */ - public $headerName = 'X-CSRF-TOKEN'; + public string $headerName = 'X-CSRF-TOKEN'; /** * -------------------------------------------------------------------------- @@ -56,10 +50,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Cookie name for Cross Site Request Forgery protection. - * - * @var string */ - public $cookieName = 'csrf_cookie_ospos_v4'; + public string $cookieName = 'csrf_cookie_ospos_v4'; /** * -------------------------------------------------------------------------- @@ -69,10 +61,8 @@ class Security extends BaseConfig * Expiration time for Cross Site Request Forgery protection cookie. * * Defaults to two hours (in seconds). - * - * @var int */ - public $expires = 7200; + public int $expires = 7200; /** * -------------------------------------------------------------------------- @@ -80,10 +70,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Regenerate CSRF Token on every submission. - * - * @var bool */ - public $regenerate = true; + public bool $regenerate = true; /** * -------------------------------------------------------------------------- @@ -91,10 +79,8 @@ class Security extends BaseConfig * -------------------------------------------------------------------------- * * Redirect to previous page with error on failure. - * - * @var bool */ - public $redirect = false; + public bool $redirect = false; /** * -------------------------------------------------------------------------- @@ -109,9 +95,7 @@ class Security extends BaseConfig * * @see https://portswigger.net/web-security/csrf/samesite-cookies * - * @var string - * * @deprecated `Config\Cookie` $samesite property is used. */ - public $samesite = 'Lax'; + public string $samesite = 'Lax'; } diff --git a/app/Config/Toolbar.php b/app/Config/Toolbar.php index 7183e1336..ecab7a2cc 100644 --- a/app/Config/Toolbar.php +++ b/app/Config/Toolbar.php @@ -33,7 +33,7 @@ class Toolbar extends BaseConfig * * @var string[] */ - public $collectors = [ + public array $collectors = [ Timers::class, Database::class, Logs::class, @@ -49,12 +49,10 @@ class Toolbar extends BaseConfig * Collect Var Data * -------------------------------------------------------------------------- * - * If set to false var data from the views will not be colleted. Usefull to + * If set to false var data from the views will not be colleted. Useful to * avoid high memory usage when there are lots of data passed to the view. - * - * @var bool */ - public $collectVarData = true; + public bool $collectVarData = true; /** * -------------------------------------------------------------------------- @@ -64,10 +62,8 @@ class Toolbar extends BaseConfig * `$maxHistory` sets a limit on the number of past requests that are stored, * helping to conserve file space used to store them. You can set it to * 0 (zero) to not have any history stored, or -1 for unlimited history. - * - * @var int */ - public $maxHistory = 20; + public int $maxHistory = 20; /** * -------------------------------------------------------------------------- @@ -76,10 +72,8 @@ class Toolbar extends BaseConfig * * The full path to the the views that are used by the toolbar. * This MUST have a trailing slash. - * - * @var string */ - public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; + public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; /** * -------------------------------------------------------------------------- @@ -92,8 +86,6 @@ class Toolbar extends BaseConfig * with hundreds of queries. * * `$maxQueries` defines the maximum amount of queries that will be stored. - * - * @var int */ - public $maxQueries = 100; + public int $maxQueries = 100; } diff --git a/app/Config/UserAgents.php b/app/Config/UserAgents.php index e1dbfa63d..fda73748d 100644 --- a/app/Config/UserAgents.php +++ b/app/Config/UserAgents.php @@ -23,7 +23,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $platforms = [ + public array $platforms = [ 'windows nt 10.0' => 'Windows 10', 'windows nt 6.3' => 'Windows 8.1', 'windows nt 6.2' => 'Windows 8', @@ -78,7 +78,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $browsers = [ + public array $browsers = [ 'OPR' => 'Opera', 'Flock' => 'Flock', 'Edge' => 'Spartan', @@ -119,7 +119,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $mobiles = [ + public array $mobiles = [ // legacy array, old values commented out 'mobileexplorer' => 'Mobile Explorer', // 'openwave' => 'Open Wave', @@ -228,7 +228,7 @@ class UserAgents extends BaseConfig * * @var array */ - public $robots = [ + public array $robots = [ 'googlebot' => 'Googlebot', 'msnbot' => 'MSNBot', 'baiduspider' => 'Baiduspider', diff --git a/app/Config/Validation.php b/app/Config/Validation.php index 0febf29d0..289d037e3 100644 --- a/app/Config/Validation.php +++ b/app/Config/Validation.php @@ -3,12 +3,13 @@ namespace Config; use CodeIgniter\Config\BaseConfig; -use CodeIgniter\Validation\CreditCardRules; -use CodeIgniter\Validation\FileRules; -use CodeIgniter\Validation\FormatRules; -use CodeIgniter\Validation\Rules; +use CodeIgniter\Validation\StrictRules\CreditCardRules; +use CodeIgniter\Validation\StrictRules\FileRules; +use CodeIgniter\Validation\StrictRules\FormatRules; +use CodeIgniter\Validation\StrictRules\Rules; use App\Libraries\MY_Validation; + class Validation extends BaseConfig { // -------------------------------------------------------------------- @@ -21,7 +22,7 @@ class Validation extends BaseConfig * * @var string[] */ - public $ruleSets = [ + public array $ruleSets = [ Rules::class, FormatRules::class, FileRules::class, @@ -35,8 +36,7 @@ class Validation extends BaseConfig * * @var array */ - public $templates = [ - 'error' => 'app\Views\errors\error.php', + public array $templates = [ 'list' => 'CodeIgniter\Validation\Views\list', 'single' => 'CodeIgniter\Validation\Views\single', ]; diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 122db5f9a..ecea16206 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -37,6 +37,12 @@ abstract class BaseController extends Controller */ protected $helpers = []; + /** + * Be sure to declare properties for any property fetch you initialized. + * The creation of dynamic property is deprecated in PHP 8.2. + */ + // protected $session; + /** * Constructor. */ diff --git a/app/Language/en-US/Error.php b/app/Language/en-US/Error.php deleted file mode 100644 index ec406866d..000000000 --- a/app/Language/en-US/Error.php +++ /dev/null @@ -1,5 +0,0 @@ - "You do not have permission to access the module named", - "unknown" => "Unexpected error", -]; diff --git a/app/Language/en-US/Errors.php b/app/Language/en-US/Errors.php new file mode 100644 index 000000000..87ab2a978 --- /dev/null +++ b/app/Language/en-US/Errors.php @@ -0,0 +1,9 @@ + "You do not have permission to access the module named", + "pageNotFound" => "404 Page Not Found", + "sorryCannotFind" => "Sorry! Cannot seem to find the page you were looking for.", + "unknown" => "Unexpected error", + "weHitASnag" => "We seem to have hit a snag. Please try again later...", + "whoops" => "Whoops!", +]; diff --git a/app/Models/Module.php b/app/Models/Module.php index 8e61cc686..5610e8aab 100644 --- a/app/Models/Module.php +++ b/app/Models/Module.php @@ -22,7 +22,7 @@ class Module extends Model return lang($row->name_lang_key); } - return lang('Error.unknown'); + return lang('Errors.unknown'); } public function get_module_desc(string $module_id): string //TODO: This method doesn't seem to be called in the code. Is it needed? Also, probably should change the name to get_module_description() @@ -37,7 +37,7 @@ class Module extends Model return lang($row->desc_lang_key); } - return lang('Error.unknown'); + return lang('Errors.unknown'); } public function get_all_permissions(): ResultInterface diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php index 5ba9f8add..c3010132f 100644 --- a/app/Views/errors/html/error_404.php +++ b/app/Views/errors/html/error_404.php @@ -2,7 +2,7 @@ - 404 Page Not Found + <?= lang('Errors.pageNotFound') ?> - diff --git a/app/Views/errors/html/production.php b/app/Views/errors/html/production.php index 9faa4a15b..2f59a8de1 100644 --- a/app/Views/errors/html/production.php +++ b/app/Views/errors/html/production.php @@ -4,9 +4,9 @@ - Whoops! + <?= lang('Errors.whoops') ?> - @@ -14,9 +14,9 @@
-

Whoops!

+

-

We seem to have hit a snag. Please try again later...

+

diff --git a/app/Views/no_access.php b/app/Views/no_access.php index 7053413e4..ad7fca392 100644 --- a/app/Views/no_access.php +++ b/app/Views/no_access.php @@ -2,4 +2,4 @@ /** * @var string $module_name */ -echo lang('Error.no_permission_module') . " $module_name" . (!empty($permission_id) ? " ($permission_id)" : ''); \ No newline at end of file +echo lang('Errors.no_permission_module') . " $module_name" . (!empty($permission_id) ? " ($permission_id)" : ''); \ No newline at end of file