Complex classes like Repository often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Repository, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
68 | class Repository |
||
69 | { |
||
70 | /** |
||
71 | * the repository path |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | private $path; |
||
76 | |||
77 | /** |
||
78 | * the caller instance |
||
79 | * |
||
80 | * @var \GitElephant\Command\Caller\Caller |
||
81 | */ |
||
82 | private $caller; |
||
83 | |||
84 | /** |
||
85 | * A general repository name |
||
86 | * |
||
87 | * @var string $name the repository name |
||
88 | */ |
||
89 | private $name; |
||
90 | |||
91 | /** |
||
92 | * A list of global configs to apply to every command |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | private $globalConfigs = []; |
||
97 | |||
98 | /** |
||
99 | * A list of global options to apply to every command |
||
100 | * |
||
101 | * @var array |
||
102 | */ |
||
103 | private $globalOptions = []; |
||
104 | |||
105 | /** |
||
106 | * A list of global arguments to apply to every command |
||
107 | * |
||
108 | * @var array |
||
109 | */ |
||
110 | private $globalCommandArguments = []; |
||
111 | |||
112 | /** |
||
113 | * Class constructor |
||
114 | * |
||
115 | * @param string $repositoryPath the path of the git repository |
||
116 | * @param string|null $binary the path to the git binary |
||
117 | * @param string $name a repository name |
||
118 | * |
||
119 | * @throws Exception\InvalidRepositoryPathException |
||
120 | */ |
||
121 | 107 | public function __construct($repositoryPath, string $binary = null, $name = null) |
|
127 | |||
128 | /** |
||
129 | * Factory method |
||
130 | * |
||
131 | * @param string $repositoryPath the path of the git repository |
||
132 | * @param string|null $binary the path to the git binary |
||
133 | * @param string $name a repository name |
||
134 | * |
||
135 | * @return \GitElephant\Repository |
||
136 | */ |
||
137 | 106 | public static function open($repositoryPath, string $binary = null, $name = null) |
|
141 | |||
142 | /** |
||
143 | * create a repository from a remote git url, or a local filesystem |
||
144 | * and save it in a temp folder |
||
145 | * |
||
146 | * @param string|Repository $git the git remote url, or the filesystem path |
||
147 | * @param null $repositoryPath path |
||
148 | * @param string|null $binary the path to the git binary |
||
149 | * @param null $name repository name |
||
150 | * |
||
151 | * @throws \RuntimeException |
||
152 | * @throws \Symfony\Component\Filesystem\Exception\IOException |
||
153 | * @return Repository |
||
154 | */ |
||
155 | 1 | public static function createFromRemote($git, $repositoryPath = null, string $binary = null, $name = null) |
|
172 | |||
173 | /** |
||
174 | * Init the repository |
||
175 | * |
||
176 | * @param bool $bare created a bare repository |
||
177 | * |
||
178 | * @throws \RuntimeException |
||
179 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
180 | * @throws InvalidArgumentException |
||
181 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
182 | * @return Repository |
||
183 | */ |
||
184 | 94 | public function init($bare = false) |
|
190 | |||
191 | /** |
||
192 | * Stage the working tree content |
||
193 | * |
||
194 | * @param string|NodeObject $path the path to store |
||
195 | * |
||
196 | * @throws \RuntimeException |
||
197 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
198 | * @throws InvalidArgumentException |
||
199 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
200 | * @return Repository |
||
201 | */ |
||
202 | 90 | public function stage($path = '.') |
|
208 | |||
209 | /** |
||
210 | * Unstage a tree content |
||
211 | * |
||
212 | * @param string|NodeObject $path the path to unstage |
||
213 | * |
||
214 | * @throws \RuntimeException |
||
215 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
216 | * @throws InvalidArgumentException |
||
217 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
218 | * @return Repository |
||
219 | */ |
||
220 | 2 | public function unstage($path) |
|
226 | |||
227 | /** |
||
228 | * Move a file/directory |
||
229 | * |
||
230 | * @param string|NodeObject $from source path |
||
231 | * @param string|NodeObject $to destination path |
||
232 | * |
||
233 | * @throws \RuntimeException |
||
234 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
235 | * @throws \InvalidArgumentException |
||
236 | * @throws InvalidArgumentException |
||
237 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
238 | * @return Repository |
||
239 | */ |
||
240 | 1 | public function move($from, $to) |
|
246 | |||
247 | /** |
||
248 | * Remove a file/directory |
||
249 | * |
||
250 | * @param string|NodeObject $path the path to remove |
||
251 | * @param bool $recursive recurse |
||
252 | * @param bool $force force |
||
253 | * |
||
254 | * @throws \RuntimeException |
||
255 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
256 | * @throws \InvalidArgumentException |
||
257 | * @throws InvalidArgumentException |
||
258 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
259 | * @return Repository |
||
260 | */ |
||
261 | 1 | public function remove($path, $recursive = false, $force = false) |
|
267 | |||
268 | /** |
||
269 | * Commit content to the repository, eventually staging all unstaged content |
||
270 | * |
||
271 | * @param string $message the commit message |
||
272 | * @param bool $stageAll whether to stage on not everything before commit |
||
273 | * @param string|null $ref the reference to commit to (checkout -> commit -> checkout previous) |
||
274 | * @param string|Author $author override the author for this commit |
||
275 | * @param bool $allowEmpty override the author for this commit |
||
276 | * |
||
277 | * @throws \RuntimeException |
||
278 | * @throws \InvalidArgumentException |
||
279 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
280 | * @return Repository |
||
281 | */ |
||
282 | 85 | public function commit(string $message, $stageAll = false, $ref = null, $author = null, $allowEmpty = false) |
|
299 | |||
300 | /** |
||
301 | * rev-parse command - often used to return a commit tag. |
||
302 | * |
||
303 | * @param array $options the options to apply to rev-parse |
||
304 | * @param string|NodeObject|Commit $arg the argument (may be a branch head, etc) |
||
305 | * |
||
306 | * @throws \RuntimeException |
||
307 | * @throws \InvalidArgumentException |
||
308 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
309 | * @return array |
||
310 | */ |
||
311 | 1 | public function revParse(string $arg = null, array $options = []) |
|
317 | |||
318 | /** |
||
319 | * Check if this is a bare repository |
||
320 | * |
||
321 | * @return boolean |
||
322 | */ |
||
323 | 1 | public function isBare() |
|
330 | |||
331 | /** |
||
332 | * @param TreeishInterface|Commit|string $arg |
||
333 | * @param array $options |
||
334 | */ |
||
335 | 2 | public function reset($arg, $options) |
|
339 | |||
340 | /** |
||
341 | * Get the repository status |
||
342 | * |
||
343 | * @return Status |
||
344 | */ |
||
345 | 5 | public function getStatus() |
|
349 | |||
350 | /** |
||
351 | * @return Status |
||
352 | */ |
||
353 | 1 | public function getWorkingTreeStatus() |
|
357 | |||
358 | /** |
||
359 | * @return Status |
||
360 | */ |
||
361 | 4 | public function getIndexStatus() |
|
365 | |||
366 | /** |
||
367 | * isClean Return true if the repository is not dirty. |
||
368 | * |
||
369 | * @return boolean |
||
370 | */ |
||
371 | public function isClean() |
||
375 | |||
376 | /** |
||
377 | * isDirty Return true if the repository has some modified files. |
||
378 | * |
||
379 | * @return boolean |
||
380 | */ |
||
381 | public function isDirty() |
||
385 | |||
386 | /** |
||
387 | * Get the repository status as a string |
||
388 | * |
||
389 | * @throws \RuntimeException |
||
390 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
391 | * @throws InvalidArgumentException |
||
392 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
393 | * @return array |
||
394 | */ |
||
395 | 4 | public function getStatusOutput() |
|
401 | |||
402 | /** |
||
403 | * Create a new branch |
||
404 | * |
||
405 | * @param string $name the new branch name |
||
406 | * @param null $startPoint the reference to create the branch from |
||
407 | * |
||
408 | * @throws \RuntimeException |
||
409 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
410 | * @return Repository |
||
411 | */ |
||
412 | 27 | public function createBranch(string $name, $startPoint = null) |
|
418 | |||
419 | /** |
||
420 | * Delete a branch by its name |
||
421 | * This function change the state of the repository on the filesystem |
||
422 | * |
||
423 | * @param string $name The branch to delete |
||
424 | * @param bool $force Force the delete |
||
425 | * |
||
426 | * @throws \RuntimeException |
||
427 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
428 | * @throws InvalidArgumentException |
||
429 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
430 | * @return Repository |
||
431 | */ |
||
432 | 1 | public function deleteBranch(string $name, bool $force = false) |
|
438 | |||
439 | /** |
||
440 | * An array of Branch objects |
||
441 | * |
||
442 | * @param bool $namesOnly return an array of branch names as a string |
||
443 | * @param bool $all lists also remote branches |
||
444 | * |
||
445 | * @throws \RuntimeException |
||
446 | * @throws InvalidArgumentException |
||
447 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
448 | * @throws \InvalidArgumentException |
||
449 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
450 | * @return array |
||
451 | */ |
||
452 | 17 | public function getBranches(bool $namesOnly = false, bool $all = false) |
|
478 | |||
479 | /** |
||
480 | * Return the actually checked out branch |
||
481 | * |
||
482 | * @throws \RuntimeException |
||
483 | * @throws \InvalidArgumentException |
||
484 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
485 | * @return Objects\Branch |
||
486 | */ |
||
487 | 5 | public function getMainBranch() |
|
499 | |||
500 | /** |
||
501 | * Retrieve a Branch object by a branch name |
||
502 | * |
||
503 | * @param string $name The branch name |
||
504 | * |
||
505 | * @throws \RuntimeException |
||
506 | * @throws \InvalidArgumentException |
||
507 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
508 | * @return null|Branch |
||
509 | */ |
||
510 | 9 | public function getBranch(string $name) |
|
521 | |||
522 | /** |
||
523 | * Checkout all branches from the remote and make them local |
||
524 | * |
||
525 | * @param string $remote remote to fetch from |
||
526 | * |
||
527 | * @throws \RuntimeException |
||
528 | * @throws \InvalidArgumentException |
||
529 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
530 | * @return Repository |
||
531 | */ |
||
532 | 1 | public function checkoutAllRemoteBranches($remote = 'origin') |
|
554 | |||
555 | /** |
||
556 | * Merge a Branch in the current checked out branch |
||
557 | * |
||
558 | * @param Objects\Branch $branch The branch to merge in the current checked out branch |
||
559 | * @param string $message The message for the merge commit, if merge is 3-way |
||
560 | * @param string $mode The merge mode: ff-only, no-ff or auto |
||
561 | * |
||
562 | * @throws \RuntimeException |
||
563 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
564 | * @throws InvalidArgumentException |
||
565 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
566 | * @return Repository |
||
567 | */ |
||
568 | 2 | public function merge(Branch $branch, string $message = '', string $mode = 'auto') |
|
593 | |||
594 | /** |
||
595 | * Create a new tag |
||
596 | * This function change the state of the repository on the filesystem |
||
597 | * |
||
598 | * @param string $name The new tag name |
||
599 | * @param null $startPoint The reference to create the tag from |
||
600 | * @param null $message the tag message |
||
601 | * |
||
602 | * @throws \RuntimeException |
||
603 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
604 | * @return Repository |
||
605 | */ |
||
606 | 25 | public function createTag(string $name, $startPoint = null, string $message = null) |
|
612 | |||
613 | /** |
||
614 | * Delete a tag by it's name or by passing a Tag object |
||
615 | * This function change the state of the repository on the filesystem |
||
616 | * |
||
617 | * @param string|Tag $tag The tag name or the Tag object |
||
618 | * |
||
619 | * @throws \RuntimeException |
||
620 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
621 | * @return Repository |
||
622 | */ |
||
623 | 2 | public function deleteTag($tag) |
|
633 | |||
634 | /** |
||
635 | * add a git submodule to the repository |
||
636 | * |
||
637 | * @param string $gitUrl git url of the submodule |
||
638 | * @param string $path path to register the submodule to |
||
639 | * |
||
640 | * @throws \RuntimeException |
||
641 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
642 | * @throws InvalidArgumentException |
||
643 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
644 | * @return Repository |
||
645 | */ |
||
646 | 1 | public function addSubmodule(string $gitUrl, $path = null) |
|
652 | |||
653 | /** |
||
654 | * initialize submodules |
||
655 | * |
||
656 | * @param string $path init only submodules at the specified path |
||
657 | * |
||
658 | * @return Repository |
||
659 | */ |
||
660 | public function initSubmodule($path = null) |
||
666 | |||
667 | /** |
||
668 | * update submodules |
||
669 | * |
||
670 | * @param bool $recursive update recursively |
||
671 | * @param bool $init init before update |
||
672 | * @param bool $force force the checkout as part of update |
||
673 | * @param string $path update only a specific submodule path |
||
674 | * |
||
675 | * @return Repository |
||
676 | */ |
||
677 | public function updateSubmodule( |
||
687 | |||
688 | /** |
||
689 | * Gets an array of Tag objects |
||
690 | * |
||
691 | * @throws \RuntimeException |
||
692 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
693 | * @throws InvalidArgumentException |
||
694 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
695 | * @return array |
||
696 | */ |
||
697 | 4 | public function getTags() |
|
709 | |||
710 | /** |
||
711 | * Return a tag object |
||
712 | * |
||
713 | * @param string $name The tag name |
||
714 | * |
||
715 | * @throws \RuntimeException |
||
716 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
717 | * @return Tag|null |
||
718 | */ |
||
719 | 28 | public function getTag(string $name) |
|
733 | |||
734 | /** |
||
735 | * Return the last created tag |
||
736 | * |
||
737 | * @throws \LogicException |
||
738 | * @throws \RuntimeException |
||
739 | * @throws \InvalidArgumentException |
||
740 | * @return Tag|null |
||
741 | */ |
||
742 | 1 | public function getLastTag() |
|
761 | |||
762 | /** |
||
763 | * Try to get a branch or a tag by its name. |
||
764 | * |
||
765 | * @param string $name the reference name (a tag name or a branch name) |
||
766 | * |
||
767 | * @throws \RuntimeException |
||
768 | * @throws \InvalidArgumentException |
||
769 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
770 | * @return \GitElephant\Objects\Tag|\GitElephant\Objects\Branch|null |
||
771 | */ |
||
772 | 1 | public function getBranchOrTag(string $name) |
|
786 | |||
787 | /** |
||
788 | * Return a Commit object |
||
789 | * |
||
790 | * @param string $ref The commit reference |
||
791 | * |
||
792 | * @throws \RuntimeException |
||
793 | * @return Objects\Commit |
||
794 | */ |
||
795 | 15 | public function getCommit($ref = 'HEAD') |
|
801 | |||
802 | /** |
||
803 | * count the commit to arrive to the given treeish |
||
804 | * |
||
805 | * @param string $start |
||
806 | * |
||
807 | * @throws \RuntimeException |
||
808 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
809 | * @return int |
||
810 | */ |
||
811 | 3 | public function countCommits($start = 'HEAD') |
|
817 | |||
818 | /** |
||
819 | * Get a log for a ref |
||
820 | * |
||
821 | * @param string|TreeishInterface|array $ref the treeish to check, as a string, as an object or as an array |
||
822 | * @param string|NodeObject $path the physical path to the tree relative to the repository root |
||
823 | * @param int|null $limit limit to n entries |
||
824 | * @param int|null $offset skip n entries |
||
825 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
826 | * |
||
827 | * @return \GitElephant\Objects\Log |
||
828 | */ |
||
829 | 20 | public function getLog( |
|
838 | |||
839 | /** |
||
840 | * Get a log for a range ref |
||
841 | * |
||
842 | * @param string $refStart |
||
843 | * @param string $refEnd |
||
844 | * @param string|NodeObject $path the physical path to the tree relative to the repository root |
||
845 | * @param int|null $limit limit to n entries |
||
846 | * @param int|null $offset skip n entries |
||
847 | * @param boolean|false $firstParent skip commits brought in to branch by a merge |
||
848 | * |
||
849 | * @return \GitElephant\Objects\LogRange|\GitElephant\Objects\Log |
||
850 | */ |
||
851 | public function getLogRange( |
||
871 | |||
872 | /** |
||
873 | * Get a log for an object |
||
874 | * |
||
875 | * @param \GitElephant\Objects\NodeObject $obj The Object instance |
||
876 | * @param null|string|\GitElephant\Objects\Branch $branch The branch to read from |
||
877 | * @param int $limit Limit to n entries |
||
878 | * @param int|null $offset Skip n entries |
||
879 | * |
||
880 | * @throws \RuntimeException |
||
881 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
882 | * @throws InvalidArgumentException |
||
883 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
884 | * @return \GitElephant\Objects\Log |
||
885 | */ |
||
886 | 3 | public function getObjectLog(NodeObject $obj, $branch = null, int $limit = 1, int $offset = null) |
|
892 | |||
893 | /** |
||
894 | * Checkout a branch |
||
895 | * This function change the state of the repository on the filesystem |
||
896 | * |
||
897 | * @param string|TreeishInterface $ref the reference to checkout |
||
898 | * @param bool $create like -b on the command line |
||
899 | * |
||
900 | * @throws \RuntimeException |
||
901 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
902 | * @throws InvalidArgumentException |
||
903 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
904 | * @return Repository |
||
905 | */ |
||
906 | 24 | public function checkout($ref, bool $create = false) |
|
915 | |||
916 | /** |
||
917 | * Retrieve an instance of Tree |
||
918 | * Tree Object is Countable, Iterable and has ArrayAccess for easy manipulation |
||
919 | * |
||
920 | * @param string|TreeishInterface $ref the treeish to check |
||
921 | * @param string|NodeObject $path Object or null for root |
||
922 | * |
||
923 | * @throws \RuntimeException |
||
924 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
925 | * @throws InvalidArgumentException |
||
926 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
927 | * @return Objects\Tree |
||
928 | */ |
||
929 | 15 | public function getTree($ref = 'HEAD', $path = null) |
|
942 | |||
943 | /** |
||
944 | * Get a Diff object for a commit with its parent, by default the diff is between the current head and its parent |
||
945 | * |
||
946 | * @param \GitElephant\Objects\Commit|string $commit1 A TreeishInterface instance |
||
947 | * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance |
||
948 | * @param null|string|NodeObject $path The path to get the diff for or a Object instance |
||
949 | * |
||
950 | * @throws \RuntimeException |
||
951 | * @throws \InvalidArgumentException |
||
952 | * @return Objects\Diff\Diff |
||
953 | */ |
||
954 | 2 | public function getDiff(string $commit1 = null, string $commit2 = null, string $path = null) |
|
958 | |||
959 | /** |
||
960 | * Clone a repository |
||
961 | * |
||
962 | * @param string $url the repository url (i.e. git://github.com/matteosister/GitElephant.git) |
||
963 | * @param null $to where to clone the repo |
||
964 | * @param string|null $repoReference Repo reference to clone. Required if performing a shallow clone. |
||
965 | * @param int|null $depth Depth to clone repo. Specify 1 to perform a shallow clone |
||
966 | * @param bool $recursive Whether to recursively clone child repos. |
||
967 | * |
||
968 | * @throws \RuntimeException |
||
969 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
970 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
971 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
972 | * @return Repository |
||
973 | */ |
||
974 | 2 | public function cloneFrom(string $url, string $to = null, string $repoReference = null, int $depth = null, bool $recursive = false) |
|
980 | |||
981 | /** |
||
982 | * @param string $name remote name |
||
983 | * @param string $url remote url |
||
984 | * |
||
985 | * @throws \RuntimeException |
||
986 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
987 | * @throws InvalidArgumentException |
||
988 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
989 | * @return Repository |
||
990 | */ |
||
991 | 7 | public function addRemote(string $name, string $url) |
|
997 | |||
998 | /** |
||
999 | * @param string $name remote name |
||
1000 | * @param bool $queryRemotes Fetch new information from remotes |
||
1001 | * |
||
1002 | * @return \GitElephant\Objects\Remote |
||
1003 | */ |
||
1004 | 1 | public function getRemote(string $name, bool $queryRemotes = true) |
|
1008 | |||
1009 | /** |
||
1010 | * gets a list of remote objects |
||
1011 | * |
||
1012 | * @param bool $queryRemotes Fetch new information from remotes |
||
1013 | * |
||
1014 | * @throws \RuntimeException |
||
1015 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1016 | * @throws InvalidArgumentException |
||
1017 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1018 | * @return array |
||
1019 | */ |
||
1020 | 1 | public function getRemotes(bool $queryRemotes = true) |
|
1033 | |||
1034 | /** |
||
1035 | * Download objects and refs from another repository |
||
1036 | * |
||
1037 | * @param string $from |
||
1038 | * @param string $ref |
||
1039 | * @param bool $tags |
||
1040 | * |
||
1041 | * @throws \RuntimeException |
||
1042 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1043 | * @throws InvalidArgumentException |
||
1044 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1045 | */ |
||
1046 | 1 | public function fetch($from = null, $ref = null, bool $tags = false) |
|
1054 | |||
1055 | /** |
||
1056 | * Fetch from and merge with another repository or a local branch |
||
1057 | * |
||
1058 | * @param string $from |
||
1059 | * @param string $ref |
||
1060 | * @param bool $rebase |
||
1061 | * |
||
1062 | * @throws \RuntimeException |
||
1063 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1064 | * @throws InvalidArgumentException |
||
1065 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1066 | */ |
||
1067 | 2 | public function pull($from = null, $ref = null, bool $rebase = true) |
|
1071 | |||
1072 | /** |
||
1073 | * Push changes to remote repository |
||
1074 | * |
||
1075 | * @param string $to |
||
1076 | * @param string $ref |
||
1077 | * @param string $args |
||
1078 | * |
||
1079 | * @throws \RuntimeException |
||
1080 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1081 | * @throws InvalidArgumentException |
||
1082 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1083 | */ |
||
1084 | 1 | public function push($to = null, $ref = null, string $args = null) |
|
1088 | |||
1089 | /** |
||
1090 | * get the humanish name of the repository |
||
1091 | * |
||
1092 | * @return string |
||
1093 | */ |
||
1094 | 2 | public function getHumanishName() |
|
1102 | |||
1103 | /** |
||
1104 | * output a node content as an array of lines |
||
1105 | * |
||
1106 | * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB |
||
1107 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
1108 | * |
||
1109 | * @throws \RuntimeException |
||
1110 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1111 | * @throws InvalidArgumentException |
||
1112 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1113 | * @return array |
||
1114 | */ |
||
1115 | 1 | public function outputContent(NodeObject $obj, $treeish) |
|
1121 | |||
1122 | /** |
||
1123 | * output a node raw content |
||
1124 | * |
||
1125 | * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB |
||
1126 | * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object |
||
1127 | * |
||
1128 | * @throws \RuntimeException |
||
1129 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
1130 | * @throws InvalidArgumentException |
||
1131 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
1132 | * @return string |
||
1133 | */ |
||
1134 | public function outputRawContent(NodeObject $obj, $treeish) |
||
1140 | |||
1141 | /** |
||
1142 | * Get the path |
||
1143 | * |
||
1144 | * @return string |
||
1145 | */ |
||
1146 | 64 | public function getPath() |
|
1150 | |||
1151 | /** |
||
1152 | * Get the repository name |
||
1153 | * |
||
1154 | * @return string |
||
1155 | */ |
||
1156 | 1 | public function getName() |
|
1160 | |||
1161 | /** |
||
1162 | * Set the repository name |
||
1163 | * |
||
1164 | * @param string $name the repository name |
||
1165 | */ |
||
1166 | 1 | public function setName(string $name) |
|
1170 | |||
1171 | /** |
||
1172 | * Caller setter |
||
1173 | * |
||
1174 | * @param \GitElephant\Command\Caller\Caller $caller the caller variable |
||
1175 | */ |
||
1176 | public function setCaller(Caller $caller) |
||
1180 | |||
1181 | /** |
||
1182 | * Caller getter |
||
1183 | * |
||
1184 | * @return \GitElephant\Command\Caller\Caller |
||
1185 | */ |
||
1186 | 91 | public function getCaller() |
|
1190 | |||
1191 | /** |
||
1192 | * get global config list |
||
1193 | * |
||
1194 | * @return array Global config list |
||
1195 | */ |
||
1196 | 97 | public function getGlobalConfigs() |
|
1200 | |||
1201 | /** |
||
1202 | * add a key/value pair to the global config list |
||
1203 | * |
||
1204 | * @param string $name The config name |
||
1205 | * @param mixed $value The config value |
||
1206 | */ |
||
1207 | 1 | public function addGlobalConfig(string $name, $value) |
|
1211 | |||
1212 | /** |
||
1213 | * remove an element form the global config list, identified by key |
||
1214 | * |
||
1215 | * @param string $name The config name |
||
1216 | */ |
||
1217 | 1 | public function removeGlobalConfig(string $name) |
|
1223 | |||
1224 | /** |
||
1225 | * get global options list |
||
1226 | * |
||
1227 | * @return array Global options list |
||
1228 | */ |
||
1229 | 97 | public function getGlobalOptions() |
|
1233 | |||
1234 | /** |
||
1235 | * add a key/value pair to the global option list |
||
1236 | * |
||
1237 | * @param string $name The option name |
||
1238 | * @param mixed $value The option value |
||
1239 | */ |
||
1240 | 1 | public function addGlobalOption(string $name, $value) |
|
1244 | |||
1245 | /** |
||
1246 | * remove an element form the global option list, identified by key |
||
1247 | * |
||
1248 | * @param string $name The option name |
||
1249 | */ |
||
1250 | 1 | public function removeGlobalOption(string $name) |
|
1256 | |||
1257 | /** |
||
1258 | * get global command arguments list |
||
1259 | * |
||
1260 | * @return array Global command arguments list |
||
1261 | */ |
||
1262 | 97 | public function getGlobalCommandArguments() |
|
1266 | |||
1267 | /** |
||
1268 | * add a value to the global command argument list |
||
1269 | * |
||
1270 | * @param string $value The command argument |
||
1271 | */ |
||
1272 | 1 | public function addGlobalCommandArgument($value) |
|
1278 | |||
1279 | /** |
||
1280 | * remove an element form the global command argument list, identified by |
||
1281 | * value |
||
1282 | * |
||
1283 | * @param string $value The command argument |
||
1284 | */ |
||
1285 | 1 | public function removeGlobalCommandArgument($value) |
|
1292 | |||
1293 | /** |
||
1294 | * Save your local modifications to a new stash, and run git reset --hard to revert them. |
||
1295 | * |
||
1296 | * @param string|null $message |
||
1297 | * @param boolean $includeUntracked |
||
1298 | * @param boolean $keepIndex |
||
1299 | */ |
||
1300 | 2 | public function stash(string $message = null, bool $includeUntracked = false, bool $keepIndex = false) |
|
1306 | |||
1307 | /** |
||
1308 | * Shows stash list |
||
1309 | * |
||
1310 | * @param array|null $options |
||
1311 | * |
||
1312 | * @return array |
||
1313 | */ |
||
1314 | 1 | public function stashList(array $options = null) |
|
1322 | |||
1323 | /** |
||
1324 | * Shows details for a stash |
||
1325 | * |
||
1326 | * @param string $stash |
||
1327 | * |
||
1328 | * @return string |
||
1329 | */ |
||
1330 | 1 | public function stashShow(string $stash) |
|
1338 | |||
1339 | /** |
||
1340 | * Drops a stash |
||
1341 | * |
||
1342 | * @param string $stash |
||
1343 | */ |
||
1344 | 1 | public function stashDrop(string $stash) |
|
1350 | |||
1351 | /** |
||
1352 | * Applies a stash |
||
1353 | * |
||
1354 | * @param string $stash |
||
1355 | * @param boolean $index |
||
1356 | */ |
||
1357 | 1 | public function stashApply(string $stash, bool $index = false) |
|
1363 | |||
1364 | /** |
||
1365 | * Applies a stash, then removes it from the stash |
||
1366 | * |
||
1367 | * @param string $stash |
||
1368 | * @param boolean $index |
||
1369 | */ |
||
1370 | 1 | public function stashPop(string $stash, bool $index = false) |
|
1376 | |||
1377 | /** |
||
1378 | * Creates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created |
||
1379 | * |
||
1380 | * @param string $branch |
||
1381 | * @param string $stash |
||
1382 | */ |
||
1383 | 1 | public function stashBranch(string $branch, string $stash) |
|
1389 | |||
1390 | /** |
||
1391 | * Save your local modifications to a new stash, and run git reset --hard to revert them. |
||
1392 | * |
||
1393 | */ |
||
1394 | public function stashClear() |
||
1400 | |||
1401 | /** |
||
1402 | * Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the |
||
1403 | * ref namespace. |
||
1404 | * |
||
1405 | * @return string |
||
1406 | */ |
||
1407 | 1 | public function stashCreate() |
|
1415 | } |
||
1416 |
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.