Skip to content

Commit 25f4361

Browse files
committed
Merge pull request #39 from jubianchi/use-static
Use LSB on class instanciation to ease extending them
2 parents 019654a + d2c9007 commit 25f4361

18 files changed

+31
-31
lines changed

lib/Gitlab/Model/Branch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Branch extends AbstractModel
1616

1717
public static function fromArray(Client $client, Project $project, array $data)
1818
{
19-
$branch = new Branch($project, $data['name'], $client);
19+
$branch = new static($project, $data['name'], $client);
2020

2121
if (isset($data['commit'])) {
2222
$data['commit'] = Commit::fromArray($client, $project, $data['commit']);

lib/Gitlab/Model/Commit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Commit extends AbstractModel
2525

2626
public static function fromArray(Client $client, Project $project, array $data)
2727
{
28-
$commit = new Commit($project, $data['id'], $client);
28+
$commit = new static($project, $data['id'], $client);
2929

3030
if (isset($data['parents'])) {
3131
$parents = array();

lib/Gitlab/Model/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Event extends AbstractModel
2020

2121
public static function fromArray(Client $client, Project $project, array $data)
2222
{
23-
$event = new Event($project, $client);
23+
$event = new static($project, $client);
2424

2525
return $event->hydrate($data);
2626
}

lib/Gitlab/Model/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class File extends AbstractModel
1414

1515
public static function fromArray(Client $client, Project $project, array $data)
1616
{
17-
$file = new File($project, $data['file_path'], $client);
17+
$file = new static($project, $data['file_path'], $client);
1818

1919
return $file->hydrate($data);
2020
}

lib/Gitlab/Model/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Group extends AbstractModel
1616

1717
public static function fromArray(Client $client, array $data)
1818
{
19-
$group = new Group($data['id'], $client);
19+
$group = new static($data['id'], $client);
2020

2121
if (isset($data['projects'])) {
2222
$projects = array();

lib/Gitlab/Model/Hook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Hook extends AbstractModel
1414

1515
public static function fromArray(Client $client, array $data)
1616
{
17-
$hook = new Hook($data['id'], $client);
17+
$hook = new static($data['id'], $client);
1818

1919
return $hook->hydrate($data);
2020
}

lib/Gitlab/Model/Issue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Issue extends AbstractModel
2525

2626
public static function fromArray(Client $client, Project $project, array $data)
2727
{
28-
$issue = new Issue($project, $data['id'], $client);
28+
$issue = new static($project, $data['id'], $client);
2929

3030
if (isset($data['author'])) {
3131
$data['author'] = User::fromArray($client, $data['author']);
@@ -50,14 +50,14 @@ public function show()
5050
{
5151
$data = $this->api('issues')->show($this->project->id, $this->id);
5252

53-
return Issue::fromArray($this->getClient(), $this->project, $data);
53+
return static::fromArray($this->getClient(), $this->project, $data);
5454
}
5555

5656
public function update(array $params)
5757
{
5858
$data = $this->api('issues')->update($this->project->id, $this->id, $params);
5959

60-
return Issue::fromArray($this->getClient(), $this->project, $data);
60+
return static::fromArray($this->getClient(), $this->project, $data);
6161
}
6262

6363
public function close($comment = null)

lib/Gitlab/Model/Key.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Key extends AbstractModel
1515

1616
public static function fromArray(Client $client, array $data)
1717
{
18-
$key = new Key($client);
18+
$key = new static($client);
1919

2020
return $key->hydrate($data);
2121
}

lib/Gitlab/Model/MergeRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MergeRequest extends AbstractModel
2727

2828
public static function fromArray(Client $client, Project $project, array $data)
2929
{
30-
$mr = new MergeRequest($project, $data['id'], $client);
30+
$mr = new static($project, $data['id'], $client);
3131

3232
if (isset($data['author'])) {
3333
$data['author'] = User::fromArray($client, $data['author']);
@@ -52,14 +52,14 @@ public function show()
5252
{
5353
$data = $this->api('mr')->show($this->project->id, $this->id);
5454

55-
return MergeRequest::fromArray($this->getClient(), $this->project, $data);
55+
return static::fromArray($this->getClient(), $this->project, $data);
5656
}
5757

5858
public function update(array $params)
5959
{
6060
$data = $this->api('mr')->update($this->project->id, $this->id, $params);
6161

62-
return MergeRequest::fromArray($this->getClient(), $this->project, $data);
62+
return static::fromArray($this->getClient(), $this->project, $data);
6363
}
6464

6565
public function close($comment = null)

lib/Gitlab/Model/Milestone.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Milestone extends AbstractModel
2222

2323
public static function fromArray(Client $client, Project $project, array $data)
2424
{
25-
$milestone = new Milestone($project, $data['id'], $client);
25+
$milestone = new static($project, $data['id'], $client);
2626

2727
return $milestone->hydrate($data);
2828
}
@@ -39,14 +39,14 @@ public function show()
3939
{
4040
$data = $this->api('milestones')->show($this->project->id, $this->id);
4141

42-
return Milestone::fromArray($this->getClient(), $this->project, $data);
42+
return static::fromArray($this->getClient(), $this->project, $data);
4343
}
4444

4545
public function update(array $params)
4646
{
4747
$data = $this->api('milestones')->update($this->project->id, $this->id, $params);
4848

49-
return Milestone::fromArray($this->getClient(), $this->project, $data);
49+
return static::fromArray($this->getClient(), $this->project, $data);
5050
}
5151

5252
public function complete()

0 commit comments

Comments
 (0)