1 | <?php |
||
33 | class MainCommand extends BaseCommand |
||
34 | { |
||
35 | public const GIT_INIT = 'init'; |
||
36 | public const GIT_STATUS = 'status'; |
||
37 | public const GIT_ADD = 'add'; |
||
38 | public const GIT_COMMIT = 'commit'; |
||
39 | public const GIT_CHECKOUT = 'checkout'; |
||
40 | public const GIT_MOVE = 'mv'; |
||
41 | public const GIT_REMOVE = 'rm'; |
||
42 | public const GIT_RESET = 'reset'; |
||
43 | |||
44 | /** |
||
45 | * constructor |
||
46 | * |
||
47 | * @param \GitElephant\Repository $repo The repository object this command |
||
48 | * will interact with |
||
49 | */ |
||
50 | 105 | public function __construct(Repository $repo = null) |
|
54 | |||
55 | /** |
||
56 | * Init the repository |
||
57 | * |
||
58 | * @param bool $bare |
||
59 | * |
||
60 | * @throws \RuntimeException |
||
61 | * @return string |
||
62 | */ |
||
63 | 100 | public function init($bare = false): string |
|
73 | |||
74 | /** |
||
75 | * Get the repository status |
||
76 | * |
||
77 | * @param bool $porcelain |
||
78 | * |
||
79 | * @throws \RuntimeException |
||
80 | * @return string |
||
81 | */ |
||
82 | 13 | public function status($porcelain = false): string |
|
94 | |||
95 | /** |
||
96 | * Add a node to the stage |
||
97 | * |
||
98 | * @param string $what what should be added to the repository |
||
99 | * |
||
100 | * @throws \RuntimeException |
||
101 | * @return string |
||
102 | */ |
||
103 | 95 | public function add($what = '.'): string |
|
112 | |||
113 | /** |
||
114 | * Remove a node from the stage and put in the working tree |
||
115 | * |
||
116 | * @param string $what what should be removed from the stage |
||
117 | * |
||
118 | * @throws \RuntimeException |
||
119 | * @return string |
||
120 | */ |
||
121 | 2 | public function unstage($what): string |
|
130 | |||
131 | /** |
||
132 | * Commit |
||
133 | * |
||
134 | * @param string|null $message the commit message |
||
135 | * @param bool $stageAll commit all changes |
||
136 | * @param string|Author $author override the author for this commit |
||
137 | * @param bool $allowEmpty whether to add param `--allow-empty` to commit command |
||
138 | * @param \DateTimeInterface|null $date |
||
139 | * |
||
140 | * @throws \RuntimeException |
||
141 | * @throws \InvalidArgumentException |
||
142 | * @return string |
||
143 | */ |
||
144 | 95 | public function commit( |
|
181 | |||
182 | /** |
||
183 | * Checkout a treeish reference |
||
184 | * |
||
185 | * @param string|Branch|TreeishInterface $ref the reference to checkout |
||
186 | * |
||
187 | * @throws \RuntimeException |
||
188 | * @return string |
||
189 | */ |
||
190 | 23 | public function checkout($ref): string |
|
207 | |||
208 | /** |
||
209 | * Move a file/directory |
||
210 | * |
||
211 | * @param string|Object $from source path |
||
212 | * @param string|Object $to destination path |
||
213 | * |
||
214 | * @throws \RuntimeException |
||
215 | * @throws \InvalidArgumentException |
||
216 | * @return string |
||
217 | */ |
||
218 | 1 | public function move($from, $to): string |
|
238 | |||
239 | /** |
||
240 | * Remove a file/directory |
||
241 | * |
||
242 | * @param string|Object $path the path to remove |
||
243 | * @param bool $recursive recurse |
||
244 | * @param bool $force force |
||
245 | * |
||
246 | * @throws \RuntimeException |
||
247 | * @throws \InvalidArgumentException |
||
248 | * @return string |
||
249 | */ |
||
250 | 1 | public function remove($path, $recursive, $force): string |
|
273 | |||
274 | /** |
||
275 | * Validates a path |
||
276 | * |
||
277 | * @param string $path path |
||
278 | * |
||
279 | * @return bool |
||
280 | */ |
||
281 | 2 | protected function validatePath($path): bool |
|
295 | } |
||
296 |
This check looks at variables that have been passed in as parameters and 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.