MAPG-191 don't pass data by reference to IContent

This commit is contained in:
Bence Pőcze 2020-07-05 00:25:34 +02:00
parent 091afb0aab
commit e17cf68007
Signed by: bence
GPG Key ID: AA52B11A3269D1C1
4 changed files with 13 additions and 6 deletions

View File

@ -2,7 +2,9 @@
interface IContent
{
public function &getData(): array;
public function setData(array $data): void;
public function getData(): array;
public function render(): void;

View File

@ -6,7 +6,12 @@ abstract class ContentBase implements IContent
{
protected array $data;
public function &getData(): array
public function setData(array $data): void
{
$this->data = $data;
}
public function getData(): array
{
return $this->data;
}

View File

@ -6,10 +6,10 @@ class HtmlContent extends ContentBase
{
private string $view;
public function __construct(string $view, array &$data = [])
public function __construct(string $view, array $data = [])
{
$this->view = $view;
$this->data = &$data;
$this->data = $data;
}
public function render(): void

View File

@ -2,9 +2,9 @@
class JsonContent extends ContentBase
{
public function __construct(array &$data = [])
public function __construct(array $data = [])
{
$this->data = &$data;
$this->data = $data;
}
public function render(): void