55namespace CodeIgniter \Shield \Test ;
66
77use CodeIgniter \CLI \CLI ;
8- use CodeIgniter \CodeIgniter ;
98use CodeIgniter \Shield \Commands \Utils \InputOutput ;
109use CodeIgniter \Shield \Exceptions \LogicException ;
1110use CodeIgniter \Test \Filters \CITestStreamFilter ;
@@ -52,23 +51,21 @@ public function prompt(string $field, $options = null, $validation = null): stri
5251 {
5352 $ input = array_shift ($ this ->inputs );
5453
55- if (version_compare (CodeIgniter::CI_VERSION , '4.3.0 ' , '>= ' )) {
56- CITestStreamFilter::registration ();
57- CITestStreamFilter::addOutputFilter ();
54+ CITestStreamFilter::registration ();
55+ CITestStreamFilter::addOutputFilter ();
5856
59- PhpStreamWrapper::register ();
60- PhpStreamWrapper::setContent ($ input );
57+ PhpStreamWrapper::register ();
58+ PhpStreamWrapper::setContent ($ input );
6159
62- $ userInput = CLI ::prompt ($ field , $ options , $ validation );
60+ $ userInput = CLI ::prompt ($ field , $ options , $ validation );
6361
64- PhpStreamWrapper::restore ();
62+ PhpStreamWrapper::restore ();
6563
66- CITestStreamFilter::removeOutputFilter ();
67- CITestStreamFilter::removeErrorFilter ();
64+ CITestStreamFilter::removeOutputFilter ();
65+ CITestStreamFilter::removeErrorFilter ();
6866
69- if ($ input !== $ userInput ) {
70- throw new LogicException ($ input . '!== ' . $ userInput );
71- }
67+ if ($ input !== $ userInput ) {
68+ throw new LogicException ($ input . '!== ' . $ userInput );
7269 }
7370
7471 return $ input ;
@@ -79,23 +76,13 @@ public function write(
7976 ?string $ foreground = null ,
8077 ?string $ background = null
8178 ): void {
82- if (version_compare (CodeIgniter::CI_VERSION , '4.3.0 ' , '>= ' )) {
83- CITestStreamFilter::registration ();
84- CITestStreamFilter::addOutputFilter ();
85- } else {
86- CITestStreamFilter::$ buffer = '' ;
87-
88- $ streamFilter = stream_filter_append (STDOUT , 'CITestStreamFilter ' );
89- }
79+ CITestStreamFilter::registration ();
80+ CITestStreamFilter::addOutputFilter ();
9081
9182 CLI ::write ($ text , $ foreground , $ background );
9283 $ this ->outputs [] = CITestStreamFilter::$ buffer ;
9384
94- if (version_compare (CodeIgniter::CI_VERSION , '4.3.0 ' , '>= ' )) {
95- CITestStreamFilter::removeOutputFilter ();
96- CITestStreamFilter::removeErrorFilter ();
97- } else {
98- stream_filter_remove ($ streamFilter );
99- }
85+ CITestStreamFilter::removeOutputFilter ();
86+ CITestStreamFilter::removeErrorFilter ();
10087 }
10188}
0 commit comments