Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure DateTime conversion to string #41600

Closed
wants to merge 3 commits into from
Closed
Changes from 2 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
8 changes: 8 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,8 @@
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
if ($expireDate !== '') {
/** @var string $expireDate */
$expireDate = $expireDate instanceof \DateTime ? $expireDate->format('Y-m-d') : $expireDate;

Check failure on line 784 in apps/files_sharing/lib/Controller/ShareAPIController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

apps/files_sharing/lib/Controller/ShareAPIController.php:784:19: TypeDoesNotContainType: Cannot resolve types for $expireDate - non-empty-string does not contain DateTime (see https://psalm.dev/056)
Fixed Show fixed Hide fixed
try {
$expireDate = $this->parseDate($expireDate);
$share->setExpirationDate($expireDate);
Expand All @@ -801,6 +803,8 @@
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
if ($expireDate !== '') {
/** @var string $expireDate */
$expireDate = $expireDate instanceof \DateTime ? $expireDate->format('Y-m-d') : $expireDate;

Check failure on line 807 in apps/files_sharing/lib/Controller/ShareAPIController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

apps/files_sharing/lib/Controller/ShareAPIController.php:807:19: TypeDoesNotContainType: Cannot resolve types for $expireDate - non-empty-string does not contain DateTime (see https://psalm.dev/056)
Fixed Show fixed Hide fixed
try {
$expireDate = $this->parseDate($expireDate);
$share->setExpirationDate($expireDate);
Expand Down Expand Up @@ -845,6 +849,8 @@

//Expire date
if ($expireDate !== '') {
/** @var string $expireDate */
$expireDate = $expireDate instanceof \DateTime ? $expireDate->format('Y-m-d') : $expireDate;
try {
$expireDate = $this->parseDate($expireDate);
$share->setExpirationDate($expireDate);
Expand Down Expand Up @@ -1384,6 +1390,8 @@
if ($expireDate === '') {
$share->setExpirationDate(null);
} elseif ($expireDate !== null) {
/** @var string $expireDate */
$expireDate = $expireDate instanceof \DateTime ? $expireDate->format('Y-m-d') : $expireDate;

Check failure on line 1394 in apps/files_sharing/lib/Controller/ShareAPIController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainType

apps/files_sharing/lib/Controller/ShareAPIController.php:1394:18: TypeDoesNotContainType: Cannot resolve types for $expireDate - non-empty-string does not contain DateTime (see https://psalm.dev/056)
Fixed Show fixed Hide fixed
try {
$expireDate = $this->parseDate($expireDate);
} catch (\Exception $e) {
Expand Down
Loading