Implement deep_copy in favor of PHP's own clone.
This commit is contained in:
parent
ec11992af5
commit
68fc440b42
|
@ -33,6 +33,7 @@
|
|||
"lstrojny/fxmlrpc": "^0.14.0",
|
||||
"maxmind-db/reader": "~1.0",
|
||||
"mobiledetect/mobiledetectlib": "^2.8",
|
||||
"myclabs/deep-copy": "^1.9",
|
||||
"php-http/socket-client": "^1.2",
|
||||
"php-http/message": "^1.4",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "78891e4670e6ede875124065877589a5",
|
||||
"content-hash": "b9f0cd0e8a111155deae8e797726f75a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
|
@ -2829,6 +2829,54 @@
|
|||
],
|
||||
"time": "2016-12-03T22:08:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.9.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
|
||||
"reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1"
|
||||
},
|
||||
"replace": {
|
||||
"myclabs/deep-copy": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/collections": "^1.0",
|
||||
"doctrine/common": "^2.6",
|
||||
"phpunit/phpunit": "^7.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DeepCopy\\": "src/DeepCopy/"
|
||||
},
|
||||
"files": [
|
||||
"src/DeepCopy/deep_copy.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Create deep copies (clones) of your objects",
|
||||
"keywords": [
|
||||
"clone",
|
||||
"copy",
|
||||
"duplicate",
|
||||
"object",
|
||||
"object graph"
|
||||
],
|
||||
"time": "2019-04-07T13:18:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/fast-route",
|
||||
"version": "v1.3.0",
|
||||
|
@ -6277,54 +6325,6 @@
|
|||
],
|
||||
"time": "2019-02-13T09:37:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.8.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/myclabs/DeepCopy.git",
|
||||
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
|
||||
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1"
|
||||
},
|
||||
"replace": {
|
||||
"myclabs/deep-copy": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/collections": "^1.0",
|
||||
"doctrine/common": "^2.6",
|
||||
"phpunit/phpunit": "^7.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DeepCopy\\": "src/DeepCopy/"
|
||||
},
|
||||
"files": [
|
||||
"src/DeepCopy/deep_copy.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Create deep copies (clones) of your objects",
|
||||
"keywords": [
|
||||
"clone",
|
||||
"copy",
|
||||
"duplicate",
|
||||
"object",
|
||||
"object graph"
|
||||
],
|
||||
"time": "2018-06-11T23:09:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nette/bootstrap",
|
||||
"version": "v2.4.6",
|
||||
|
|
|
@ -82,22 +82,6 @@ class NowPlaying implements ResolvableUrlInterface
|
|||
return json_decode(json_encode($this), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement special cloning rules.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->station = clone $this->station;
|
||||
$this->now_playing = clone $this->now_playing;
|
||||
$this->playing_next = clone $this->playing_next;
|
||||
|
||||
$new_history = [];
|
||||
foreach($this->song_history as $history_obj) {
|
||||
$new_history[] = clone $history_obj;
|
||||
}
|
||||
$this->song_history = $new_history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through sub-items and re-resolve any Uri instances to reflect base URL changes.
|
||||
*
|
||||
|
|
|
@ -59,14 +59,6 @@ class SongHistory implements ResolvableUrlInterface
|
|||
*/
|
||||
public $song;
|
||||
|
||||
/**
|
||||
* Special handling for deep cloning.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->song = clone $this->song;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-resolve any Uri instances to reflect base URL changes.
|
||||
*
|
||||
|
|
|
@ -78,15 +78,6 @@ class Station implements ResolvableUrlInterface
|
|||
*/
|
||||
public $remotes;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$new_mounts = [];
|
||||
foreach($this->mounts as $mount) {
|
||||
$new_mounts[] = clone $mount;
|
||||
}
|
||||
$this->mounts = $new_mounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-resolve any Uri instances to reflect base URL changes.
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@ use App\Entity\Api\NowPlaying;
|
|||
use App\Entity\Station;
|
||||
use App\Http\Router;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use function DeepCopy\deep_copy;
|
||||
|
||||
class SendWebhooks extends Event
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ class SendWebhooks extends Event
|
|||
{
|
||||
$this->station = $station;
|
||||
|
||||
$this->np = clone $np;
|
||||
$this->np = deep_copy($np);
|
||||
|
||||
$this->is_standalone = $is_standalone;
|
||||
|
||||
|
|
Loading…
Reference in New Issue