@@ -17,12 +17,10 @@ discard block |
||
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | * @author Johannes M. Schmitt <[email protected]> |
19 | 19 | */ |
20 | -class PhpExecutableFinder |
|
21 | -{ |
|
20 | +class PhpExecutableFinder { |
|
22 | 21 | private $executableFinder; |
23 | 22 | |
24 | - public function __construct() |
|
25 | - { |
|
23 | + public function __construct() { |
|
26 | 24 | $this->executableFinder = new ExecutableFinder(); |
27 | 25 | } |
28 | 26 | |
@@ -31,8 +29,7 @@ discard block |
||
31 | 29 | * |
32 | 30 | * @return string|false The PHP executable path or false if it cannot be found |
33 | 31 | */ |
34 | - public function find(bool $includeArgs = true) |
|
35 | - { |
|
32 | + public function find(bool $includeArgs = true) { |
|
36 | 33 | if ($php = getenv('PHP_BINARY')) { |
37 | 34 | if (!is_executable($php)) { |
38 | 35 | $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v'; |
@@ -87,8 +84,7 @@ discard block |
||
87 | 84 | * |
88 | 85 | * @return array The PHP executable arguments |
89 | 86 | */ |
90 | - public function findArguments() |
|
91 | - { |
|
87 | + public function findArguments() { |
|
92 | 88 | $arguments = []; |
93 | 89 | if ('phpdbg' === \PHP_SAPI) { |
94 | 90 | $arguments[] = '-qrr'; |
@@ -17,23 +17,20 @@ discard block |
||
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | * @author Johannes M. Schmitt <[email protected]> |
19 | 19 | */ |
20 | -class ExecutableFinder |
|
21 | -{ |
|
20 | +class ExecutableFinder { |
|
22 | 21 | private $suffixes = ['.exe', '.bat', '.cmd', '.com']; |
23 | 22 | |
24 | 23 | /** |
25 | 24 | * Replaces default suffixes of executable. |
26 | 25 | */ |
27 | - public function setSuffixes(array $suffixes) |
|
28 | - { |
|
26 | + public function setSuffixes(array $suffixes) { |
|
29 | 27 | $this->suffixes = $suffixes; |
30 | 28 | } |
31 | 29 | |
32 | 30 | /** |
33 | 31 | * Adds new possible suffix to check for executable. |
34 | 32 | */ |
35 | - public function addSuffix(string $suffix) |
|
36 | - { |
|
33 | + public function addSuffix(string $suffix) { |
|
37 | 34 | $this->suffixes[] = $suffix; |
38 | 35 | } |
39 | 36 | |
@@ -46,8 +43,7 @@ discard block |
||
46 | 43 | * |
47 | 44 | * @return string|null The executable path or default value |
48 | 45 | */ |
49 | - public function find(string $name, string $default = null, array $extraDirs = []) |
|
50 | - { |
|
46 | + public function find(string $name, string $default = null, array $extraDirs = []) { |
|
51 | 47 | if (ini_get('open_basedir')) { |
52 | 48 | $searchPath = array_merge(explode(\PATH_SEPARATOR, ini_get('open_basedir')), $extraDirs); |
53 | 49 | $dirs = []; |
@@ -28,8 +28,7 @@ discard block |
||
28 | 28 | * @author Fabien Potencier <[email protected]> |
29 | 29 | * @author Romain Neutron <[email protected]> |
30 | 30 | */ |
31 | -class Process implements \IteratorAggregate |
|
32 | -{ |
|
31 | +class Process implements \IteratorAggregate { |
|
33 | 32 | public const ERR = 'err'; |
34 | 33 | public const OUT = 'out'; |
35 | 34 | |
@@ -138,8 +137,7 @@ discard block |
||
138 | 137 | * |
139 | 138 | * @throws LogicException When proc_open is not installed |
140 | 139 | */ |
141 | - public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) |
|
142 | - { |
|
140 | + public function __construct(array $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { |
|
143 | 141 | if (!\function_exists('proc_open')) { |
144 | 142 | throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.'); |
145 | 143 | } |
@@ -187,8 +185,7 @@ discard block |
||
187 | 185 | * |
188 | 186 | * @throws LogicException When proc_open is not installed |
189 | 187 | */ |
190 | - public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) |
|
191 | - { |
|
188 | + public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60) { |
|
192 | 189 | $process = new static([], $cwd, $env, $input, $timeout); |
193 | 190 | $process->commandline = $command; |
194 | 191 | |
@@ -198,18 +195,15 @@ discard block |
||
198 | 195 | /** |
199 | 196 | * @return array |
200 | 197 | */ |
201 | - public function __sleep() |
|
202 | - { |
|
198 | + public function __sleep() { |
|
203 | 199 | throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
204 | 200 | } |
205 | 201 | |
206 | - public function __wakeup() |
|
207 | - { |
|
202 | + public function __wakeup() { |
|
208 | 203 | throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
209 | 204 | } |
210 | 205 | |
211 | - public function __destruct() |
|
212 | - { |
|
206 | + public function __destruct() { |
|
213 | 207 | if ($this->options['create_new_console'] ?? false) { |
214 | 208 | $this->processPipes->close(); |
215 | 209 | } else { |
@@ -217,8 +211,7 @@ discard block |
||
217 | 211 | } |
218 | 212 | } |
219 | 213 | |
220 | - public function __clone() |
|
221 | - { |
|
214 | + public function __clone() { |
|
222 | 215 | $this->resetProcessData(); |
223 | 216 | } |
224 | 217 | |
@@ -292,8 +285,7 @@ discard block |
||
292 | 285 | * @throws RuntimeException When process is already running |
293 | 286 | * @throws LogicException In case a callback is provided and output has been disabled |
294 | 287 | */ |
295 | - public function start(callable $callback = null, array $env = []) |
|
296 | - { |
|
288 | + public function start(callable $callback = null, array $env = []) { |
|
297 | 289 | if ($this->isRunning()) { |
298 | 290 | throw new RuntimeException('Process is already running.'); |
299 | 291 | } |
@@ -410,8 +402,7 @@ discard block |
||
410 | 402 | * @throws ProcessSignaledException When process stopped after receiving signal |
411 | 403 | * @throws LogicException When process is not yet started |
412 | 404 | */ |
413 | - public function wait(callable $callback = null) |
|
414 | - { |
|
405 | + public function wait(callable $callback = null) { |
|
415 | 406 | $this->requireProcessIsStarted(__FUNCTION__); |
416 | 407 | |
417 | 408 | $this->updateStatus(false); |
@@ -493,8 +484,7 @@ discard block |
||
493 | 484 | * |
494 | 485 | * @return int|null The process id if running, null otherwise |
495 | 486 | */ |
496 | - public function getPid() |
|
497 | - { |
|
487 | + public function getPid() { |
|
498 | 488 | return $this->isRunning() ? $this->processInformation['pid'] : null; |
499 | 489 | } |
500 | 490 | |
@@ -509,8 +499,7 @@ discard block |
||
509 | 499 | * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed |
510 | 500 | * @throws RuntimeException In case of failure |
511 | 501 | */ |
512 | - public function signal(int $signal) |
|
513 | - { |
|
502 | + public function signal(int $signal) { |
|
514 | 503 | $this->doSignal($signal, true); |
515 | 504 | |
516 | 505 | return $this; |
@@ -524,8 +513,7 @@ discard block |
||
524 | 513 | * @throws RuntimeException In case the process is already running |
525 | 514 | * @throws LogicException if an idle timeout is set |
526 | 515 | */ |
527 | - public function disableOutput() |
|
528 | - { |
|
516 | + public function disableOutput() { |
|
529 | 517 | if ($this->isRunning()) { |
530 | 518 | throw new RuntimeException('Disabling output while the process is running is not possible.'); |
531 | 519 | } |
@@ -545,8 +533,7 @@ discard block |
||
545 | 533 | * |
546 | 534 | * @throws RuntimeException In case the process is already running |
547 | 535 | */ |
548 | - public function enableOutput() |
|
549 | - { |
|
536 | + public function enableOutput() { |
|
550 | 537 | if ($this->isRunning()) { |
551 | 538 | throw new RuntimeException('Enabling output while the process is running is not possible.'); |
552 | 539 | } |
@@ -561,8 +548,7 @@ discard block |
||
561 | 548 | * |
562 | 549 | * @return bool |
563 | 550 | */ |
564 | - public function isOutputDisabled() |
|
565 | - { |
|
551 | + public function isOutputDisabled() { |
|
566 | 552 | return $this->outputDisabled; |
567 | 553 | } |
568 | 554 | |
@@ -574,8 +560,7 @@ discard block |
||
574 | 560 | * @throws LogicException in case the output has been disabled |
575 | 561 | * @throws LogicException In case the process is not started |
576 | 562 | */ |
577 | - public function getOutput() |
|
578 | - { |
|
563 | + public function getOutput() { |
|
579 | 564 | $this->readPipesForOutput(__FUNCTION__); |
580 | 565 | |
581 | 566 | if (false === $ret = stream_get_contents($this->stdout, -1, 0)) { |
@@ -596,8 +581,7 @@ discard block |
||
596 | 581 | * @throws LogicException in case the output has been disabled |
597 | 582 | * @throws LogicException In case the process is not started |
598 | 583 | */ |
599 | - public function getIncrementalOutput() |
|
600 | - { |
|
584 | + public function getIncrementalOutput() { |
|
601 | 585 | $this->readPipesForOutput(__FUNCTION__); |
602 | 586 | |
603 | 587 | $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset); |
@@ -621,8 +605,7 @@ discard block |
||
621 | 605 | * @return \Generator |
622 | 606 | */ |
623 | 607 | #[\ReturnTypeWillChange] |
624 | - public function getIterator(int $flags = 0) |
|
625 | - { |
|
608 | + public function getIterator(int $flags = 0) { |
|
626 | 609 | $this->readPipesForOutput(__FUNCTION__, false); |
627 | 610 | |
628 | 611 | $clearOutput = !(self::ITER_KEEP_OUTPUT & $flags); |
@@ -673,8 +656,7 @@ discard block |
||
673 | 656 | * |
674 | 657 | * @return $this |
675 | 658 | */ |
676 | - public function clearOutput() |
|
677 | - { |
|
659 | + public function clearOutput() { |
|
678 | 660 | ftruncate($this->stdout, 0); |
679 | 661 | fseek($this->stdout, 0); |
680 | 662 | $this->incrementalOutputOffset = 0; |
@@ -690,8 +672,7 @@ discard block |
||
690 | 672 | * @throws LogicException in case the output has been disabled |
691 | 673 | * @throws LogicException In case the process is not started |
692 | 674 | */ |
693 | - public function getErrorOutput() |
|
694 | - { |
|
675 | + public function getErrorOutput() { |
|
695 | 676 | $this->readPipesForOutput(__FUNCTION__); |
696 | 677 | |
697 | 678 | if (false === $ret = stream_get_contents($this->stderr, -1, 0)) { |
@@ -713,8 +694,7 @@ discard block |
||
713 | 694 | * @throws LogicException in case the output has been disabled |
714 | 695 | * @throws LogicException In case the process is not started |
715 | 696 | */ |
716 | - public function getIncrementalErrorOutput() |
|
717 | - { |
|
697 | + public function getIncrementalErrorOutput() { |
|
718 | 698 | $this->readPipesForOutput(__FUNCTION__); |
719 | 699 | |
720 | 700 | $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset); |
@@ -732,8 +712,7 @@ discard block |
||
732 | 712 | * |
733 | 713 | * @return $this |
734 | 714 | */ |
735 | - public function clearErrorOutput() |
|
736 | - { |
|
715 | + public function clearErrorOutput() { |
|
737 | 716 | ftruncate($this->stderr, 0); |
738 | 717 | fseek($this->stderr, 0); |
739 | 718 | $this->incrementalErrorOutputOffset = 0; |
@@ -746,8 +725,7 @@ discard block |
||
746 | 725 | * |
747 | 726 | * @return int|null The exit status code, null if the Process is not terminated |
748 | 727 | */ |
749 | - public function getExitCode() |
|
750 | - { |
|
728 | + public function getExitCode() { |
|
751 | 729 | $this->updateStatus(false); |
752 | 730 | |
753 | 731 | return $this->exitcode; |
@@ -764,8 +742,7 @@ discard block |
||
764 | 742 | * @see http://tldp.org/LDP/abs/html/exitcodes.html |
765 | 743 | * @see http://en.wikipedia.org/wiki/Unix_signal |
766 | 744 | */ |
767 | - public function getExitCodeText() |
|
768 | - { |
|
745 | + public function getExitCodeText() { |
|
769 | 746 | if (null === $exitcode = $this->getExitCode()) { |
770 | 747 | return null; |
771 | 748 | } |
@@ -778,8 +755,7 @@ discard block |
||
778 | 755 | * |
779 | 756 | * @return bool true if the process ended successfully, false otherwise |
780 | 757 | */ |
781 | - public function isSuccessful() |
|
782 | - { |
|
758 | + public function isSuccessful() { |
|
783 | 759 | return 0 === $this->getExitCode(); |
784 | 760 | } |
785 | 761 | |
@@ -792,8 +768,7 @@ discard block |
||
792 | 768 | * |
793 | 769 | * @throws LogicException In case the process is not terminated |
794 | 770 | */ |
795 | - public function hasBeenSignaled() |
|
796 | - { |
|
771 | + public function hasBeenSignaled() { |
|
797 | 772 | $this->requireProcessIsTerminated(__FUNCTION__); |
798 | 773 | |
799 | 774 | return $this->processInformation['signaled']; |
@@ -809,8 +784,7 @@ discard block |
||
809 | 784 | * @throws RuntimeException In case --enable-sigchild is activated |
810 | 785 | * @throws LogicException In case the process is not terminated |
811 | 786 | */ |
812 | - public function getTermSignal() |
|
813 | - { |
|
787 | + public function getTermSignal() { |
|
814 | 788 | $this->requireProcessIsTerminated(__FUNCTION__); |
815 | 789 | |
816 | 790 | if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) { |
@@ -829,8 +803,7 @@ discard block |
||
829 | 803 | * |
830 | 804 | * @throws LogicException In case the process is not terminated |
831 | 805 | */ |
832 | - public function hasBeenStopped() |
|
833 | - { |
|
806 | + public function hasBeenStopped() { |
|
834 | 807 | $this->requireProcessIsTerminated(__FUNCTION__); |
835 | 808 | |
836 | 809 | return $this->processInformation['stopped']; |
@@ -845,8 +818,7 @@ discard block |
||
845 | 818 | * |
846 | 819 | * @throws LogicException In case the process is not terminated |
847 | 820 | */ |
848 | - public function getStopSignal() |
|
849 | - { |
|
821 | + public function getStopSignal() { |
|
850 | 822 | $this->requireProcessIsTerminated(__FUNCTION__); |
851 | 823 | |
852 | 824 | return $this->processInformation['stopsig']; |
@@ -857,8 +829,7 @@ discard block |
||
857 | 829 | * |
858 | 830 | * @return bool true if the process is currently running, false otherwise |
859 | 831 | */ |
860 | - public function isRunning() |
|
861 | - { |
|
832 | + public function isRunning() { |
|
862 | 833 | if (self::STATUS_STARTED !== $this->status) { |
863 | 834 | return false; |
864 | 835 | } |
@@ -873,8 +844,7 @@ discard block |
||
873 | 844 | * |
874 | 845 | * @return bool true if status is ready, false otherwise |
875 | 846 | */ |
876 | - public function isStarted() |
|
877 | - { |
|
847 | + public function isStarted() { |
|
878 | 848 | return self::STATUS_READY != $this->status; |
879 | 849 | } |
880 | 850 | |
@@ -883,8 +853,7 @@ discard block |
||
883 | 853 | * |
884 | 854 | * @return bool true if process is terminated, false otherwise |
885 | 855 | */ |
886 | - public function isTerminated() |
|
887 | - { |
|
856 | + public function isTerminated() { |
|
888 | 857 | $this->updateStatus(false); |
889 | 858 | |
890 | 859 | return self::STATUS_TERMINATED == $this->status; |
@@ -897,8 +866,7 @@ discard block |
||
897 | 866 | * |
898 | 867 | * @return string The current process status |
899 | 868 | */ |
900 | - public function getStatus() |
|
901 | - { |
|
869 | + public function getStatus() { |
|
902 | 870 | $this->updateStatus(false); |
903 | 871 | |
904 | 872 | return $this->status; |
@@ -912,8 +880,7 @@ discard block |
||
912 | 880 | * |
913 | 881 | * @return int|null The exit-code of the process or null if it's not running |
914 | 882 | */ |
915 | - public function stop(float $timeout = 10, int $signal = null) |
|
916 | - { |
|
883 | + public function stop(float $timeout = 10, int $signal = null) { |
|
917 | 884 | $timeoutMicro = microtime(true) + $timeout; |
918 | 885 | if ($this->isRunning()) { |
919 | 886 | // given SIGTERM may not be defined and that "proc_terminate" uses the constant value and not the constant itself, we use the same here |
@@ -946,8 +913,7 @@ discard block |
||
946 | 913 | * |
947 | 914 | * @internal |
948 | 915 | */ |
949 | - public function addOutput(string $line) |
|
950 | - { |
|
916 | + public function addOutput(string $line) { |
|
951 | 917 | $this->lastOutputTime = microtime(true); |
952 | 918 | |
953 | 919 | fseek($this->stdout, 0, \SEEK_END); |
@@ -960,8 +926,7 @@ discard block |
||
960 | 926 | * |
961 | 927 | * @internal |
962 | 928 | */ |
963 | - public function addErrorOutput(string $line) |
|
964 | - { |
|
929 | + public function addErrorOutput(string $line) { |
|
965 | 930 | $this->lastOutputTime = microtime(true); |
966 | 931 | |
967 | 932 | fseek($this->stderr, 0, \SEEK_END); |
@@ -984,8 +949,7 @@ discard block |
||
984 | 949 | * |
985 | 950 | * @return string The command to execute |
986 | 951 | */ |
987 | - public function getCommandLine() |
|
988 | - { |
|
952 | + public function getCommandLine() { |
|
989 | 953 | return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline; |
990 | 954 | } |
991 | 955 | |
@@ -994,8 +958,7 @@ discard block |
||
994 | 958 | * |
995 | 959 | * @return float|null The timeout in seconds or null if it's disabled |
996 | 960 | */ |
997 | - public function getTimeout() |
|
998 | - { |
|
961 | + public function getTimeout() { |
|
999 | 962 | return $this->timeout; |
1000 | 963 | } |
1001 | 964 | |
@@ -1004,8 +967,7 @@ discard block |
||
1004 | 967 | * |
1005 | 968 | * @return float|null The timeout in seconds or null if it's disabled |
1006 | 969 | */ |
1007 | - public function getIdleTimeout() |
|
1008 | - { |
|
970 | + public function getIdleTimeout() { |
|
1009 | 971 | return $this->idleTimeout; |
1010 | 972 | } |
1011 | 973 | |
@@ -1018,8 +980,7 @@ discard block |
||
1018 | 980 | * |
1019 | 981 | * @throws InvalidArgumentException if the timeout is negative |
1020 | 982 | */ |
1021 | - public function setTimeout(?float $timeout) |
|
1022 | - { |
|
983 | + public function setTimeout(?float $timeout) { |
|
1023 | 984 | $this->timeout = $this->validateTimeout($timeout); |
1024 | 985 | |
1025 | 986 | return $this; |
@@ -1035,8 +996,7 @@ discard block |
||
1035 | 996 | * @throws LogicException if the output is disabled |
1036 | 997 | * @throws InvalidArgumentException if the timeout is negative |
1037 | 998 | */ |
1038 | - public function setIdleTimeout(?float $timeout) |
|
1039 | - { |
|
999 | + public function setIdleTimeout(?float $timeout) { |
|
1040 | 1000 | if (null !== $timeout && $this->outputDisabled) { |
1041 | 1001 | throw new LogicException('Idle timeout can not be set while the output is disabled.'); |
1042 | 1002 | } |
@@ -1053,8 +1013,7 @@ discard block |
||
1053 | 1013 | * |
1054 | 1014 | * @throws RuntimeException In case the TTY mode is not supported |
1055 | 1015 | */ |
1056 | - public function setTty(bool $tty) |
|
1057 | - { |
|
1016 | + public function setTty(bool $tty) { |
|
1058 | 1017 | if ('\\' === \DIRECTORY_SEPARATOR && $tty) { |
1059 | 1018 | throw new RuntimeException('TTY mode is not supported on Windows platform.'); |
1060 | 1019 | } |
@@ -1073,8 +1032,7 @@ discard block |
||
1073 | 1032 | * |
1074 | 1033 | * @return bool true if the TTY mode is enabled, false otherwise |
1075 | 1034 | */ |
1076 | - public function isTty() |
|
1077 | - { |
|
1035 | + public function isTty() { |
|
1078 | 1036 | return $this->tty; |
1079 | 1037 | } |
1080 | 1038 | |
@@ -1083,8 +1041,7 @@ discard block |
||
1083 | 1041 | * |
1084 | 1042 | * @return $this |
1085 | 1043 | */ |
1086 | - public function setPty(bool $bool) |
|
1087 | - { |
|
1044 | + public function setPty(bool $bool) { |
|
1088 | 1045 | $this->pty = $bool; |
1089 | 1046 | |
1090 | 1047 | return $this; |
@@ -1095,8 +1052,7 @@ discard block |
||
1095 | 1052 | * |
1096 | 1053 | * @return bool |
1097 | 1054 | */ |
1098 | - public function isPty() |
|
1099 | - { |
|
1055 | + public function isPty() { |
|
1100 | 1056 | return $this->pty; |
1101 | 1057 | } |
1102 | 1058 | |
@@ -1105,8 +1061,7 @@ discard block |
||
1105 | 1061 | * |
1106 | 1062 | * @return string|null The current working directory or null on failure |
1107 | 1063 | */ |
1108 | - public function getWorkingDirectory() |
|
1109 | - { |
|
1064 | + public function getWorkingDirectory() { |
|
1110 | 1065 | if (null === $this->cwd) { |
1111 | 1066 | // getcwd() will return false if any one of the parent directories does not have |
1112 | 1067 | // the readable or search mode set, even if the current directory does |
@@ -1121,8 +1076,7 @@ discard block |
||
1121 | 1076 | * |
1122 | 1077 | * @return $this |
1123 | 1078 | */ |
1124 | - public function setWorkingDirectory(string $cwd) |
|
1125 | - { |
|
1079 | + public function setWorkingDirectory(string $cwd) { |
|
1126 | 1080 | $this->cwd = $cwd; |
1127 | 1081 | |
1128 | 1082 | return $this; |
@@ -1133,8 +1087,7 @@ discard block |
||
1133 | 1087 | * |
1134 | 1088 | * @return array The current environment variables |
1135 | 1089 | */ |
1136 | - public function getEnv() |
|
1137 | - { |
|
1090 | + public function getEnv() { |
|
1138 | 1091 | return $this->env; |
1139 | 1092 | } |
1140 | 1093 | |
@@ -1153,8 +1106,7 @@ discard block |
||
1153 | 1106 | * |
1154 | 1107 | * @return $this |
1155 | 1108 | */ |
1156 | - public function setEnv(array $env) |
|
1157 | - { |
|
1109 | + public function setEnv(array $env) { |
|
1158 | 1110 | // Process can not handle env values that are arrays |
1159 | 1111 | $env = array_filter($env, function ($value) { |
1160 | 1112 | return !\is_array($value); |
@@ -1170,8 +1122,7 @@ discard block |
||
1170 | 1122 | * |
1171 | 1123 | * @return resource|string|\Iterator|null The Process input |
1172 | 1124 | */ |
1173 | - public function getInput() |
|
1174 | - { |
|
1125 | + public function getInput() { |
|
1175 | 1126 | return $this->input; |
1176 | 1127 | } |
1177 | 1128 | |
@@ -1186,8 +1137,7 @@ discard block |
||
1186 | 1137 | * |
1187 | 1138 | * @throws LogicException In case the process is running |
1188 | 1139 | */ |
1189 | - public function setInput($input) |
|
1190 | - { |
|
1140 | + public function setInput($input) { |
|
1191 | 1141 | if ($this->isRunning()) { |
1192 | 1142 | throw new LogicException('Input can not be set while the process is running.'); |
1193 | 1143 | } |
@@ -1205,8 +1155,7 @@ discard block |
||
1205 | 1155 | * |
1206 | 1156 | * @throws ProcessTimedOutException In case the timeout was reached |
1207 | 1157 | */ |
1208 | - public function checkTimeout() |
|
1209 | - { |
|
1158 | + public function checkTimeout() { |
|
1210 | 1159 | if (self::STATUS_STARTED !== $this->status) { |
1211 | 1160 | return; |
1212 | 1161 | } |
@@ -1244,8 +1193,7 @@ discard block |
||
1244 | 1193 | * Enabling the "create_new_console" option allows a subprocess to continue |
1245 | 1194 | * to run after the main process exited, on both Windows and *nix |
1246 | 1195 | */ |
1247 | - public function setOptions(array $options) |
|
1248 | - { |
|
1196 | + public function setOptions(array $options) { |
|
1249 | 1197 | if ($this->isRunning()) { |
1250 | 1198 | throw new RuntimeException('Setting options while the process is running is not possible.'); |
1251 | 1199 | } |
@@ -1281,8 +1229,7 @@ discard block |
||
1281 | 1229 | * |
1282 | 1230 | * @return bool |
1283 | 1231 | */ |
1284 | - public static function isPtySupported() |
|
1285 | - { |
|
1232 | + public static function isPtySupported() { |
|
1286 | 1233 | static $result; |
1287 | 1234 | |
1288 | 1235 | if (null !== $result) { |
@@ -1323,8 +1270,7 @@ discard block |
||
1323 | 1270 | * |
1324 | 1271 | * @return \Closure A PHP closure |
1325 | 1272 | */ |
1326 | - protected function buildCallback(callable $callback = null) |
|
1327 | - { |
|
1273 | + protected function buildCallback(callable $callback = null) { |
|
1328 | 1274 | if ($this->outputDisabled) { |
1329 | 1275 | return function ($type, $data) use ($callback): bool { |
1330 | 1276 | return null !== $callback && $callback($type, $data); |
@@ -1349,8 +1295,7 @@ discard block |
||
1349 | 1295 | * |
1350 | 1296 | * @param bool $blocking Whether to use a blocking read call |
1351 | 1297 | */ |
1352 | - protected function updateStatus(bool $blocking) |
|
1353 | - { |
|
1298 | + protected function updateStatus(bool $blocking) { |
|
1354 | 1299 | if (self::STATUS_STARTED !== $this->status) { |
1355 | 1300 | return; |
1356 | 1301 | } |
@@ -1374,8 +1319,7 @@ discard block |
||
1374 | 1319 | * |
1375 | 1320 | * @return bool |
1376 | 1321 | */ |
1377 | - protected function isSigchildEnabled() |
|
1378 | - { |
|
1322 | + protected function isSigchildEnabled() { |
|
1379 | 1323 | if (null !== self::$sigchild) { |
1380 | 1324 | return self::$sigchild; |
1381 | 1325 | } |
@@ -1398,8 +1342,7 @@ discard block |
||
1398 | 1342 | * |
1399 | 1343 | * @throws LogicException in case output has been disabled or process is not started |
1400 | 1344 | */ |
1401 | - private function readPipesForOutput(string $caller, bool $blocking = false) |
|
1402 | - { |
|
1345 | + private function readPipesForOutput(string $caller, bool $blocking = false) { |
|
1403 | 1346 | if ($this->outputDisabled) { |
1404 | 1347 | throw new LogicException('Output has been disabled.'); |
1405 | 1348 | } |
@@ -1433,8 +1376,7 @@ discard block |
||
1433 | 1376 | * @param bool $blocking Whether to use blocking calls or not |
1434 | 1377 | * @param bool $close Whether to close file handles or not |
1435 | 1378 | */ |
1436 | - private function readPipes(bool $blocking, bool $close) |
|
1437 | - { |
|
1379 | + private function readPipes(bool $blocking, bool $close) { |
|
1438 | 1380 | $result = $this->processPipes->readAndWrite($blocking, $close); |
1439 | 1381 | |
1440 | 1382 | $callback = $this->callback; |
@@ -1482,8 +1424,7 @@ discard block |
||
1482 | 1424 | /** |
1483 | 1425 | * Resets data related to the latest run of the process. |
1484 | 1426 | */ |
1485 | - private function resetProcessData() |
|
1486 | - { |
|
1427 | + private function resetProcessData() { |
|
1487 | 1428 | $this->starttime = null; |
1488 | 1429 | $this->callback = null; |
1489 | 1430 | $this->exitcode = null; |
@@ -1605,8 +1546,7 @@ discard block |
||
1605 | 1546 | * |
1606 | 1547 | * @throws LogicException if the process has not run |
1607 | 1548 | */ |
1608 | - private function requireProcessIsStarted(string $functionName) |
|
1609 | - { |
|
1549 | + private function requireProcessIsStarted(string $functionName) { |
|
1610 | 1550 | if (!$this->isStarted()) { |
1611 | 1551 | throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName)); |
1612 | 1552 | } |
@@ -1617,8 +1557,7 @@ discard block |
||
1617 | 1557 | * |
1618 | 1558 | * @throws LogicException if the process is not yet terminated |
1619 | 1559 | */ |
1620 | - private function requireProcessIsTerminated(string $functionName) |
|
1621 | - { |
|
1560 | + private function requireProcessIsTerminated(string $functionName) { |
|
1622 | 1561 | if (!$this->isTerminated()) { |
1623 | 1562 | throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName)); |
1624 | 1563 | } |
@@ -1646,8 +1585,7 @@ discard block |
||
1646 | 1585 | return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"'; |
1647 | 1586 | } |
1648 | 1587 | |
1649 | - private function replacePlaceholders(string $commandline, array $env) |
|
1650 | - { |
|
1588 | + private function replacePlaceholders(string $commandline, array $env) { |
|
1651 | 1589 | return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) { |
1652 | 1590 | if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) { |
1653 | 1591 | throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline); |
@@ -18,8 +18,7 @@ |
||
18 | 18 | * |
19 | 19 | * @internal |
20 | 20 | */ |
21 | -final class Php80 |
|
22 | -{ |
|
21 | +final class Php80 { |
|
23 | 22 | public static function fdiv(float $dividend, float $divisor): float |
24 | 23 | { |
25 | 24 | return @($dividend / $divisor); |
@@ -1,8 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (\PHP_VERSION_ID < 80000) { |
4 | - interface Stringable |
|
5 | - { |
|
4 | + interface Stringable { |
|
6 | 5 | /** |
7 | 6 | * @return string |
8 | 7 | */ |
@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class ValueError extends Error |
|
4 | -{ |
|
3 | +class ValueError extends Error { |
|
5 | 4 | } |
@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class UnhandledMatchError extends Error |
|
4 | -{ |
|
3 | +class UnhandledMatchError extends Error { |
|
5 | 4 | } |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | #[Attribute(Attribute::TARGET_CLASS)] |
4 | -final class Attribute |
|
5 | -{ |
|
4 | +final class Attribute { |
|
6 | 5 | public const TARGET_CLASS = 1; |
7 | 6 | public const TARGET_FUNCTION = 2; |
8 | 7 | public const TARGET_METHOD = 4; |
@@ -15,8 +14,7 @@ discard block |
||
15 | 14 | /** @var int */ |
16 | 15 | public $flags; |
17 | 16 | |
18 | - public function __construct(int $flags = self::TARGET_ALL) |
|
19 | - { |
|
17 | + public function __construct(int $flags = self::TARGET_ALL) { |
|
20 | 18 | $this->flags = $flags; |
21 | 19 | } |
22 | 20 | } |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @internal |
19 | 19 | */ |
20 | -final class Php73 |
|
21 | -{ |
|
20 | +final class Php73 { |
|
22 | 21 | public static $startAt = 1533462603; |
23 | 22 | |
24 | 23 | /** |
@@ -26,8 +25,7 @@ discard block |
||
26 | 25 | * |
27 | 26 | * @return array|float|int |
28 | 27 | */ |
29 | - public static function hrtime($asNum = false) |
|
30 | - { |
|
28 | + public static function hrtime($asNum = false) { |
|
31 | 29 | $ns = microtime(false); |
32 | 30 | $s = substr($ns, 11) - self::$startAt; |
33 | 31 | $ns = 1E9 * (float) $ns; |