* may be subject to change in the future
*
* @since 14.0.0
+ *
+ * @template T of Entity
*/
abstract class QBMapper {
/** @var string */
protected $tableName;
- /** @var string */
+ /** @var string|class-string<T> */
protected $entityClass;
/** @var IDBConnection */
/**
* @param IDBConnection $db Instance of the Db abstraction layer
* @param string $tableName the name of the table. set this to allow entity
- * @param string $entityClass the name of the entity that the sql should be
+ * @param string|null $entityClass the name of the entity that the sql should be
+ * @psalm-param class-string<T>|null $entityClass the name of the entity that the sql should be
* mapped to queries without using sql
* @since 14.0.0
*/
/**
* Deletes an entity from the table
* @param Entity $entity the entity that should be deleted
+ * @psalm-param T $entity the entity that should be deleted
* @return Entity the deleted entity
+ * @psalm-return T the deleted entity
* @since 14.0.0
*/
public function delete(Entity $entity): Entity {
/**
* Creates a new entry in the db from an entity
* @param Entity $entity the entity that should be created
+ * @psalm-param T $entity the entity that should be created
* @return Entity the saved entity with the set id
+ * @psalm-return T the saved entity with the set id
* @since 14.0.0
*/
public function insert(Entity $entity): Entity {
* by the database
*
* @param Entity $entity the entity that should be created/updated
+ * @psalm-param T $entity the entity that should be created/updated
* @return Entity the saved entity with the (new) id
+ * @psalm-return T the saved entity with the (new) id
* @throws \InvalidArgumentException if entity has no id
* @since 15.0.0
*/
* Updates an entry in the db from an entity
* @throws \InvalidArgumentException if entity has no id
* @param Entity $entity the entity that should be created
+ * @psalm-param T $entity the entity that should be created
* @return Entity the saved entity with the set id
+ * @psalm-return T the saved entity with the set id
* @since 14.0.0
*/
public function update(Entity $entity): Entity {
* of the $entity
*
* @param Entity $entity The entity to get the types from
+ * @psalm-param T $entity
* @param string $property The property of $entity to get the type for
* @return int
* @since 16.0.0
*
* @param array $row the row which should be converted to an entity
* @return Entity the entity
+ * @psalm-return T the entity
* @since 14.0.0
*/
protected function mapRowToEntity(array $row): Entity {
*
* @param IQueryBuilder $query
* @return Entity[] all fetched entities
+ * @psalm-return T[] all fetched entities
* @since 14.0.0
*/
protected function findEntities(IQueryBuilder $query): array {
* @throws DoesNotExistException if the item does not exist
* @throws MultipleObjectsReturnedException if more than one item exist
* @return Entity the entity
+ * @psalm-return T the entity
* @since 14.0.0
*/
protected function findEntity(IQueryBuilder $query): Entity {