diff --git a/system/BaseModel.php b/system/BaseModel.php index 5986d7e6a9d5..1c2a6f6c0678 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -416,7 +416,7 @@ abstract protected function doDelete($id = null, bool $purge = false); * through soft deletes (deleted = 1) * This methods works only with dbCalls * - * @return bool|mixed + * @return bool|string Returns a string if in test mode. */ abstract protected function doPurgeDeleted(); diff --git a/system/Common.php b/system/Common.php index 2c78a92c5bc8..72b653023044 100644 --- a/system/Common.php +++ b/system/Common.php @@ -414,10 +414,11 @@ function env(string $key, $default = null) * If $data is an array, then it loops over it, escaping each * 'value' of the key/value pairs. * - * Valid context values: html, js, css, url, attr, raw - * * @param array|string $data - * @param string $encoding + * @phpstan-param 'html'|'js'|'css'|'url'|'attr'|'raw' $context + * @param string|null $encoding Current encoding for escaping. + * If not UTF-8, we convert strings from this encoding + * pre-escaping and back to this encoding post-escaping. * * @return array|string * @@ -823,10 +824,11 @@ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn * Provides access to "old input" that was set in the session * during a redirect()->withInput(). * - * @param null $default - * @param bool|string $escape + * @param string|null $default + * @param false|string $escape + * @phpstan-param false|'attr'|'css'|'html'|'js'|'raw'|'url' $escape * - * @return mixed|null + * @return array|string|null */ function old(string $key, $default = null, $escape = 'html') { @@ -932,7 +934,8 @@ function route_to(string $method, ...$params) * * @param string $val * - * @return mixed|Session|null + * @return array|bool|float|int|object|Session|string|null + * @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null) */ function session(?string $val = null) { diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 99aca6604cf5..3433de491fa6 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -2350,7 +2350,7 @@ public function getCompiledDelete(bool $reset = true): string * * @param mixed $where * - * @return bool|string + * @return bool|string Returns a string if in test mode. * * @throws DatabaseException */ diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index b32e148a7da9..ac7af71832ed 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -25,7 +25,7 @@ class XMLFormatter implements FormatterInterface * * @param mixed $data * - * @return bool|string (XML string | false) + * @return false|string (XML string | false) */ public function format($data) { diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index 44327a855d9d..61492adc4275 100755 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -671,7 +671,7 @@ public function getUserAgent() * with redirect_with_input(). It first checks for the data in the old * POST data, then the old GET data and finally check for dot arrays * - * @return mixed + * @return array|string|null */ public function getOldInput(string $key) { diff --git a/system/HTTP/ResponseInterface.php b/system/HTTP/ResponseInterface.php index e8f9fd3fcf3b..c96bf8b30bbf 100644 --- a/system/HTTP/ResponseInterface.php +++ b/system/HTTP/ResponseInterface.php @@ -202,7 +202,7 @@ public function setJSON($body, bool $unencoded = false); /** * Returns the current body, converted to JSON is it isn't already. * - * @return mixed|string + * @return string|null * * @throws InvalidArgumentException If the body property is not array. */ diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index ea922daf4d7d..bd69a41376f8 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -252,7 +252,7 @@ public function setJSON($body, bool $unencoded = false) /** * Returns the current body, converted to JSON is it isn't already. * - * @return mixed|string + * @return string|null * * @throws InvalidArgumentException If the body property is not array. */ diff --git a/system/Model.php b/system/Model.php index ef5669844ef3..04628bbb2c1a 100644 --- a/system/Model.php +++ b/system/Model.php @@ -406,7 +406,7 @@ protected function doDelete($id = null, bool $purge = false) * through soft deletes (deleted = 1) * This methods works only with dbCalls * - * @return bool|mixed + * @return bool|string Returns a string if in test mode. */ protected function doPurgeDeleted() { diff --git a/system/Session/Session.php b/system/Session/Session.php index 041b795e6d48..a0d9f4902584 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -481,7 +481,7 @@ public function set($data, $value = null) * * @param string|null $key Identifier of the session property to retrieve * - * @return mixed The property value(s) + * @return array|bool|float|int|object|string|null The property value(s) */ public function get(?string $key = null) { diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index 47fb6dc92e58..6169da6f82a7 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -147,7 +147,7 @@ abstract class CIUnitTestCase extends TestCase /** * Migration Runner instance. * - * @var MigrationRunner|mixed + * @var MigrationRunner|null */ protected $migrations; diff --git a/system/Test/TestResponse.php b/system/Test/TestResponse.php index 16a50f74d1e5..40fd494db9d8 100644 --- a/system/Test/TestResponse.php +++ b/system/Test/TestResponse.php @@ -347,7 +347,7 @@ public function assertCookieExpired(string $key, string $prefix = '') /** * Returns the response's body as JSON * - * @return false|mixed + * @return false|string|null */ public function getJSON() { diff --git a/system/View/Filters.php b/system/View/Filters.php index 79324322c0b0..e2c827927796 100644 --- a/system/View/Filters.php +++ b/system/View/Filters.php @@ -75,6 +75,7 @@ public static function default($value, string $default): string * Escapes the given value with our `esc()` helper function. * * @param string $value + * @phpstan-param 'html'|'js'|'css'|'url'|'attr'|'raw' $context */ public static function esc($value, string $context = 'html'): string { diff --git a/system/View/View.php b/system/View/View.php index b0206d67caba..9a39104728df 100644 --- a/system/View/View.php +++ b/system/View/View.php @@ -305,8 +305,9 @@ public function excerpt(string $string, int $length = 20): string /** * Sets several pieces of view data at once. * - * @param string $context The context to escape it for: html, css, js, url - * If null, no escaping will happen + * @param string|null $context The context to escape it for: html, css, js, url + * If null, no escaping will happen + * @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context */ public function setData(array $data = [], ?string $context = null): RendererInterface { @@ -326,6 +327,7 @@ public function setData(array $data = [], ?string $context = null): RendererInte * @param mixed $value * @param string|null $context The context to escape it for: html, css, js, url * If null, no escaping will happen + * @phpstan-param null|'html'|'js'|'css'|'url'|'attr'|'raw' $context */ public function setVar(string $name, $value = null, ?string $context = null): RendererInterface {