Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,21 @@
) {
}

public function triggerEvent($objectType, $object, $subject, $additionalParams = [], $author = null) {
/**
* @param Column|Row2|Table|View $object
* @param (Share|\OCA\Tables\Model\ImportStats)[]|null|string $additionalParams
* @param (array|null)[]|null|string $author
*
* @psalm-param array{importStats?: \OCA\Tables\Model\ImportStats, share?: Share}|null|string $additionalParams
* @psalm-param array{before: array|null, after: array|null}|null|string $author
*/
public function triggerEvent(string $objectType, Table|Column|Row2|View $object, string $subject, array|string|null $additionalParams = [], array|string|null $author = null) {
if ($author === null) {
$author = $this->userId;
}

try {
$event = $this->createEvent($objectType, $object, $subject, $additionalParams, $author);

Check failure on line 98 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArgument

lib/Activity/ActivityManager.php:98:64: InvalidArgument: Argument 4 of OCA\Tables\Activity\ActivityManager::createEvent expects array{after?: mixed, before?: mixed}, but array{importStats?: OCA\Tables\Model\ImportStats, share?: OCA\Tables\Db\Share}|null|string with additional array shape fields (importStats, share) was provided (see https://psalm.dev/004)

Check failure on line 98 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArgument

lib/Activity/ActivityManager.php:98:64: InvalidArgument: Argument 4 of OCA\Tables\Activity\ActivityManager::createEvent expects array{after?: mixed, before?: mixed}, but array{importStats?: OCA\Tables\Model\ImportStats, share?: OCA\Tables\Db\Share}|null|string with additional array shape fields (importStats, share) was provided (see https://psalm.dev/004)

Check failure on line 98 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidArgument

lib/Activity/ActivityManager.php:98:64: InvalidArgument: Argument 4 of OCA\Tables\Activity\ActivityManager::createEvent expects array{after?: mixed, before?: mixed}, but array{importStats?: OCA\Tables\Model\ImportStats, share?: OCA\Tables\Db\Share}|null|string with additional array shape fields (importStats, share) was provided (see https://psalm.dev/004)

if ($event !== null) {
$this->sendToUsers($event, $object);
Expand All @@ -97,7 +105,11 @@
}
}

public function triggerUpdateEvents($objectType, ChangeSet $changeSet, $subject) {
/**
* @psalm-param 'tables_table'|'tables_view' $objectType
* @psalm-param 'table_update'|'view_update' $subject
*/
public function triggerUpdateEvents(string $objectType, ChangeSet $changeSet, string $subject) {
$previousEntity = $changeSet->getBefore();
$entity = $changeSet->getAfter();
$events = [];
Expand Down Expand Up @@ -134,7 +146,10 @@
}
}

private function createEvent($objectType, $object, $subject, $additionalParams = [], $author = null) {
/**
* @psalm-param array{before?: mixed, after?: mixed} $additionalParams
*/
private function createEvent($objectType, $object, string $subject, array $additionalParams = [], $author = null) {
if ($object instanceof Table) {
$objectTitle = $object->getTitle();
$table = $object;
Expand Down Expand Up @@ -198,10 +213,10 @@
case self::SUBJECT_SHARE_UPDATE:
case self::SUBJECT_SHARE_DELETE:
$eventType = self::EVENT_TYPE_SHARING;
$subjectParams['sharedWith'] = $this->buildSharedWithParam($additionalParams['share'] ?? []);

Check failure on line 216 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArrayOffset

lib/Activity/ActivityManager.php:216:64: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'share', expecting 'before' or 'after' (see https://psalm.dev/115)

Check failure on line 216 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArrayOffset

lib/Activity/ActivityManager.php:216:64: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'share', expecting 'before' or 'after' (see https://psalm.dev/115)

Check failure on line 216 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidArrayOffset

lib/Activity/ActivityManager.php:216:64: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'share', expecting 'before' or 'after' (see https://psalm.dev/115)
break;
case self::SUBJECT_IMPORT_FINISHED:
$subjectParams['importStats'] = $additionalParams['importStats'] ?? null;

Check failure on line 219 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArrayOffset

lib/Activity/ActivityManager.php:219:37: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'importStats', expecting 'before' or 'after' (see https://psalm.dev/115)

Check failure on line 219 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArrayOffset

lib/Activity/ActivityManager.php:219:37: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'importStats', expecting 'before' or 'after' (see https://psalm.dev/115)

Check failure on line 219 in lib/Activity/ActivityManager.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidArrayOffset

lib/Activity/ActivityManager.php:219:37: InvalidArrayOffset: Cannot access value on variable $additionalParams using offset value of 'importStats', expecting 'before' or 'after' (see https://psalm.dev/115)
break;
default:
throw new \Exception(sprintf('Unknown subject "%s" for activity.', $subject));
Expand Down Expand Up @@ -539,7 +554,7 @@
return $columnIds;
}

public function getActivitySubject($language, $subjectIdentifier, $subjectParams = [], $ownActivity = false) {
public function getActivitySubject(string $language, $subjectIdentifier, array $subjectParams = [], bool $ownActivity = false) {
$l = $this->l10nFactory->get(Application::APP_ID, $language);
$isViewContext = $subjectParams['isViewContext'] ?? false;
$isViewObject = ($subjectParams['objectType'] ?? null) === self::TABLES_OBJECT_VIEW;
Expand Down Expand Up @@ -577,7 +592,7 @@
return '';
}

private function formatTableActivity($l, string $subjectIdentifier, bool $ownActivity): ?string {
private function formatTableActivity(\OCP\IL10N $l, string $subjectIdentifier, bool $ownActivity): ?string {
return match ($subjectIdentifier) {
self::SUBJECT_TABLE_CREATE => $ownActivity ? $l->t('You have created a new table {table}') : $l->t('{user} has created a new table {table}'),
self::SUBJECT_TABLE_UPDATE => $ownActivity ? $l->t('You have updated the table {table}') : $l->t('{user} has updated the table {table}'),
Expand All @@ -588,7 +603,7 @@
};
}

private function formatViewActivity($l, string $subjectIdentifier, bool $ownActivity): ?string {
private function formatViewActivity(\OCP\IL10N $l, string $subjectIdentifier, bool $ownActivity): ?string {
return match ($subjectIdentifier) {
self::SUBJECT_VIEW_CREATE => $ownActivity ? $l->t('You have created a new view {view} in table {table}') : $l->t('{user} has created a new view {view} in table {table}'),
self::SUBJECT_VIEW_UPDATE => $ownActivity ? $l->t('You have updated the view {view} in table {table}') : $l->t('{user} has updated the view {view} in table {table}'),
Expand All @@ -599,7 +614,7 @@
};
}

private function formatRowActivity($l, string $subjectIdentifier, array $subjectParams, bool $ownActivity, bool $isViewContext): ?string {
private function formatRowActivity(\OCP\IL10N $l, string $subjectIdentifier, array $subjectParams, bool $ownActivity, bool $isViewContext): ?string {
switch ($subjectIdentifier) {
case self::SUBJECT_ROW_CREATE:
if ($isViewContext) {
Expand Down Expand Up @@ -664,7 +679,7 @@
);
}

private function formatColumnActivity($l, string $subjectIdentifier, bool $ownActivity, bool $isViewContext): ?string {
private function formatColumnActivity(\OCP\IL10N $l, string $subjectIdentifier, bool $ownActivity, bool $isViewContext): ?string {
if ($isViewContext) {
return match ($subjectIdentifier) {
self::SUBJECT_COLUMN_CREATE => $ownActivity ? $l->t('You have created a new column {column} in view {view}') : $l->t('{user} has created a new column {column} in view {view}'),
Expand All @@ -682,7 +697,7 @@
};
}

private function formatShareActivity($l, string $subjectIdentifier, array $subjectParams, bool $ownActivity, bool $isViewObject, mixed $sharedWith): ?string {
private function formatShareActivity(\OCP\IL10N $l, string $subjectIdentifier, array $subjectParams, bool $ownActivity, bool $isViewObject, mixed $sharedWith): ?string {
$sharedWithYou = $this->isSharedWithYou($subjectParams, $ownActivity);
$isLinkShare = $this->isLinkShare($sharedWith);

Expand Down Expand Up @@ -766,7 +781,7 @@
return is_array($sharedWith) && ($sharedWith['type'] ?? null) === ShareReceiverType::LINK;
}

public function getActivityMessage($language, $subjectIdentifier) {
public function getActivityMessage(string $language, $subjectIdentifier) {
$l = $this->l10nFactory->get(Application::APP_ID, $language);

switch ($subjectIdentifier) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Activity/ChangeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public function __construct(
}
}

public function setBefore($before) {
public function setBefore(Entity $before) {
$this->before = clone $before;
}

public function setAfter($after) {
public function setAfter(Entity $after) {
$this->after = clone $after;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Analytics/AnalyticsDatasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@
return '';
}

private function formatTextValue(Column $column, mixed $value): string {
private function formatTextValue(Column $column, string $value): string {
if ($value === null || $value === '') {

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: Type string for $value is never null (see https://psalm.dev/090)

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: string does not contain null (see https://psalm.dev/090)

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: Type string for $value is never null (see https://psalm.dev/090)

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: string does not contain null (see https://psalm.dev/090)

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: Type string for $value is never null (see https://psalm.dev/090)

Check failure on line 342 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

TypeDoesNotContainNull

lib/Analytics/AnalyticsDatasource.php:342:7: TypeDoesNotContainNull: string does not contain null (see https://psalm.dev/090)
return '';
}

$value = (string)$value;

Check failure on line 346 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

RedundantCast

lib/Analytics/AnalyticsDatasource.php:346:12: RedundantCast: Redundant cast to string (see https://psalm.dev/262)

Check failure on line 346 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

RedundantCast

lib/Analytics/AnalyticsDatasource.php:346:12: RedundantCast: Redundant cast to string (see https://psalm.dev/262)

Check failure on line 346 in lib/Analytics/AnalyticsDatasource.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

RedundantCast

lib/Analytics/AnalyticsDatasource.php:346:12: RedundantCast: Redundant cast to string (see https://psalm.dev/262)
if ($column->getSubtype() === 'link') {
return $this->formatLinkValue($value);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use OCA\Tables\Event\ViewDeletedEvent;
use OCA\Tables\Listener\AddMissingIndicesListener;
use OCA\Tables\Listener\AnalyticsDatasourceListener;
use OCA\Tables\Listener\BeforeTemplateRenderedListener;
use OCA\Tables\Listener\LoadAdditionalEntriesListener;
use OCA\Tables\Listener\LoadAdditionalListener;
use OCA\Tables\Listener\ReceiverCleanupListener;
use OCA\Tables\Listener\TablesReferenceListener;
Expand All @@ -39,11 +39,11 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\Navigation\Events\LoadAdditionalEntriesEvent;
use OCP\User\Events\BeforeUserDeletedEvent;
use OCP\User\Events\UserDeletedEvent;
use Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -85,7 +85,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(BeforeUserDeletedEvent::class, UserDeletedListener::class);
$context->registerEventListener(DatasourceEvent::class, AnalyticsDatasourceListener::class);
$context->registerEventListener(RenderReferenceEvent::class, TablesReferenceListener::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
$context->registerEventListener(LoadAdditionalEntriesEvent::class, LoadAdditionalEntriesListener::class);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that the BeforeTemplateRenderedListener class still exists. Is it obsolete now that it's not loaded anymore? Or is it still used somewhere else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed it

$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
$context->registerEventListener(TableDeletedEvent::class, WhenTableDeletedAuditLogListener::class);
$context->registerEventListener(ViewDeletedEvent::class, WhenViewDeletedAuditLogListener::class);
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/LegacyRowMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function find(int $id): LegacyRow {
return $this->findEntity($qb);
}

private function buildFilterByColumnType($qb, array $filter, string $filterId): ?IQueryFunction {
private function buildFilterByColumnType(IQueryBuilder $qb, array $filter, string $filterId): ?IQueryFunction {
try {
$columnQbClassName = 'OCA\Tables\Db\ColumnTypes\\';
$type = explode('-', $filter['columnType'])[0];
Expand Down
5 changes: 4 additions & 1 deletion lib/Db/RowCellMapperSuper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public function formatRowData(Column $column, array $row) {
* Transform value from a filter rule to the actual query parameter used
* for constructing the view filter query
*/
public function filterValueToQueryParam(Column $column, mixed $value): mixed {
/**
* @param array|float|null|string $value
*/
public function filterValueToQueryParam(Column $column, array|string|float|null $value): mixed {
return $value;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Db/RowCellSuper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$this->setColumnId($columnId);
}

public function setValueWrapper($value) {
public function setValueWrapper(array|float|null $value) {
$this->setValue($value);

Check failure on line 64 in lib/Db/RowCellSuper.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidArgument

lib/Db/RowCellSuper.php:64:19: InvalidArgument: Argument 1 of setValue expects string, but array<array-key, mixed>|float|null provided (see https://psalm.dev/004)

Check failure on line 64 in lib/Db/RowCellSuper.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidArgument

lib/Db/RowCellSuper.php:64:19: InvalidArgument: Argument 1 of setValue expects string, but array<array-key, mixed>|float|null provided (see https://psalm.dev/004)

Check failure on line 64 in lib/Db/RowCellSuper.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidArgument

lib/Db/RowCellSuper.php:64:19: InvalidArgument: Argument 1 of setValue expects string, but array<array-key, mixed>|float|null provided (see https://psalm.dev/004)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
namespace OCA\Tables\Listener;

use OCA\Tables\Service\ContextService;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IUserSession;
use OCP\Navigation\Events\LoadAdditionalEntriesEvent;

/**
* @template-implements IEventListener<Event|BeforeTemplateRenderedEvent>
* @template-implements IEventListener<Event|LoadAdditionalEntriesEvent>
*/
class BeforeTemplateRenderedListener implements IEventListener {
class LoadAdditionalEntriesListener implements IEventListener {
public function __construct(
protected IUserSession $userSession,
protected ContextService $contextService,
Expand All @@ -27,7 +27,7 @@ public function __construct(
* @inheritDoc
*/
public function handle(Event $event): void {
if (!$event instanceof BeforeTemplateRenderedEvent) {
if (!$event instanceof LoadAdditionalEntriesEvent) {
return;
}

Expand Down
20 changes: 10 additions & 10 deletions lib/Migration/Version000800Date20240213123743.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
Expand Down Expand Up @@ -39,15 +38,12 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
return $schema;
}

protected function shouldAddTable(string $tableName, ISchemaWrapper $schema): ?Table {
return !$schema->hasTable($tableName) ? $schema->createTable($tableName) : null;
}

/**
* @throws SchemaException
*/
protected function haveContextTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'context', $schema)) {
if (!$schema->hasTable(self::PREFIX . 'context')) {
$table = $schema->createTable(self::PREFIX . 'context');
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('name', Types::STRING, ['notnull' => true, 'length' => 200]);
$table->addColumn('icon', Types::STRING, ['notnull' => true, 'length' => 64]);
Expand All @@ -63,7 +59,8 @@ protected function haveContextTable(ISchemaWrapper $schema): void {
* @throws SchemaException
*/
protected function haveContextNodeRelationTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'rel_context_node', $schema)) {
if (!$schema->hasTable(self::PREFIX . 'rel_context_node')) {
$table = $schema->createTable(self::PREFIX . 'rel_context_node');
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('context_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('node_id', Types::INTEGER, ['notnull' => true]);
Expand All @@ -78,7 +75,8 @@ protected function haveContextNodeRelationTable(ISchemaWrapper $schema): void {
* @throws SchemaException
*/
protected function havePageTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'page', $schema)) {
if (!$schema->hasTable(self::PREFIX . 'page')) {
$table = $schema->createTable(self::PREFIX . 'page');
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('context_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('page_type', Types::STRING, ['notnull' => true, 'length' => 32]);
Expand All @@ -91,7 +89,8 @@ protected function havePageTable(ISchemaWrapper $schema): void {
* @throws SchemaException
*/
protected function havePageContentTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'page_content', $schema)) {
if (!$schema->hasTable(self::PREFIX . 'page_content')) {
$table = $schema->createTable(self::PREFIX . 'page_content');
$table->addColumn('id', Types::INTEGER, ['autoincrement' => true, 'notnull' => true]);
$table->addColumn('page_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('node_rel_id', Types::INTEGER, ['notnull' => true]);
Expand All @@ -105,7 +104,8 @@ protected function havePageContentTable(ISchemaWrapper $schema): void {
* @throws SchemaException
*/
protected function haveNavigationTable(ISchemaWrapper $schema): void {
if ($table = $this->shouldAddTable(self::PREFIX . 'navigation', $schema)) {
if (!$schema->hasTable(self::PREFIX . 'navigation')) {
$table = $schema->createTable(self::PREFIX . 'navigation');
$table->addColumn('share_id', Types::INTEGER, ['notnull' => true]);
$table->addColumn('display_mode', Types::INTEGER, ['notnull' => true]);
$table->addColumn('user_id', Types::STRING, ['notnull' => true, 'length' => 64, 'default' => '']);
Expand Down
5 changes: 4 additions & 1 deletion lib/Model/RowDataInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class RowDataInput implements ArrayAccess, Iterator {
/** @psalm-var array<array{'columnId': int, 'value': mixed}> */
protected array $data = [];

public function add(int $columnId, mixed $value): self {
/**
* @param array|float|int|null|string $value
*/
public function add(int $columnId, array|string|int|float|null $value): self {
$this->data[] = [self::DATA_KEY => $columnId, self::DATA_VAL => $value];
return $this;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public function get(string $key): string|bool {
*
* @throws BadRequestError
* @throws PermissionError
*
* @param bool|numeric|string $value
*/
public function set(string $key, mixed $value): void {
$userId = $this->getUserId();
Expand Down
34 changes: 16 additions & 18 deletions lib/Service/ContextService.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,23 @@ public function findForNavigation(string $userId): array {
public function addToNavigation(string $userId): void {
$contexts = $this->findForNavigation($userId);
foreach ($contexts as $context) {
$this->navigationManager->add(function () use ($context) {
$iconRelPath = 'material/' . $context->getIcon() . '.svg';
if (file_exists(__DIR__ . '/../../img/' . $iconRelPath)) {
$iconUrl = $this->urlGenerator->imagePath(Application::APP_ID, $iconRelPath);
} else {
$iconUrl = $this->urlGenerator->imagePath('core', 'places/default-app-icon.svg');
}
$iconRelPath = 'material/' . $context->getIcon() . '.svg';
if (file_exists(__DIR__ . '/../../img/' . $iconRelPath)) {
$iconUrl = $this->urlGenerator->imagePath(Application::APP_ID, $iconRelPath);
} else {
$iconUrl = $this->urlGenerator->imagePath('core', 'places/default-app-icon.svg');
}

$contextUrl = $this->urlGenerator->linkToRoute('tables.page.context', ['contextId' => $context->getId()]);

$contextUrl = $this->urlGenerator->linkToRoute('tables.page.context', ['contextId' => $context->getId()]);

return [
'id' => Application::APP_ID . '_application_' . $context->getId(),
'name' => $context->getName(),
'href' => $contextUrl,
'icon' => $iconUrl,
'order' => 500,
'type' => 'link',
];
});
$this->navigationManager->add([
'id' => Application::APP_ID . '_application_' . $context->getId(),
'name' => $context->getName(),
'href' => $contextUrl,
'icon' => $iconUrl,
'order' => 500,
'type' => 'link',
]);
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/Service/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,14 @@
}
}

private function valueToDateTimeImmutable(mixed $value): ?DateTimeImmutable {
/**
* @param null|string $value
*/
private function valueToDateTimeImmutable(string|null $value): ?DateTimeImmutable {
if (
$value === false

Check failure on line 712 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

TypeDoesNotContainType

lib/Service/ImportService.php:712:4: TypeDoesNotContainType: Type null|string for $value is never !false (see https://psalm.dev/056)

Check failure on line 712 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

TypeDoesNotContainType

lib/Service/ImportService.php:712:4: TypeDoesNotContainType: null|string does not contain false (see https://psalm.dev/056)

Check failure on line 712 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

TypeDoesNotContainType

lib/Service/ImportService.php:712:4: TypeDoesNotContainType: Type null|string for $value is never !false (see https://psalm.dev/056)

Check failure on line 712 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

TypeDoesNotContainType

lib/Service/ImportService.php:712:4: TypeDoesNotContainType: null|string does not contain false (see https://psalm.dev/056)
|| $value === null
|| (is_string($value)

Check failure on line 714 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

RedundantCondition

lib/Service/ImportService.php:714:8: RedundantCondition: Type string for $value is always string (see https://psalm.dev/122)

Check failure on line 714 in lib/Service/ImportService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

RedundantCondition

lib/Service/ImportService.php:714:8: RedundantCondition: Type string for $value is always string (see https://psalm.dev/122)
&& mb_strlen($value) < 3 // Let pass potential 3-letter month names
&& preg_match('/\d/', $value) !== 1) // or anything containing a digit
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ValueObject/ColumnOrderInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function jsonSerialize(): array {
];
}

protected function ensureType(string $offset, mixed $value): int|bool {
protected function ensureType(string $offset, bool|int $value): int|bool {
return match ($offset) {
self::KEY_ID,
self::KEY_ORDER => (int)$value,
Expand Down
Loading