1 | <?php |
||
24 | final class Composer |
||
25 | { |
||
26 | /** |
||
27 | * The filesystem instance. |
||
28 | * |
||
29 | * @var \Illuminate\Filesystem\Filesystem |
||
30 | */ |
||
31 | private $files; |
||
32 | |||
33 | /** |
||
34 | * The working path to execute Composer from. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $workingPath; |
||
39 | |||
40 | /** |
||
41 | * The logging path to store Composer logs. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $loggingPath; |
||
46 | |||
47 | /** |
||
48 | * Create a new Composer manager instance. |
||
49 | * |
||
50 | * @param \Illuminate\Filesystem\Filesystem $files |
||
51 | * @param string $workingPath |
||
52 | * @param string $loggingPath |
||
53 | */ |
||
54 | public function __construct(Filesystem $files, string $workingPath, string $loggingPath) |
||
60 | |||
61 | /** |
||
62 | * Regenerate the Composer autoloader files. |
||
63 | * |
||
64 | * @param string[] $extra |
||
65 | * @return void |
||
66 | */ |
||
67 | public function dumpAutoload(array $extra = []): void |
||
73 | |||
74 | /** |
||
75 | * Regenerate the optimized Composer autoloader files. |
||
76 | * |
||
77 | * @return void |
||
78 | */ |
||
79 | public function dumpOptimized(): void |
||
83 | |||
84 | /** |
||
85 | * Install Composer requirement. |
||
86 | * |
||
87 | * @param \Cog\Contracts\Paket\Requirement\Entities\Requirement $requirement |
||
88 | * @param \Cog\Contracts\Paket\Job\Entities\Job $job |
||
89 | * @return void |
||
90 | * |
||
91 | * @throws \Cog\Contracts\Paket\Job\Exceptions\JobFailed |
||
92 | */ |
||
93 | public function install(RequirementContract $requirement, JobContract $job): void |
||
94 | { |
||
95 | $flags = [ |
||
96 | '--no-interaction', |
||
97 | ]; |
||
98 | |||
99 | if ($requirement->isDevelopment()) { |
||
100 | $flags[] = '--dev'; |
||
101 | } |
||
102 | |||
103 | $command = sprintf( |
||
104 | '%s require %s %s', |
||
105 | '/usr/bin/composer', |
||
106 | $requirement, |
||
107 | implode(' ', $flags) |
||
108 | ); |
||
109 | |||
110 | $this->executeCommand($job, $command); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Uninstall Composer requirement. |
||
115 | * |
||
116 | * @param \Cog\Contracts\Paket\Requirement\Entities\Requirement $requirement |
||
117 | * @param \Cog\Contracts\Paket\Job\Entities\Job $job |
||
118 | * @return void |
||
119 | * |
||
120 | * @throws \Cog\Contracts\Paket\Job\Exceptions\JobFailed |
||
121 | */ |
||
122 | public function uninstall(RequirementContract $requirement, JobContract $job): void |
||
123 | { |
||
124 | $flags = [ |
||
125 | '--no-interaction', |
||
126 | ]; |
||
127 | |||
128 | if ($requirement->isDevelopment()) { |
||
129 | $flags[] = '--dev'; |
||
130 | } |
||
131 | |||
132 | $command = sprintf( |
||
133 | '%s remove %s %s', |
||
134 | '/usr/bin/composer', |
||
135 | $requirement->getName(), |
||
136 | implode(' ', $flags) |
||
137 | ); |
||
138 | |||
139 | $this->executeCommand($job, $command); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Builds full command, executes it and logs process output. |
||
144 | * |
||
145 | * @param \Cog\Contracts\Paket\Job\Entities\Job $job |
||
146 | * @param string $command |
||
147 | * |
||
148 | * @throws \Cog\Contracts\Paket\Job\Exceptions\JobFailed |
||
149 | */ |
||
150 | private function executeCommand(JobContract $job, string $command): void |
||
180 | |||
181 | private function getComposerExecutable(): array |
||
189 | |||
190 | private function getPhpBinary(): string |
||
194 | |||
195 | private function getProcess(array $command): Process |
||
199 | |||
200 | private function writeLineToLogFile(string $jobLogFile, string $line): void |
||
201 | { |
||
204 | } |
||
205 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.