diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index ac5e632ad2a3..3352e27c665b 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -1,7 +1,5 @@ setRule($field, null, $rules); @@ -380,10 +380,12 @@ public static function wait(int $seconds, bool $countdown = false) /** * if operating system === windows + * + * @return boolean */ - public static function isWindows() + public static function isWindows(): bool { - return stripos(PHP_OS, 'WIN') === 0; + return stripos(PHP_OS, 'WIN') === 0; } //-------------------------------------------------------------------- @@ -436,7 +438,7 @@ public static function clearScreen() * * @return string The color coded string */ - public static function color(string $text, string $foreground, string $background = null, string $format = null) + public static function color(string $text, string $foreground, string $background = null, string $format = null): string { if (static::isWindows() && ! isset($_SERVER['ANSICON'])) { @@ -655,7 +657,7 @@ public static function wrap(string $string = null, int $max = 0, int $pad_left = * Parses the command line it was called from and collects all * options and valid segments. * - * I tried to use getopt but had it fail occassionally to find any + * I tried to use getopt but had it fail occasionally to find any * options but argc has always had our back. We don't have all of the power * of getopt but this does us just fine. */ @@ -706,7 +708,7 @@ protected static function parseCommandLine() * * @return string */ - public static function getURI() + public static function getURI(): string { return implode('/', static::$segments); } @@ -743,7 +745,7 @@ public static function getSegment(int $index) * * @return array */ - public static function getSegments() + public static function getSegments(): array { return static::$segments; } @@ -779,7 +781,7 @@ public static function getOption(string $name) * * @return array */ - public static function getOptions() + public static function getOptions(): array { return static::$options; } @@ -819,12 +821,12 @@ public static function getOptionString(): string //-------------------------------------------------------------------- /** - * Returns a well formated table + * Returns a well formatted table * * @param array $tbody List of rows * @param array $thead List of columns * - * @return string + * @return void */ public static function table(array $tbody, array $thead = []) { diff --git a/system/CLI/CommandRunner.php b/system/CLI/CommandRunner.php index 012c037b086c..9ccee58ebf99 100644 --- a/system/CLI/CommandRunner.php +++ b/system/CLI/CommandRunner.php @@ -63,6 +63,8 @@ class CommandRunner extends Controller * * @param string $method * @param array ...$params + * + * @throws \ReflectionException */ public function _remap($method, ...$params) { @@ -81,6 +83,7 @@ public function _remap($method, ...$params) * @param array $params * * @return mixed + * @throws \ReflectionException */ public function index(array $params) { @@ -128,6 +131,8 @@ protected function runCommand(string $command, array $params) /** * Scans all Commands directories and prepares a list * of each command with it's group and file. + * + * @throws \ReflectionException */ protected function createCommandList() { diff --git a/system/CLI/Console.php b/system/CLI/Console.php index 8b596b0315ed..6d19e259fb72 100644 --- a/system/CLI/Console.php +++ b/system/CLI/Console.php @@ -68,7 +68,7 @@ public function __construct(CodeIgniter $app) * @param boolean $useSafeOutput * * @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed - * @throws \CodeIgniter\HTTP\RedirectException + * @throws \CodeIgniter\Router\RedirectException */ public function run(bool $useSafeOutput = false) { diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php index f1b1c003d01a..aafe092d9b49 100644 --- a/system/Cache/Handlers/PredisHandler.php +++ b/system/Cache/Handlers/PredisHandler.php @@ -37,7 +37,7 @@ */ use CodeIgniter\Cache\CacheInterface; -use CodeIgniter\CriticalError; +use CodeIgniter\Exceptions\CriticalError; class PredisHandler implements CacheInterface { diff --git a/system/Cache/Handlers/RedisHandler.php b/system/Cache/Handlers/RedisHandler.php index 8336f6d661ce..1df728d8ed94 100644 --- a/system/Cache/Handlers/RedisHandler.php +++ b/system/Cache/Handlers/RedisHandler.php @@ -36,7 +36,6 @@ * @filesource */ -use CodeIgniter\Exceptions\CriticalError; use CodeIgniter\Cache\CacheInterface; class RedisHandler implements CacheInterface @@ -106,28 +105,19 @@ public function initialize() $config = $this->config; $this->redis = new \Redis(); + if (!$this->redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout'])) + { + log_message('error', 'Cache: Redis connection failed. Check your configuration.'); + } - try + if (isset($config['password']) && !$this->redis->auth($config['password'])) { - if (! $this->redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']) - ) - { - // log_message('error', 'Cache: Redis connection failed. Check your configuration.'); - } - - if (isset($config['password']) && ! $this->redis->auth($config['password'])) - { - log_message('error', 'Cache: Redis authentication failed.'); - } - - if (isset($config['database']) && ! $this->redis->select($config['database'])) - { - log_message('error', 'Cache: Redis select database failed.'); - } + log_message('error', 'Cache: Redis authentication failed.'); } - catch (\RedisException $e) + + if (isset($config['database']) && !$this->redis->select($config['database'])) { - throw new CriticalError('Cache: Redis connection refused (' . $e->getMessage() . ')'); + log_message('error', 'Cache: Redis select database failed.'); } } diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index a646a27b3477..5d43c4b52ed9 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -615,7 +615,7 @@ public function cachePage(Cache $config) * * @return array */ - public function getPerformanceStats() + public function getPerformanceStats(): array { return [ 'startTime' => $this->startTime, diff --git a/system/Commands/Help.php b/system/Commands/Help.php index 19852a89d1ee..fbd92932aae0 100644 --- a/system/Commands/Help.php +++ b/system/Commands/Help.php @@ -37,7 +37,6 @@ */ use CodeIgniter\CLI\BaseCommand; -use CodeIgniter\CLI\CLI; /** * CI Help command for the spark script. diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index f8c8092d24d3..fc00b1cef6f6 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -15,7 +15,7 @@ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - *RouRouddfdf + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index b74dd7a74c7b..fd6f2244c921 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -167,6 +167,8 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr /** * Provides external libraries a simple way to register one or more * options into a config file. + * + * @throws \ReflectionException */ protected function registerProperties() { diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 41c4bb67904b..57aa06fbfef2 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -298,7 +298,7 @@ protected function render(\Throwable $exception, int $statusCode) * * @return array */ - protected function collectVars(\Throwable $exception, int $statusCode) + protected function collectVars(\Throwable $exception, int $statusCode): array { return [ 'title' => get_class($exception), @@ -356,7 +356,7 @@ protected function determineCodes(\Throwable $exception): array * * @return string */ - public static function cleanPath($file) + public static function cleanPath(string $file): string { if (strpos($file, APPPATH) === 0) { @@ -403,13 +403,13 @@ public static function describeMemory(int $bytes): string /** * Creates a syntax-highlighted version of a PHP file. * - * @param $file - * @param $lineNumber - * @param integer $lines + * @param string $file + * @param integer $lineNumber + * @param integer $lines * * @return boolean|string */ - public static function highlightFile($file, $lineNumber, $lines = 15) + public static function highlightFile(string $file, int $lineNumber, int $lines = 15) { if (empty($file) || ! is_readable($file)) { diff --git a/system/Debug/Iterator.php b/system/Debug/Iterator.php index a8c0e33ab2bd..1cce200e9484 100644 --- a/system/Debug/Iterator.php +++ b/system/Debug/Iterator.php @@ -129,7 +129,7 @@ public function run($iterations = 1000, $output = true) * * @return string */ - public function getReport() + public function getReport(): string { if (empty($this->results)) { diff --git a/system/Debug/Timer.php b/system/Debug/Timer.php index b124a388f238..47b54ad5ab9c 100644 --- a/system/Debug/Timer.php +++ b/system/Debug/Timer.php @@ -146,7 +146,7 @@ public function getElapsedTime(string $name, int $decimals = 4) * * @return array */ - public function getTimers(int $decimals = 4) + public function getTimers(int $decimals = 4): array { $timers = $this->timers; @@ -172,7 +172,7 @@ public function getTimers(int $decimals = 4) * * @return boolean */ - public function has(string $name) + public function has(string $name): bool { return array_key_exists(strtolower($name), $this->timers); } diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 2cf3e7098eff..2b7e307053e0 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -273,7 +273,7 @@ protected function collectTimelineData($collectors): array * * @return array */ - protected function collectVarData()// : array + protected function collectVarData(): array { $data = []; @@ -300,7 +300,7 @@ protected function collectVarData()// : array * * @return float */ - protected function roundTo($number, $increments = 5) + protected function roundTo($number, $increments = 5): float { $increments = 1 / $increments; @@ -440,7 +440,7 @@ public function respond() * * @return string */ - protected function format(string $data, string $format = 'html') + protected function format(string $data, string $format = 'html'): string { $data = json_decode($data, true); diff --git a/system/Debug/Toolbar/Collectors/BaseCollector.php b/system/Debug/Toolbar/Collectors/BaseCollector.php index dd06de6433bc..a4ab03b1f33f 100644 --- a/system/Debug/Toolbar/Collectors/BaseCollector.php +++ b/system/Debug/Toolbar/Collectors/BaseCollector.php @@ -172,9 +172,9 @@ public function timelineData(): array * Does this Collector have data that should be shown in the * 'Vars' tab? * - * @return mixed + * @return boolean */ - public function hasVarData() + public function hasVarData(): bool { return (bool) $this->hasVarData; } @@ -249,7 +249,7 @@ public function display(): array * * @return string */ - public function cleanPath($file) + public function cleanPath(string $file): string { if (strpos($file, APPPATH) === 0) { @@ -284,7 +284,7 @@ public function getBadgeValue() * * @return boolean */ - public function isEmpty() + public function isEmpty(): bool { return false; } @@ -302,7 +302,7 @@ public function icon(): string return ''; } - public function getAsArray() + public function getAsArray(): array { return [ 'title' => $this->getTitle(), diff --git a/system/Debug/Toolbar/Collectors/Config.php b/system/Debug/Toolbar/Collectors/Config.php index cd23cc747016..8053fe3dca30 100644 --- a/system/Debug/Toolbar/Collectors/Config.php +++ b/system/Debug/Toolbar/Collectors/Config.php @@ -6,7 +6,7 @@ class Config { - public static function display() + public static function display(): array { $config = config(App::class); diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php index f1d31fd7290e..d5c0aeeedd37 100644 --- a/system/Debug/Toolbar/Collectors/Database.php +++ b/system/Debug/Toolbar/Collectors/Database.php @@ -226,7 +226,7 @@ public function display(): array * * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { return count(static::$queries); } @@ -251,7 +251,7 @@ public function getTitleDetails(): string * * @return boolean */ - public function isEmpty() + public function isEmpty(): bool { return empty(static::$queries); } diff --git a/system/Debug/Toolbar/Collectors/Events.php b/system/Debug/Toolbar/Collectors/Events.php index 9ad73cb96c33..6c8ded88e7c9 100644 --- a/system/Debug/Toolbar/Collectors/Events.php +++ b/system/Debug/Toolbar/Collectors/Events.php @@ -36,7 +36,7 @@ * @filesource */ -use CodeIgniter\Services; +use CodeIgniter\Config\Services; use CodeIgniter\View\RendererInterface; /** @@ -160,8 +160,10 @@ public function display(): array /** * Gets the "badge" value for the button. + * + * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { return count(\CodeIgniter\Events\Events::getPerformanceLogs()); } diff --git a/system/Debug/Toolbar/Collectors/Files.php b/system/Debug/Toolbar/Collectors/Files.php index 34c6fc5b20aa..15a104726a10 100644 --- a/system/Debug/Toolbar/Collectors/Files.php +++ b/system/Debug/Toolbar/Collectors/Files.php @@ -127,7 +127,7 @@ public function display(): array * * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { return count(get_included_files()); } diff --git a/system/Debug/Toolbar/Collectors/History.php b/system/Debug/Toolbar/Collectors/History.php index 062d160d5829..9c329585f8ac 100644 --- a/system/Debug/Toolbar/Collectors/History.php +++ b/system/Debug/Toolbar/Collectors/History.php @@ -144,12 +144,12 @@ public function display(): array * * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { return count($this->files); } - public function isEmpty() + public function isEmpty(): bool { return empty($this->files); } diff --git a/system/Debug/Toolbar/Collectors/Logs.php b/system/Debug/Toolbar/Collectors/Logs.php index 5e0c7e9eff28..f2c35ef27a3c 100644 --- a/system/Debug/Toolbar/Collectors/Logs.php +++ b/system/Debug/Toolbar/Collectors/Logs.php @@ -93,8 +93,10 @@ public function display(): array /** * Does this collector actually have any data to display? + * + * @return boolean */ - public function isEmpty() + public function isEmpty(): bool { $this->collectLogs(); diff --git a/system/Debug/Toolbar/Collectors/Routes.php b/system/Debug/Toolbar/Collectors/Routes.php index b4176dc153e2..ace97012953c 100644 --- a/system/Debug/Toolbar/Collectors/Routes.php +++ b/system/Debug/Toolbar/Collectors/Routes.php @@ -74,6 +74,7 @@ class Routes extends BaseCollector * Returns the data of this collector to be formatted in the toolbar * * @return array + * @throws \ReflectionException */ public function display(): array { @@ -137,7 +138,7 @@ public function display(): array * * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { $rawRoutes = Services::routes(true); diff --git a/system/Debug/Toolbar/Collectors/Views.php b/system/Debug/Toolbar/Collectors/Views.php index d1ec28562f85..7889262cdaae 100644 --- a/system/Debug/Toolbar/Collectors/Views.php +++ b/system/Debug/Toolbar/Collectors/Views.php @@ -154,9 +154,9 @@ protected function formatTimelineData(): array * ], * ]; * - * @return null + * @return array */ - public function getVarData() + public function getVarData(): array { return [ 'View Data' => $this->viewer->getData(), @@ -170,7 +170,7 @@ public function getVarData() * * @return integer */ - public function getBadgeValue() + public function getBadgeValue(): int { return count($this->viewer->getPerformanceData()); } diff --git a/system/Entity.php b/system/Entity.php index f2b99a2ae846..cee612856670 100644 --- a/system/Entity.php +++ b/system/Entity.php @@ -454,6 +454,7 @@ protected function mapProperty(string $key) * @param $value * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ protected function mutateDate($value) { @@ -484,7 +485,7 @@ protected function mutateDate($value) /** * Provides the ability to cast an item as a specific data type. - * Add ? at the beginning of $type (i.e. ?string) to get NULL instead of castig $value if $value === null + * Add ? at the beginning of $type (i.e. ?string) to get NULL instead of casting $value if $value === null * * @param $value * @param string $type diff --git a/system/Filters/CSRF.php b/system/Filters/CSRF.php index 914e6191710a..f4edd226cafb 100644 --- a/system/Filters/CSRF.php +++ b/system/Filters/CSRF.php @@ -40,7 +40,6 @@ * @codeCoverageIgnore */ -use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Security\Exceptions\SecurityException; diff --git a/system/Filters/DebugToolbar.php b/system/Filters/DebugToolbar.php index 9f83bb6e359e..9a3ac29e64cc 100644 --- a/system/Filters/DebugToolbar.php +++ b/system/Filters/DebugToolbar.php @@ -36,7 +36,6 @@ * @filesource */ -use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; @@ -48,7 +47,7 @@ class DebugToolbar implements FilterInterface * * @param RequestInterface|\CodeIgniter\HTTP\IncomingRequest $request * - * @return mixed + * @return void */ public function before(RequestInterface $request) { @@ -63,7 +62,7 @@ public function before(RequestInterface $request) * @param RequestInterface|\CodeIgniter\HTTP\IncomingRequest $request * @param ResponseInterface|\CodeIgniter\HTTP\Response $response * - * @return mixed + * @return void */ public function after(RequestInterface $request, ResponseInterface $response) { diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 7b6a41654a8f..a00076c38b55 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -117,7 +117,7 @@ public function setResponse(ResponseInterface $response) * @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\ResponseInterface|mixed * @throws \CodeIgniter\Filters\Exceptions\FilterException */ - public function run(string $uri, $position = 'before') + public function run(string $uri, string $position = 'before') { $this->initialize(strtolower($uri)); @@ -142,7 +142,7 @@ public function run(string $uri, $position = 'before') if ($position === 'before') { - $result = $class->before($this->request, $this->arguments[$alias] ?? null); + $result = $class->before($this->request); if ($result instanceof RequestInterface) { diff --git a/system/Filters/Honeypot.php b/system/Filters/Honeypot.php index e0c55f340ada..04d7445a7a20 100644 --- a/system/Filters/Honeypot.php +++ b/system/Filters/Honeypot.php @@ -36,7 +36,6 @@ * @filesource */ -use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; @@ -49,7 +48,7 @@ class Honeypot implements FilterInterface * Checks if Honeypot field is empty; if not * then the requester is a bot * - * @param CodeIgniter\HTTP\RequestInterface $request + * @param \CodeIgniter\HTTP\RequestInterface $request * * @return mixed */ @@ -65,8 +64,8 @@ public function before(RequestInterface $request) /** * Attach a honypot to the current response. * - * @param CodeIgniter\HTTP\RequestInterface $request - * @param CodeIgniter\HTTP\ResponseInterface $response + * @param \CodeIgniter\HTTP\RequestInterface $request + * @param \CodeIgniter\HTTP\ResponseInterface $response * @return mixed */ public function after(RequestInterface $request, ResponseInterface $response) diff --git a/system/HTTP/DownloadResponse.php b/system/HTTP/DownloadResponse.php index 100c7e29d3d1..4c1975f0a5b0 100644 --- a/system/HTTP/DownloadResponse.php +++ b/system/HTTP/DownloadResponse.php @@ -202,11 +202,11 @@ private function getDownloadFileName(): string } /** - * get Content-Disponsition Header string. + * get Content-Disposition Header string. * * @return string */ - private function getContentDisponsition() : string + private function getContentDisposition() : string { $download_filename = $this->getDownloadFileName(); @@ -375,7 +375,7 @@ public function buildHeaders() $this->setContentTypeByMimeType(); } - $this->setHeader('Content-Disposition', $this->getContentDisponsition()); + $this->setHeader('Content-Disposition', $this->getContentDisposition()); $this->setHeader('Expires-Disposition', '0'); $this->setHeader('Content-Transfer-Encoding', 'binary'); $this->setHeader('Content-Length', (string)$this->getContentLength()); diff --git a/system/HTTP/Files/FileCollection.php b/system/HTTP/Files/FileCollection.php index a3aad603268a..74e3405a388b 100644 --- a/system/HTTP/Files/FileCollection.php +++ b/system/HTTP/Files/FileCollection.php @@ -243,7 +243,7 @@ protected function fixFilesArray(array $data): array new \RecursiveArrayIterator($value), \RecursiveIteratorIterator::SELF_FIRST ); - foreach ($iterator as $key => $value) + foreach ($iterator as $key => $val) { array_splice($stack, $iterator->getDepth() + 1); $pointer = &$stack[count($stack) - 1]; @@ -251,7 +251,7 @@ protected function fixFilesArray(array $data): array $stack[] = &$pointer; if (! $iterator->hasChildren()) { - $pointer[$field] = $value; + $pointer[$field] = $val; } } } @@ -270,7 +270,7 @@ protected function fixFilesArray(array $data): array * * @return mixed */ - protected function getValueDotNotationSyntax($index, $value) + protected function getValueDotNotationSyntax(array $index, array $value) { if (is_array($index) && ! empty($index)) { diff --git a/system/HTTP/Files/UploadedFile.php b/system/HTTP/Files/UploadedFile.php index b4b97fc3818a..8b703913edd3 100644 --- a/system/HTTP/Files/UploadedFile.php +++ b/system/HTTP/Files/UploadedFile.php @@ -259,11 +259,11 @@ public function getError(): int /** * Get error string * - * @staticvar array $errors + * @var array $errors * * @return string */ - public function getErrorString() + public function getErrorString(): string { $errors = [ UPLOAD_ERR_OK => lang('HTTP.uploadErrOk'), @@ -393,7 +393,7 @@ public function isValid(): bool * @param string $fileName the name to rename the file to. * @return string file full path */ - public function store($folderName = null, $fileName = null): string + public function store(string $folderName = null, string $fileName = null): string { $folderName = $folderName ?? date('Ymd'); $fileName = $fileName ?? $this->getRandomName(); diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 0deb9c998c88..f237b2dffa50 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -528,7 +528,7 @@ public function getOldInput(string $key) * Returns an array of all files that have been uploaded with this * request. Each file is represented by an UploadedFile instance. * - * @return Files\FileCollection + * @return array */ public function getFiles() { @@ -570,7 +570,7 @@ public function getFile(string $fileID) * @param string $protocol * @param string $baseURL */ - protected function detectURI($protocol, $baseURL) + protected function detectURI(string $protocol, string $baseURL) { $this->uri->setPath($this->detectPath($protocol)); @@ -612,7 +612,7 @@ protected function detectURI($protocol, $baseURL) * * @return string */ - public function detectPath($protocol = '') + public function detectPath(string $protocol = ''): string { if (empty($protocol)) { @@ -648,7 +648,7 @@ public function detectPath($protocol = '') * * @return string */ - public function negotiate(string $type, array $supported, bool $strictMatch = false) + public function negotiate(string $type, array $supported, bool $strictMatch = false): string { if (is_null($this->negotiator)) { @@ -773,7 +773,7 @@ protected function parseQueryString(): string * * @return string */ - protected function removeRelativeDirectory($uri) + protected function removeRelativeDirectory(string $uri): string { $uris = []; $tok = strtok($uri, '/'); diff --git a/system/HTTP/Response.php b/system/HTTP/Response.php index 825307f68ea3..8808a7f64fde 100644 --- a/system/HTTP/Response.php +++ b/system/HTTP/Response.php @@ -807,7 +807,7 @@ public function redirect(string $uri, string $method = 'auto', int $code = null) /** * Set a cookie * - * Accepts an arbitrary number of binds (up to 7) or an associateive + * Accepts an arbitrary number of binds (up to 7) or an associative * array in the first parameter containing all the values. * * @param string|array $name Cookie name or array containing binds diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index 28e929dc55d4..bd09adff9e19 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -327,7 +327,7 @@ public function showPassword(bool $val = true) * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 * @return string The URI host. */ - public function getHost() + public function getHost(): string { return $this->host; } @@ -539,15 +539,15 @@ public function __toString() /** * Builds a representation of the string from the component parts. * - * @param $scheme - * @param $authority - * @param $path - * @param $query - * @param $fragment + * @param string $scheme + * @param string $authority + * @param string $path + * @param string $query + * @param string $fragment * * @return string */ - public static function createURIString($scheme = null, $authority = null, $path = null, $query = null, $fragment = null) + public static function createURIString(string $scheme = null, string $authority = null, string $path = null, string $query = null, string $fragment = null): string { $uri = ''; if (! empty($scheme)) @@ -962,9 +962,9 @@ protected function filterPath(string $path = null) /** * Saves our parts from a parse_url call. * - * @param $parts + * @param array $parts */ - protected function applyParts($parts) + protected function applyParts(array $parts) { if (! empty($parts['host'])) { @@ -1107,7 +1107,7 @@ public function resolveRelativeURI(string $uri) * * @return string */ - protected function mergePaths(URI $base, URI $reference) + protected function mergePaths(URI $base, URI $reference): string { if (! empty($base->getAuthority()) && empty($base->getPath())) { diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index 1b8ecdb14100..4b39c6b92f62 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -1,5 +1,6 @@ isBrowser) { @@ -139,7 +140,7 @@ public function isBrowser($key = null) * * @return boolean */ - public function isRobot($key = null) + public function isRobot(string $key = null): bool { if (! $this->isRobot) { @@ -165,7 +166,7 @@ public function isRobot($key = null) * * @return boolean */ - public function isMobile($key = null) + public function isMobile(string $key = null): bool { if (! $this->isMobile) { @@ -189,7 +190,7 @@ public function isMobile($key = null) * * @return boolean */ - public function isReferral() + public function isReferral(): bool { if (! isset($this->referrer)) { @@ -216,7 +217,7 @@ public function isReferral() * * @return string */ - public function getAgentString() + public function getAgentString(): string { return $this->agent; } @@ -228,7 +229,7 @@ public function getAgentString() * * @return string */ - public function getPlatform() + public function getPlatform(): string { return $this->platform; } @@ -240,7 +241,7 @@ public function getPlatform() * * @return string */ - public function getBrowser() + public function getBrowser(): string { return $this->browser; } @@ -252,7 +253,7 @@ public function getBrowser() * * @return string */ - public function getVersion() + public function getVersion(): string { return $this->version; } @@ -264,7 +265,7 @@ public function getVersion() * * @return string */ - public function getRobot() + public function getRobot(): string { return $this->robot; } @@ -275,7 +276,7 @@ public function getRobot() * * @return string */ - public function getMobile() + public function getMobile(): string { return $this->mobile; } @@ -285,9 +286,9 @@ public function getMobile() /** * Get the referrer * - * @return boolean + * @return string */ - public function getReferrer() + public function getReferrer(): string { return empty($_SERVER['HTTP_REFERER']) ? '' : trim($_SERVER['HTTP_REFERER']); } @@ -301,7 +302,7 @@ public function getReferrer() * * @return void */ - public function parse($string) + public function parse(string $string) { // Reset values $this->isBrowser = false; @@ -325,7 +326,7 @@ public function parse($string) /** * Compile the User Agent Data * - * @return boolean + * @return void */ protected function compileData() { @@ -347,7 +348,7 @@ protected function compileData() * * @return boolean */ - protected function setPlatform() + protected function setPlatform(): bool { if (is_array($this->config->platforms) && $this->config->platforms) { @@ -374,7 +375,7 @@ protected function setPlatform() * * @return boolean */ - protected function setBrowser() + protected function setBrowser(): bool { if (is_array($this->config->browsers) && $this->config->browsers) { @@ -402,7 +403,7 @@ protected function setBrowser() * * @return boolean */ - protected function setRobot() + protected function setRobot(): bool { if (is_array($this->config->robots) && $this->config->robots) { @@ -429,7 +430,7 @@ protected function setRobot() * * @return boolean */ - protected function setMobile() + protected function setMobile(): bool { if (is_array($this->config->mobiles) && $this->config->mobiles) { @@ -455,7 +456,7 @@ protected function setMobile() * * @return string */ - public function __toString() + public function __toString(): string { return $this->getAgentString(); } diff --git a/system/I18n/Time.php b/system/I18n/Time.php index 45114b6e0a84..52648534e6f6 100644 --- a/system/I18n/Time.php +++ b/system/I18n/Time.php @@ -184,6 +184,7 @@ public static function today($timezone = null, string $locale = null) * @param string|null $locale * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function yesterday($timezone = null, string $locale = null) { @@ -199,6 +200,7 @@ public static function yesterday($timezone = null, string $locale = null) * @param string|null $locale * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function tomorrow($timezone = null, string $locale = null) { @@ -257,6 +259,7 @@ public static function createFromTime(int $hour = null, int $minutes = null, int * @param string|null $locale * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function create(int $year = null, int $month = null, int $day = null, int $hour = null, int $minutes = null, int $seconds = null, $timezone = null, string $locale = null) { @@ -281,6 +284,7 @@ public static function create(int $year = null, int $month = null, int $day = nu * @param DateTimeZone $timeZone * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function createFromFormat($format, $datetime, $timeZone = null) { @@ -299,6 +303,7 @@ public static function createFromFormat($format, $datetime, $timeZone = null) * @param string|null $locale * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function createFromTimestamp(int $timestamp, $timeZone = null, string $locale = null) { @@ -314,6 +319,7 @@ public static function createFromTimestamp(int $timestamp, $timeZone = null, str * @param string|null $locale * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ public static function instance(\DateTime $dateTime, string $locale = null) { @@ -329,6 +335,7 @@ public static function instance(\DateTime $dateTime, string $locale = null) * Converts the current instance to a mutable DateTime object. * * @return \DateTime + * @throws \Exception */ public function toDateTime() { @@ -349,6 +356,8 @@ public function toDateTime() * @param \CodeIgniter\I18n\Time|string $datetime * @param null $timezone * @param string|null $locale + * + * @throws \Exception */ public static function setTestNow($datetime = null, $timezone = null, string $locale = null) { @@ -394,7 +403,7 @@ public static function hasTestNow(): bool * * @return string */ - public function getYear() + public function getYear(): string { return $this->toLocalizedString('Y'); } @@ -406,7 +415,7 @@ public function getYear() * * @return string */ - public function getMonth() + public function getMonth(): string { return $this->toLocalizedString('M'); } @@ -418,7 +427,7 @@ public function getMonth() * * @return string */ - public function getDay() + public function getDay(): string { return $this->toLocalizedString('d'); } @@ -430,7 +439,7 @@ public function getDay() * * @return string */ - public function getHour() + public function getHour(): string { return $this->toLocalizedString('H'); } @@ -442,7 +451,7 @@ public function getHour() * * @return string */ - public function getMinute() + public function getMinute(): string { return $this->toLocalizedString('m'); } @@ -454,7 +463,7 @@ public function getMinute() * * @return string */ - public function getSecond() + public function getSecond(): string { return $this->toLocalizedString('s'); } @@ -466,7 +475,7 @@ public function getSecond() * * @return string */ - public function getDayOfWeek() + public function getDayOfWeek(): string { return $this->toLocalizedString('c'); } @@ -478,7 +487,7 @@ public function getDayOfWeek() * * @return string */ - public function getDayOfYear() + public function getDayOfYear(): string { return $this->toLocalizedString('D'); } @@ -490,7 +499,7 @@ public function getDayOfYear() * * @return string */ - public function getWeekOfMonth() + public function getWeekOfMonth(): string { return $this->toLocalizedString('W'); } @@ -502,7 +511,7 @@ public function getWeekOfMonth() * * @return string */ - public function getWeekOfYear() + public function getWeekOfYear(): string { return $this->toLocalizedString('w'); } @@ -528,7 +537,7 @@ public function getAge() * * @return string */ - public function getQuarter() + public function getQuarter(): string { return $this->toLocalizedString('Q'); } @@ -562,7 +571,7 @@ public function getDst() * Returns boolean whether the passed timezone is the same as * the local timezone. */ - public function getLocal() + public function getLocal(): bool { $local = date_default_timezone_get(); @@ -574,17 +583,17 @@ public function getLocal() /** * Returns boolean whether object is in UTC. */ - public function getUtc() + public function getUtc(): bool { return $this->getOffset() === 0; } /** - * Reeturns the name of the current timezone. + * Returns the name of the current timezone. * * @return string */ - public function getTimezoneName() + public function getTimezoneName(): string { return $this->timezone->getName(); } @@ -709,6 +718,7 @@ public function setSecond($value) * @param $value * * @return \CodeIgniter\I18n\Time + * @throws \Exception */ protected function setValue(string $name, $value) { @@ -976,6 +986,7 @@ public function toTimeString() * @param string|null $format * * @return string + * @throws \Exception */ public function toLocalizedString(?string $format = null) { @@ -999,6 +1010,7 @@ public function toLocalizedString(?string $format = null) * @param string|null $timezone * * @return boolean + * @throws \Exception */ public function equals($testTime, string $timezone = null): bool { @@ -1124,7 +1136,7 @@ public function humanize() { $before = $days < 0; - // Yesterday/Tommorrow special cases + // Yesterday/Tomorrow special cases if (abs($days) === 1) { return $before ? lang('Time.yesterday') : lang('Time.tomorrow'); @@ -1240,8 +1252,9 @@ protected static function hasRelativeKeywords(string $time): bool * Outputs a short format version of the datetime. * * @return string + * @throws \Exception */ - public function __toString() + public function __toString(): string { return IntlDateFormatter::formatObject($this->toDateTime(), $this->toStringFormat, $this->locale); } diff --git a/system/I18n/TimeDifference.php b/system/I18n/TimeDifference.php index 4a4ac3a4749e..30ce8f529fea 100644 --- a/system/I18n/TimeDifference.php +++ b/system/I18n/TimeDifference.php @@ -260,7 +260,7 @@ public function humanize(string $locale = null): string } /** - * Allow property-like access to our calucalated values. + * Allow property-like access to our calculated values. * * @param $name * diff --git a/system/Images/Exceptions/ImageException.php b/system/Images/Exceptions/ImageException.php index abbc58f499a5..10218248cad7 100644 --- a/system/Images/Exceptions/ImageException.php +++ b/system/Images/Exceptions/ImageException.php @@ -22,7 +22,7 @@ public static function forEXIFUnsupported() public static function forInvalidImageCreate(string $extra = null) { - return new static(lang('Images.unsupportedImagecreate') . ' ' . $extra); + return new static(lang('Images.unsupportedImageCreate') . ' ' . $extra); } public static function forSaveFailed() diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index f7ee1adc0b5f..6417d53ca848 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -21,7 +21,7 @@ 'gifNotSupported' => 'GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.', 'jpgNotSupported' => 'JPG images are not supported.', 'pngNotSupported' => 'PNG images are not supported.', - 'unsupportedImagecreate' => 'Your server does not support the GD function required to process this type of image.', + 'unsupportedImageCreate' => 'Your server does not support the GD function required to process this type of image.', 'jpgOrPngRequired' => 'The image resize protocol specified in your preferences only works with JPEG or PNG image types.', 'rotateUnsupported' => 'Image rotation does not appear to be supported by your server.', 'libPathInvalid' => 'The path to your image library is not correct. Please set the correct path in your image preferences. {0, string)', diff --git a/system/Log/Handlers/ChromeLoggerHandler.php b/system/Log/Handlers/ChromeLoggerHandler.php index 62dce6cc5f18..b19b5d25465b 100644 --- a/system/Log/Handlers/ChromeLoggerHandler.php +++ b/system/Log/Handlers/ChromeLoggerHandler.php @@ -38,7 +38,7 @@ use CodeIgniter\Events\Events; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Services; +use CodeIgniter\Config\Services; /** * Class ChromeLoggerHandler @@ -61,7 +61,7 @@ class ChromeLoggerHandler extends BaseHandler implements HandlerInterface const VERSION = 1.0; /** - * The number of strack frames returned from the backtrace. + * The number of track frames returned from the backtrace. * * @var integer */ diff --git a/system/Log/Handlers/FileHandler.php b/system/Log/Handlers/FileHandler.php index f65f73badc61..e687125768f3 100644 --- a/system/Log/Handlers/FileHandler.php +++ b/system/Log/Handlers/FileHandler.php @@ -36,8 +36,6 @@ * @filesource */ -use CodeIgniter\Log\Exceptions\LogException; - /** * Log error messages to file system */ @@ -96,6 +94,7 @@ public function __construct(array $config = []) * @param $message * * @return boolean + * @throws \Exception */ public function handle($level, $message): bool { diff --git a/system/Model.php b/system/Model.php index d23dba3fd8a8..b67b6b0ef193 100644 --- a/system/Model.php +++ b/system/Model.php @@ -384,7 +384,7 @@ public function findAll(int $limit = 0, int $offset = 0) /** * Returns the first row of the result set. Will take any previous - * Query Builder calls into account when determing the result set. + * Query Builder calls into account when determining the result set. * * @return array|object|null */ @@ -429,7 +429,7 @@ public function first() * * @return $this */ - public function set($key, $value = '', bool $escape = null) + public function set($key, string $value = '', bool $escape = null) { $data = is_array($key) ? $key @@ -1356,7 +1356,7 @@ public function validate($data): bool * * @return array */ - protected function cleanValidationRules($rules, array $data = null): array + protected function cleanValidationRules(array $rules, array $data = null): array { if (empty($data)) { diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 3ffde19b1442..c5d6b61d4e10 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -156,7 +156,7 @@ class RouteCollection implements RouteCollectionInterface /** * The current method that the script is being called by. * - * @var + * @var string */ protected $HTTPVerb; @@ -248,7 +248,7 @@ public function __construct(FileLocator $locator, $moduleConfig) * @param string|array $placeholder * @param string $pattern * - * @return mixed + * @return \CodeIgniter\Router\RouteCollectionInterface */ public function addPlaceholder($placeholder, string $pattern = null): RouteCollectionInterface { @@ -270,7 +270,7 @@ public function addPlaceholder($placeholder, string $pattern = null): RouteColle * * @param $value * - * @return mixed + * @return \CodeIgniter\Router\RouteCollectionInterface */ public function setDefaultNamespace(string $value): RouteCollectionInterface { @@ -288,7 +288,7 @@ public function setDefaultNamespace(string $value): RouteCollectionInterface * * @param $value * - * @return mixed + * @return \CodeIgniter\Router\RouteCollectionInterface */ public function setDefaultController(string $value): RouteCollectionInterface { @@ -305,7 +305,7 @@ public function setDefaultController(string $value): RouteCollectionInterface * * @param $value * - * @return mixed + * @return \CodeIgniter\Router\RouteCollectionInterface */ public function setDefaultMethod(string $value): RouteCollectionInterface { @@ -325,7 +325,7 @@ public function setDefaultMethod(string $value): RouteCollectionInterface * * @param boolean $value * - * @return mixed + * @return \CodeIgniter\Router\RouteCollectionInterface */ public function setTranslateURIDashes(bool $value): RouteCollectionInterface { @@ -483,9 +483,9 @@ public function getDefaultNamespace(): string //-------------------------------------------------------------------- /** - * Returns the current value of the translateURIDashses setting. + * Returns the current value of the translateURIDashes setting. * - * @return mixed + * @return boolean */ public function shouldTranslateURIDashes(): bool { @@ -555,7 +555,7 @@ public function getRoutes($verb = null): array * * @return array */ - public function getRoutesOptions(string $from = null) + public function getRoutesOptions(string $from = null): array { return $from ? $this->routesOptions[$from] ?? [] : $this->routesOptions; } @@ -887,10 +887,10 @@ public function resource(string $name, array $options = null): RouteCollectionIn * Example: * $route->match( ['get', 'post'], 'users/(:num)', 'users/$1); * - * @param array $verbs - * @param $from - * @param $to - * @param array $options + * @param array $verbs + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -911,9 +911,9 @@ public function match(array $verbs = [], string $from, $to, array $options = nul /** * Specifies a route that is only available to GET requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -929,9 +929,9 @@ public function get(string $from, $to, array $options = null): RouteCollectionIn /** * Specifies a route that is only available to POST requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -947,9 +947,9 @@ public function post(string $from, $to, array $options = null): RouteCollectionI /** * Specifies a route that is only available to PUT requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -965,9 +965,9 @@ public function put(string $from, $to, array $options = null): RouteCollectionIn /** * Specifies a route that is only available to DELETE requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -983,9 +983,9 @@ public function delete(string $from, $to, array $options = null): RouteCollectio /** * Specifies a route that is only available to HEAD requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -1001,9 +1001,9 @@ public function head(string $from, $to, array $options = null): RouteCollectionI /** * Specifies a route that is only available to PATCH requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -1019,9 +1019,9 @@ public function patch(string $from, $to, array $options = null): RouteCollection /** * Specifies a route that is only available to OPTIONS requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -1037,9 +1037,9 @@ public function options(string $from, $to, array $options = null): RouteCollecti /** * Specifies a route that is only available to command-line requests. * - * @param $from - * @param $to - * @param array $options + * @param string $from + * @param string|array $to + * @param array $options * * @return \CodeIgniter\Router\RouteCollectionInterface */ @@ -1225,10 +1225,10 @@ protected function fillRouteParams(string $from, array $params = null): string * the request method(s) that this route will work for. They can be separated * by a pipe character "|" if there is more than one. * - * @param string $verb - * @param string $from - * @param $to - * @param array|null $options + * @param string $verb + * @param string $from + * @param string|array $to + * @param array $options */ protected function create(string $verb, string $from, $to, array $options = null) { @@ -1238,7 +1238,7 @@ protected function create(string $verb, string $from, $to, array $options = null $from = filter_var($prefix . $from, FILTER_SANITIZE_STRING); // While we want to add a route within a group of '/', - // it doens't work with matching, so remove them... + // it doesn't work with matching, so remove them... if ($from !== '/') { $from = trim($from, '/'); @@ -1341,11 +1341,11 @@ protected function create(string $verb, string $from, $to, array $options = null * Compares the subdomain(s) passed in against the current subdomain * on this page request. * - * @param $subdomains + * @param mixed $subdomains * * @return boolean */ - private function checkSubdomains($subdomains) + private function checkSubdomains($subdomains): bool { // CLI calls can't be on subdomain. if (! isset($_SERVER['HTTP_HOST'])) diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index 2413ccfb637d..181aa89b844c 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -192,7 +192,7 @@ public function getDefaultMethod(); //-------------------------------------------------------------------- /** - * Returns the current value of the translateURIDashses setting. + * Returns the current value of the translateURIDashes setting. * * @return mixed */ diff --git a/system/Security/Security.php b/system/Security/Security.php index 246e304046e7..11401455d317 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -264,7 +264,7 @@ public function CSRFSetCookie(RequestInterface $request) * * @return string */ - public function getCSRFHash() + public function getCSRFHash(): string { return $this->CSRFHash; } @@ -276,7 +276,7 @@ public function getCSRFHash() * * @return string */ - public function getCSRFTokenName() + public function getCSRFTokenName(): string { return $this->CSRFTokenName; } @@ -287,8 +287,9 @@ public function getCSRFTokenName() * Sets the CSRF Hash and cookie. * * @return string + * @throws \Exception */ - protected function CSRFSetHash() + protected function CSRFSetHash(): string { if ($this->CSRFHash === null) { diff --git a/system/Session/Handlers/BaseHandler.php b/system/Session/Handlers/BaseHandler.php index 7605b4fa981d..ec8a08025e8d 100644 --- a/system/Session/Handlers/BaseHandler.php +++ b/system/Session/Handlers/BaseHandler.php @@ -64,49 +64,49 @@ abstract class BaseHandler implements \SessionHandlerInterface /** * Cookie prefix * - * @var type + * @var string */ protected $cookiePrefix = ''; /** * Cookie domain * - * @var type + * @var string */ protected $cookieDomain = ''; /** * Cookie path * - * @var type + * @var string */ protected $cookiePath = '/'; /** * Cookie secure? * - * @var type + * @var boolean */ protected $cookieSecure = false; /** * Cookie name to use * - * @var type + * @var string */ protected $cookieName; /** * Match IP addresses for cookies? * - * @var type + * @var boolean */ protected $matchIP = false; /** * Current session ID * - * @var type + * @var string */ protected $sessionID; @@ -201,9 +201,9 @@ protected function releaseLock(): bool * so that the INI is set just in time for the error message to * be properly generated. * - * @return mixed + * @return boolean */ - protected function fail() + protected function fail(): bool { ini_set('session.save_path', $this->savePath); diff --git a/system/Session/Handlers/DatabaseHandler.php b/system/Session/Handlers/DatabaseHandler.php index 6d045693f9e1..883a82e492e8 100644 --- a/system/Session/Handlers/DatabaseHandler.php +++ b/system/Session/Handlers/DatabaseHandler.php @@ -152,7 +152,7 @@ public function open($savePath, $name): bool * * @return string Serialized session data */ - public function read($sessionID) + public function read($sessionID): string { if ($this->lockSession($sessionID) === false) { diff --git a/system/Session/Handlers/FileHandler.php b/system/Session/Handlers/FileHandler.php index d14c01df9066..49c911dc16d8 100644 --- a/system/Session/Handlers/FileHandler.php +++ b/system/Session/Handlers/FileHandler.php @@ -162,7 +162,7 @@ public function open($savePath, $name): bool * * @return string Serialized session data */ - public function read($sessionID) + public function read($sessionID): string { // This might seem weird, but PHP 5.6 introduced session_reset(), // which re-reads session data diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index 8a786e52e2f2..10d73e9d7fe9 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -115,7 +115,7 @@ public function __construct(BaseConfig $config, string $ipAddress) * * @return boolean */ - public function open($save_path, $name) + public function open($save_path, $name): bool { $this->memcached = new \Memcached(); $this->memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); // required for touch() usage @@ -176,7 +176,7 @@ public function open($save_path, $name) * * @return string Serialized session data */ - public function read($sessionID) + public function read($sessionID): string { if (isset($this->memcached) && $this->lockSession($sessionID)) { @@ -204,7 +204,7 @@ public function read($sessionID) * * @return boolean */ - public function write($sessionID, $sessionData) + public function write($sessionID, $sessionData): bool { if (! isset($this->memcached)) { @@ -253,7 +253,7 @@ public function write($sessionID, $sessionData) * * @return boolean */ - public function close() + public function close(): bool { if (isset($this->memcached)) { @@ -283,7 +283,7 @@ public function close() * * @return boolean */ - public function destroy($session_id) + public function destroy($session_id): bool { if (isset($this->memcached, $this->lockKey)) { @@ -306,7 +306,7 @@ public function destroy($session_id) * * @return boolean */ - public function gc($maxlifetime) + public function gc($maxlifetime): bool { // Not necessary, Memcached takes care of that. return true; diff --git a/system/Throttle/Throttler.php b/system/Throttle/Throttler.php index 3ce6847b7783..b1a612bea89c 100644 --- a/system/Throttle/Throttler.php +++ b/system/Throttle/Throttler.php @@ -97,7 +97,7 @@ public function __construct(CacheInterface $cache) * * @return integer */ - public function getTokenTime() + public function getTokenTime(): int { return $this->tokenTime; } @@ -123,7 +123,7 @@ public function getTokenTime() * @return boolean * @internal param int $maxRequests */ - public function check(string $key, int $capacity, int $seconds, int $cost = 1) + public function check(string $key, int $capacity, int $seconds, int $cost = 1): bool { $tokenName = $this->prefix . $key; @@ -193,7 +193,7 @@ public function setTestTime(int $time) * * @return integer */ - public function time() + public function time(): int { return $this->testTime ?? time(); } diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index a994c678e3f8..389c30e5c088 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -287,11 +287,6 @@ public function valid_email(string $str = null): bool */ public function valid_emails(string $str = null): bool { - if (strpos($str, ',') === false) - { - return $this->valid_email(trim($str)); - } - foreach (explode(',', $str) as $email) { $email = trim($email); diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index 864736a8ea89..acdef8cffc4c 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -116,7 +116,7 @@ public function __construct($config, RendererInterface $view) /** * Runs the validation process, returning true/false determining whether - * or not validation was successful. + * validation was successful or not. * * @param array $data The array of data to validate. * @param string $group The pre-defined group of rules to apply. @@ -168,7 +168,7 @@ public function run(array $data = null, string $group = null, string $db_group = /** * Check; runs the validation process, returning true or false - * determining whether or not validation was successful. + * determining whether validation was successful or not. * * @param mixed $value Value to validation. * @param string $rule Rule. @@ -202,7 +202,7 @@ public function check($value, string $rule, array $errors = []): bool * * @return boolean */ - protected function processRules(string $field, string $label = null, $value, $rules = null, array $data) + protected function processRules(string $field, string $label = null, $value, $rules = null, array $data): bool { // If the if_exist rule is defined... if (in_array('if_exist', $rules)) @@ -399,7 +399,7 @@ public function setRules(array $rules, array $errors = []): ValidationInterface * * @return array */ - public function getRules() + public function getRules(): array { return $this->rules; } @@ -615,7 +615,7 @@ public function getError(string $field = null): string /** * Returns the array of errors that were encountered during - * a run() call. The array should be in the followig format: + * a run() call. The array should be in the following format: * * [ * 'field1' => 'error message', diff --git a/system/View/Parser.php b/system/View/Parser.php index b6de221c173d..bad1b64233cf 100644 --- a/system/View/Parser.php +++ b/system/View/Parser.php @@ -118,7 +118,7 @@ public function __construct($config, string $viewPath = null, $loader = null, bo * * @return string */ - public function render(string $view, array $options = null, $saveData = null): string + public function render(string $view, array $options = null, bool $saveData = null): string { $start = microtime(true); if (is_null($saveData)) @@ -185,7 +185,7 @@ public function render(string $view, array $options = null, $saveData = null): s * * @return string */ - public function renderString(string $template, array $options = null, $saveData = null): string + public function renderString(string $template, array $options = null, bool $saveData = null): string { $start = microtime(true); if (is_null($saveData)) @@ -599,7 +599,7 @@ protected function replaceSingle($pattern, $content, $template, bool $escape = f * * @return string */ - protected function prepareReplacement(array $matches, string $replace, bool $escape = true) + protected function prepareReplacement(array $matches, string $replace, bool $escape = true): string { $orig = array_shift($matches); diff --git a/system/View/Plugins.php b/system/View/Plugins.php index 28987f4f0ff3..36564db5ffb1 100644 --- a/system/View/Plugins.php +++ b/system/View/Plugins.php @@ -68,7 +68,7 @@ public static function previousURL(array $params = []) * * @return string */ - public static function mailto(array $params = []) + public static function mailto(array $params = []): string { $email = $params['email'] ?? ''; $title = $params['title'] ?? ''; @@ -84,7 +84,7 @@ public static function mailto(array $params = []) * * @return string */ - public static function safeMailto(array $params = []) + public static function safeMailto(array $params = []): string { $email = $params['email'] ?? ''; $title = $params['title'] ?? ''; @@ -100,7 +100,7 @@ public static function safeMailto(array $params = []) * * @return string */ - public static function lang(array $params = []) + public static function lang(array $params = []): string { $line = array_shift($params); @@ -114,7 +114,7 @@ public static function lang(array $params = []) * * @return string */ - public static function ValidationErrors(array $params = []) + public static function ValidationErrors(array $params = []): string { $validator = \Config\Services::validation(); if (empty($params)) @@ -130,7 +130,7 @@ public static function ValidationErrors(array $params = []) /** * @param array $params * - * @return string| + * @return string|false */ public static function route(array $params = []) { @@ -144,7 +144,7 @@ public static function route(array $params = []) * * @return string */ - public static function siteURL(array $params = []) + public static function siteURL(array $params = []): string { return site_url(...$params); } diff --git a/system/View/RendererInterface.php b/system/View/RendererInterface.php index 1de07d038e71..43458acd4aec 100644 --- a/system/View/RendererInterface.php +++ b/system/View/RendererInterface.php @@ -60,7 +60,7 @@ interface RendererInterface * * @return string */ - public function render(string $view, array $options = null, $saveData = false): string; + public function render(string $view, array $options = null, bool $saveData = false): string; //-------------------------------------------------------------------- @@ -78,7 +78,7 @@ public function render(string $view, array $options = null, $saveData = false): * * @return string */ - public function renderString(string $view, array $options = null, $saveData = false): string; + public function renderString(string $view, array $options = null, bool $saveData = false): string; //-------------------------------------------------------------------- diff --git a/system/View/View.php b/system/View/View.php index 7f0e6d2483e6..32680ebf11ea 100644 --- a/system/View/View.php +++ b/system/View/View.php @@ -179,7 +179,7 @@ public function __construct($config, string $viewPath = null, $loader = null, bo * * @return string */ - public function render(string $view, array $options = null, $saveData = null): string + public function render(string $view, array $options = null, bool $saveData = null): string { $this->renderVars['start'] = microtime(true); @@ -294,7 +294,7 @@ public function render(string $view, array $options = null, $saveData = null): s * * @return string */ - public function renderString(string $view, array $options = null, $saveData = null): string + public function renderString(string $view, array $options = null, bool $saveData = null): string { $start = microtime(true); if (is_null($saveData)) @@ -388,7 +388,7 @@ public function setVar(string $name, $value = null, string $context = null): Ren * * @return RendererInterface */ - public function resetData() + public function resetData(): RendererInterface { $this->data = []; @@ -402,7 +402,7 @@ public function resetData() * * @return array */ - public function getData() + public function getData(): array { return $this->data; } @@ -494,7 +494,7 @@ public function renderSection(string $sectionName) * * @return string */ - public function include(string $view, array $options = null, $saveData = null) + public function include(string $view, array $options = null, $saveData = null): string { return $this->render($view, $options, $saveData); }