Skip to content

Commit 5daf113

Browse files
authored
Merge pull request #16 from packagist/json-encode-deprecation
Deprecation: avoid passing json encoded strings to post|put calls
2 parents f7d9fef + 60c74c9 commit 5daf113

File tree

10 files changed

+19
-25
lines changed

10 files changed

+19
-25
lines changed

lib/Bitbucket/API/Repositories/BranchRestrictions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function create($account, $repo, $params = array())
8686

8787
return $this->getClient()->setApiVersion('2.0')->post(
8888
sprintf('/repositories/%s/%s/branch-restrictions', $account, $repo),
89-
json_encode($params),
89+
$params,
9090
array('Content-Type' => 'application/json')
9191
);
9292
}
@@ -135,7 +135,7 @@ public function update($account, $repo, $id, $params = array())
135135

136136
return $this->getClient()->setApiVersion('2.0')->put(
137137
sprintf('/repositories/%s/%s/branch-restrictions/%d', $account, $repo, $id),
138-
json_encode($params),
138+
$params,
139139
array('Content-Type' => 'application/json')
140140
);
141141
}

lib/Bitbucket/API/Repositories/Commits/BuildStatuses.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function create($account, $repository, $revision, $params)
5353
{
5454
return $this->getClient()->setApiVersion('2.0')->post(
5555
sprintf('/repositories/%s/%s/commit/%s/statuses/build', $account, $repository, $revision),
56-
json_encode($params),
56+
$params,
5757
array('Content-Type' => 'application/json')
5858
);
5959
}
@@ -74,7 +74,7 @@ public function update($account, $repository, $revision, $key, $params)
7474
{
7575
return $this->getClient()->setApiVersion('2.0')->put(
7676
sprintf('/repositories/%s/%s/commit/%s/statuses/build/%s', $account, $repository, $revision, $key),
77-
json_encode($params),
77+
$params,
7878
array('Content-Type' => 'application/json')
7979
);
8080
}

lib/Bitbucket/API/Repositories/Hooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function create($account, $repo, array $params = array())
4848

4949
return $this->getClient()->setApiVersion('2.0')->post(
5050
sprintf('/repositories/%s/%s/hooks', $account, $repo),
51-
json_encode($params),
51+
$params,
5252
array('Content-Type' => 'application/json')
5353
);
5454
}
@@ -83,7 +83,7 @@ public function update($account, $repo, $uuid, array $params = array())
8383

8484
return $this->getClient()->setApiVersion('2.0')->put(
8585
sprintf('/repositories/%s/%s/hooks/%s', $account, $repo, $uuid),
86-
json_encode($params),
86+
$params,
8787
array('Content-Type' => 'application/json')
8888
);
8989
}

lib/Bitbucket/API/Repositories/Pipelines.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function create($account, $repo, $params = array())
5959

6060
return $this->getClient()->setApiVersion('2.0')->post(
6161
sprintf('/repositories/%s/%s/pipelines/', $account, $repo),
62-
json_encode($params),
62+
$params,
6363
array('Content-Type' => 'application/json')
6464
);
6565
}

lib/Bitbucket/API/Repositories/PullRequests.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function create($account, $repo, $params = array())
118118

119119
return $this->getClient()->setApiVersion('2.0')->post(
120120
sprintf('/repositories/%s/%s/pullrequests', $account, $repo),
121-
json_encode($params),
121+
$params,
122122
array('Content-Type' => 'application/json')
123123
);
124124
}
@@ -168,7 +168,7 @@ public function update($account, $repo, $id, $params = array())
168168

169169
return $this->getClient()->setApiVersion('2.0')->put(
170170
sprintf('/repositories/%s/%s/pullrequests/%d', $account, $repo, $id),
171-
json_encode($params),
171+
$params,
172172
array('Content-Type' => 'application/json')
173173
);
174174
}
@@ -302,7 +302,7 @@ public function accept($account, $repo, $id, $params = array())
302302
{
303303
return $this->getClient()->setApiVersion('2.0')->post(
304304
sprintf('/repositories/%s/%s/pullrequests/%d/merge', $account, $repo, $id),
305-
json_encode($params),
305+
$params,
306306
array('Content-Type' => 'application/json')
307307
);
308308
}
@@ -324,7 +324,7 @@ public function decline($account, $repo, $id, $params = array())
324324

