3636 * @filesource
3737 */
3838
39+ use CodeIgniter \Config \Config ;
40+ use CodeIgniter \Files \Exceptions \FileNotFoundException ;
3941use CodeIgniter \HTTP \RedirectResponse ;
4042use CodeIgniter \HTTP \RequestInterface ;
4143use CodeIgniter \HTTP \ResponseInterface ;
44+ use CodeIgniter \HTTP \URI ;
45+ use Config \App ;
46+ use Config \Database ;
47+ use Config \Logger ;
4248use Config \Services ;
49+ use Tests \Support \Log \TestLogger ;
50+ use Zend \Escaper \Escaper ;
4351
4452/**
4553 * Common Functions
@@ -97,7 +105,7 @@ function cache(string $key = null)
97105 */
98106 function config (string $ name , bool $ getShared = true )
99107 {
100- return \ CodeIgniter \ Config \ Config::get ($ name , $ getShared );
108+ return Config::get ($ name , $ getShared );
101109 }
102110}
103111
@@ -126,7 +134,7 @@ function config(string $name, bool $getShared = true)
126134 */
127135 function db_connect ($ db = null , bool $ getShared = true )
128136 {
129- return \ Config \ Database::connect ($ db , $ getShared );
137+ return Database::connect ($ db , $ getShared );
130138 }
131139}
132140
@@ -182,6 +190,7 @@ function view(string $name, array $data = [], array $options = []): string
182190 * @param string|null $cacheName
183191 *
184192 * @return string
193+ * @throws \ReflectionException
185194 */
186195 function view_cell (string $ library , $ params = null , int $ ttl = 0 , string $ cacheName = null ): string
187196 {
@@ -281,7 +290,7 @@ function esc($data, string $context = 'html', string $encoding = null)
281290
282291 if (! in_array ($ context , ['html ' , 'js ' , 'css ' , 'url ' , 'attr ' ]))
283292 {
284- throw new \ InvalidArgumentException ('Invalid escape context provided. ' );
293+ throw new InvalidArgumentException ('Invalid escape context provided. ' );
285294 }
286295
287296 if ($ context === 'attr ' )
@@ -296,12 +305,12 @@ function esc($data, string $context = 'html', string $encoding = null)
296305 static $ escaper ;
297306 if (! $ escaper )
298307 {
299- $ escaper = new \ Zend \ Escaper \ Escaper ($ encoding );
308+ $ escaper = new Escaper ($ encoding );
300309 }
301310
302311 if ($ encoding && $ escaper ->getEncoding () !== $ encoding )
303312 {
304- $ escaper = new \ Zend \ Escaper \ Escaper ($ encoding );
313+ $ escaper = new Escaper ($ encoding );
305314 }
306315
307316 $ data = $ escaper ->$ method ($ data );
@@ -471,7 +480,7 @@ function log_message(string $level, string $message, array $context = [])
471480 // for asserting that logs were called in the test code.
472481 if (ENVIRONMENT === 'testing ' )
473482 {
474- $ logger = new \ Tests \ Support \ Log \ TestLogger (new \ Config \ Logger ());
483+ $ logger = new TestLogger (new Logger ());
475484
476485 return $ logger ->log ($ level , $ message , $ context );
477486 }
@@ -534,27 +543,27 @@ function route_to(string $method, ...$params)
534543 * between ascii characters, like Java\0script.
535544 *
536545 * @param string $str
537- * @param boolean $url_encoded
546+ * @param boolean $urlEncoded
538547 *
539548 * @return string
540549 */
541- function remove_invisible_characters (string $ str , bool $ url_encoded = true ): string
550+ function remove_invisible_characters (string $ str , bool $ urlEncoded = true ): string
542551 {
543- $ non_displayables = [];
552+ $ nonDisplayables = [];
544553
545554 // every control character except newline (dec 10),
546555 // carriage return (dec 13) and horizontal tab (dec 09)
547- if ($ url_encoded )
556+ if ($ urlEncoded )
548557 {
549- $ non_displayables [] = '/%0[0-8bcef]/ ' ; // url encoded 00-08, 11, 12, 14, 15
550- $ non_displayables [] = '/%1[0-9a-f]/ ' ; // url encoded 16-31
558+ $ nonDisplayables [] = '/%0[0-8bcef]/ ' ; // url encoded 00-08, 11, 12, 14, 15
559+ $ nonDisplayables [] = '/%1[0-9a-f]/ ' ; // url encoded 16-31
551560 }
552561
553- $ non_displayables [] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S ' ; // 00-08, 11, 12, 14-31, 127
562+ $ nonDisplayables [] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S ' ; // 00-08, 11, 12, 14-31, 127
554563
555564 do
556565 {
557- $ str = preg_replace ($ non_displayables , '' , $ str , -1 , $ count );
566+ $ str = preg_replace ($ nonDisplayables , '' , $ str , -1 , $ count );
558567 }
559568 while ($ count );
560569
@@ -611,7 +620,7 @@ function helper($filenames)
611620
612621 if (empty ($ path ))
613622 {
614- throw \ CodeIgniter \ Files \ Exceptions \ FileNotFoundException::forFileNotFound ($ filename );
623+ throw FileNotFoundException::forFileNotFound ($ filename );
615624 }
616625
617626 $ includes [] = $ path ;
@@ -687,7 +696,7 @@ function helper($filenames)
687696 */
688697 function app_timezone (): string
689698 {
690- $ config = config (\ Config \ App::class);
699+ $ config = config (App::class);
691700
692701 return $ config ->appTimezone ;
693702 }
@@ -706,7 +715,7 @@ function app_timezone(): string
706715 */
707716 function csrf_token (): string
708717 {
709- $ config = config (\ Config \ App::class);
718+ $ config = config (App::class);
710719
711720 return $ config ->CSRFTokenName ;
712721 }
@@ -797,7 +806,7 @@ function force_https(int $duration = 31536000, RequestInterface $request = null,
797806 $ uri = $ request ->uri ;
798807 $ uri ->setScheme ('https ' );
799808
800- $ uri = \ CodeIgniter \ HTTP \ URI ::createURIString (
809+ $ uri = URI ::createURIString (
801810 $ uri ->getScheme (), $ uri ->getAuthority (true ), $ uri ->getPath (), // Absolute URIs should use a "/" for an empty path
802811 $ uri ->getQuery (), $ uri ->getFragment ()
803812 );
@@ -936,12 +945,13 @@ function stringify_attributes($attributes, bool $js = false): string
936945 * the file, based on the read-only attribute. is_writable() is also unreliable
937946 * on Unix servers if safe_mode is on.
938947 *
939- * @link https://bugs.php.net/bug.php?id=54709
948+ * @link https://bugs.php.net/bug.php?id=54709
940949 *
941950 * @param string $file
942951 *
943952 * @return boolean
944953 *
954+ * @throws \Exception
945955 * @codeCoverageIgnore Not practical to test, as travis runs on linux
946956 */
947957 function is_really_writable (string $ file ): bool
@@ -996,7 +1006,7 @@ function is_really_writable(string $file): bool
9961006 */
9971007 function slash_item (string $ item ): ?string
9981008 {
999- $ config = config (\ Config \ App::class);
1009+ $ config = config (App::class);
10001010 $ configItem = $ config ->{$ item };
10011011
10021012 if (! isset ($ configItem ) || empty (trim ($ configItem )))
0 commit comments