1 | <?php |
||
19 | class GithubController extends CommonController |
||
20 | { |
||
21 | protected $_name; |
||
22 | protected $_vendor; |
||
23 | protected $_description; |
||
24 | |||
25 | /** |
||
26 | * @var string GitHub OAuth access token |
||
27 | */ |
||
28 | protected $_token; |
||
29 | |||
30 | public function setFull_name($value) |
||
34 | |||
35 | public function getFull_name() |
||
39 | |||
40 | public function setFullName($value) |
||
44 | |||
45 | public function getFullName() |
||
49 | |||
50 | public function setName($value) |
||
54 | |||
55 | public function getName() |
||
63 | |||
64 | public function setVendor($value) |
||
68 | |||
69 | public function getVendor() |
||
77 | |||
78 | public function setDescription($value) |
||
82 | |||
83 | public function getDescription() |
||
91 | |||
92 | /** |
||
93 | * Create the repo on GitHub. |
||
94 | * @return int exit code |
||
95 | */ |
||
96 | public function actionCreate() |
||
108 | |||
109 | /** |
||
110 | * Clone repo from github. |
||
111 | * TODO this action must be run without `start`. |
||
112 | * @param string $repo full name vendor/package |
||
113 | * @return int exit code |
||
114 | */ |
||
115 | public function actionClone($repo) |
||
116 | { |
||
117 | return $this->passthru('git', ['clone', '[email protected]:' . $repo]); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Action to check if repo exists. |
||
122 | * @param string $repo full name vendor/package defaults to this repo name |
||
123 | * @return int exit code |
||
124 | */ |
||
125 | public function actionExists($repo = null) |
||
129 | |||
130 | /** |
||
131 | * Check if repo exists. |
||
132 | * @param string $repo |
||
133 | * @return bool |
||
134 | */ |
||
135 | public static function exists($repo) |
||
139 | |||
140 | /** |
||
141 | * Creates github release. |
||
142 | */ |
||
143 | public function actionRelease($version = null) |
||
144 | { |
||
145 | $version = $this->takeGoal('version')->getVersion($version); |
||
146 | $notes = $this->takeGoal('chkipper')->getReleaseNotes(); |
||
147 | $wait = $this->actionWaitPush(); |
||
148 | if ($wait) { |
||
149 | return $wait; |
||
150 | } |
||
151 | |||
152 | return $this->request('POST', '/repos/' . $this->getFull_name() . '/releases', [ |
||
153 | 'tag_name' => $version, |
||
154 | 'name' => $version, |
||
155 | 'body' => $notes, |
||
156 | ]); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Waits until push is actually finished. |
||
161 | * TODO Check github if it really has latest local commit. |
||
162 | * @return int 0 - success, 1 - failed |
||
163 | */ |
||
164 | public function actionWaitPush() |
||
170 | |||
171 | public function request($method, $path, $data) |
||
172 | { |
||
173 | $url = 'https://api.github.com' . $path; |
||
174 | |||
175 | return $this->passthru('curl', ['-X', $method, '-H', 'Authorization: token ' . $this->getToken(), '--data', Json::encode($data), $url]); |
||
176 | } |
||
177 | |||
178 | public function findToken() |
||
182 | |||
183 | public function getToken() |
||
184 | { |
||
191 | } |
||
192 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: