@@ -23,12 +23,15 @@ class PHPTAL_Php_TalesChainExecutor
2323 const CHAIN_BREAK = 1 ;
2424 const CHAIN_CONT = 2 ;
2525
26- public function __construct (PHPTAL_Php_CodeWriter $ codewriter , array $ chain , PHPTAL_Php_TalesChainReader $ reader )
26+ private int $ state = 0 ;
27+ private bool $ chainStarted = false ;
28+
29+ public function __construct (
30+ private PHPTAL_Php_CodeWriter $ codewriter ,
31+ private array $ chain ,
32+ private PHPTAL_Php_TalesChainReader $ reader
33+ )
2734 {
28- $ this ->_chain = $ chain ;
29- $ this ->_chainStarted = false ;
30- $ this ->codewriter = $ codewriter ;
31- $ this ->_reader = $ reader ;
3235 $ this ->_executeChain ();
3336 }
3437
@@ -37,10 +40,10 @@ public function getCodeWriter()
3740 return $ this ->codewriter ;
3841 }
3942
40- public function doIf ($ condition )
43+ public function doIf (string $ condition )
4144 {
42- if ($ this ->_chainStarted == false ) {
43- $ this ->_chainStarted = true ;
45+ if ($ this ->chainStarted == false ) {
46+ $ this ->chainStarted = true ;
4447 $ this ->codewriter ->doIf ($ condition );
4548 } else {
4649 $ this ->codewriter ->doElseIf ($ condition );
@@ -54,43 +57,38 @@ public function doElse()
5457
5558 public function breakChain ()
5659 {
57- $ this ->_state = self ::CHAIN_BREAK ;
60+ $ this ->state = self ::CHAIN_BREAK ;
5861 }
5962
6063 public function continueChain ()
6164 {
62- $ this ->_state = self ::CHAIN_CONT ;
65+ $ this ->state = self ::CHAIN_CONT ;
6366 }
6467
6568 private function _executeChain ()
6669 {
6770 $ this ->codewriter ->noThrow (true );
6871
69- end ($ this ->_chain ); $ lastkey = key ($ this ->_chain );
72+ end ($ this ->chain ); $ lastkey = key ($ this ->chain );
7073
71- foreach ($ this ->_chain as $ key => $ exp ) {
72- $ this ->_state = 0 ;
74+ foreach ($ this ->chain as $ key => $ exp ) {
75+ $ this ->state = 0 ;
7376
7477 if ($ exp == PHPTAL_Php_TalesInternal::NOTHING_KEYWORD ) {
75- $ this ->_reader ->talesChainNothingKeyword ($ this );
78+ $ this ->reader ->talesChainNothingKeyword ($ this );
7679 } elseif ($ exp == PHPTAL_Php_TalesInternal::DEFAULT_KEYWORD ) {
77- $ this ->_reader ->talesChainDefaultKeyword ($ this );
80+ $ this ->reader ->talesChainDefaultKeyword ($ this );
7881 } else {
79- $ this ->_reader ->talesChainPart ($ this , $ exp , $ lastkey === $ key );
82+ $ this ->reader ->talesChainPart ($ this , $ exp , $ lastkey === $ key );
8083 }
8184
82- if ($ this ->_state == self ::CHAIN_BREAK )
85+ if ($ this ->state == self ::CHAIN_BREAK )
8386 break ;
84- if ($ this ->_state == self ::CHAIN_CONT )
87+ if ($ this ->state == self ::CHAIN_CONT )
8588 continue ;
8689 }
8790
8891 $ this ->codewriter ->doEnd ('if ' );
8992 $ this ->codewriter ->noThrow (false );
9093 }
91-
92- private $ _state = 0 ;
93- private $ _chain ;
94- private $ _chainStarted = false ;
95- private $ codewriter = null ;
9694}
0 commit comments