21 Commits
7.1 ... 11.x

Author SHA1 Message Date
User
35026bb223 20250530#1 2025-05-30 11:26:18 +03:00
User
e2727c34e8 20250510#1 2025-05-10 14:20:24 +03:00
User
e16700fe8d 20250509#1 2025-05-09 23:00:16 +03:00
User
335c4d240c 20250427#1 2025-04-27 01:31:26 +03:00
User
91af1ea14f 20250419#2 2025-04-19 18:46:40 +03:00
User
41523e6899 20250419#1 2025-04-19 18:45:41 +03:00
User
4a56e42af4 20250413#1 2025-04-13 12:45:30 +03:00
User
4b1c0d7044 20250330#8 2025-03-31 02:49:17 +03:00
User
d300a6b628 20250330#7 2025-03-31 02:48:18 +03:00
User
09e8520ded 20250330#6 2025-03-30 20:19:12 +03:00
User
e6fd18fa2f 20250330#5 2025-03-30 19:18:31 +03:00
User
9c1f6be326 20250330#4 2025-03-30 19:16:20 +03:00
User
f3458d1870 20250330#3 2025-03-30 18:35:21 +03:00
User
1ce2a09e01 20250330#2 2025-03-30 15:13:47 +03:00
User
fd996d40c8 20250330#1 2025-03-30 13:28:30 +03:00
User
96ee46476c 20250327#4 2025-03-27 03:44:20 +03:00
User
d8991dcef5 20250327#3 2025-03-27 03:13:36 +03:00
User
30a20d427b 20250327#2 2025-03-27 03:01:09 +03:00
User
10f6d62b43 20250327#1 2025-03-27 00:02:46 +03:00
User
2beff209de 20250326#3 2025-03-26 16:31:17 +03:00
User
a39c0a6bf1 20250326#2 2025-03-26 16:30:23 +03:00
20 changed files with 297 additions and 74 deletions

View File