325325
return $this->getClient()->setApiVersion('2.0')->post(
326326
sprintf('/repositories/%s/%s/pullrequests/%d/decline', $account, $repo, $id),
327-
json_encode($params),
327+
$params,
328328
array('Content-Type' => 'application/json')
329329
);
330330
}

lib/Bitbucket/API/Repositories/PullRequests/Comments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function create($account, $repo, $requestID, $content)
6565
{
6666
return $this->getClient()->setApiVersion('2.0')->post(
6767
sprintf('/repositories/%s/%s/pullrequests/%d/comments', $account, $repo, $requestID),
68-
json_encode(array('content' => array('raw' => $content))),
68+
array('content' => array('raw' => $content)),
6969
array('Content-Type' => 'application/json')
7070
);
7171
}
@@ -84,7 +84,7 @@ public function update($account, $repo, $requestID, $commentID, $content)
8484
{
8585
return $this->getClient()->setApiVersion('2.0')->put(
8686
sprintf('/repositories/%s/%s/pullrequests/%d/comments/%d', $account, $repo, $requestID, $commentID),
87-
json_encode(array('content' => array('raw' => $content))),
87+
array('content' => array('raw' => $content)),
8888
array('Content-Type' => 'application/json')
8989
);
9090
}

lib/Bitbucket/API/Repositories/Refs/Tags.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ public function create($account, $repo, $name, $hash)
7272
],
7373
];
7474

75-
$data = json_encode($params);
76-
7775
return $this->getClient()->setApiVersion('2.0')->post(
7876
sprintf('/repositories/%s/%s/refs/tags', $account, $repo),
79-
$data,
77+
$params,
8078
array('Content-Type' => 'application/json')
8179
);
8280
}

lib/Bitbucket/API/Repositories/Repository.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ public function create($account, $repo, $params = array())
7171
$params = $this->decodeJSON($params);
7272
}
7373

74-
$params = json_encode(array_merge($defaults, $params));
75-
7674
return $this->getClient()->setApiVersion('2.0')->post(
7775
sprintf('/repositories/%s/%s', $account, $repo),
78-
$params,
76+
array_merge($defaults, $params),
7977
array('Content-Type' => 'application/json')
8078
);
8179
}
@@ -155,8 +153,6 @@ public function fork($account, $repo, $name, array $params = array())
155153
{
156154
$params['name'] = $name;
157155

158-
$params = json_encode($params);
159-
160156
return $this->getClient()->setApiVersion('2.0')->post(
161157
sprintf('/repositories/%s/%s/forks', $account, $repo),
162158
$params,

lib/Bitbucket/API/Teams/Hooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function create($team, array $hookConfiguration)
3333

3434
return $this->getClient()->setApiVersion('2.0')->post(
3535
sprintf('/teams/%s/hooks', $team),
36-
json_encode($hookConfiguration),
36+
$hookConfiguration,
3737
['Content-Type' => 'application/json']
3838
);
3939
}
@@ -65,7 +65,7 @@ public function update($team, $uuid, array $hookConfiguration)
6565

6666
return $this->getClient()->setApiVersion('2.0')->put(
6767
sprintf('/teams/%s/hooks/%s', $team, $uuid),
68-
json_encode($hookConfiguration),
68+
$hookConfiguration,
6969
['Content-Type' => 'application/json']
7070
);
7171
}

lib/Bitbucket/API/Workspaces/Hooks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function create($workspace, array $hookConfiguration)
3333

3434
return $this->getClient()->setApiVersion('2.0')->post(
3535
sprintf('/workspaces/%s/hooks', $workspace),
36-
json_encode($hookConfiguration),
36+
$hookConfiguration,
3737
['Content-Type' => 'application/json']
3838
);
3939
}
@@ -65,7 +65,7 @@ public function update($workspace, $uuid, array $hookConfiguration)
6565

6666
return $this->getClient()->setApiVersion('2.0')->put(
6767
sprintf('/workspaces/%s/hooks/%s', $workspace, $uuid),
68-
json_encode($hookConfiguration),
68+
$hookConfiguration,
6969
['Content-Type' => 'application/json']
7070
);
7171
}

0 commit comments

Comments
 (0)