Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: TypeError caused by improper use of new self() instead of new static() in base class method (#878) #879

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Model/Suppression/Bounce/Bounce.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class Bounce
private $error;
private $createdAt;

private function __construct()
final private function __construct()
{
}

public static function create(array $data): self
{
$model = new self();
$model = new static();
$model->address = $data['address'] ?? null;
$model->code = $data['code'] ?? null;
$model->error = $data['error'] ?? null;
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Suppression/Complaint/Complaint.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class Complaint
private $address;
private $createdAt;

private function __construct()
final private function __construct()
{
}

public static function create(array $data): self
{
$model = new self();
$model = new static();
$model->address = $data['address'] ?? null;
$model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;

Expand Down
4 changes: 2 additions & 2 deletions src/Model/Suppression/Unsubscribe/Unsubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class Unsubscribe
private $createdAt;
private $tags = [];

private function __construct()
final private function __construct()
{
}

public static function create(array $data): self
{
$model = new self();
$model = new static();
$model->tags = $data['tags'] ?? [];
$model->address = $data['address'] ?? null;
$model->createdAt = isset($data['created_at']) ? new \DateTimeImmutable($data['created_at']) : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Suppression/Whitelist/DeleteResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final private function __construct()

public static function create(array $data): self
{
$model = new static();
$model = new self();
$model->value = $data['value'] ?? '';
$model->message = $data['message'] ?? '';

Expand Down
4 changes: 2 additions & 2 deletions src/Model/Suppression/Whitelist/Whitelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class Whitelist
private $type;
private $createdAt;

private function __construct()
final private function __construct()
{
}

public static function create(array $data): self
{
$model = new self();
$model = new static();
$model->value = $data['value'] ?? null;
$model->reason = $data['reason'] ?? null;
$model->type = $data['type'] ?? null;
Expand Down
1 change: 1 addition & 0 deletions tests/Model/Suppression/Whitelists/ShowResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public function testCreate()
$this->assertEquals('why the record was created', $model->getReason());
$this->assertEquals('address', $model->getType());
$this->assertEquals('2011-10-21 11:02:55', $model->getCreatedAt()->format('Y-m-d H:i:s'));
$this->assertInstanceOf(ShowResponse::class, $model);
}
}