@@ -10,12 +10,12 @@ Stable version
composer require rmphp/storage
```
```bash
composer require rmphp/storage:"^6.0"
composer require rmphp/storage:"^11.0"
```
Dev version contains the latest changes
```bash
composer require rmphp/storage:"6.x-dev"
composer require rmphp/storage:"11.x-dev"
```

View File

@@ -25,7 +25,7 @@ abstract class AbstractMysqlRepository extends AbstractRepository implements Mys
/** @inheritDoc */
public function createFromResult(string $class, bool|MysqlResultData $result, callable $function = null): mixed {
public function createFromResult(string $class, ?MysqlResultData $result, callable $function = null): mixed {
if($result instanceof MysqlResultData) {
$val = (isset($function)) ? $function($result->fetchOne()) : $result->fetchOne();
$out = $this->createFromData($class, $val);
@@ -35,7 +35,7 @@ abstract class AbstractMysqlRepository extends AbstractRepository implements Mys
/** @inheritDoc */
public function createListFromResult(string $class, bool|MysqlResultData $result, callable $function = null): array {
public function createListFromResult(string $class, ?MysqlResultData $result, callable $function = null): array {
if($result instanceof MysqlResultData) {
foreach($result->fetch() as $resultValue) {
$val = (isset($function)) ? $function($resultValue) : $resultValue;
@@ -60,7 +60,7 @@ abstract class AbstractMysqlRepository extends AbstractRepository implements Mys
$in = $this->getProperties($object, function ($value){
return (is_string($value)) ? $this->mysql->escapeStr($value) : $value;
});
if($this->getDebug()) {$this->debug($object, $in, $table, $this->getRepositoryStack()); exit;}
if($this->isDebug()) {$this->debug($object, $in, $table, ...$this->getDebugExtraData()); exit;}
try {
if (!empty($object->getId()) && !empty($this->mysql->findById($table, $object->getId()))) {
$this->mysql->updateById($table, $in, $object->getId());
@@ -79,7 +79,7 @@ abstract class AbstractMysqlRepository extends AbstractRepository implements Mys
$in = array_map(function ($value){
return (is_string($value)) ? $this->mysql->escapeStr($value) : $value;
}, $data);
if($this->getDebug()) {$this->debug($data, $in, $table, $this->getRepositoryStack()); exit;}
if($this->isDebug()) {$this->debug($data, $in, $table, ...$this->getDebugExtraData()); exit;}
try {
if (!empty($data[$primaryKey]) && !empty($this->mysql->findById($table, $data[$primaryKey], $primaryKey))) {
$this->mysql->updateById($table, $in, $data[$primaryKey]);
@@ -181,12 +181,19 @@ abstract class AbstractMysqlRepository extends AbstractRepository implements Mys
/**
* @return bool
*/
private function getDebug(): bool {
private function isDebug(): bool {
if(!empty($this->debug)) return $this->debug;
if(!empty(static::DEBUG)) return static::DEBUG;
return false;
}
/**
* @return array
*/
protected function getDebugExtraData() : array {
return [$this->getRepositoryStack(), $this->getClassesCache(), $this->getAttributesObjectsCache()];
}
/**
* @param ...$arg
* @return void

14
src/Attribute/Data.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class Data {
public function __construct(
public bool $ignorEmpty = false,
) {}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class DataIgnorEmpty {}

14
src/Attribute/Entity.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class Entity {
public function __construct(
public bool $noReturnIfNull = false,
) {}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class EntityNoReturnIfNull {}

View File

@@ -0,0 +1,16 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_PROPERTY)]
class Property {
public function __construct(
public ?string $keyName = null,
public bool $noReturn = false,
public bool $noReturnIfNull = false,
) {}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_PROPERTY)]
class PropertyNoReturn {}

View File

@@ -0,0 +1,8 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_PROPERTY)]
class PropertyNoReturnIfNull {}

View File

@@ -0,0 +1,15 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class ValueObject {
public function __construct(
public ?string $propertyName = null,
public bool $firstProperty = false
) {}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class ValueObjectFirstProperty {}

View File

@@ -0,0 +1,14 @@
<?php
namespace Rmphp\Storage\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
class ValueObjectPropertyName {
public function __construct(
public ?string $name = null,
) {}
}

View File

@@ -5,25 +5,40 @@ namespace Rmphp\Storage\Component;
use Exception;
use ReflectionClass;
use ReflectionException;
use Rmphp\Storage\Attribute\Data;
use Rmphp\Storage\Attribute\DataIgnorEmpty;
class AbstractDataObject {
abstract class AbstractDataObject {
private static array $constructorEmptyAvailableClasses = [];
private static array $stack = [];
protected static array $constructorEmptyAvailableClasses = [];
protected static array $classes = [];
protected static array $attributeObjects = [];
/**
* @param ReflectionClass $class
* @param object $object
* @param array $data
* @param bool $update
* @param bool $withEmpty
* @return mixed
* @throws Exception
*/
protected static function fillObject(ReflectionClass $class, object $object, array $data, bool $update = false) : mixed {
protected static function fillObject(ReflectionClass $class, object $object, array $data, bool $update = false, bool $withEmpty = true) : mixed {
try {
if(!isset(self::$attributeObjects[$class->getName()][0])){
self::$attributeObjects[$class->getName()][0] = !empty($class->getAttributes(Data::class))
? $class->getAttributes(Data::class)[0]->newInstance()
: new Data();
}
/** @var Data $dataAttributes */
$dataAttributes = self::$attributeObjects[$class->getName()][0];
if(!empty($class->getAttributes(DataIgnorEmpty::class))) $dataAttributes->ignorEmpty = true;
$value = [];
foreach($class->getProperties() as $property){
$prop[$property->getName()] = ($property->hasType()) ? $property->getType()->getName() : "";
// значение в массиве по ключю с именем свойства
if(array_key_exists($property->getName(), $data)){
$value[$property->getName()] = $data[$property->getName()];
@@ -39,38 +54,53 @@ class AbstractDataObject {
// если есть внутренний метод (приоритетная обработка)
if($class->hasMethod('set'.ucfirst($property->getName()))) {
$object->{'set'.ucfirst($property->getName())}($value[$property->getName()] ?? null);
$case[$property->getName()] = 'Method set'.ucfirst($property->getName());
}
// Если тип свойства класс (valueObject)
elseif($property->hasType() && class_exists($property->getType()->getName())) {
if(is_object($value[$property->getName()])){
// значение объект
if(isset($value[$property->getName()]) && is_object($value[$property->getName()])){
$object->{$property->getName()} = $value[$property->getName()];
$case[$property->getName()] = 'VO: Object';
}
elseif(isset($value[$property->getName()])){
// значение не пустое
elseif(isset($value[$property->getName()]) && $value[$property->getName()] !== ""){
$object->{$property->getName()} = new ($property->getType()->getName())($value[$property->getName()]);
$case[$property->getName()] = 'VO: NewInstance';
}
// Значения нет и VO может быть без параметров
elseif(self::isEmptyAvailable($property->getType()->getName())) {
elseif(($withEmpty && empty($dataAttributes->ignorEmpty)) && self::isEmptyAvailable($property->getType()->getName())) {
$object->{$property->getName()} = new ($property->getType()->getName())();
$case[$property->getName()] = 'VO: Without params';
}
}
// Базовые типы при наличии значения
elseif(array_key_exists($property->getName(), $value)){
if(!$property->hasType()){
$object->{$property->getName()} = $value[$property->getName()];
$case[$property->getName()] = 'Base: Hasn`t type';
}
elseif(in_array($property->getType()->getName(), ['float', 'int'])){
if(is_numeric($value[$property->getName()])) $object->{$property->getName()} = $value[$property->getName()];
$case[$property->getName()] = 'Base: Number';
}
elseif($property->getType()->getName() == 'bool'){
$object->{$property->getName()} = (bool)$value[$property->getName()];
$case[$property->getName()] = 'Base: Boolean';
}
elseif(isset($value[$property->getName()])){
$object->{$property->getName()} = $value[$property->getName()];
$case[$property->getName()] = 'Base: NotNull';
}
elseif($property->getType()->allowsNull()){
$object->{$property->getName()} = $value[$property->getName()];
$case[$property->getName()] = 'Base: Null';
}
}
}
self::$stack[$object::class." #".spl_object_id($object)]['properties'] = $prop ?? [];
self::$stack[$object::class." #".spl_object_id($object)]['values'] = $value;
self::$stack[$object::class." #".spl_object_id($object)]['matchCase'] = $case ?? [];
self::$stack[$object::class." #".spl_object_id($object)]['object'] = $object;
return $object;
}
@@ -94,11 +124,11 @@ class AbstractDataObject {
return self::$constructorEmptyAvailableClasses[$class] = true;
}
/**
* @return array
*/
protected function getFillObjectStack() : array {
return self::$stack;
}
}

