@@ -145,7 +145,10 @@ function command(string $command)
145145 $ args [] = stripcslashes ($ match [1 ]);
146146 } else {
147147 // @codeCoverageIgnoreStart
148- throw new InvalidArgumentException (sprintf ('Unable to parse input near "... %s ...". ' , substr ($ command , $ cursor , 10 )));
148+ throw new InvalidArgumentException (sprintf (
149+ 'Unable to parse input near "... %s ...". ' ,
150+ substr ($ command , $ cursor , 10 )
151+ ));
149152 // @codeCoverageIgnoreEnd
150153 }
151154
@@ -357,12 +360,10 @@ function db_connect($db = null, bool $getShared = true)
357360 */
358361 function dd (...$ vars )
359362 {
360- // @codeCoverageIgnoreStart
361363 Kint::$ aliases [] = 'dd ' ;
362364 Kint::dump (...$ vars );
363365
364366 exit ;
365- // @codeCoverageIgnoreEnd
366367 }
367368}
368369
@@ -414,10 +415,11 @@ function env(string $key, $default = null)
414415 * If $data is an array, then it loops over it, escaping each
415416 * 'value' of the key/value pairs.
416417 *
417- * Valid context values: html, js, css, url, attr, raw
418- *
419418 * @param array|string $data
420- * @param string $encoding
419+ * @phpstan-param 'html'|'js'|'css'|'url'|'attr'|'raw' $context
420+ * @param string|null $encoding Current encoding for escaping.
421+ * If not UTF-8, we convert strings from this encoding
422+ * pre-escaping and back to this encoding post-escaping.
421423 *
422424 * @return array|string
423425 *
@@ -437,7 +439,7 @@ function esc($data, string $context = 'html', ?string $encoding = null)
437439 // Provide a way to NOT escape data since
438440 // this could be called automatically by
439441 // the View library.
440- if (empty ( $ context ) || $ context === 'raw ' ) {
442+ if ($ context === 'raw ' ) {
441443 return $ data ;
442444 }
443445
@@ -493,18 +495,13 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
493495 }
494496
495497 if ((ENVIRONMENT !== 'testing ' && (is_cli () || $ request ->isSecure ())) || (isset ($ _SERVER ['HTTPS ' ]) && $ _SERVER ['HTTPS ' ] === 'test ' )) {
496- // @codeCoverageIgnoreStart
497- return ;
498- // @codeCoverageIgnoreEnd
498+ return ; // @codeCoverageIgnore
499499 }
500500
501501 // If the session status is active, we should regenerate
502502 // the session ID for safety sake.
503503 if (ENVIRONMENT !== 'testing ' && session_status () === PHP_SESSION_ACTIVE ) {
504- // @codeCoverageIgnoreStart
505- Services::session (null , true )
506- ->regenerate ();
507- // @codeCoverageIgnoreEnd
504+ Services::session (null , true )->regenerate (); // @codeCoverageIgnore
508505 }
509506
510507 $ baseURL = config (App::class)->baseURL ;
@@ -529,9 +526,7 @@ function force_https(int $duration = 31_536_000, ?RequestInterface $request = nu
529526 $ response ->sendHeaders ();
530527
531528 if (ENVIRONMENT !== 'testing ' ) {
532- // @codeCoverageIgnoreStart
533- exit ();
534- // @codeCoverageIgnoreEnd
529+ exit (); // @codeCoverageIgnore
535530 }
536531 }
537532}
@@ -782,7 +777,7 @@ function lang(string $line, array $args = [], ?string $locale = null)
782777 * - info
783778 * - debug
784779 *
785- * @return mixed
780+ * @return bool
786781 */
787782 function log_message (string $ level , string $ message , array $ context = [])
788783 {
@@ -795,10 +790,7 @@ function log_message(string $level, string $message, array $context = [])
795790 return $ logger ->log ($ level , $ message , $ context );
796791 }
797792
798- // @codeCoverageIgnoreStart
799- return Services::logger (true )
800- ->log ($ level , $ message , $ context );
801- // @codeCoverageIgnoreEnd
793+ return Services::logger (true )->log ($ level , $ message , $ context ); // @codeCoverageIgnore
802794 }
803795}
804796
@@ -823,18 +815,17 @@ function model(string $name, bool $getShared = true, ?ConnectionInterface &$conn
823815 * Provides access to "old input" that was set in the session
824816 * during a redirect()->withInput().
825817 *
826- * @param null $default
827- * @param bool|string $escape
818+ * @param string|null $default
819+ * @param false|string $escape
820+ * @phpstan-param false|'attr'|'css'|'html'|'js'|'raw'|'url' $escape
828821 *
829- * @return mixed |null
822+ * @return array|string |null
830823 */
831824 function old (string $ key , $ default = null , $ escape = 'html ' )
832825 {
833826 // Ensure the session is loaded
834827 if (session_status () === PHP_SESSION_NONE && ENVIRONMENT !== 'testing ' ) {
835- // @codeCoverageIgnoreStart
836- session ();
837- // @codeCoverageIgnoreEnd
828+ session (); // @codeCoverageIgnore
838829 }
839830
840831 $ request = Services::request ();
@@ -932,7 +923,8 @@ function route_to(string $method, ...$params)
932923 *
933924 * @param string $val
934925 *
935- * @return mixed|Session|null
926+ * @return array|bool|float|int|object|Session|string|null
927+ * @phpstan-return ($val is null ? Session : array|bool|float|int|object|string|null)
936928 */
937929 function session (?string $ val = null )
938930 {
@@ -1054,7 +1046,7 @@ function slash_item(string $item): ?string
10541046 * Helper function used to convert a string, array, or object
10551047 * of attributes to a string.
10561048 *
1057- * @param mixed $attributes string, array, object
1049+ * @param array|object|string $attributes string, array, object that can be cast to array
10581050 */
10591051 function stringify_attributes ($ attributes , bool $ js = false ): string
10601052 {
0 commit comments