File tree Expand file tree Collapse file tree 4 files changed +19
-29
lines changed
Expand file tree Collapse file tree 4 files changed +19
-29
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ abstract class BaseLoader implements LoaderInterface
1111{
1212 protected Tinker $ tinker ;
1313
14- public function init ()
14+ public function init (): void
1515 {
1616 $ config = new Configuration ([
1717 'configFile ' => null ,
@@ -26,7 +26,9 @@ public function init()
2626 $ config ->setVerbosity (Configuration::VERBOSITY_QUIET );
2727 $ config ->setHistoryFile (defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'null ' : '/dev/null ' );
2828 $ config ->setRawOutput (false );
29- $ config ->setUsePcntl (false );
29+ if (getenv ('KUBERNETES_SERVICE_HOST ' ) || defined ('PHP_WINDOWS_VERSION_BUILD ' )) {
30+ $ config ->setUsePcntl (false );
31+ }
3032
3133 if (class_exists ('Illuminate\Support\Collection ' ) && class_exists ('Laravel\Tinker\TinkerCaster ' )) {
3234 $ config ->getPresenter ()->addCasters ([
@@ -47,10 +49,10 @@ public function init()
4749 $ this ->tinker = new Tinker (new CustomOutputModifier , $ config );
4850 }
4951
50- public function execute (string $ code )
52+ public function execute (string $ code ): string
5153 {
5254 $ output = $ this ->tinker ->execute ($ code );
5355
54- echo trim ($ output );
56+ return trim ($ output );
5557 }
5658}
Original file line number Diff line number Diff line change @@ -10,13 +10,7 @@ public function name(): string;
1010
1111 public function version (): string ;
1212
13- /**
14- * @return void
15- */
16- public function init ();
13+ public function init (): void ;
1714
18- /**
19- * @return string
20- */
21- public function execute (string $ code );
15+ public function execute (string $ code ): string ;
2216}
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ public function name(): string
2626 public function version (): string
2727 {
2828 try {
29- return get_bloginfo ('version ' );
29+ if (function_exists ('get_bloginfo ' )) {
30+ return get_bloginfo ('version ' );
31+ }
3032 } catch (Throwable $ e ) {
3133 //
3234 }
Original file line number Diff line number Diff line change @@ -29,23 +29,15 @@ public function execute(string $phpCode): string
2929 {
3030 $ phpCode = $ this ->removeComments ($ phpCode );
3131
32- $ phpCode = explode ("\n" , $ phpCode );
33-
34- $ output = '' ;
35-
36- foreach ($ phpCode as $ key => $ line ) {
37- $ this ->shell ->addInput ($ line );
38- $ closure = new ExecutionLoopClosure ($ this ->shell );
39- $ closure ->execute ();
40- $ result = $ this ->outputModifier ->modify ($ this ->cleanOutput ($ this ->output ->fetch ()));
41- if (trim ($ result ) !== '' && trim ($ result ) !== 'null ' ) {
42- $ output .= 'Line ' .$ key + 1 .' Result: ' .PHP_EOL ;
43- $ output .= $ result ;
44- $ output .= PHP_EOL ;
45- }
46- }
32+ $ this ->shell ->addInput ($ phpCode );
33+
34+ $ closure = new ExecutionLoopClosure ($ this ->shell );
35+
36+ $ closure ->execute ();
37+
38+ $ output = $ this ->cleanOutput ($ this ->output ->fetch ());
4739
48- return $ output ;
40+ return $ this -> outputModifier -> modify ( $ output) ;
4941 }
5042
5143 protected function createShell (BufferedOutput $ output , Configuration $ config ): Shell
You can’t perform that action at this time.
0 commit comments