- Some minors adjustments to match PHP 8.x coding styles
This commit is contained in:
		
							parent
							
								
									3736fbe0f6
								
							
						
					
					
						commit
						fed7d2e302
					
				| @ -62,7 +62,7 @@ trait EntityTrait { | ||||
|                         $data = json_decode($value, true); | ||||
| 
 | ||||
|                         if (json_last_error() !== \JSON_ERROR_NONE) { | ||||
|                             throw new \Exception(sprintf("JSON error while decoding in EntityTrait : '%s' given %s with field %s", json_last_error_msg(), $value, json_encode($field))); | ||||
|                             throw new \Exception(sprintf("JSON error while decoding in EntityTrait : '%s' given %s", json_last_error_msg(), $value)); | ||||
|                         } | ||||
| 
 | ||||
|                         $this->{$field['name']} = $data; | ||||
| @ -123,11 +123,9 @@ trait EntityTrait { | ||||
|     public function resetVirtualProperties() : self | ||||
|     { | ||||
|         foreach($this->resolveEntity()->properties as $prop => $property) { | ||||
|             if ( empty($property['builtin']) ) { | ||||
|                 foreach($property['tags'] as $tag) { | ||||
|                     if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) { | ||||
|                         unset($this->$prop); | ||||
|                     } | ||||
|             foreach($property['tags'] as $tag) { | ||||
|                 if ( in_array(strtolower($tag['tag']), [ 'relation', 'join', 'virtual' ] ) ) { | ||||
|                     unset($this->$prop); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -16,7 +16,7 @@ class Where extends Fragment { | ||||
|     const COMPARISON_IS = "IS"; | ||||
|     const COMPARISON_NULL = "NULL"; | ||||
|      | ||||
|     const SQL_TOKEN = "WHERE";  | ||||
|     const SQL_TOKEN = "WHERE"; | ||||
| 
 | ||||
|     public int $order = 50; | ||||
| 
 | ||||
| @ -35,7 +35,7 @@ class Where extends Fragment { | ||||
|         $this->parent = $queryBuilder->where ?? null; | ||||
|     } | ||||
|      | ||||
|     public function add($field, $value, string $operator, string $condition, bool $not = false) : self | ||||
|     public function add($field, mixed $value, string $operator, string $condition, bool $not = false) : self | ||||
|     { | ||||
|         $this->validateFieldType($field); | ||||
|         # $this->validateValueType($value);
 | ||||
| @ -73,7 +73,7 @@ class Where extends Fragment { | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     protected function whereCondition($field, $value, string $operator = self::OPERATOR_EQUAL, string $condition = self::CONDITION_AND, bool $not = false) { | ||||
|     protected function whereCondition($field, mixed $value, string $operator = self::OPERATOR_EQUAL, string $condition = self::CONDITION_AND, bool $not = false) { | ||||
|         return new class($this->queryBuilder, $field, $value, $operator, $condition, $not) { | ||||
| 
 | ||||
|             public mixed $value; | ||||
| @ -123,7 +123,7 @@ class Where extends Fragment { | ||||
|                     $stack = []; | ||||
| 
 | ||||
|                     if ($this->value) { | ||||
|                         foreach ($this->value as $item) { | ||||
|                         foreach($this->value as $item) { | ||||
|                             $stack[] = $this->filterValue($item); | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
| @ -198,9 +198,9 @@ class QueryBuilder implements Query\QueryBuilderInterface | ||||
|     public function where(string|\Stringable $field, mixed $value, string $operator = Query\Where::OPERATOR_EQUAL, string $condition = Query\Where::CONDITION_AND, bool $not = false) : self | ||||
|     { | ||||
|         # Empty IN case
 | ||||
|         #if ( [] === $value ) {
 | ||||
|         #    return $this;
 | ||||
|         #}
 | ||||
|         # if ( [] === $value ) {
 | ||||
|         #     return $this;
 | ||||
|         # }
 | ||||
| 
 | ||||
|         if ( $this->where ?? false ) { | ||||
|             $where = $this->where; | ||||
|  | ||||
| @ -47,7 +47,7 @@ class RelationBuilder | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public function searchRelation(string $name) : object|bool | ||||
|     public function searchRelation(string $name) : mixed | ||||
|     { | ||||
|         # Resolve relations here if one is called
 | ||||
|         if ( $this->entity->isLoaded() ) { | ||||
| @ -55,7 +55,13 @@ class RelationBuilder | ||||
|                 return $dataset; | ||||
|             } | ||||
| 
 | ||||
|             return $this->resolveRelation($name) ?: $this->resolveVirtual($name) ?: false; | ||||
|             if ( false !== $value = $this->resolveRelation($name) ) { | ||||
|             return $value; | ||||
|             } | ||||
|             elseif (  false !== $value = $this->resolveVirtual($name) ) { | ||||
|                                             return $value; | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|         else { | ||||
|             if ( $relation = $this->resolver->searchFieldAnnotation($name, [ Attribute\Property\Relation::class , Relation::class ] ) ) { | ||||
| @ -69,7 +75,7 @@ class RelationBuilder | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     protected function resolveVirtual(string $name) : bool|object | ||||
|     protected function resolveVirtual(string $name) : mixed | ||||
|     { | ||||
|         if (null !== ($virtual = $this->resolver->searchFieldAnnotation($name, [ Attribute\Property\Virtual::class, Annotation\Property\Virtual::class ]))) { | ||||
|             if ($virtual->closure ?? false) { | ||||
| @ -82,7 +88,7 @@ class RelationBuilder | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     protected function resolveRelation(string $name) : bool|object | ||||
|     protected function resolveRelation(string $name) : mixed | ||||
|     { | ||||
|         if ( null !== ( $relation = $this->resolver->searchFieldAnnotation($name, [ Attribute\Property\Relation::class, Relation::class ] ) ) ) { | ||||
|             $this->orders = $this->resolver->searchFieldAnnotationList($name, [ Attribute\Property\OrderBy::class, OrderBy::class ] ); | ||||
| @ -109,14 +115,14 @@ class RelationBuilder | ||||
| 
 | ||||
|                     $this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository); | ||||
| 
 | ||||
|                     return call_user_func([ $this->repository, $relation->function() ]); | ||||
| return call_user_func([ $this->repository, $relation->function() ]); | ||||
| 
 | ||||
|                 case $relation->isManyToMany(): | ||||
|                     $this->manyToMany($name, $relation, $relationRelation); | ||||
| 
 | ||||
|                     $this->entity->eventExecute(Event\EntityRelationLoadInterface::class, $name, $this->repository); | ||||
| 
 | ||||
|                     $results = call_user_func([ $this->repository, 'loadAll' ]); | ||||
|                     $results = call_user_func([ $this->repository, $relationRelation->function() ]); | ||||
| 
 | ||||
|                     if ($relation->bridgeField ?? false) { | ||||
|                         $collection = $relation->bridge::entityCollection(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user