Skip to content

Commit f64dbc8

Browse files
committed
use constructor property promotion
1 parent 56c8a1e commit f64dbc8

File tree

6 files changed

+24
-39
lines changed

6 files changed

+24
-39
lines changed

Exception/ProcessFailedException.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
*/
2121
class ProcessFailedException extends RuntimeException
2222
{
23-
private Process $process;
24-
25-
public function __construct(Process $process)
26-
{
23+
public function __construct(
24+
private Process $process,
25+
) {
2726
if ($process->isSuccessful()) {
2827
throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
2928
}

Exception/ProcessSignaledException.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
*/
2121
final class ProcessSignaledException extends RuntimeException
2222
{
23-
private Process $process;
24-
25-
public function __construct(Process $process)
26-
{
27-
$this->process = $process;
28-
23+
public function __construct(
24+
private Process $process,
25+
) {
2926
parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
3027
}
3128

Exception/ProcessStartFailedException.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
class ProcessStartFailedException extends ProcessFailedException
2020
{
21-
private Process $process;
22-
23-
public function __construct(Process $process, ?string $message)
24-
{
21+
public function __construct(
22+
private Process $process,
23+
?string $message,
24+
) {
2525
if ($process->isStarted()) {
2626
throw new InvalidArgumentException('Expected a process that failed during startup, but the given process was started successfully.');
2727
}
@@ -34,8 +34,6 @@ public function __construct(Process $process, ?string $message)
3434

3535
// Skip parent constructor
3636
RuntimeException::__construct($error);
37-
38-
$this->process = $process;
3937
}
4038

4139
public function getProcess(): Process

Exception/ProcessTimedOutException.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,10 @@ class ProcessTimedOutException extends RuntimeException
2323
public const TYPE_GENERAL = 1;
2424
public const TYPE_IDLE = 2;
2525

26-
private Process $process;
27-
private int $timeoutType;
28-
29-
public function __construct(Process $process, int $timeoutType)
30-
{
31-
$this->process = $process;
32-
$this->timeoutType = $timeoutType;
33-
26+
public function __construct(
27+
private Process $process,
28+
private int $timeoutType,
29+
) {
3430
parent::__construct(sprintf(
3531
'The process "%s" exceeded the timeout of %s seconds.',
3632
$process->getCommandLine(),

Pipes/UnixPipes.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@
2222
*/
2323
class UnixPipes extends AbstractPipes
2424
{
25-
private ?bool $ttyMode;
26-
private bool $ptyMode;
27-
private bool $haveReadSupport;
28-
29-
public function __construct(?bool $ttyMode, bool $ptyMode, mixed $input, bool $haveReadSupport)
30-
{
31-
$this->ttyMode = $ttyMode;
32-
$this->ptyMode = $ptyMode;
33-
$this->haveReadSupport = $haveReadSupport;
34-
25+
public function __construct(
26+
private ?bool $ttyMode,
27+
private bool $ptyMode,
28+
mixed $input,
29+
private bool $haveReadSupport,
30+
) {
3531
parent::__construct($input);
3632
}
3733

Pipes/WindowsPipes.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ class WindowsPipes extends AbstractPipes
3333
Process::STDOUT => 0,
3434
Process::STDERR => 0,
3535
];
36-
private bool $haveReadSupport;
37-
38-
public function __construct(mixed $input, bool $haveReadSupport)
39-
{
40-
$this->haveReadSupport = $haveReadSupport;
4136

37+
public function __construct(
38+
mixed $input,
39+
private bool $haveReadSupport,
40+
) {
4241
if ($this->haveReadSupport) {
4342
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
4443
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.

0 commit comments

Comments
 (0)