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

fix: Deprecation with PHP 8.1 #7

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
ini-values: error_reporting=E_ALL, display_errors=On
with:
php-version: ${{ matrix.php }}
coverage: xdebug
Expand Down
10 changes: 4 additions & 6 deletions src/MySQLReplication/BinLog/BinLogCurrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
namespace MySQLReplication\BinLog;

use JsonSerializable;
use MySQLReplication\Util\JsonSerializableTrait;

class BinLogCurrent implements JsonSerializable
{
use JsonSerializableTrait;

/**
* @var int
*/
Expand Down Expand Up @@ -63,9 +66,4 @@ public function setMariaDbGtid(string $mariaDbGtid): void
{
$this->mariaDbGtid = $mariaDbGtid;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
namespace MySQLReplication\Config;

use JsonSerializable;
use MySQLReplication\Util\JsonSerializableTrait;

class Config implements JsonSerializable
{
use JsonSerializableTrait;

private $user;
private $host;
private $port;
Expand Down Expand Up @@ -238,9 +241,4 @@ public function getRetry(): int
{
return $this->retry;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/FormatDescriptionEventDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
namespace MySQLReplication\Event\DTO;

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Util\JsonSerializableTrait;

class FormatDescriptionEventDTO extends EventDTO
{
use JsonSerializableTrait;

private $type = ConstEventsNames::FORMAT_DESCRIPTION;

public function getType(): string
Expand All @@ -22,9 +25,4 @@ public function __toString(): string
'Log position: ' . $this->eventInfo->getPos() . PHP_EOL .
'Event size: ' . $this->eventInfo->getSize() . PHP_EOL;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/GTIDLogDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Util\JsonSerializableTrait;

class GTIDLogDTO extends EventDTO
{
use JsonSerializableTrait;

private $commit;
private $gtid;
private $type = ConstEventsNames::GTID;
Expand Down Expand Up @@ -54,9 +57,4 @@ public function __toString(): string
'Commit: ' . var_export($this->commit, true) . PHP_EOL .
'GTID NEXT: ' . $this->gtid . PHP_EOL;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/HeartbeatDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
namespace MySQLReplication\Event\DTO;

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Util\JsonSerializableTrait;

class HeartbeatDTO extends EventDTO
{
use JsonSerializableTrait;

protected $type = ConstEventsNames::HEARTBEAT;

public function __toString(): string
Expand All @@ -22,9 +25,4 @@ public function getType(): string
{
return $this->type;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
11 changes: 4 additions & 7 deletions src/MySQLReplication/Event/DTO/MariaDbGtidLogDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Util\JsonSerializableTrait;

class MariaDbGtidLogDTO extends EventDTO
{
use JsonSerializableTrait;

private $type = ConstEventsNames::MARIADB_GTID;
private $flag;
private $domainId;
Expand Down Expand Up @@ -44,12 +47,6 @@ public function getType(): string
return $this->type;
}


public function jsonSerialize()
{
return get_object_vars($this);
}

public function getFlag(): int
{
return $this->flag;
Expand All @@ -64,4 +61,4 @@ public function getDomainId(): int
{
return $this->domainId;
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/QueryDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Util\JsonSerializableTrait;

class QueryDTO extends EventDTO
{
use JsonSerializableTrait;

private $executionTime;
private $query;
private $database;
Expand Down Expand Up @@ -57,9 +60,4 @@ public function __toString(): string
'Execution time: ' . $this->executionTime . PHP_EOL .
'Query: ' . $this->query . PHP_EOL;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/RotateDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Util\JsonSerializableTrait;

class RotateDTO extends EventDTO
{
use JsonSerializableTrait;

private $position;
private $nextBinlog;
private $type = ConstEventsNames::ROTATE;
Expand Down Expand Up @@ -48,9 +51,4 @@ public function __toString(): string
'Binlog position: ' . $this->position . PHP_EOL .
'Binlog filename: ' . $this->nextBinlog . PHP_EOL;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/RowsDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Event\EventInfo;
use MySQLReplication\Event\RowEvent\TableMap;
use MySQLReplication\Util\JsonSerializableTrait;

abstract class RowsDTO extends EventDTO
{
use JsonSerializableTrait;

private $values;
private $changedRows;
private $tableMap;
Expand Down Expand Up @@ -52,9 +55,4 @@ public function __toString(): string
'Changed rows: ' . $this->changedRows . PHP_EOL .
'Values: ' . print_r($this->values, true) . PHP_EOL;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/TableMapDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Event\RowEvent\TableMap;
use MySQLReplication\Util\JsonSerializableTrait;

class TableMapDTO extends EventDTO
{
use JsonSerializableTrait;

private $type = ConstEventsNames::TABLE_MAP;
private $tableMap;

Expand Down Expand Up @@ -39,13 +42,8 @@ public function getType(): string
return $this->type;
}

public function jsonSerialize()
{
return get_object_vars($this);
}

public function getTableMap(): TableMap
{
return $this->tableMap;
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/DTO/XidDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use MySQLReplication\Definitions\ConstEventsNames;
use MySQLReplication\Event\EventInfo;
use MySQLReplication\Util\JsonSerializableTrait;

class XidDTO extends EventDTO
{
use JsonSerializableTrait;

private $type = ConstEventsNames::XID;
private $xid;

Expand Down Expand Up @@ -39,9 +42,4 @@ public function getType(): string
{
return $this->type;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/EventInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@

use JsonSerializable;
use MySQLReplication\BinLog\BinLogCurrent;
use MySQLReplication\Util\JsonSerializableTrait;

class EventInfo implements JsonSerializable
{
use JsonSerializableTrait;

private $timestamp;
private $type;
private $id;
Expand Down Expand Up @@ -96,9 +99,4 @@ public function getFlag(): int
{
return $this->flag;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
10 changes: 4 additions & 6 deletions src/MySQLReplication/Event/RowEvent/TableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
namespace MySQLReplication\Event\RowEvent;

use JsonSerializable;
use MySQLReplication\Util\JsonSerializableTrait;

class TableMap implements JsonSerializable
{
use JsonSerializableTrait;

private $database;
private $table;
private $tableId;
Expand Down Expand Up @@ -54,9 +57,4 @@ public function getColumnDTOCollection(): ColumnDTOCollection
{
return $this->columnDTOCollection;
}

public function jsonSerialize()
{
return get_object_vars($this);
}
}
}
16 changes: 16 additions & 0 deletions src/MySQLReplication/Util/JsonSerializableTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MySQLReplication\Util;

use function get_object_vars;

/**
* Provide implementation of {@see JsonSerializable::jsonSerialize()} which dumps all properties (public or private).
*/
trait JsonSerializableTrait
{
public function jsonSerialize(): array
{
return get_object_vars($this);
}
}