@@ -44,32 +44,32 @@ public static function download(string $remote, string $targetDir): self
44
44
return new self (realpath ($ targetDir ));
45
45
}
46
46
47
- public function getPath ()
47
+ public function getPath (): string
48
48
{
49
49
return $ this ->path ;
50
50
}
51
51
52
- public function getUrl ()
52
+ public function getUrl (): string
53
53
{
54
54
return $ this ->getLastLine ($ this ->execInPath ('git config --get remote.origin.url ' ));
55
55
}
56
56
57
- public function getLastCommitHash ()
57
+ public function getLastCommitHash (): string
58
58
{
59
59
return $ this ->getLastLine ($ this ->execInPath ('git log -1 --format="%H" ' ));
60
60
}
61
61
62
- public function getLastAuthor ()
62
+ public function getLastAuthor (): string
63
63
{
64
64
return $ this ->getLastLine ($ this ->execInPath ('git log -1 --format="%an" ' ));
65
65
}
66
66
67
- public function getLastAuthoredDate ()
67
+ public function getLastAuthoredDate (): \ DateTime
68
68
{
69
69
return new \DateTime ($ this ->getLastLine ($ this ->execInPath ('git log -1 --format="%ai" ' )));
70
70
}
71
71
72
- public function getLastTag (callable $ filter = null )
72
+ public function getLastTag (callable $ filter = null ): string
73
73
{
74
74
$ tags = $ this ->execInPath ('git tag -l --sort=v:refname ' );
75
75
@@ -80,17 +80,17 @@ public function getLastTag(callable $filter = null)
80
80
return $ this ->getLastLine ($ tags );
81
81
}
82
82
83
- public function checkout ($ branch )
83
+ public function checkout (string $ branch )
84
84
{
85
85
$ this ->execInPath (sprintf ('git checkout %s ' , escapeshellarg ($ branch )));
86
86
}
87
87
88
- private function execInPath (string $ command )
88
+ private function execInPath (string $ command ): array
89
89
{
90
90
return self ::exec (sprintf ('cd %s && %s ' , escapeshellarg ($ this ->path ), $ command ));
91
91
}
92
92
93
- private static function exec ($ command , $ customErrorMessage = null )
93
+ private static function exec (string $ command , string $ customErrorMessage = null ): array
94
94
{
95
95
exec (sprintf ('%s 2>&1 ' , $ command ), $ output , $ result );
96
96
@@ -101,7 +101,7 @@ private static function exec($command, $customErrorMessage = null)
101
101
return $ output ;
102
102
}
103
103
104
- private function getLastLine (array $ output )
104
+ private function getLastLine (array $ output ): string
105
105
{
106
106
return array_pop ($ output );
107
107
}
0 commit comments