1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
/*
4
6
* This file is part of CLI Executor.
5
7
*
@@ -47,10 +49,9 @@ final class ScriptExecutor
47
49
48
50
/**
49
51
* @param string[] $scriptParts
50
- * @param string $cwd
51
52
* @param ?string[] $scriptInit
52
53
*/
53
- public function __construct ($ scriptParts , $ cwd , array $ scriptInit = null )
54
+ public function __construct (array $ scriptParts , string $ cwd , array $ scriptInit = null )
54
55
{
55
56
$ this ->scriptParts = $ scriptParts ;
56
57
$ this ->cwd = $ cwd ;
@@ -66,24 +67,17 @@ public function __destruct()
66
67
67
68
/**
68
69
* @param string[] $scriptParts
69
- * @param string $cwd
70
70
* @param ?string[] $scriptInit
71
- *
72
- * @return self
73
71
*/
74
- public static function create ($ scriptParts , $ cwd , array $ scriptInit = null )
72
+ public static function create (array $ scriptParts , string $ cwd , array $ scriptInit = null ): self
75
73
{
76
74
return new self ($ scriptParts , $ cwd , $ scriptInit );
77
75
}
78
76
79
77
/**
80
- * @param bool $checkCode
81
- *
82
78
* @throws ExecutionException
83
- *
84
- * @return CliResult
85
79
*/
86
- public function getResult ($ checkCode = true )
80
+ public function getResult (bool $ checkCode = true ): CliResult
87
81
{
88
82
if (null === $ this ->result ) {
89
83
$ tmpFileName = 'tmp- ' .self ::$ tmpCounter ++.'.sh ' ;
@@ -109,7 +103,7 @@ public function getResult($checkCode = true)
109
103
sprintf (
110
104
"Cannot execute `%s`: \n%s \nCode: %s \nExit text: %s \nError output: %s \nDetails: \n%s " ,
111
105
$ command ,
112
- implode ("\n" , array_map (function ($ line ) { return "$ $ { line}" ; }, $ tmpFileLines )),
106
+ implode ("\n" , array_map (function ($ line ) { return "$ { $ line }" ; }, $ tmpFileLines )),
113
107
$ this ->result ->getCode (),
114
108
isset (Process::$ exitCodes [$ this ->result ->getCode ()]) ? Process::$ exitCodes [$ this ->result ->getCode ()] : 'Unknown exit code ' ,
115
109
$ this ->result ->getError (),
0 commit comments