View File

@@ -25,7 +25,7 @@ abstract class AbstractEntity implements EntityInterface {
* @return string
*/
public function __get(string $name) {
return $this->$name ?? "";
return $this->$name ?? null;
}
/**

View File

@@ -4,7 +4,6 @@ namespace Rmphp\Storage\Entity;
interface ValueObjectInterface {
public function getValue();
public function __toString(): string;
}

View File

@@ -16,21 +16,19 @@ interface MysqlRepositoryInterface extends RepositoryInterface {
/**
* @param string $class
* @param bool|MysqlResultData $result
* @param MysqlResultData|null $result
* @param callable|null $function
* @return mixed
* @throws RepositoryException
*/
public function createFromResult(string $class, bool|MysqlResultData $result, callable $function = null): mixed;
public function createFromResult(string $class, ?MysqlResultData $result, callable $function = null): mixed;
/**
* @param string $class
* @param bool|MysqlResultData $result
* @param MysqlResultData|null $result
* @param callable|null $function
* @return array
* @throws RepositoryException
*/
public function createListFromResult(string $class, bool|MysqlResultData $result, callable $function = null): array;
public function createListFromResult(string $class, ?MysqlResultData $result, callable $function = null): array;
/**
* @param int $id

View File

@@ -13,26 +13,23 @@ class MysqlStorage implements MysqlStorageInterface {
private Mysqli $mysqli;
/**
* Внутренний конструктор подключения к БД
* Mysql constructor.
* @param object $params
* @param array $paramsArray
* @throws Exception
*/
public function __construct(
private readonly object $params
) {
public function __construct(array $paramsArray) {
$params = (object) $paramsArray;
$this->mysqli = new mysqli(
$this->params->host,
$this->params->user,
$this->params->pass,
$this->params->base
$params->host,
$params->user,
$params->pass,
$params->base
);
// выводим ошибку при неудачном подключении
if ($this->mysqli->connect_errno) {
throw new Exception($this->mysqli->connect_errno);
}
$this->mysqli->set_charset("utf8");
if(!empty($this->params->logsEnable)) $this->logsEnabled = true;
$this->mysqli->set_charset($params->chartset ?? "utf8");
if(!empty($params->logs)) $this->logsEnabled = true;
}
/** @inheritDoc */
@@ -118,7 +115,7 @@ class MysqlStorage implements MysqlStorageInterface {
/** @inheritDoc */
public function find(string $sql, int $ln=0, int $numPage=1, int $count=0): bool|MysqlResultData {
public function find(string $sql, int $ln=0, int $numPage=1, int $count=0): ?MysqlResultData {
if ($ln > 1) {
$cnts = (!empty($count)) ? $count : $this->query($sql)->num_rows;
@@ -131,7 +128,7 @@ class MysqlStorage implements MysqlStorageInterface {
}
$result = $this->query($sql.$limit);
if (!$result || $result->num_rows == 0) return false;
if (!$result || $result->num_rows == 0) return null;
$data = new MysqlResultData($result);
$data->count = $cnts ?? 0;
@@ -140,17 +137,17 @@ class MysqlStorage implements MysqlStorageInterface {
}
/** @inheritDoc */
public function findOne(string $sql) : bool|MysqlResultData {
public function findOne(string $sql) : ?MysqlResultData {
$result = $this->query($sql." limit 0, 1");
if (!$result || $result->num_rows == 0) return false;
if (!$result || $result->num_rows == 0) return null;
return new MysqlResultData($result);
}
/** @inheritDoc */
public function findById(string $table, mixed $id, string $name = 'id') : bool|array {
public function findById(string $table, mixed $id, string $name = 'id') : ?array {
$id = (is_numeric($id)) ? (int) $id : $this->escapeStr($id);
$result = $this->query("select * from ".$this->escapeStr($table)." where `$name`='$id' limit 0, 1");
if (!$result || $result->num_rows == 0) return false;
if (!$result || $result->num_rows == 0) return null;
$data = new MysqlResultData($result);
return $data->fetchOne();
}

View File

@@ -82,13 +82,13 @@ interface MysqlStorageInterface {
* @param int $count
* @return bool|MysqlResultData
*/
public function find(string $sql, int $ln = 0, int $numPage = 1, int $count=0) : bool|MysqlResultData;
public function find(string $sql, int $ln = 0, int $numPage = 1, int $count=0) : ?MysqlResultData;
/**
* @param string $sql
* @return bool|array
*/
public function findOne(string $sql) : bool|MysqlResultData;
public function findOne(string $sql) : ?MysqlResultData;
/**
* @param string $table
@@ -96,7 +96,7 @@ interface MysqlStorageInterface {
* @param string $name
* @return bool|array
*/
public function findById(string $table, mixed $id, string $name = 'id') : bool|array;
public function findById(string $table, mixed $id, string $name = 'id') : ?array;
/**
* Метод экранирования данных с учетом текущего подключения в т.ч для LIKE

View File

@@ -4,56 +4,118 @@ namespace Rmphp\Storage\Repository;
use Exception;
use ReflectionClass;
use ReflectionException;
use Rmphp\Storage\Attribute\Entity;
use Rmphp\Storage\Attribute\EntityNoReturnIfNull;
use Rmphp\Storage\Attribute\Property;
use Rmphp\Storage\Attribute\PropertyNoReturn;
use Rmphp\Storage\Attribute\PropertyNoReturnIfNull;
use Rmphp\Storage\Attribute\ValueObject;
use Rmphp\Storage\Attribute\ValueObjectFirstProperty;
use Rmphp\Storage\Attribute\ValueObjectPropertyName;
use Rmphp\Storage\Component\AbstractDataObject;
use Rmphp\Storage\Entity\ValueObjectInterface;
use Rmphp\Storage\Exception\RepositoryException;
abstract class AbstractRepository extends AbstractDataObject implements RepositoryInterface {
private static array $classes = [];
/** @inheritDoc */
public function getProperties(object $object, callable $method = null) : array {
try{
$class = get_class($object);
if(!isset(self::$classes[$class])) self::$classes[$class] = new ReflectionClass($class);
if(!isset(self::$attributeObjects[$class][0])){
self::$attributeObjects[$class][0] = !empty(self::$classes[$class]->getAttributes(Entity::class))
? self::$classes[$class]->getAttributes(Entity::class)[0]->newInstance()
: new Entity();
}
/** @var Entity $entityAttributes */
$entityAttributes = self::$attributeObjects[$class][0];
if(!empty(self::$classes[$class]->getAttributes(EntityNoReturnIfNull::class))) $entityAttributes->noReturnIfNull = true;
$fieldValue = [];
foreach(self::$classes[$class]->getProperties() as $property){
if(!$property->isInitialized($object) || is_array($property->getValue($object))) continue;
if(!isset(self::$attributeObjects[$class][$property->getName()])){
self::$attributeObjects[$class][$property->getName()] = !empty($property->getAttributes(Property::class))
? $property->getAttributes(Property::class)[0]->newInstance()
: new Property();
}
/** @var Property $propertyAttributes */
$propertyAttributes = self::$attributeObjects[$class][$property->getName()];
if(!empty($property->getAttributes(PropertyNoReturnIfNull::class))) $propertyAttributes->noReturnIfNull = true;
if(!empty($property->getAttributes(PropertyNoReturn::class)) || !empty($propertyAttributes->noReturn)) continue;
if($property->isInitialized($object)) {
if(is_array($property->getValue($object))) continue;
if(self::$classes[$class]->hasMethod('get'.ucfirst($property->getName()))){
$fieldValue[$property->getName()] = $object->{'get'.ucfirst($property->getName())}($property->getValue($object));
}
elseif($property->hasType() && class_exists($property->getType()->getName()) && $property->getValue($object) instanceof ValueObjectInterface){
$value = $property->getValue($object)->getValue();
if(isset($value)) $fieldValue[$property->getName()] = $value;
elseif($property->hasType() && class_exists($property->getType()->getName())){
$valueObjectClass = get_class($property->getValue($object));
if(!isset(self::$classes[$valueObjectClass])) self::$classes[$valueObjectClass] = new ReflectionClass($valueObjectClass);
if(!isset(self::$attributeObjects[$valueObjectClass])){
self::$attributeObjects[$valueObjectClass] = !empty(self::$classes[$valueObjectClass]->getAttributes(ValueObject::class))
? self::$classes[$valueObjectClass]->getAttributes(ValueObject::class)[0]->newInstance()
: new ValueObject();
if(!empty(self::$classes[$valueObjectClass]->getAttributes(ValueObjectFirstProperty::class))) {
self::$attributeObjects[$valueObjectClass]->firstProperty = true;
}
if(!empty(self::$classes[$valueObjectClass]->getAttributes(ValueObjectPropertyName::class))) {
$propertyName = self::$classes[$valueObjectClass]->getAttributes(ValueObjectPropertyName::class)[0]->newInstance();
if(isset($propertyName->name)) self::$attributeObjects[$valueObjectClass]->propertyName = $propertyName->name;
}
}
$valueObjectAttributes = self::$attributeObjects[$valueObjectClass];
if(!empty($valueObjectAttributes->propertyName) && self::$classes[$valueObjectClass]->hasProperty($valueObjectAttributes->propertyName)){
if(self::$classes[$valueObjectClass]->getProperty($valueObjectAttributes->propertyName)->isInitialized($property->getValue($object))){
$fieldValue[$property->getName()] = self::$classes[$valueObjectClass]->getProperty($valueObjectAttributes->propertyName)->getValue($property->getValue($object));
}
}
elseif(!empty($valueObjectAttributes->firstProperty) && count(self::$classes[$valueObjectClass]->getProperties()) > 0){
if(self::$classes[$valueObjectClass]->getProperties()[0]->isInitialized($property->getValue($object))){
$fieldValue[$property->getName()] = self::$classes[$valueObjectClass]->getProperties()[0]->getValue($property->getValue($object));
}
}
elseif(self::$classes[$valueObjectClass]->hasMethod('getValue')){
$fieldValue[$property->getName()] = $property->getValue($object)->getValue();
}
}
elseif(is_bool($property->getValue($object))){
$fieldValue[$property->getName()] = (int) $property->getValue($object);
$fieldValue[$property->getName()] = (int)$property->getValue($object);
}
else {
else{
$fieldValue[$property->getName()] = $property->getValue($object);
}
if(!isset($fieldValue[$property->getName()]) && (!empty($propertyAttributes->noReturnIfNull) || !empty($entityAttributes->noReturnIfNull))) continue;
if(array_key_exists($property->getName(), $fieldValue) && false !== $fieldValue[$property->getName()]) {
$out[strtolower(preg_replace("'([A-Z])'", "_$1", $property->getName()))] = $fieldValue[$property->getName()];
$columnName = !empty($propertyAttributes->keyName) ? $propertyAttributes->keyName : strtolower(preg_replace("'([A-Z])'", "_$1", $property->getName()));
$out[$columnName] = $fieldValue[$property->getName()];
}
}
}
return (isset($method)) ? array_map($method, $out ?? []) : $out ?? [];
}
catch (ReflectionException $exception) {
catch (\ReflectionException $exception) {
throw new RepositoryException($exception->getMessage());
}
}
/** @inheritDoc */
public function createFromData(string $class, array|object $data) : object {
/**
* @inheritDoc
* @throws RepositoryException
*/
public function createFromData(string $class, array|object $data, bool $withEmpty = true) : object {
try {
if(!isset(self::$classes[$class])) self::$classes[$class] = new ReflectionClass($class);
return self::fillObject(self::$classes[$class], new $class, (is_object($data)) ? get_object_vars($data) : $data);
return self::fillObject(self::$classes[$class], new $class, (is_object($data)) ? get_object_vars($data) : $data, false, $withEmpty);
}
catch (Exception $exception) {
throw new RepositoryException($exception->getMessage());
@@ -61,12 +123,15 @@ abstract class AbstractRepository extends AbstractDataObject implements Reposito
}
/** @inheritDoc */
public function updateFromData(object $object, array|object $data) : object {
/**
* @inheritDoc
* @throws RepositoryException
*/
public function updateFromData(object $object, array|object $data, bool $withEmpty = true) : object {
try {
$class = get_class($object);
if(!isset(self::$classes[$class])) self::$classes[$class] = new ReflectionClass($class);
return self::fillObject(self::$classes[$class], clone $object, (is_object($data)) ? get_object_vars($data) : $data, true);
return self::fillObject(self::$classes[$class], clone $object, (is_object($data)) ? get_object_vars($data) : $data, true, $withEmpty);
}
catch (Exception $exception) {
throw new RepositoryException($exception->getMessage());
@@ -83,8 +148,22 @@ abstract class AbstractRepository extends AbstractDataObject implements Reposito
/**
* @return array
*/
public function getClassesCash() : array {
public function getClassesCache() : array {
return self::$classes;
}
/**
* @return array
*/
public function getAttributesObjectsCache() : array {
return self::$attributeObjects;
}
/**
* @return array
*/
public function getConstructorEmptyAvailableClassesCache() : array {
return self::$constructorEmptyAvailableClasses;
}
}

View File

@@ -25,19 +25,19 @@ interface RepositoryInterface {
/**
* @param string $class
* @param array|object $data
* @param bool $withEmpty
* @return mixed
* @throws RepositoryException
*/
public function createFromData(string $class, array|object $data) : mixed;
public function createFromData(string $class, array|object $data, bool $withEmpty = true) : mixed;
/**
* @param object $object
* @param array|object $data
* @param bool $withEmpty
* @return mixed
* @throws RepositoryException
*/
public function updateFromData(object $object, array|object $data) : mixed;
public function updateFromData(object $object, array|object $data, bool $withEmpty = true) : mixed;
/**