Prepping everything for a PHP 8 release
This commit is contained in:
parent
dfb84c104d
commit
0e8443b1c1
|
@ -90,6 +90,6 @@ trait DefaultAdapterTrait
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $typeOnly ? $type : $type . ( $length ? "($length" . ( $precision ? ",$precision" : "" ) . ")" : "" );
|
return $typeOnly ? $type : $type . ( isset($length) ? "($length" . ( ! empty($precision) ? ",$precision" : "" ) . ")" : "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,4 +34,9 @@ class Datetime extends \DateTime implements EntityObjectInterface {
|
||||||
{
|
{
|
||||||
return strftime($format, $this->getTimestamp());
|
return strftime($format, $this->getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ageAt(null|\DateTime $dateTime) : int
|
||||||
|
{
|
||||||
|
return (int) ( (int) ($dateTime ?: new DateTime())->format('Ymd') - (int) $this->format('Ymd') ) / 10000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,6 +308,12 @@ class EntityCollection extends \ArrayObject {
|
||||||
$this->append( $this->arrayToEntity($value) );
|
$this->append( $this->arrayToEntity($value) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
foreach ($this as $duplicate) {
|
||||||
|
if ($duplicate === $value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parent::append($value);
|
parent::append($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,10 @@
|
||||||
|
|
||||||
namespace Ulmus;
|
namespace Ulmus;
|
||||||
|
|
||||||
use Ulmus\Repository,
|
use Ulmus\{ Repository, Query, Common\EntityResolver, Common\EntityField };
|
||||||
Ulmus\Query,
|
|
||||||
Ulmus\Common\EntityResolver,
|
|
||||||
Ulmus\Common\EntityField;
|
|
||||||
|
|
||||||
use Ulmus\Annotation\Classes\{ Method, Table, Collation, };
|
use Ulmus\Annotation\Classes\{ Method, Table, Collation, };
|
||||||
use Ulmus\Annotation\Property\{ Field, Filter, FilterJoin, Relation, OrderBy, Where, OrWhere, Join, Virtual, On, WithJoin, };
|
use Ulmus\Annotation\Property\{ Field, Filter, FilterJoin, Relation, OrderBy, Where, OrWhere, Join, Virtual, On, WithJoin, };
|
||||||
use Ulmus\Annotation\Property\Field\{ Id, ForeignKey, CreatedAt, UpdatedAt, Datetime as DateTime, Date, Time, Bigint, Tinyint, Text, Mediumtext, Longtext, Blob, Mediumblob, Longblob };
|
use Ulmus\Annotation\Property\Field\{ Id, ForeignKey, CreatedAt, UpdatedAt, Datetime as DateTime, Date, Time, Bigint, Tinyint, Text, Mediumtext, Longtext, Blob, Mediumblob, Longblob, };
|
||||||
use Ulmus\Annotation\Property\Relation\{ Ignore as RelationIgnore };
|
use Ulmus\Annotation\Property\Relation\{ Ignore as RelationIgnore };
|
||||||
|
|
||||||
trait EntityTrait {
|
trait EntityTrait {
|
||||||
|
@ -110,7 +106,7 @@ trait EntityTrait {
|
||||||
public function resetVirtualProperties() : self
|
public function resetVirtualProperties() : self
|
||||||
{
|
{
|
||||||
foreach($this->resolveEntity()->properties as $prop => $property) {
|
foreach($this->resolveEntity()->properties as $prop => $property) {
|
||||||
if ( ! $property['builtin'] ) {
|
if ( empty($property['builtin']) ) {
|
||||||
foreach($property['tags'] as $tag) {
|
foreach($property['tags'] as $tag) {
|
||||||
if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) {
|
if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) {
|
||||||
unset($this->$prop);
|
unset($this->$prop);
|
||||||
|
@ -273,7 +269,7 @@ trait EntityTrait {
|
||||||
/**
|
/**
|
||||||
* @Ignore
|
* @Ignore
|
||||||
*/
|
*/
|
||||||
public function jsonSerialize() : mixed
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return $this->entityGetDataset();
|
return $this->entityGetDataset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,7 +294,20 @@ class Repository
|
||||||
|
|
||||||
$dataset = array_change_key_case($entity->entityGetDataset(false, true));
|
$dataset = array_change_key_case($entity->entityGetDataset(false, true));
|
||||||
|
|
||||||
return array_diff_assoc($oldValues ? $dataset : $array , $oldValues ? $array : $dataset );
|
return array_udiff_assoc($oldValues ? $dataset : $array , $oldValues ? $array : $dataset, function($e1, $e2) {
|
||||||
|
if ( is_array($e1) ) {
|
||||||
|
if (is_array($e2)) {
|
||||||
|
return Ulmus::encodeArray($e1) !== Ulmus::encodeArray($e2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (string) $e1 !== (string) $e2;
|
||||||
|
});
|
||||||
|
|
||||||
|
# return array_diff_assoc($oldValues ? $dataset : $array , $oldValues ? $array : $dataset );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -606,11 +619,14 @@ class Repository
|
||||||
$field = clone $condition->field;
|
$field = clone $condition->field;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $condition->field->entityClass === $entity ) {
|
/* @TODO FIX THIS !
|
||||||
|
*
|
||||||
|
* if ( $condition->field->entityClass === $entity ) {
|
||||||
|
if ( $this->entityClass === $entity ) {
|
||||||
$field->alias = $alias;
|
$field->alias = $alias;
|
||||||
|
|
||||||
$join->where(is_object($field) ? $field : $entity::field($field, $alias), $condition->value, $condition->operator);
|
$join->where(is_object($field) ? $field : $entity::field($field, $alias), $condition->value, $condition->operator);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->entityResolver->searchFieldAnnotationList($item, new FilterJoin() ) as $filter) {
|
foreach($this->entityResolver->searchFieldAnnotationList($item, new FilterJoin() ) as $filter) {
|
||||||
|
|
Loading…
Reference in New Issue