@@ -57,7 +57,7 @@ final public function apply()
57
57
protected function doApply ()
58
58
{
59
59
$ patchPath = escapeshellarg ($ this ->fileInfo ->getRealPath ());
60
- $ process = Process:: fromShellCommandline ("patch -p 1 < $ patchPath " );
60
+ $ process = $ this -> fromShellCommandline ("patch -p 1 < $ patchPath " );
61
61
$ process ->mustRun ();
62
62
return $ process ->getExitCode () === 0 ;
63
63
}
@@ -68,7 +68,7 @@ protected function doApply()
68
68
protected function canApply ()
69
69
{
70
70
$ patchPath = escapeshellarg ($ this ->fileInfo ->getRealPath ());
71
- $ process = Process:: fromShellCommandline ("patch --dry-run -p 1 < $ patchPath " );
71
+ $ process = $ this -> fromShellCommandline ("patch --dry-run -p 1 < $ patchPath " );
72
72
try {
73
73
$ process ->mustRun ();
74
74
return $ process ->getExitCode () === 0 ;
@@ -85,7 +85,7 @@ protected function canApply()
85
85
protected function isApplied ()
86
86
{
87
87
$ patchPath = escapeshellarg ($ this ->fileInfo ->getRealPath ());
88
- $ process = Process:: fromShellCommandline ("patch --dry-run -p 1 -R < $ patchPath " );
88
+ $ process = $ this -> fromShellCommandline ("patch --dry-run -p 1 -R < $ patchPath " );
89
89
try {
90
90
$ process ->mustRun ();
91
91
$ result = $ process ->getExitCode () === 0 ;
@@ -101,6 +101,20 @@ protected function isApplied()
101
101
}
102
102
}
103
103
104
+ /**
105
+ * @process string $cmd Command to execute.
106
+ * @return Process
107
+ */
108
+ protected function fromShellCommandline ($ cmd )
109
+ {
110
+ // Newer Symfony/Process versions use Process::fromShellCommandline().
111
+ // We have to support both because Composer uses an ancient one bundled in the phar.
112
+ if (is_callable ([Process::class, 'fromShellCommandline ' ])) {
113
+ return Process::fromShellCommandline ($ cmd );
114
+ }
115
+ return new Process ($ cmd );
116
+ }
117
+
104
118
/**
105
119
* @return Output
106
120
*/
0 commit comments