@@ -167,14 +167,14 @@ public function getUniqueId(): string
167167
168168 public function isModuleCurrent (string $ module ): bool
169169 {
170- $ current = Helpers::splitName ($ this ->getName ())[0 ];
170+ $ current = Helpers::splitName (( string ) $ this ->getName ())[0 ];
171171 return str_starts_with ($ current . ': ' , ltrim ($ module . ': ' , ': ' ));
172172 }
173173
174174
175175 public function isForwarded (): bool
176176 {
177- return $ this ->forwarded || $ this ->request -> isMethod ($ this ->request ::FORWARD );
177+ return $ this ->forwarded || ( $ this ->request !== null && $ this -> request -> isMethod ($ this ->request ::FORWARD ) );
178178 }
179179
180180
@@ -277,10 +277,11 @@ public function run(Application\Request $request): Application\Response
277277 $ this ->response = new Responses \VoidResponse ;
278278 }
279279
280- Arrays::invoke ($ this ->onShutdown , $ this , $ this ->response );
281- $ this ->shutdown ($ this ->response );
280+ $ response = $ this ->response ;
281+ Arrays::invoke ($ this ->onShutdown , $ this , $ response );
282+ $ this ->shutdown ($ response );
282283
283- return $ this -> response ;
284+ return $ response ;
284285 }
285286
286287
@@ -402,7 +403,7 @@ final public function isSignalReceiver(
402403 return $ this ->signalReceiver === $ component ;
403404 }
404405
405- return $ this ->signalReceiver === $ component && strcasecmp ($ signal , $ this ->signal ) === 0 ;
406+ return $ this ->signalReceiver === $ component && strcasecmp (( string ) $ signal , $ this ->signal ) === 0 ;
406407 }
407408
408409
@@ -545,12 +546,12 @@ public function findLayoutTemplateFile(): ?string
545546 public function formatLayoutTemplateFiles (): array
546547 {
547548 if (preg_match ('#/| \\\# ' , (string ) $ this ->layout )) {
548- return [$ this ->layout ];
549+ return [( string ) $ this ->layout ];
549550 }
550551
551552 $ layout = $ this ->layout ?: 'layout ' ;
552- $ dir = dirname (static ::getReflection ()->getFileName ());
553- $ levels = substr_count ($ this ->getName (), ': ' );
553+ $ dir = dirname (( string ) static ::getReflection ()->getFileName ());
554+ $ levels = substr_count (( string ) $ this ->getName (), ': ' );
554555 if (!is_dir ("$ dir/templates " )) {
555556 $ dir = dirname ($ origDir = $ dir );
556557 if (!is_dir ("$ dir/templates " )) {
@@ -562,7 +563,7 @@ public function formatLayoutTemplateFiles(): array
562563 }
563564 }
564565
565- [, $ presenter ] = Helpers::splitName ($ this ->getName ());
566+ [, $ presenter ] = Helpers::splitName (( string ) $ this ->getName ());
566567 $ list = [
567568 "$ dir/templates/ $ presenter/@ $ layout.latte " ,
568569 "$ dir/templates/ $ presenter.@ $ layout.latte " ,
@@ -581,7 +582,7 @@ public function formatLayoutTemplateFiles(): array
581582 */
582583 public function formatTemplateFiles (): array
583584 {
584- $ dir = dirname (static ::getReflection ()->getFileName ());
585+ $ dir = dirname (( string ) static ::getReflection ()->getFileName ());
585586 if (!is_dir ("$ dir/templates " )) {
586587 $ dir = dirname ($ origDir = $ dir );
587588 if (!is_dir ("$ dir/templates " )) {
@@ -591,7 +592,7 @@ public function formatTemplateFiles(): array
591592 }
592593 }
593594
594- [, $ presenter ] = Helpers::splitName ($ this ->getName ());
595+ [, $ presenter ] = Helpers::splitName (( string ) $ this ->getName ());
595596 return [
596597 "$ dir/templates/ $ presenter/ $ this ->view .latte " ,
597598 "$ dir/templates/ $ presenter. $ this ->view .latte " ,
@@ -777,7 +778,7 @@ final public function getLastCreatedRequestFlag(string $flag): bool
777778 public function canonicalize (?string $ destination = null , ...$ args ): void
778779 {
779780 $ request = $ this ->request ;
780- if ($ this ->isAjax () || (!$ request ->isMethod ('get ' ) && !$ request ->isMethod ('head ' ))) {
781+ if ($ this ->isAjax () || ($ request !== null && !$ request ->isMethod ('get ' ) && !$ request ->isMethod ('head ' ))) {
781782 return ;
782783 }
783784
@@ -798,7 +799,7 @@ public function canonicalize(?string $destination = null, ...$args): void
798799 return ;
799800 }
800801
801- $ code = $ request ->hasFlag ($ request ::VARYING )
802+ $ code = $ request !== null && $ request ->hasFlag ($ request ::VARYING )
802803 ? Http \IResponse::S302_Found
803804 : Http \IResponse::S301_MovedPermanently;
804805 $ this ->sendResponse (new Responses \RedirectResponse ($ url , $ code ));
@@ -904,6 +905,7 @@ public function restoreRequest(string $key): void
904905 }
905906
906907 $ request = clone $ data [1 ];
908+ assert ($ request instanceof Application \Request);
907909 $ session ->remove ($ key );
908910 $ params = $ request ->getParameters ();
909911 $ params [self ::FlashKey] = $ this ->getFlashKey ();
@@ -959,13 +961,14 @@ public function getGlobalState(?string $forClass = null): array
959961
960962 $ persistents = $ this ->getReflection ()->getPersistentComponents ();
961963
964+ $ since = false ;
962965 foreach ($ this ->getComponentTree () as $ component ) {
963966 if ($ component ->getParent () === $ this ) {
964967 // counts on child-first search
965- $ since = $ persistents [$ component ->getName ()]['since ' ] ?? false ; // false = nonpersistent
968+ $ since = $ persistents [( string ) $ component ->getName ()]['since ' ] ?? false ; // false = nonpersistent
966969 }
967970
968- if (!$ component instanceof StatePersistent ) {
971+ if (!$ component instanceof Component ) {
969972 continue ;
970973 }
971974
@@ -1025,13 +1028,15 @@ private function initGlobalParameters(): void
10251028 // init $this->globalParams
10261029 $ this ->globalParams = [];
10271030 $ selfParams = [];
1031+ $ request = $ this ->request ;
1032+ assert ($ request !== null );
10281033
1029- $ params = $ this -> request ->getParameters ();
1030- if (($ tmp = $ this -> request ->getPost ('_ ' . self ::SignalKey)) !== null ) {
1034+ $ params = $ request ->getParameters ();
1035+ if (($ tmp = $ request ->getPost ('_ ' . self ::SignalKey)) !== null ) {
10311036 $ params [self ::SignalKey] = $ tmp ;
10321037 } elseif ($ this ->isAjax ()) {
1033- $ params += $ this -> request ->getPost ();
1034- if (($ tmp = $ this -> request ->getPost (self ::SignalKey)) !== null ) {
1038+ $ params += $ request ->getPost ();
1039+ if (($ tmp = $ request ->getPost (self ::SignalKey)) !== null ) {
10351040 $ params [self ::SignalKey] = $ tmp ;
10361041 }
10371042 }
0 commit comments