diff --git a/.docker/app.dockerfile b/.docker/app.dockerfile index 07555e352..ac825ecc4 100644 --- a/.docker/app.dockerfile +++ b/.docker/app.dockerfile @@ -1,8 +1,8 @@ -# PHP 8.1.13 -#FROM php:8.1-fpm-alpine -FROM php@sha256:88407bcb4821e7a9da273d9dad746e1f795e9a6480d9cba5ba502d7836e23718 -MAINTAINER Martin Zurowietz -LABEL org.opencontainers.image.source https://github.com/biigle/core +# PHP 8.2.21 +#FROM php:8.2-fpm-alpine +FROM php@sha256:95c34aeeef07aa9774e0b70d5b70065ab0647ece183ebe007c5f2e6b5db16725 +LABEL org.opencontainers.image.authors="Martin Zurowietz " +LABEL org.opencontainers.image.source="https://github.com/biigle/core" RUN ln -s "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" ADD ".docker/all-php.ini" "$PHP_INI_DIR/conf.d/all.ini" @@ -37,7 +37,7 @@ RUN apk add --no-cache yaml \ # Unset proxy configuration again. RUN [ -z "$HTTP_PROXY" ] || pear config-set http_proxy "" -ARG PHPREDIS_VERSION=5.3.7 +ARG PHPREDIS_VERSION=6.0.2 RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${PHPREDIS_VERSION}.tar.gz \ && tar -xzf /tmp/redis.tar.gz \ && rm /tmp/redis.tar.gz \ diff --git a/.docker/web.dockerfile b/.docker/web.dockerfile index 7260dc22d..aa1c55f47 100644 --- a/.docker/web.dockerfile +++ b/.docker/web.dockerfile @@ -1,7 +1,7 @@ # FROM nginx:1.21-alpine FROM nginx@sha256:5a0df7fb7c8c03e4158ae9974bfbd6a15da2bdfdeded4fb694367ec812325d31 -MAINTAINER Martin Zurowietz -LABEL org.opencontainers.image.source https://github.com/biigle/core +LABEL org.opencontainers.image.authors="Martin Zurowietz " +LABEL org.opencontainers.image.source="https://github.com/biigle/core" ADD .docker/vhost.conf /etc/nginx/conf.d/default.conf ADD .docker/ffdhe2048.txt /etc/nginx/conf.d/ffdhe2048.txt diff --git a/.docker/worker.dockerfile b/.docker/worker.dockerfile index 5339ed683..3b7942265 100644 --- a/.docker/worker.dockerfile +++ b/.docker/worker.dockerfile @@ -1,8 +1,8 @@ -# PHP 8.1.27 -# FROM php:8.1 -FROM php@sha256:9b5dfb7deef3e48d67b2599e4d3967bb3ece19fd5ba09cb8e7ee10f5facf36e0 -MAINTAINER Martin Zurowietz -LABEL org.opencontainers.image.source https://github.com/biigle/core +# PHP 8.2.21 +# FROM php:8.2 +FROM php@sha256:a61daae986bdf9bbeff9a514e3598a4f72bb2e3d01a0b3d0eff960bbfe85acdf +LABEL org.opencontainers.image.authors="Martin Zurowietz " +LABEL org.opencontainers.image.source="https://github.com/biigle/core" RUN LC_ALL=C.UTF-8 apt-get update \ && apt-get install -y --no-install-recommends \ @@ -21,16 +21,21 @@ RUN LC_ALL=C.UTF-8 apt-get update \ RUN ln -s "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" ADD ".docker/all-php.ini" "$PHP_INI_DIR/conf.d/all.ini" +# Enable FFI for jcupitt/vips. +# See: https://github.com/libvips/php-vips?tab=readme-ov-file#install +RUN echo "ffi.enable = true" > "$PHP_INI_DIR/conf.d/vips.ini" RUN LC_ALL=C.UTF-8 apt-get update \ && apt-get install -y --no-install-recommends \ libxml2-dev \ libzip-dev \ libpq-dev \ + libffi-dev \ && apt-get install -y --no-install-recommends \ libxml2 \ libzip4 \ postgresql-client \ + libffi8 \ && docker-php-ext-configure pgsql -with-pgsql=/usr/bin/pgsql \ && docker-php-ext-install -j$(nproc) \ exif \ @@ -40,10 +45,12 @@ RUN LC_ALL=C.UTF-8 apt-get update \ pgsql \ soap \ zip \ + ffi \ && apt-get purge -y \ libxml2-dev \ libzip-dev \ libpq-dev \ + libffi-dev \ && apt-get -y autoremove \ && apt-get clean \ && rm -r /var/lib/apt/lists/* @@ -64,7 +71,7 @@ RUN LC_ALL=C.UTF-8 apt-get update \ && apt-get clean \ && rm -r /var/lib/apt/lists/* -ARG PHPREDIS_VERSION=5.3.7 +ARG PHPREDIS_VERSION=6.0.2 RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${PHPREDIS_VERSION}.tar.gz \ && tar -xzf /tmp/redis.tar.gz \ && rm /tmp/redis.tar.gz \ @@ -72,18 +79,8 @@ RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${ && mv phpredis-${PHPREDIS_VERSION} /usr/src/php/ext/redis \ && docker-php-ext-install -j$(nproc) redis -# ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}" - RUN LC_ALL=C.UTF-8 apt-get update \ - && apt-get install -y --no-install-recommends \ - libvips-dev \ - && apt-get install -y --no-install-recommends \ - libvips42 \ - && pecl install vips \ - && docker-php-ext-enable vips \ - && apt-get purge -y \ - libvips-dev \ - && apt-get -y autoremove \ + && apt-get install -y --no-install-recommends libvips42 \ && apt-get clean \ && rm -r /var/lib/apt/lists/* diff --git a/.env.example b/.env.example index 95fc1dfb5..bfaa548c0 100644 --- a/.env.example +++ b/.env.example @@ -8,7 +8,17 @@ APP_DEBUG=true APP_URL="http://localhost:8000" APP_TIMEZONE="Europe/Berlin" +APP_LOCALE=en +APP_FALLBACK_LOCALE=en +APP_FAKER_LOCALE=en_US + +APP_MAINTENANCE_DRIVER=file +# APP_MAINTENANCE_STORE=database + +BCRYPT_ROUNDS=12 + LOG_CHANNEL=single +LOG_STACK=single LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug @@ -40,23 +50,29 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" #HTTP_PROXY=host:port # normally you don't have to edit these -CACHE_DRIVER="file" -FILESYSTEM_DISK=local SESSION_DRIVER="file" SESSION_LIFETIME=120 SESSION_SECURE_COOKIE=false -QUEUE_CONNECTION="database" +SESSION_ENCRYPT=false +SESSION_PATH=/ +SESSION_DOMAIN=null + +BROADCAST_CONNECTION=log +FILESYSTEM_DISK=local +QUEUE_CONNECTION=database + +CACHE_STORE=file +CACHE_PREFIX= MEMCACHED_HOST=127.0.0.1 +REDIS_CLIENT=phpredis REDIS_HOST="127.0.0.1" REDIS_PASSWORD=null REDIS_PORT=6379 -# see config/mail.php for what drivers are available -# default is the PHP mail function which doesn't require any credentials -MAIL_MAILER="log" -MAIL_HOST="smtp.mailtrap.io" +MAIL_MAILER=log +MAIL_HOST=127.0.0.1 MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d3030564e..97b90c73c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' - uses: actions/checkout@v1 with: @@ -50,7 +50,7 @@ jobs: - name: Set testing key run: echo "APP_KEY=base64:STZFA4bQKDjE2mlpRPmsJ/okG0eCh4RHd9BghtZeYmQ=" >> .env - - name: Run Psalm + - name: Run Linter run: composer lint cs-php: @@ -61,7 +61,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' tools: cs2pr - uses: actions/checkout@v1 diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 45a52dcba..1a0af90a7 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -14,6 +14,7 @@ ->ignoreVCS(true); return (new PhpCsFixer\Config()) + ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) ->setRules([ '@PSR2' => true, 'ordered_imports' => true, diff --git a/app/Annotation.php b/app/Annotation.php index 440edd9a2..b915d69f4 100644 --- a/app/Annotation.php +++ b/app/Annotation.php @@ -11,6 +11,11 @@ /** * An image annotation is a region of an image that can be labeled by the users. * It consists of one or many points and has a specific shape. + * + * @property int $id + * @property array $points + * @property string $created_at + * @property int $shape_id */ abstract class Annotation extends Model implements AnnotationContract { @@ -19,7 +24,7 @@ abstract class Annotation extends Model implements AnnotationContract /** * The attributes excluded from the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'pivot', @@ -28,7 +33,7 @@ abstract class Annotation extends Model implements AnnotationContract /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'points' => 'array', @@ -40,7 +45,7 @@ abstract class Annotation extends Model implements AnnotationContract * @param \Illuminate\Database\Query\Builder $query * @param User $user The user to whom the restrictions should apply ('own' user) * - * @return \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Query\Builder */ public function scopeVisibleFor($query, User $user) { @@ -73,7 +78,7 @@ public function scopeVisibleFor($query, User $user) * @param \Illuminate\Database\Query\Builder $query * @param Label $label * - * @return \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Query\Builder */ public function scopeWithLabel($query, Label $label) { @@ -93,7 +98,7 @@ public function scopeWithLabel($query, Label $label) * @param \Illuminate\Database\Query\Builder $query * @param AnnotationSession $session * @param User $user The user to whom the restrictions should apply ('own' user) - * @return \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Query\Builder */ public function scopeAllowedBySession($query, AnnotationSession $session, User $user) { @@ -153,14 +158,14 @@ public function scopeAllowedBySession($query, AnnotationSession $session, User $ /** * The file, this annotation belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ abstract public function file(); /** * The labels, this annotation got assigned by the users. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ abstract public function labels(); @@ -174,7 +179,7 @@ abstract public function getFileIdAttribute(); /** * The shape of this annotation. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function shape() { diff --git a/app/AnnotationLabel.php b/app/AnnotationLabel.php index c630ccd64..754dc2139 100644 --- a/app/AnnotationLabel.php +++ b/app/AnnotationLabel.php @@ -5,6 +5,12 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +/** + * @property int $id + * @property int $annotation_id + * @property int $user_id + * @property int $label_id + */ abstract class AnnotationLabel extends Model { use HasFactory; @@ -12,7 +18,7 @@ abstract class AnnotationLabel extends Model /** * The attributes that are mass assignable. * - * @var array + * @var array */ protected $fillable = [ 'label_id', @@ -23,7 +29,7 @@ abstract class AnnotationLabel extends Model /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'user_id' => 'int', @@ -33,14 +39,14 @@ abstract class AnnotationLabel extends Model /** * The annotation, this annotation label belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ abstract public function annotation(); /** * The label, this annotation label belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function label() { @@ -50,7 +56,7 @@ public function label() /** * The user who created this annotation label. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function user() { diff --git a/app/AnnotationSession.php b/app/AnnotationSession.php index f583681ed..26bf601fc 100644 --- a/app/AnnotationSession.php +++ b/app/AnnotationSession.php @@ -18,7 +18,7 @@ class AnnotationSession extends Model /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'starts_at' => 'datetime', @@ -31,7 +31,7 @@ class AnnotationSession extends Model /** * The accessors to append to the model's array form. * - * @var array + * @var array */ protected $appends = [ 'starts_at_iso8601', @@ -41,7 +41,7 @@ class AnnotationSession extends Model /** * The volume, this annotation session belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function volume() { @@ -51,7 +51,7 @@ public function volume() /** * The users, this annotation session is restricted to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function users() { @@ -65,7 +65,7 @@ public function users() * @param VolumeFile $file The file to get the annotations from * @param User $user The user to whom the restrictions should apply ('own' user) * - * @return \Illuminate\Support\Collection + * @return \Illuminate\Database\Eloquent\Collection */ public function getVolumeFileAnnotations(VolumeFile $file, User $user) { @@ -113,7 +113,7 @@ public function getVolumeFileAnnotations(VolumeFile $file, User $user) * * This is **not** an Eloquent relation! * - * @return \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder */ public function annotations() { diff --git a/app/Announcement.php b/app/Announcement.php index 78acd2607..1a4b276ca 100644 --- a/app/Announcement.php +++ b/app/Announcement.php @@ -22,14 +22,14 @@ class Announcement extends Model /** * The attributes that are mass assignable. * - * @var array + * @var array */ protected $fillable = ['title', 'show_until', 'body']; /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'show_until' => 'datetime', diff --git a/app/ApiToken.php b/app/ApiToken.php index 8f3aa4cbe..46bc6a133 100644 --- a/app/ApiToken.php +++ b/app/ApiToken.php @@ -12,7 +12,7 @@ class ApiToken extends Model /** * The attributes excluded from the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'hash', @@ -21,7 +21,7 @@ class ApiToken extends Model /** * The user, this token belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function owner() { diff --git a/app/Console/Commands/MigrateTiledImages.php b/app/Console/Commands/MigrateTiledImages.php index c1b014910..72ff13dac 100644 --- a/app/Console/Commands/MigrateTiledImages.php +++ b/app/Console/Commands/MigrateTiledImages.php @@ -38,7 +38,7 @@ public function handle() $query = Image::where('tiled', true); $bar = $this->output->createProgressBar($query->count()); - $query->eachById(function ($image) use ($dryRun, $bar, $disk) { + $query->eachById(function (Image $image) use ($dryRun, $bar, $disk) { if (!$dryRun) { Queue::push(new MigrateTiledImage($image, $disk)); } diff --git a/app/Console/Commands/UpdateImageMetadata.php b/app/Console/Commands/UpdateImageMetadata.php deleted file mode 100644 index 3e3097db1..000000000 --- a/app/Console/Commands/UpdateImageMetadata.php +++ /dev/null @@ -1,101 +0,0 @@ -dryRun = $this->option('dry-run'); - $this->stripTileProperties(); - $this->dispatchReprocessJobs(); - } - - /** - * Removes the tileProperties attribute from images. - */ - protected function stripTileProperties() - { - $images = Image::whereRaw("jsonb_exists(attrs::jsonb, 'tileProperties')") - ->select('id', 'attrs') - ->get(); - - $this->line('Removing obsolete image tileProperties.'); - - $total = $images->count(); - - if ($total > 0) { - $remaining = $total; - $bar = $this->output->createProgressBar($total); - - foreach ($images as $image) { - $attrs = $image->attrs; - unset($attrs['tileProperties']); - $image->attrs = $attrs; - if (!$this->dryRun) { - $image->save(); - } - - $remaining--; - - if ($remaining % 1000 === 0) { - $bar->setProgress($total - $remaining); - } - } - - $bar->setProgress($total); - $bar->finish(); - $this->line(''); - } - - $this->info('Done.'); - } - - /** - * Dispatches jobs to process all images anew. - */ - protected function dispatchReprocessJobs() - { - $volumes = Volume::select('id')->get(); - $this->line('Submitting jobs to reprocess images.'); - - foreach ($volumes as $volume) { - if (!$this->dryRun) { - $volume->handleNewImages(); - } - } - - $this->info('Done.'); - } -} diff --git a/app/Console/Commands/UpdateVideoMetadata.php b/app/Console/Commands/UpdateVideoMetadata.php index feeb1588d..400c62d78 100644 --- a/app/Console/Commands/UpdateVideoMetadata.php +++ b/app/Console/Commands/UpdateVideoMetadata.php @@ -38,7 +38,7 @@ class UpdateVideoMetadata extends Command /** * The FFProbe video instance. * - * @var FFProbe + * @var FFProbe|null */ protected $ffprobe; diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 225da6d57..028e9e1ac 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -35,7 +35,7 @@ public function register(): void * Prepare exception for rendering. * * @param Throwable $e - * @return \Exception + * @return Throwable */ protected function prepareException(Throwable $e) { diff --git a/app/Facades/VipsImage.php b/app/Facades/VipsImage.php deleted file mode 100644 index 0ce3a9428..000000000 --- a/app/Facades/VipsImage.php +++ /dev/null @@ -1,18 +0,0 @@ - */ protected $fillable = [ 'name', @@ -28,7 +28,7 @@ class FederatedSearchInstance extends Model implements AuthenticatableContract /** * The attributes excluded from the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'local_token', @@ -38,7 +38,7 @@ class FederatedSearchInstance extends Model implements AuthenticatableContract /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'index_interval' => 'int', @@ -72,7 +72,7 @@ public function scopeWithRemoteToken($query) /** * The models that belong to this instance. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function models() { @@ -100,7 +100,7 @@ public function setRemoteTokenAttribute($value) */ public function getRemoteTokenAttribute() { - if (!isset($this->attributes['remote_token']) || is_null($this->attributes['remote_token'])) { + if (!isset($this->attributes['remote_token'])) { return null; } else { return decrypt($this->attributes['remote_token']); diff --git a/app/FederatedSearchModel.php b/app/FederatedSearchModel.php index 38e5095ef..d89f6bb29 100644 --- a/app/FederatedSearchModel.php +++ b/app/FederatedSearchModel.php @@ -13,7 +13,7 @@ class FederatedSearchModel extends Model /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'attrs' => 'array', @@ -58,7 +58,7 @@ public function scopeVolumes($query) /** * The instance, this model belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function instance() { @@ -68,7 +68,7 @@ public function instance() /** * The users who can access this model. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function users() { diff --git a/app/Http/Controllers/Api/AnnotationSessionController.php b/app/Http/Controllers/Api/AnnotationSessionController.php index 424e94a7d..f64b72d39 100644 --- a/app/Http/Controllers/Api/AnnotationSessionController.php +++ b/app/Http/Controllers/Api/AnnotationSessionController.php @@ -42,11 +42,10 @@ class AnnotationSessionController extends Controller * } * * @param UpdateAnnotationSession $request - * @return \Illuminate\Http\Response */ public function update(UpdateAnnotationSession $request) { - $session = $request->session; + $session = $request->annotationSession; if ($request->filled('starts_at')) { $newStartsAt = Carbon::parse($request->input('starts_at')) @@ -157,14 +156,13 @@ public function update(UpdateAnnotationSession $request) * * @param DestroyAnnotationSession $request * @param int $id - * @return \Illuminate\Http\Response */ public function destroy(DestroyAnnotationSession $request, $id) { - if (!$request->input('force') && $request->session->annotations()->exists()) { + if (!$request->input('force') && $request->annotationSession->annotations()->exists()) { abort(400, 'There are annotations belonging to this annotation session. Use the force attribute to delete it anyway (the annotations will not be deleted).'); } - $request->session->delete(); + $request->annotationSession->delete(); } } diff --git a/app/Http/Controllers/Api/Annotations/Filters/AnnotationController.php b/app/Http/Controllers/Api/Annotations/Filters/AnnotationController.php index 37ed83410..7a7094073 100644 --- a/app/Http/Controllers/Api/Annotations/Filters/AnnotationController.php +++ b/app/Http/Controllers/Api/Annotations/Filters/AnnotationController.php @@ -26,7 +26,7 @@ class AnnotationController extends Controller * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index(Request $request, $id) { diff --git a/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php b/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php index 19af1e5ff..e0768ada2 100644 --- a/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php +++ b/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php @@ -28,7 +28,7 @@ class AnnotationUserController extends Controller * @param Request $request * @param int $tid * @param int $uid - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index(Request $request, $tid, $uid) { diff --git a/app/Http/Controllers/Api/Annotations/VolumeAnnotationLabelController.php b/app/Http/Controllers/Api/Annotations/VolumeAnnotationLabelController.php index 49219fb9e..ef550cd1d 100644 --- a/app/Http/Controllers/Api/Annotations/VolumeAnnotationLabelController.php +++ b/app/Http/Controllers/Api/Annotations/VolumeAnnotationLabelController.php @@ -39,7 +39,7 @@ class VolumeAnnotationLabelController extends Controller * ] * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Annotations/VolumeImageAreaController.php b/app/Http/Controllers/Api/Annotations/VolumeImageAreaController.php index 3a42452d9..e9c06fd0f 100644 --- a/app/Http/Controllers/Api/Annotations/VolumeImageAreaController.php +++ b/app/Http/Controllers/Api/Annotations/VolumeImageAreaController.php @@ -26,7 +26,7 @@ class VolumeImageAreaController extends Controller * } * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/AnnouncementController.php b/app/Http/Controllers/Api/AnnouncementController.php index 2156e071a..3c6c548ea 100644 --- a/app/Http/Controllers/Api/AnnouncementController.php +++ b/app/Http/Controllers/Api/AnnouncementController.php @@ -21,7 +21,7 @@ class AnnouncementController extends Controller * @apiParam (Optional parameters) {Number} show_until Date and time until the announcement should be shown. Only one announcement can be shown at a time. If not specified, the announcement will be shown indefinitely. * * @param StoreAnnouncement $request - * @return Announcement + * @return Announcement|\Illuminate\Http\RedirectResponse */ public function store(StoreAnnouncement $request) { @@ -47,7 +47,7 @@ public function store(StoreAnnouncement $request) * @apiParam {Number} id The announcement ID. * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy($id) { diff --git a/app/Http/Controllers/Api/ApiTokenController.php b/app/Http/Controllers/Api/ApiTokenController.php index 83bf925dd..f0d0f3819 100644 --- a/app/Http/Controllers/Api/ApiTokenController.php +++ b/app/Http/Controllers/Api/ApiTokenController.php @@ -40,7 +40,7 @@ public function __construct() * ] * * @param Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request) { @@ -72,7 +72,7 @@ public function index(Request $request) * } * * @param Request $request - * @return \Illuminate\Http\Response + * @return ApiToken|\Illuminate\Http\RedirectResponse */ public function store(Request $request) { @@ -108,7 +108,7 @@ public function store(Request $request) * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(Request $request, $id) { diff --git a/app/Http/Controllers/Api/FederatedSearchInstanceController.php b/app/Http/Controllers/Api/FederatedSearchInstanceController.php index 24025486a..85de3fbb1 100644 --- a/app/Http/Controllers/Api/FederatedSearchInstanceController.php +++ b/app/Http/Controllers/Api/FederatedSearchInstanceController.php @@ -31,7 +31,7 @@ class FederatedSearchInstanceController extends Controller * } * * @param StoreFederatedSearchInstance $request - * @return \Illuminate\Http\Response + * @return FederatedSearchInstance|\Illuminate\Http\RedirectResponse */ public function store(StoreFederatedSearchInstance $request) { @@ -61,7 +61,7 @@ public function store(StoreFederatedSearchInstance $request) * @apiParam (Attributes that can be updated) {Boolean} local_token Set to `true` to (re-)set a new token that can be used by the remote instance to authenticate to the local instance. A new token is returned only once in plain text as `new_local_token`. Set this attribute to `false` to clear the local token and thus deny access by the remote instance. * * @param UpdateFederatedSearchInstance $request - * @return \Illuminate\Http\Response + * @return FederatedSearchInstance|\Illuminate\Http\RedirectResponse */ public function update(UpdateFederatedSearchInstance $request) { @@ -94,6 +94,7 @@ public function update(UpdateFederatedSearchInstance $request) if ($this->isAutomatedRequest()) { if (isset($token)) { + /** @phpstan-ignore-next-line */ $instance->new_local_token = $token; } @@ -120,7 +121,7 @@ public function update(UpdateFederatedSearchInstance $request) * @apiParam {Number} id ID of the instance to disconnect * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy($id) { diff --git a/app/Http/Controllers/Api/ImageAnnotationBulkController.php b/app/Http/Controllers/Api/ImageAnnotationBulkController.php index c22472999..0d5aa982e 100644 --- a/app/Http/Controllers/Api/ImageAnnotationBulkController.php +++ b/app/Http/Controllers/Api/ImageAnnotationBulkController.php @@ -90,18 +90,22 @@ public function store(StoreImageAnnotations $request) $annotation->points = $input['points']; $annotation->image_id = $input['image_id']; + /** @phpstan-ignore property.notFound */ $annotation->label_id = $input['label_id']; + /** @phpstan-ignore property.notFound */ $annotation->confidence = $input['confidence']; return $annotation; }); DB::transaction(function () use ($request, $annotations) { - $annotations->each(function ($annotation) use ($request) { + $annotations->each(function (ImageAnnotation $annotation) use ($request) { + /** @phpstan-ignore property.notFound */ $label = $request->labels[$annotation->label_id]; + /** @phpstan-ignore property.notFound */ $confidence = $annotation->confidence; unset($annotation->label_id, $annotation->confidence); - + $this->authorize('attach-label', [$annotation, $label]); $annotation->save(); diff --git a/app/Http/Controllers/Api/ImageAnnotationController.php b/app/Http/Controllers/Api/ImageAnnotationController.php index 02e118401..64461ec36 100644 --- a/app/Http/Controllers/Api/ImageAnnotationController.php +++ b/app/Http/Controllers/Api/ImageAnnotationController.php @@ -60,7 +60,7 @@ class ImageAnnotationController extends Controller * * @param Request $request * @param int $id image id - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request, $id) { @@ -266,7 +266,6 @@ public function store(StoreImageAnnotation $request) * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { diff --git a/app/Http/Controllers/Api/ImageAnnotationLabelController.php b/app/Http/Controllers/Api/ImageAnnotationLabelController.php index 357a19e7d..1e233f6d6 100644 --- a/app/Http/Controllers/Api/ImageAnnotationLabelController.php +++ b/app/Http/Controllers/Api/ImageAnnotationLabelController.php @@ -73,7 +73,7 @@ class ImageAnnotationLabelController extends Controller * ] * * @param int $id ImageAnnotation ID - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { @@ -161,7 +161,7 @@ public function index($id) * } * * @param StoreImageAnnotationLabel $request - * @return \Illuminate\Http\Response + * @return ImageAnnotationLabel|null */ public function store(StoreImageAnnotationLabel $request) { @@ -187,7 +187,7 @@ public function store(StoreImageAnnotationLabel $request) AnnotationLabelAttached::dispatch($annotationLabel); - return response($annotationLabel, 201); + return $annotationLabel; } catch (QueryException $e) { // Although we check for existence above, this error happened some time. // I suspect some kind of race condition between PHP FPM workers. diff --git a/app/Http/Controllers/Api/ImageController.php b/app/Http/Controllers/Api/ImageController.php index 2d5e32e1e..fe9ccee14 100644 --- a/app/Http/Controllers/Api/ImageController.php +++ b/app/Http/Controllers/Api/ImageController.php @@ -54,7 +54,7 @@ public function show($id) * @apiParam {Number} id The image ID. * * @param int $id image id - * @return \Illuminate\Http\Response + * @return array|\Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\StreamedResponse */ public function showFile($id) { diff --git a/app/Http/Controllers/Api/ImageLabelController.php b/app/Http/Controllers/Api/ImageLabelController.php index 8d5593385..a11bd207a 100644 --- a/app/Http/Controllers/Api/ImageLabelController.php +++ b/app/Http/Controllers/Api/ImageLabelController.php @@ -72,7 +72,7 @@ class ImageLabelController extends VolumeFileLabelController * } * * @param StoreImageLabel $request - * @return \Illuminate\Http\Response + * @return \Biigle\VolumeFileLabel */ public function store(StoreImageLabel $request) { diff --git a/app/Http/Controllers/Api/LabelController.php b/app/Http/Controllers/Api/LabelController.php index 37b5f696b..51a771fd8 100644 --- a/app/Http/Controllers/Api/LabelController.php +++ b/app/Http/Controllers/Api/LabelController.php @@ -22,7 +22,6 @@ class LabelController extends Controller * @apiParam (Attributes that can be updated) {Number} parent_id ID of the parent label for ordering in a tree-like structure. * * @param UpdateLabel $request - * @return \Illuminate\Http\Response */ public function update(UpdateLabel $request) { @@ -47,7 +46,6 @@ public function update(UpdateLabel $request) * @apiParam {Number} id The label ID * * @param DestroyLabel $request - * @return \Illuminate\Http\Response */ public function destroy(DestroyLabel $request) { diff --git a/app/Http/Controllers/Api/LabelSourceController.php b/app/Http/Controllers/Api/LabelSourceController.php index df9adcc00..f2f3ec432 100644 --- a/app/Http/Controllers/Api/LabelSourceController.php +++ b/app/Http/Controllers/Api/LabelSourceController.php @@ -20,7 +20,7 @@ class LabelSourceController extends Controller * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response + * @return array */ public function find(Request $request, $id) { diff --git a/app/Http/Controllers/Api/LabelTreeAuthorizedProjectController.php b/app/Http/Controllers/Api/LabelTreeAuthorizedProjectController.php index 944ad83d6..8d3adaf3c 100644 --- a/app/Http/Controllers/Api/LabelTreeAuthorizedProjectController.php +++ b/app/Http/Controllers/Api/LabelTreeAuthorizedProjectController.php @@ -23,7 +23,7 @@ class LabelTreeAuthorizedProjectController extends Controller * @apiParam (Required attributes) {Number} id ID of the project to authorize * * @param StoreLabelTreeAuthorizedProject $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function store(StoreLabelTreeAuthorizedProject $request) { @@ -67,7 +67,7 @@ public function store(StoreLabelTreeAuthorizedProject $request) * @param Request $request * @param int $lid * @param int $pid - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(Request $request, $lid, $pid) { diff --git a/app/Http/Controllers/Api/LabelTreeController.php b/app/Http/Controllers/Api/LabelTreeController.php index 6624c82be..abf2c6b95 100644 --- a/app/Http/Controllers/Api/LabelTreeController.php +++ b/app/Http/Controllers/Api/LabelTreeController.php @@ -34,7 +34,7 @@ class LabelTreeController extends Controller * ] * * @param Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request) { @@ -94,14 +94,16 @@ public function index(Request $request) * } * * - * @return \Illuminate\Http\Response + * @return LabelTree */ public function show($id) { $tree = LabelTree::findOrFail($id); $this->authorize('access', $tree); - return $tree->load('labels', 'members', 'version', 'versions'); + $tree->load(['labels', 'members', 'version', 'versions']); + + return $tree; } /** @@ -132,7 +134,7 @@ public function show($id) * } * * @param StoreLabelTree $request - * @return \Illuminate\Http\Response + * @return LabelTree|\Illuminate\Http\RedirectResponse */ public function store(StoreLabelTree $request) { @@ -184,7 +186,7 @@ public function store(StoreLabelTree $request) * @apiParam (Attributes that can be updated) {Number} visibility_id ID of the new visibility of the label tree (public or private). * * @param UpdateLabelTree $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function update(UpdateLabelTree $request) { @@ -236,7 +238,7 @@ public function update(UpdateLabelTree $request) * @apiParam {Number} id The label tree ID. * * @param DestroyLabelTree $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(DestroyLabelTree $request) { diff --git a/app/Http/Controllers/Api/LabelTreeLabelController.php b/app/Http/Controllers/Api/LabelTreeLabelController.php index 2398f8b82..9fee3ff9d 100644 --- a/app/Http/Controllers/Api/LabelTreeLabelController.php +++ b/app/Http/Controllers/Api/LabelTreeLabelController.php @@ -41,7 +41,7 @@ class LabelTreeLabelController extends Controller * ] * * @param StoreLabel $request - * @return \Illuminate\Http\Response + * @return array|\Illuminate\Http\RedirectResponse */ public function store(StoreLabel $request) { diff --git a/app/Http/Controllers/Api/LabelTreeMergeController.php b/app/Http/Controllers/Api/LabelTreeMergeController.php index f92611947..d19ef8e4b 100644 --- a/app/Http/Controllers/Api/LabelTreeMergeController.php +++ b/app/Http/Controllers/Api/LabelTreeMergeController.php @@ -42,7 +42,7 @@ class LabelTreeMergeController extends Controller * } * * @param StoreLabelTreeMerge $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function store(StoreLabelTreeMerge $request) { diff --git a/app/Http/Controllers/Api/LabelTreeUserController.php b/app/Http/Controllers/Api/LabelTreeUserController.php index c5ffb098e..b26909049 100644 --- a/app/Http/Controllers/Api/LabelTreeUserController.php +++ b/app/Http/Controllers/Api/LabelTreeUserController.php @@ -22,7 +22,7 @@ class LabelTreeUserController extends Controller * @apiParam (Required attributes) {Number} role_id ID of the role of the new member (admin or editor). * * @param StoreLabelTreeUser $request - * @return \Illuminate\Http\Response + * @return \Biigle\LabelTree|\Illuminate\Http\RedirectResponse */ public function store(StoreLabelTreeUser $request) { @@ -50,7 +50,7 @@ public function store(StoreLabelTreeUser $request) * @apiParam (Attributes that can be updated) {Number} role_id New role of the member (admin or editor) * * @param UpdateLabelTreeUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function update(UpdateLabelTreeUser $request) { @@ -77,7 +77,7 @@ public function update(UpdateLabelTreeUser $request) * @apiParam {Number} uid User ID of the member. * * @param DestroyLabelTreeUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(DestroyLabelTreeUser $request) { diff --git a/app/Http/Controllers/Api/LabelTreeVersionController.php b/app/Http/Controllers/Api/LabelTreeVersionController.php index 43ec57a74..707d52fbb 100644 --- a/app/Http/Controllers/Api/LabelTreeVersionController.php +++ b/app/Http/Controllers/Api/LabelTreeVersionController.php @@ -36,7 +36,7 @@ class LabelTreeVersionController extends Controller * } * * @param StoreLabelTreeVersion $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function store(StoreLabelTreeVersion $request) { @@ -83,7 +83,6 @@ public function store(StoreLabelTreeVersion $request) * @apiParam (Required attributes) {String} doi DOI that should be associated with the new label tree version. * * @param UpdateLabelTreeVersion $request - * @return \Illuminate\Http\Response */ public function update(UpdateLabelTreeVersion $request) { @@ -103,7 +102,7 @@ public function update(UpdateLabelTreeVersion $request) * @apiParam {Number} id The label tree version ID. * * @param DestroyLabelTreeVersion $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(DestroyLabelTreeVersion $request) { diff --git a/app/Http/Controllers/Api/LinkVideoAnnotationController.php b/app/Http/Controllers/Api/LinkVideoAnnotationController.php index 08b885328..2cc3e235d 100644 --- a/app/Http/Controllers/Api/LinkVideoAnnotationController.php +++ b/app/Http/Controllers/Api/LinkVideoAnnotationController.php @@ -54,7 +54,7 @@ class LinkVideoAnnotationController extends Controller * } * * @param LinkVideoAnnotation $request - * @return \Illuminate\Http\Response + * @return VideoAnnotation */ public function store(LinkVideoAnnotation $request) { diff --git a/app/Http/Controllers/Api/MediaTypeController.php b/app/Http/Controllers/Api/MediaTypeController.php index 3f9cff19e..6e89bdda7 100644 --- a/app/Http/Controllers/Api/MediaTypeController.php +++ b/app/Http/Controllers/Api/MediaTypeController.php @@ -26,7 +26,7 @@ class MediaTypeController extends Controller * } * ] * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index() { diff --git a/app/Http/Controllers/Api/NotificationController.php b/app/Http/Controllers/Api/NotificationController.php index f2ec45f7a..aa47ef854 100644 --- a/app/Http/Controllers/Api/NotificationController.php +++ b/app/Http/Controllers/Api/NotificationController.php @@ -3,6 +3,7 @@ namespace Biigle\Http\Controllers\Api; use Illuminate\Http\Request; +use Illuminate\Http\Response; class NotificationController extends Controller { @@ -20,11 +21,13 @@ class NotificationController extends Controller * * @param Request $request * @param int $id Image ID - * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { - $notification = $request->user()->unreadNotifications()->findOrFail($id); + $notification = $request->user()->unreadNotifications()->find($id); + if (is_null($notification)) { + abort(Response::HTTP_NOT_FOUND); + } $notification->markAsRead(); } @@ -57,11 +60,13 @@ public function updateAll(Request $request) * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response */ public function destroy(Request $request, $id) { - $notification = $request->user()->notifications()->findOrFail($id); + $notification = $request->user()->notifications()->find($id); + if (is_null($notification)) { + abort(Response::HTTP_NOT_FOUND); + } $notification->delete(); } } diff --git a/app/Http/Controllers/Api/ProjectController.php b/app/Http/Controllers/Api/ProjectController.php index 635ab0dcb..6f06f288d 100644 --- a/app/Http/Controllers/Api/ProjectController.php +++ b/app/Http/Controllers/Api/ProjectController.php @@ -32,7 +32,7 @@ class ProjectController extends Controller * ] * * @param Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request) { @@ -87,7 +87,7 @@ public function show($id) * @apiParam (Required attributes) {String} description Description of the new project. * * @param StoreProject $request - * @return Project + * @return Project|\Illuminate\Http\RedirectResponse */ public function store(StoreProject $request) { @@ -121,7 +121,7 @@ public function store(StoreProject $request) * @apiParam (Attributes that can be updated) {String} description Description of the project. * * @param UpdateProject $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function update(UpdateProject $request) { @@ -153,7 +153,7 @@ public function update(UpdateProject $request) * * @param Request $request * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(Request $request, $id) { diff --git a/app/Http/Controllers/Api/ProjectInvitationController.php b/app/Http/Controllers/Api/ProjectInvitationController.php index afa1e1f3b..bfa235ec3 100644 --- a/app/Http/Controllers/Api/ProjectInvitationController.php +++ b/app/Http/Controllers/Api/ProjectInvitationController.php @@ -9,7 +9,7 @@ use Biigle\Role; use DB; use Endroid\QrCode\Encoding\Encoding; -use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow; +use Endroid\QrCode\ErrorCorrectionLevel; use Endroid\QrCode\QrCode; use Endroid\QrCode\Writer\SvgWriter; use Ramsey\Uuid\Uuid; @@ -33,7 +33,7 @@ class ProjectInvitationController extends Controller * @apiParam (Optional attributes) {Boolean} add_to_sessions If set to `true`, all users joining the project will automatically be added to all annotation sessions of all volumes that belong to the project. * * @param StoreProjectInvitation $request - * @return \Illuminate\Http\Response + * @return ProjectInvitation */ public function store(StoreProjectInvitation $request) { @@ -62,7 +62,7 @@ public function store(StoreProjectInvitation $request) * @param JoinProjectInvitation $request * @param int $id * - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function join(JoinProjectInvitation $request, $id) { @@ -83,7 +83,7 @@ public function join(JoinProjectInvitation $request, $id) if ($invitation->add_to_sessions) { AnnotationSession::join('project_volume', 'annotation_sessions.volume_id', '=', 'project_volume.volume_id') ->where('project_volume.project_id', $project->id) - ->eachById(fn ($session) => $session->users()->syncWithoutDetaching([$userId])); + ->eachById(fn (AnnotationSession $session) => $session->users()->syncWithoutDetaching([$userId])); } } @@ -108,7 +108,6 @@ public function join(JoinProjectInvitation $request, $id) * @apiParam {Number} id The invitation ID. * * @param int $id - * @return \Illuminate\Http\Response */ public function destroy($id) { @@ -137,7 +136,7 @@ public function showQrCode($id) $qrCode = QrCode::create(route('project-invitation', $invitation->uuid)) ->setEncoding(new Encoding('UTF-8')) - ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow()) + ->setErrorCorrectionLevel(ErrorCorrectionLevel::Low) ->setSize(300) ->setMargin(10); diff --git a/app/Http/Controllers/Api/ProjectLabelTreeController.php b/app/Http/Controllers/Api/ProjectLabelTreeController.php index 2db28f374..1a57fbc08 100644 --- a/app/Http/Controllers/Api/ProjectLabelTreeController.php +++ b/app/Http/Controllers/Api/ProjectLabelTreeController.php @@ -45,7 +45,7 @@ class ProjectLabelTreeController extends Controller * ] * * @param int $id Project ID - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { @@ -86,7 +86,7 @@ public function index($id) * ] * * @param int $id Project ID - * @return \Illuminate\Http\Response + * @return array */ public function available($id) { @@ -122,7 +122,7 @@ public function available($id) * id: 3 * * @param StoreProjectLabelTree $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function store(StoreProjectLabelTree $request) { @@ -147,7 +147,7 @@ public function store(StoreProjectLabelTree $request) * @param Request $request * @param int $pid * @param int $lid - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(Request $request, $pid, $lid) { diff --git a/app/Http/Controllers/Api/ProjectUserController.php b/app/Http/Controllers/Api/ProjectUserController.php index 97077229e..76d956b83 100644 --- a/app/Http/Controllers/Api/ProjectUserController.php +++ b/app/Http/Controllers/Api/ProjectUserController.php @@ -36,7 +36,7 @@ class ProjectUserController extends Controller * ] * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { @@ -60,7 +60,6 @@ public function index($id) * @apiParam (Attributes that can be updated) {Number} project_role_id The project role of the member. Users with the global guest role cannot become project admins. * * @param UpdateProjectUser $request - * @return \Illuminate\Http\Response */ public function update(UpdateProjectUser $request) { @@ -84,7 +83,6 @@ public function update(UpdateProjectUser $request) * project_role_id: 3 * * @param AttachProjectUser $request - * @return \Illuminate\Http\Response */ public function attach(AttachProjectUser $request) { @@ -106,7 +104,6 @@ public function attach(AttachProjectUser $request) * @apiParam {Number} uid The user ID of the member. * * @param DestroyProjectUser $request - * @return \Illuminate\Http\Response */ public function destroy(DestroyProjectUser $request) { diff --git a/app/Http/Controllers/Api/ProjectVolumeController.php b/app/Http/Controllers/Api/ProjectVolumeController.php index 47e1e53e2..f5925cca3 100644 --- a/app/Http/Controllers/Api/ProjectVolumeController.php +++ b/app/Http/Controllers/Api/ProjectVolumeController.php @@ -43,7 +43,7 @@ class ProjectVolumeController extends Controller * ] * * @param int $id Project ID - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { @@ -103,7 +103,7 @@ public function index($id) * } * * @param StoreVolume $request - * @return Volume + * @return Volume|\Illuminate\Http\RedirectResponse */ public function store(StoreVolume $request) { @@ -167,7 +167,6 @@ public function store(StoreVolume $request) * @param Request $request * @param int $projectId * @param int $volumeId - * @return \Illuminate\Http\Response */ public function attach(Request $request, $projectId, $volumeId) { @@ -199,7 +198,6 @@ public function attach(Request $request, $projectId, $volumeId) * @param Request $request * @param int $projectId * @param int $volumeId - * @return \Illuminate\Http\Response */ public function destroy(Request $request, $projectId, $volumeId) { diff --git a/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php b/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php index 94bccbd0e..70232d8e8 100644 --- a/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php +++ b/app/Http/Controllers/Api/ProjectsAttachableVolumesController.php @@ -35,7 +35,7 @@ class ProjectsAttachableVolumesController extends Controller * @param Request $request * @param int $id Project ID * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request, $id) { diff --git a/app/Http/Controllers/Api/RoleController.php b/app/Http/Controllers/Api/RoleController.php index a19c3978c..b7e11a44e 100644 --- a/app/Http/Controllers/Api/RoleController.php +++ b/app/Http/Controllers/Api/RoleController.php @@ -30,7 +30,7 @@ class RoleController extends Controller * } * ] * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index() { diff --git a/app/Http/Controllers/Api/ShapeController.php b/app/Http/Controllers/Api/ShapeController.php index 9d0f1fec4..3c5d712bd 100644 --- a/app/Http/Controllers/Api/ShapeController.php +++ b/app/Http/Controllers/Api/ShapeController.php @@ -26,7 +26,7 @@ class ShapeController extends Controller * } * ] * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index() { diff --git a/app/Http/Controllers/Api/SplitVideoAnnotationController.php b/app/Http/Controllers/Api/SplitVideoAnnotationController.php index 10537f8b7..946aa4fa6 100644 --- a/app/Http/Controllers/Api/SplitVideoAnnotationController.php +++ b/app/Http/Controllers/Api/SplitVideoAnnotationController.php @@ -79,7 +79,7 @@ class SplitVideoAnnotationController extends Controller * ] * * @param SplitVideoAnnotation $request - * @return \Illuminate\Http\Response + * @return array */ public function store(SplitVideoAnnotation $request) { @@ -130,7 +130,7 @@ public function store(SplitVideoAnnotation $request) } } - $newAnnotation = VideoAnnotation::make([ + $newAnnotation = new VideoAnnotation([ 'video_id' => $oldAnnotation->video_id, 'shape_id' => $oldAnnotation->shape_id, 'points' => $newPoints, diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 6bef665a8..1c7649f8e 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -57,7 +57,7 @@ public function __construct() * ] * * @param string $pattern - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function find($pattern) { @@ -98,7 +98,7 @@ public function find($pattern) * ] * * @param Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index(Request $request) { @@ -204,7 +204,7 @@ public function showOwn(Request $request) * auth_password: 'password123' * * @param UpdateUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function update(UpdateUser $request) { @@ -265,7 +265,7 @@ public function update(UpdateUser $request) * super_user_mode: 0 * * @param UpdateOwnUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function updateOwn(UpdateOwnUser $request) { @@ -328,7 +328,7 @@ public function updateOwn(UpdateOwnUser $request) * } * * @param StoreUser $request - * @return User + * @return User|\Illuminate\Http\RedirectResponse */ public function store(StoreUser $request) { @@ -375,7 +375,7 @@ public function store(StoreUser $request) * @apiParam {Number} id The user ID. * * @param DestroyUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroy(DestroyUser $request) { @@ -404,7 +404,7 @@ public function destroy(DestroyUser $request) * @apiDescription This action is allowed only by session cookie authentication. If the user is the last admin of a project, they cannot be deleted. The admin role needs to be passed on to another member of the project first. * * @param DestroyOwnUser $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function destroyOwn(DestroyOwnUser $request) { diff --git a/app/Http/Controllers/Api/UserSettingsController.php b/app/Http/Controllers/Api/UserSettingsController.php index 2603a44bc..e472ec940 100644 --- a/app/Http/Controllers/Api/UserSettingsController.php +++ b/app/Http/Controllers/Api/UserSettingsController.php @@ -17,7 +17,7 @@ class UserSettingsController extends Controller * attributes which cannot be documented here. * * @param UpdateUserSettings $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|null */ public function update(UpdateUserSettings $request) { diff --git a/app/Http/Controllers/Api/VideoAnnotationController.php b/app/Http/Controllers/Api/VideoAnnotationController.php index ff6a17446..c9d9a7334 100644 --- a/app/Http/Controllers/Api/VideoAnnotationController.php +++ b/app/Http/Controllers/Api/VideoAnnotationController.php @@ -209,7 +209,7 @@ public function store(StoreVideoAnnotation $request) $points = json_decode($points); } - $annotation = VideoAnnotation::make([ + $annotation = new VideoAnnotation([ 'video_id' => $request->video->id, 'shape_id' => $request->input('shape_id'), 'points' => $points, @@ -240,6 +240,7 @@ public function store(StoreVideoAnnotation $request) $queue = config('videos.track_object_queue'); Queue::pushOn($queue, new TrackObject($annotation, $request->user())); Cache::increment(TrackObject::getRateLimitCacheKey($request->user())); + /** @phpstan-ignore property.notFound */ $annotation->trackingJobLimitReached = $currentJobs === ($maxJobs - 1); } @@ -267,7 +268,6 @@ public function store(StoreVideoAnnotation $request) * } * * @param UpdateVideoAnnotation $request - * @return \Illuminate\Http\Response */ public function update(UpdateVideoAnnotation $request) { @@ -301,7 +301,6 @@ public function update(UpdateVideoAnnotation $request) * @apiParam {Number} id The annotation ID. * * @param int $id - * @return \Illuminate\Http\Response */ public function destroy($id) { diff --git a/app/Http/Controllers/Api/VideoFileController.php b/app/Http/Controllers/Api/VideoFileController.php index ab3b5ccf5..51df639bb 100644 --- a/app/Http/Controllers/Api/VideoFileController.php +++ b/app/Http/Controllers/Api/VideoFileController.php @@ -68,7 +68,7 @@ public function show(Request $request, $id) $offset = $range[0]; $length = $range[1] - $range[0] + 1; $total = $video->size; - $response->headers->set('Content-Length', $length); + $response->headers->set('Content-Length', "$length"); $response->headers->set('Content-Range', 'bytes '.implode('-', $range).'/'.$total); $response->setStatusCode(206); diff --git a/app/Http/Controllers/Api/VideoLabelController.php b/app/Http/Controllers/Api/VideoLabelController.php index c817ca970..2aa9e612a 100644 --- a/app/Http/Controllers/Api/VideoLabelController.php +++ b/app/Http/Controllers/Api/VideoLabelController.php @@ -72,7 +72,7 @@ class VideoLabelController extends VolumeFileLabelController * } * * @param StoreVideoLabel $request - * @return \Illuminate\Http\Response + * @return \Biigle\VolumeFileLabel */ public function store(StoreVideoLabel $request) { diff --git a/app/Http/Controllers/Api/VisibilityController.php b/app/Http/Controllers/Api/VisibilityController.php index 9becc64e1..c78a2169a 100644 --- a/app/Http/Controllers/Api/VisibilityController.php +++ b/app/Http/Controllers/Api/VisibilityController.php @@ -26,7 +26,7 @@ class VisibilityController extends Controller * } * ] * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index() { diff --git a/app/Http/Controllers/Api/VolumeAnnotationSessionController.php b/app/Http/Controllers/Api/VolumeAnnotationSessionController.php index 84494160a..1ac6b66a7 100644 --- a/app/Http/Controllers/Api/VolumeAnnotationSessionController.php +++ b/app/Http/Controllers/Api/VolumeAnnotationSessionController.php @@ -44,7 +44,7 @@ class VolumeAnnotationSessionController extends Controller * ] * * @param int $id volume id - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/VolumeController.php b/app/Http/Controllers/Api/VolumeController.php index 2ced33713..41f03b3a0 100644 --- a/app/Http/Controllers/Api/VolumeController.php +++ b/app/Http/Controllers/Api/VolumeController.php @@ -19,7 +19,7 @@ class VolumeController extends Controller * Shows all volumes the user has access to. * * @param Request $request - * @return Response + * @return \Illuminate\Database\Eloquent\Collection * @api {get} volumes Get accessible volumes * @apiGroup Volumes * @apiName IndexVolumes @@ -112,7 +112,7 @@ public function show(Request $request, $id) * Updates the attributes of the specified volume. * * @param UpdateVolume $request - * @return Response + * @return \Illuminate\Http\RedirectResponse|null * @api {put} volumes/:id Update a volume * @apiGroup Volumes * @apiName UpdateVolumes @@ -153,7 +153,7 @@ public function update(UpdateVolume $request) * Clones volume to destination project. * * @param CloneVolume $request - * @return Response + * @return Volume|\Illuminate\Http\RedirectResponse * @api {post} volumes/:id/clone-to/:project_id Clones a volume * @apiGroup Volumes * @apiName CloneVolume diff --git a/app/Http/Controllers/Api/VolumeFileController.php b/app/Http/Controllers/Api/VolumeFileController.php index ef3af4d85..71305abf3 100644 --- a/app/Http/Controllers/Api/VolumeFileController.php +++ b/app/Http/Controllers/Api/VolumeFileController.php @@ -24,7 +24,7 @@ class VolumeFileController extends Controller * * @param int $id * - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { @@ -70,7 +70,7 @@ public function index($id) * * * @param StoreVolumeFile $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function store(StoreVolumeFile $request) { diff --git a/app/Http/Controllers/Api/VolumeFileLabelController.php b/app/Http/Controllers/Api/VolumeFileLabelController.php index 9ae82f02d..cd893ab14 100644 --- a/app/Http/Controllers/Api/VolumeFileLabelController.php +++ b/app/Http/Controllers/Api/VolumeFileLabelController.php @@ -28,11 +28,12 @@ public function index($id) * Creates a new label for the specified file. * * @param StoreVolumeFileLabel $request - * @return \Illuminate\Http\Response + * @return \Biigle\VolumeFileLabel */ public function baseStore(StoreVolumeFileLabel $request) { $model = $this->getFileLabelModel(); + /** @var \Biigle\VolumeFileLabel */ $fileLabel = new $model; $fileLabel->user()->associate($request->user()); $fileLabel->label()->associate($request->label); @@ -58,7 +59,6 @@ public function baseStore(StoreVolumeFileLabel $request) * Deletes the specified file label. * * @param int $id - * @return \Illuminate\Http\Response */ public function destroy($id) { diff --git a/app/Http/Controllers/Api/Volumes/BrowserController.php b/app/Http/Controllers/Api/Volumes/BrowserController.php index 0eba09873..e619a2bd4 100644 --- a/app/Http/Controllers/Api/Volumes/BrowserController.php +++ b/app/Http/Controllers/Api/Volumes/BrowserController.php @@ -33,7 +33,7 @@ class BrowserController extends Controller * * @param Request $request * @param string $disk - * @return \Illuminate\Http\Response + * @return array */ public function indexDirectories(Request $request, $disk) { @@ -82,7 +82,7 @@ public function indexDirectories(Request $request, $disk) * * @param Request $request * @param string $disk - * @return \Illuminate\Http\Response + * @return array */ public function indexImages(Request $request, $disk) { @@ -114,7 +114,7 @@ public function indexImages(Request $request, $disk) * * @param Request $request * @param string $disk - * @return \Illuminate\Http\Response + * @return array */ public function indexVideos(Request $request, $disk) { @@ -132,7 +132,7 @@ public function indexVideos(Request $request, $disk) * @param string $disk * @param string $regex * - * @return \Illuminate\Http\Response + * @return array */ protected function indexFiles(Request $request, $disk, $regex) { diff --git a/app/Http/Controllers/Api/Volumes/FileLabelsController.php b/app/Http/Controllers/Api/Volumes/FileLabelsController.php index b6b8277c9..60d646ef8 100644 --- a/app/Http/Controllers/Api/Volumes/FileLabelsController.php +++ b/app/Http/Controllers/Api/Volumes/FileLabelsController.php @@ -44,7 +44,7 @@ class FileLabelsController extends Controller * } * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Volumes/FilenamesController.php b/app/Http/Controllers/Api/Volumes/FilenamesController.php index 5532c90ac..0145eebd8 100644 --- a/app/Http/Controllers/Api/Volumes/FilenamesController.php +++ b/app/Http/Controllers/Api/Volumes/FilenamesController.php @@ -25,7 +25,7 @@ class FilenamesController extends Controller * } * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php b/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php index 080258eda..c6e513571 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php @@ -28,7 +28,7 @@ class AnnotationLabelController extends Controller * @param Request $request * @param int $tid * @param int $lid - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index(Request $request, $tid, $lid) { diff --git a/app/Http/Controllers/Api/Volumes/Filters/AnyFileLabelController.php b/app/Http/Controllers/Api/Volumes/Filters/AnyFileLabelController.php index 266373c65..49e672df7 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/AnyFileLabelController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/AnyFileLabelController.php @@ -21,7 +21,7 @@ class AnyFileLabelController extends Controller * [1, 5, 6] * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Volumes/Filters/FileLabelController.php b/app/Http/Controllers/Api/Volumes/Filters/FileLabelController.php index ca626589a..109f9d542 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/FileLabelController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/FileLabelController.php @@ -24,7 +24,7 @@ class FileLabelController extends Controller * * @param int $vid * @param int $lid - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($vid, $lid) { diff --git a/app/Http/Controllers/Api/Volumes/Filters/FileLabelUserController.php b/app/Http/Controllers/Api/Volumes/Filters/FileLabelUserController.php index 8ab127b5e..de1d3f116 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/FileLabelUserController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/FileLabelUserController.php @@ -24,7 +24,7 @@ class FileLabelUserController extends Controller * * @param int $vid * @param int $uid - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($vid, $uid) { diff --git a/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php b/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php index 1da167675..87b1f60da 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/FilenameController.php @@ -23,7 +23,7 @@ class FilenameController extends Controller * * @param int $id * @param string $pattern - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id, $pattern) { diff --git a/app/Http/Controllers/Api/Volumes/IfdoController.php b/app/Http/Controllers/Api/Volumes/IfdoController.php index 6e27cb797..11f3afac2 100644 --- a/app/Http/Controllers/Api/Volumes/IfdoController.php +++ b/app/Http/Controllers/Api/Volumes/IfdoController.php @@ -17,7 +17,7 @@ class IfdoController extends Controller ~ * @param int $id * - * @return \Illuminate\Http\Response + * @return \Symfony\Component\HttpFoundation\StreamedResponse */ public function show($id) { @@ -36,8 +36,6 @@ public function show($id) * @apiPermission projectAdmin ~ * @param int $id - * - * @return \Illuminate\Http\Response */ public function destroy($id) { diff --git a/app/Http/Controllers/Api/Volumes/MetadataController.php b/app/Http/Controllers/Api/Volumes/MetadataController.php index 7ba285721..520b104a2 100644 --- a/app/Http/Controllers/Api/Volumes/MetadataController.php +++ b/app/Http/Controllers/Api/Volumes/MetadataController.php @@ -54,7 +54,7 @@ class MetadataController extends Controller * * @param StoreVolumeMetadata $request * - * @return \Illuminate\Http\Response + * @return void */ public function store(StoreVolumeMetadata $request) { @@ -187,9 +187,11 @@ protected function mergeVideoMetadata(Video $video, Collection $rows) $origTakenAtNull = $origTakenAt->combine($origTakenAt->map(fn ($x) => null)); $newTakenAtNull = $newTakenAt->combine($newTakenAt->map(fn ($x) => null)); + /** @var \Illuminate\Support\Collection */ $originalAttributes = collect(VideoMetadata::ALLOWED_ATTRIBUTES) ->mapWithKeys(fn ($key) => [$key => $video->$key]); + /** @var \Illuminate\Support\Collection */ $originalMetadata = collect(VideoMetadata::ALLOWED_METADATA) ->mapWithKeys(fn ($key) => [$key => null]) ->merge($video->metadata); diff --git a/app/Http/Controllers/Api/Volumes/ParseIfdoController.php b/app/Http/Controllers/Api/Volumes/ParseIfdoController.php index 6a325a90a..530cd4b50 100644 --- a/app/Http/Controllers/Api/Volumes/ParseIfdoController.php +++ b/app/Http/Controllers/Api/Volumes/ParseIfdoController.php @@ -20,7 +20,7 @@ class ParseIfdoController extends Controller * * @param StoreParseIfdo $request * - * @return \Illuminate\Http\Response + * @return array */ public function store(StoreParseIfdo $request) { diff --git a/app/Http/Controllers/Api/Volumes/StatisticsController.php b/app/Http/Controllers/Api/Volumes/StatisticsController.php index af46ee3a8..ae37d123e 100644 --- a/app/Http/Controllers/Api/Volumes/StatisticsController.php +++ b/app/Http/Controllers/Api/Volumes/StatisticsController.php @@ -21,7 +21,7 @@ class StatisticsController extends Controller * * @param int $id * - * @return \Illuminate\Http\Response + * @return \Illuminate\Support\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Volumes/UsedFileLabelsController.php b/app/Http/Controllers/Api/Volumes/UsedFileLabelsController.php index ea1a88149..8a45783b2 100644 --- a/app/Http/Controllers/Api/Volumes/UsedFileLabelsController.php +++ b/app/Http/Controllers/Api/Volumes/UsedFileLabelsController.php @@ -37,7 +37,7 @@ class UsedFileLabelsController extends Controller * ] * * @param int $id - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Api/Volumes/UserController.php b/app/Http/Controllers/Api/Volumes/UserController.php index 1b3d404c3..48d5c6e0b 100644 --- a/app/Http/Controllers/Api/Volumes/UserController.php +++ b/app/Http/Controllers/Api/Volumes/UserController.php @@ -42,7 +42,7 @@ class UserController extends Controller * * @param int $id * - * @return \Illuminate\Http\Response + * @return \Illuminate\Database\Eloquent\Collection */ public function index($id) { diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ae5bad4fc..ed6539699 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -117,7 +117,7 @@ protected function create(array $data) /** * Show the application registration form. * - * @return \Illuminate\Http\Response + * @return \Illuminate\View\View */ public function showRegistrationForm() { @@ -132,7 +132,7 @@ public function showRegistrationForm() * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ public function register(Request $request) { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 02e30c16d..abb816744 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -31,7 +31,6 @@ class ResetPasswordController extends Controller public function __construct() { $this->middleware('guest'); - $this->redirectTo = route('home'); } /** diff --git a/app/Http/Controllers/Views/Admin/AnnouncementsController.php b/app/Http/Controllers/Views/Admin/AnnouncementsController.php index 3e3cfb0fe..980cb254f 100644 --- a/app/Http/Controllers/Views/Admin/AnnouncementsController.php +++ b/app/Http/Controllers/Views/Admin/AnnouncementsController.php @@ -9,8 +9,6 @@ class AnnouncementsController extends Controller { /** * Shows the admin announcements page. - * - * @return \Illuminate\Http\Response */ public function index() { @@ -24,8 +22,6 @@ public function index() /** * Shows the admin new announcement page. - * - * @return \Illuminate\Http\Response */ public function create() { diff --git a/app/Http/Controllers/Views/Admin/FederatedSearchController.php b/app/Http/Controllers/Views/Admin/FederatedSearchController.php index f623fdee9..36bc7afd6 100644 --- a/app/Http/Controllers/Views/Admin/FederatedSearchController.php +++ b/app/Http/Controllers/Views/Admin/FederatedSearchController.php @@ -12,7 +12,6 @@ class FederatedSearchController extends Controller * Show the federated search admin page. * * @param Request $request - * @return \Illuminate\Http\Response */ public function index(Request $request) { diff --git a/app/Http/Controllers/Views/Admin/IndexController.php b/app/Http/Controllers/Views/Admin/IndexController.php index c775d0a9b..3f5a1253e 100644 --- a/app/Http/Controllers/Views/Admin/IndexController.php +++ b/app/Http/Controllers/Views/Admin/IndexController.php @@ -15,7 +15,6 @@ class IndexController extends Controller * Shows the admin dashboard. * * @param Modules $modules - * @return \Illuminate\Http\Response */ public function get(Modules $modules) { diff --git a/app/Http/Controllers/Views/Admin/LabelTreesController.php b/app/Http/Controllers/Views/Admin/LabelTreesController.php index e6eff69e2..43b70a37f 100644 --- a/app/Http/Controllers/Views/Admin/LabelTreesController.php +++ b/app/Http/Controllers/Views/Admin/LabelTreesController.php @@ -9,8 +9,6 @@ class LabelTreesController extends Controller { /** * Show the label tree admin page. - * - * @return \Illuminate\Http\Response */ public function index() { diff --git a/app/Http/Controllers/Views/Admin/LogsController.php b/app/Http/Controllers/Views/Admin/LogsController.php index 59ee8efa0..7598de919 100644 --- a/app/Http/Controllers/Views/Admin/LogsController.php +++ b/app/Http/Controllers/Views/Admin/LogsController.php @@ -12,8 +12,6 @@ class LogsController extends Controller { /** * Shows the available logfiles. - * - * @return \Illuminate\Http\Response */ public function index(Request $request) { @@ -63,8 +61,6 @@ public function index(Request $request) /** * Shows a specific logfile. - * - * @return \Illuminate\Http\Response */ public function show($file) { diff --git a/app/Http/Controllers/Views/Admin/UsersController.php b/app/Http/Controllers/Views/Admin/UsersController.php index 8bd7a75cf..04d0c1486 100644 --- a/app/Http/Controllers/Views/Admin/UsersController.php +++ b/app/Http/Controllers/Views/Admin/UsersController.php @@ -19,7 +19,6 @@ class UsersController extends Controller * Shows the admin users page. * * @param Request $request - * @return \Illuminate\Http\Response */ public function get(Request $request) { @@ -54,8 +53,6 @@ public function get(Request $request) /** * Shows the admin new user page. - * - * @return \Illuminate\Http\Response */ public function newUser() { @@ -64,8 +61,6 @@ public function newUser() /** * Shows the admin edit user page. - * - * @return \Illuminate\Http\Response */ public function edit($id) { @@ -80,8 +75,6 @@ public function edit($id) /** * Shows the admin delete user page. - * - * @return \Illuminate\Http\Response */ public function delete($id) { @@ -94,7 +87,6 @@ public function delete($id) * * @param Modules $modules * @param int $id User ID - * @return \Illuminate\Http\Response */ public function show(Modules $modules, $id) { diff --git a/app/Http/Controllers/Views/Annotations/AnnotationToolController.php b/app/Http/Controllers/Views/Annotations/AnnotationToolController.php index 6dbdf9909..8221b1aa1 100644 --- a/app/Http/Controllers/Views/Annotations/AnnotationToolController.php +++ b/app/Http/Controllers/Views/Annotations/AnnotationToolController.php @@ -19,8 +19,6 @@ class AnnotationToolController extends Controller * * @param Request $request * @param int $id the image ID - * - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { diff --git a/app/Http/Controllers/Views/Annotations/ImageAnnotationController.php b/app/Http/Controllers/Views/Annotations/ImageAnnotationController.php index 766e4a2ae..c009f249b 100644 --- a/app/Http/Controllers/Views/Annotations/ImageAnnotationController.php +++ b/app/Http/Controllers/Views/Annotations/ImageAnnotationController.php @@ -11,7 +11,7 @@ class ImageAnnotationController extends Controller * Redirect to the annotator link that shows a specified annotation. * * @param int $id Image annotation ID - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function show($id) { diff --git a/app/Http/Controllers/Views/DashboardController.php b/app/Http/Controllers/Views/DashboardController.php index 00c209ea3..905f16cb5 100644 --- a/app/Http/Controllers/Views/DashboardController.php +++ b/app/Http/Controllers/Views/DashboardController.php @@ -26,7 +26,6 @@ public function __construct() * Show the application dashboard to the user. * * @param Guard $auth - * @return \Illuminate\Http\Response */ public function index(Guard $auth) { @@ -41,8 +40,6 @@ public function index(Guard $auth) * Show the dashboard for a logged in user. * * @param User $user - * - * @return \Illuminate\Http\Response */ protected function indexDashboard(User $user) { @@ -121,6 +118,7 @@ public function annotationsActivityItems(User $user, $limit = 3, $newerThan = nu ->map(function ($item) { return [ 'item' => $item, + /** @phpstan-ignore property.notFound */ 'created_at' => $item->annotation_labels_created_at, 'include' => 'annotations.dashboardActivityItem', ]; @@ -153,6 +151,7 @@ public function videosActivityItems(User $user, $limit = 3, $newerThan = null) ->map(function ($item) { return [ 'item' => $item, + /** @phpstan-ignore property.notFound */ 'created_at' => $item->video_annotation_labels_created_at, 'include' => 'videos.dashboardActivityItem', ]; @@ -162,8 +161,6 @@ public function videosActivityItems(User $user, $limit = 3, $newerThan = null) /** * Show the landing page if no user is authenticated. - * - * @return \Illuminate\Http\Response */ protected function indexLandingPage() { diff --git a/app/Http/Controllers/Views/ImprintController.php b/app/Http/Controllers/Views/ImprintController.php index 0d60cb2e3..9084350fb 100644 --- a/app/Http/Controllers/Views/ImprintController.php +++ b/app/Http/Controllers/Views/ImprintController.php @@ -9,8 +9,6 @@ class ImprintController extends Controller { /** * Show the the imprint view. - * - * @return \Illuminate\Http\Response */ public function show() { diff --git a/app/Http/Controllers/Views/LabelTrees/LabelTreeMembersController.php b/app/Http/Controllers/Views/LabelTrees/LabelTreeMembersController.php index eec802c05..d632f8296 100644 --- a/app/Http/Controllers/Views/LabelTrees/LabelTreeMembersController.php +++ b/app/Http/Controllers/Views/LabelTrees/LabelTreeMembersController.php @@ -16,7 +16,6 @@ class LabelTreeMembersController extends Controller * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { diff --git a/app/Http/Controllers/Views/LabelTrees/LabelTreeMergeController.php b/app/Http/Controllers/Views/LabelTrees/LabelTreeMergeController.php index 5d7c855c0..41fb67da0 100644 --- a/app/Http/Controllers/Views/LabelTrees/LabelTreeMergeController.php +++ b/app/Http/Controllers/Views/LabelTrees/LabelTreeMergeController.php @@ -13,8 +13,6 @@ class LabelTreeMergeController extends Controller * * @param Request $request * @param int $id ID of the base label tree - * - * @return mixed */ public function index(Request $request, $id) { @@ -37,8 +35,6 @@ public function index(Request $request, $id) * * @param int $id1 ID of the base label tree * @param int $id2 ID of the label tree to merge into the base - * - * @return mixed */ public function show($id1, $id2) { diff --git a/app/Http/Controllers/Views/LabelTrees/LabelTreeProjectsController.php b/app/Http/Controllers/Views/LabelTrees/LabelTreeProjectsController.php index 08372cb6f..6d3975ddd 100644 --- a/app/Http/Controllers/Views/LabelTrees/LabelTreeProjectsController.php +++ b/app/Http/Controllers/Views/LabelTrees/LabelTreeProjectsController.php @@ -16,7 +16,6 @@ class LabelTreeProjectsController extends Controller * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { @@ -37,8 +36,6 @@ public function show(Request $request, $id) * * @param LabelTree $tree * @param User $user - * - * @return \Illuminate\Http\Response */ protected function showMasterLabelTree(LabelTree $tree, User $user) { @@ -90,8 +87,6 @@ protected function showMasterLabelTree(LabelTree $tree, User $user) * * @param LabelTree $tree * @param User $user - * - * @return \Illuminate\Http\Response */ protected function showVersionedLabelTree(LabelTree $tree, User $user) { diff --git a/app/Http/Controllers/Views/LabelTrees/LabelTreeVersionsController.php b/app/Http/Controllers/Views/LabelTrees/LabelTreeVersionsController.php index dafbd5ce8..79416ce99 100644 --- a/app/Http/Controllers/Views/LabelTrees/LabelTreeVersionsController.php +++ b/app/Http/Controllers/Views/LabelTrees/LabelTreeVersionsController.php @@ -16,7 +16,7 @@ class LabelTreeVersionsController extends Controller * @param int $tid Label tree ID * @param int $vid Label tree version ID * - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function show(Request $request, $tid, $vid) { @@ -32,8 +32,6 @@ public function show(Request $request, $tid, $vid) * Show the create label tree version page. * * @param int $id Label tree ID - * - * @return \Illuminate\Http\Response */ public function create($id) { diff --git a/app/Http/Controllers/Views/LabelTrees/LabelTreesController.php b/app/Http/Controllers/Views/LabelTrees/LabelTreesController.php index 2e1385d3c..e2b97ccfb 100644 --- a/app/Http/Controllers/Views/LabelTrees/LabelTreesController.php +++ b/app/Http/Controllers/Views/LabelTrees/LabelTreesController.php @@ -17,8 +17,6 @@ class LabelTreesController extends Controller * * @param Request $request * @param int $id Label tree ID - * - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { @@ -38,7 +36,7 @@ public function show(Request $request, $id) * Show the label tree list. * * @deprecated This is a legacy route and got replaced by the global search. - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function index() { @@ -49,7 +47,6 @@ public function index() * Show the create label tree page. * * @param Request $request - * @return \Illuminate\Http\Response */ public function create(Request $request) { @@ -89,8 +86,6 @@ public function create(Request $request) * * @param LabelTree $tree * @param User $user - * - * @return \Illuminate\Http\Response */ protected function showMasterLabelTree(LabelTree $tree, User $user) { @@ -118,8 +113,6 @@ protected function showMasterLabelTree(LabelTree $tree, User $user) * * @param LabelTree $tree * @param User $user - * - * @return \Illuminate\Http\Response */ protected function showVersionedLabelTree(LabelTree $tree, User $user) { diff --git a/app/Http/Controllers/Views/ManualController.php b/app/Http/Controllers/Views/ManualController.php index db99e4b3b..ed7a1f316 100644 --- a/app/Http/Controllers/Views/ManualController.php +++ b/app/Http/Controllers/Views/ManualController.php @@ -9,8 +9,6 @@ class ManualController extends Controller { /** * Show the application manual to the user. - * - * @return \Illuminate\Http\Response */ public function index() { @@ -22,7 +20,6 @@ public function index() * * @param string $module Name of the module or name of the article * @param string $article Article name (only if the article belongs to a module) - * @return \Illuminate\Http\Response */ public function tutorialsArticle($module, $article = null) { @@ -44,7 +41,6 @@ public function tutorialsArticle($module, $article = null) * * @param string $module Name of the module or name of the article * @param string $article Article name (only if the article belongs to a module) - * @return \Illuminate\Http\Response */ public function documentationArticle($module, $article = null) { diff --git a/app/Http/Controllers/Views/Notifications/NotificationsController.php b/app/Http/Controllers/Views/Notifications/NotificationsController.php index fe9e9c541..cc982e5b2 100644 --- a/app/Http/Controllers/Views/Notifications/NotificationsController.php +++ b/app/Http/Controllers/Views/Notifications/NotificationsController.php @@ -3,7 +3,6 @@ namespace Biigle\Http\Controllers\Views\Notifications; use Biigle\Http\Controllers\Controller; -use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; class NotificationsController extends Controller @@ -12,14 +11,13 @@ class NotificationsController extends Controller * Shows the notification center. * * @param Request $request - * @param Guard $auth - * @return \Illuminate\Http\Response */ - public function index(Request $request, Guard $auth) + public function index(Request $request) { + $user = $request->user(); $all = (boolean) $request->input('all', false); - $user = $auth->user(); - $notifications = $all ? $user->notifications : $user->unreadNotifications; + $notifications = $all ? $user->notifications() : $user->unreadNotifications(); + $notifications = $notifications->get(); foreach ($notifications as $n) { $n->created_at_diff = $n->created_at->diffForHumans(); diff --git a/app/Http/Controllers/Views/PrivacyController.php b/app/Http/Controllers/Views/PrivacyController.php index 7e0d6196e..efa5a1dfa 100644 --- a/app/Http/Controllers/Views/PrivacyController.php +++ b/app/Http/Controllers/Views/PrivacyController.php @@ -9,8 +9,6 @@ class PrivacyController extends Controller { /** * Show the the privacy view. - * - * @return \Illuminate\Http\Response */ public function show() { diff --git a/app/Http/Controllers/Views/Projects/ProjectInvitationController.php b/app/Http/Controllers/Views/Projects/ProjectInvitationController.php index 150262729..fa05864e6 100644 --- a/app/Http/Controllers/Views/Projects/ProjectInvitationController.php +++ b/app/Http/Controllers/Views/Projects/ProjectInvitationController.php @@ -27,7 +27,7 @@ public function __construct() * * @param Request $request * @param string $uuid Invitation UUID - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function show(Request $request, $uuid) { diff --git a/app/Http/Controllers/Views/Projects/ProjectLabelTreeController.php b/app/Http/Controllers/Views/Projects/ProjectLabelTreeController.php index cbff19415..e9e89276b 100644 --- a/app/Http/Controllers/Views/Projects/ProjectLabelTreeController.php +++ b/app/Http/Controllers/Views/Projects/ProjectLabelTreeController.php @@ -13,7 +13,6 @@ class ProjectLabelTreeController extends Controller * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { @@ -27,7 +26,7 @@ public function show(Request $request, $id) $userProject = $request->user()->projects()->where('id', $id)->first(); $isMember = $userProject !== null; - $isPinned = $isMember && $userProject->pivot->pinned; + $isPinned = $isMember && $userProject->getRelationValue('pivot')->pinned; $canPin = $isMember && 3 > $request->user() ->projects() ->wherePivot('pinned', true) diff --git a/app/Http/Controllers/Views/Projects/ProjectStatisticsController.php b/app/Http/Controllers/Views/Projects/ProjectStatisticsController.php index 04e70c4a8..5fa7fc1f8 100644 --- a/app/Http/Controllers/Views/Projects/ProjectStatisticsController.php +++ b/app/Http/Controllers/Views/Projects/ProjectStatisticsController.php @@ -17,7 +17,6 @@ class ProjectStatisticsController extends Controller * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { @@ -26,7 +25,7 @@ public function show(Request $request, $id) $userProject = $request->user()->projects()->where('id', $id)->first(); $isMember = $userProject !== null; - $isPinned = $isMember && $userProject->pivot->pinned; + $isPinned = $isMember && $userProject->getRelationValue('pivot')->pinned; $canPin = $isMember && 3 > $request->user() ->projects() ->wherePivot('pinned', true) diff --git a/app/Http/Controllers/Views/Projects/ProjectUserController.php b/app/Http/Controllers/Views/Projects/ProjectUserController.php index a474218e3..d05475897 100644 --- a/app/Http/Controllers/Views/Projects/ProjectUserController.php +++ b/app/Http/Controllers/Views/Projects/ProjectUserController.php @@ -14,7 +14,6 @@ class ProjectUserController extends Controller * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { @@ -43,7 +42,7 @@ public function show(Request $request, $id) $userProject = $request->user()->projects()->where('id', $id)->first(); $isMember = $userProject !== null; - $isPinned = $isMember && $userProject->pivot->pinned; + $isPinned = $isMember && $userProject->getRelationValue('pivot')->pinned; $canPin = $isMember && 3 > $request->user() ->projects() ->wherePivot('pinned', true) diff --git a/app/Http/Controllers/Views/Projects/ProjectsController.php b/app/Http/Controllers/Views/Projects/ProjectsController.php index e04d206ef..a294f00b6 100644 --- a/app/Http/Controllers/Views/Projects/ProjectsController.php +++ b/app/Http/Controllers/Views/Projects/ProjectsController.php @@ -10,8 +10,6 @@ class ProjectsController extends Controller { /** * Shows the create project page. - * - * @return \Illuminate\Http\Response */ public function create() { @@ -24,7 +22,7 @@ public function create() * Shows the project index page. * * @deprecated This is a legacy route and got replaced by the global search. - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function index() { @@ -36,7 +34,6 @@ public function index() * * @param Request $request * @param int $id project ID - * @return \Illuminate\Http\Response */ protected function show(Request $request, $id) { @@ -57,7 +54,7 @@ protected function show(Request $request, $id) $userProject = $request->user()->projects()->where('id', $id)->first(); $isMember = $userProject !== null; - $isPinned = $isMember && $userProject->pivot->pinned; + $isPinned = $isMember && $userProject->getRelationValue('pivot')->pinned; $canPin = $isMember && 3 > $request->user() ->projects() ->wherePivot('pinned', true) diff --git a/app/Http/Controllers/Views/SearchController.php b/app/Http/Controllers/Views/SearchController.php index 63f3b6e63..e5b182962 100644 --- a/app/Http/Controllers/Views/SearchController.php +++ b/app/Http/Controllers/Views/SearchController.php @@ -21,7 +21,6 @@ class SearchController extends Controller * @param Guard $auth * @param Request $request * @param Modules $modules - * @return \Illuminate\Http\Response */ public function index(Guard $auth, Request $request, Modules $modules) { @@ -76,6 +75,7 @@ protected function searchLabelTrees(User $user, $query, $type, $includeFederated }); if ($includeFederatedSearch) { + /** @var \Illuminate\Database\Query\Builder $queryBuilder2 */ $queryBuilder2 = $user->federatedSearchModels() ->labelTrees() ->selectRaw("id, name, description, updated_at, true as external") @@ -103,6 +103,7 @@ protected function searchLabelTrees(User $user, $query, $type, $includeFederated $external = FederatedSearchModel::whereIn('id', $collection->where('external', true)->pluck('id'))->get()->keyBy('id'); $results->setCollection($collection->map(function ($item) use ($internal, $external) { + /** @phpstan-ignore property.notFound */ if ($item->external) { return $external[$item->id]; } @@ -147,6 +148,7 @@ protected function searchProjects(User $user, $query, $type, $includeFederatedSe }); if ($includeFederatedSearch) { + /** @var \Illuminate\Database\Query\Builder $queryBuilder2 */ $queryBuilder2 = $user->federatedSearchModels() ->projects() ->selectRaw("id, name, description, updated_at, true as external") @@ -174,6 +176,7 @@ protected function searchProjects(User $user, $query, $type, $includeFederatedSe $external = FederatedSearchModel::whereIn('id', $collection->where('external', true)->pluck('id'))->get()->keyBy('id'); $results->setCollection($collection->map(function ($item) use ($internal, $external) { + /** @phpstan-ignore property.notFound */ if ($item->external) { return $external[$item->id]; } @@ -213,6 +216,7 @@ protected function searchVolumes(User $user, $query, $type, $includeFederatedSea }); if ($includeFederatedSearch) { + /** @var \Illuminate\Database\Query\Builder $queryBuilder2 */ $queryBuilder2 = $user->federatedSearchModels() ->volumes() ->selectRaw("id, name, updated_at, true as external") @@ -239,6 +243,7 @@ protected function searchVolumes(User $user, $query, $type, $includeFederatedSea $external = FederatedSearchModel::whereIn('id', $collection->where('external', true)->pluck('id'))->get()->keyBy('id'); $results->setCollection($collection->map(function ($item) use ($internal, $external) { + /** @phpstan-ignore property.notFound */ if ($item->external) { return $external[$item->id]; } diff --git a/app/Http/Controllers/Views/SettingsController.php b/app/Http/Controllers/Views/SettingsController.php index 3faf4272c..be12d6d3f 100644 --- a/app/Http/Controllers/Views/SettingsController.php +++ b/app/Http/Controllers/Views/SettingsController.php @@ -10,7 +10,7 @@ class SettingsController extends Controller /** * Redirects to the profile settings. * - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function index() { @@ -21,7 +21,6 @@ public function index() * Shows the profile settings. * * @param Guard $auth - * @return \Illuminate\Http\Response */ public function profile(Guard $auth) { @@ -34,7 +33,6 @@ public function profile(Guard $auth) * Shows the account settings. * * @param Guard $auth - * @return \Illuminate\Http\Response */ public function account(Guard $auth) { @@ -48,7 +46,6 @@ public function account(Guard $auth) * Shows the authentication settings. * * @param Guard $auth - * @return \Illuminate\Http\Response */ public function authentication(Guard $auth) { @@ -61,7 +58,6 @@ public function authentication(Guard $auth) * Shows the tokens settings. * * @param Guard $auth - * @return \Illuminate\Http\Response */ public function tokens(Guard $auth) { @@ -76,8 +72,6 @@ public function tokens(Guard $auth) /** * Shows the notification settings. - * - * @return \Illuminate\Http\Response */ public function notifications() { diff --git a/app/Http/Controllers/Views/TermsController.php b/app/Http/Controllers/Views/TermsController.php index b5b529a69..994f8abc3 100644 --- a/app/Http/Controllers/Views/TermsController.php +++ b/app/Http/Controllers/Views/TermsController.php @@ -9,8 +9,6 @@ class TermsController extends Controller { /** * Show the the terms view. - * - * @return \Illuminate\Http\Response */ public function show() { diff --git a/app/Http/Controllers/Views/Videos/VideoAnnotationController.php b/app/Http/Controllers/Views/Videos/VideoAnnotationController.php index d532f356d..bd82a7c01 100644 --- a/app/Http/Controllers/Views/Videos/VideoAnnotationController.php +++ b/app/Http/Controllers/Views/Videos/VideoAnnotationController.php @@ -11,7 +11,7 @@ class VideoAnnotationController extends Controller * Redirect to the annotator link that shows a specified annotation. * * @param int $id Video annotation ID - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\RedirectResponse */ public function show($id) { diff --git a/app/Http/Controllers/Views/Videos/VideoController.php b/app/Http/Controllers/Views/Videos/VideoController.php index 873fd9d74..97b58c87f 100644 --- a/app/Http/Controllers/Views/Videos/VideoController.php +++ b/app/Http/Controllers/Views/Videos/VideoController.php @@ -18,8 +18,6 @@ class VideoController extends Controller * * @param Request $request * @param int $id - * - * @return mixed */ public function show(Request $request, $id) { diff --git a/app/Http/Controllers/Views/Volumes/ImageController.php b/app/Http/Controllers/Views/Volumes/ImageController.php index 8b190719c..250d22563 100644 --- a/app/Http/Controllers/Views/Volumes/ImageController.php +++ b/app/Http/Controllers/Views/Volumes/ImageController.php @@ -12,7 +12,6 @@ class ImageController extends Controller * Shows the image index page. * * @param int $id volume ID - * @return \Illuminate\Http\Response */ public function index($id) { diff --git a/app/Http/Controllers/Views/Volumes/VolumeCloneController.php b/app/Http/Controllers/Views/Volumes/VolumeCloneController.php index 5d7b5ebe7..de5c05fb7 100644 --- a/app/Http/Controllers/Views/Volumes/VolumeCloneController.php +++ b/app/Http/Controllers/Views/Volumes/VolumeCloneController.php @@ -2,7 +2,6 @@ namespace Biigle\Http\Controllers\Views\Volumes; -use \Illuminate\Contracts\View\View; use Biigle\Http\Controllers\Views\Controller; use Biigle\LabelTree; use Biigle\Project; @@ -16,8 +15,6 @@ class VolumeCloneController extends Controller * Shows the volume clone page. * @param Request $request * @param $id volume ID - * - * @return View **/ public function clone(Request $request, $id) { @@ -37,7 +34,7 @@ public function clone(Request $request, $id) } // Collection of projects where cloned volume can be copied to. - $destProjects = $destProjectQuery->select('name', 'id')->get(); + $destProjects = $destProjectQuery->select(['name', 'id'])->get(); $labelTrees = LabelTree::select('id', 'name', 'version_id') ->with('labels', 'version') diff --git a/app/Http/Controllers/Views/Volumes/VolumeController.php b/app/Http/Controllers/Views/Volumes/VolumeController.php index 17266ecea..77c699398 100644 --- a/app/Http/Controllers/Views/Volumes/VolumeController.php +++ b/app/Http/Controllers/Views/Volumes/VolumeController.php @@ -20,7 +20,6 @@ class VolumeController extends Controller * Shows the create volume page. * * @param Request $request - * @return \Illuminate\Http\Response */ public function create(Request $request) { @@ -64,7 +63,7 @@ public function create(Request $request) return view('volumes.create', [ 'project' => $project, 'disks' => $disks, - 'hasDisks' => !empty($disks), + 'hasDisks' => $disks->isNotEmpty(), 'mediaType' => $mediaType, 'filenames' => $filenames, 'offlineMode' => $offlineMode, @@ -77,8 +76,6 @@ public function create(Request $request) * * @param Request $request * @param int $id volume ID - * - * @return \Illuminate\Http\Response */ public function index(Request $request, $id) { @@ -122,8 +119,6 @@ public function index(Request $request, $id) * * @param Request $request * @param int $id volume ID - * - * @return \Illuminate\Http\Response */ public function edit(Request $request, $id) { diff --git a/app/Http/Middleware/AuthenticateRegister.php b/app/Http/Middleware/AuthenticateRegister.php index 341165582..fed559787 100644 --- a/app/Http/Middleware/AuthenticateRegister.php +++ b/app/Http/Middleware/AuthenticateRegister.php @@ -17,5 +17,7 @@ protected function redirectTo($request) if (!$request->expectsJson()) { return route('register'); } + + return ''; } } diff --git a/app/Http/Requests/DestroyAnnotationSession.php b/app/Http/Requests/DestroyAnnotationSession.php index bf98d25e9..bd0d5f9cb 100644 --- a/app/Http/Requests/DestroyAnnotationSession.php +++ b/app/Http/Requests/DestroyAnnotationSession.php @@ -12,7 +12,7 @@ class DestroyAnnotationSession extends FormRequest * * @var AnnotationSession */ - public $session; + public $annotationSession; /** * Determine if the user is authorized to make this request. @@ -21,9 +21,9 @@ class DestroyAnnotationSession extends FormRequest */ public function authorize() { - $this->session = AnnotationSession::findOrFail($this->route('id')); + $this->annotationSession = AnnotationSession::findOrFail($this->route('id')); - return $this->user()->can('update', $this->session->volume); + return $this->user()->can('update', $this->annotationSession->volume); } /** diff --git a/app/Http/Requests/StoreImageAnnotations.php b/app/Http/Requests/StoreImageAnnotations.php index 221db9e4c..d6bffa5d6 100644 --- a/app/Http/Requests/StoreImageAnnotations.php +++ b/app/Http/Requests/StoreImageAnnotations.php @@ -18,21 +18,21 @@ class StoreImageAnnotations extends FormRequest /** * Unique image IDs of this request. * - * @var array + * @var \Illuminate\Support\Collection */ public $imageIds; /** * The images on which the annotations should be created. * - * @var array + * @var \Illuminate\Database\Eloquent\Collection<\Biigle\Image> */ public $images; /** * The labels that should be attached to the new annotations. * - * @var array + * @var \Illuminate\Database\Eloquent\Collection */ public $labels; diff --git a/app/Http/Requests/StoreLabelTree.php b/app/Http/Requests/StoreLabelTree.php index 38d0b75cd..284fad460 100644 --- a/app/Http/Requests/StoreLabelTree.php +++ b/app/Http/Requests/StoreLabelTree.php @@ -11,14 +11,14 @@ class StoreLabelTree extends FormRequest /** * The project to which the new label tree should be attached (if any). * - * @var Project + * @var Project|null */ public $project; /** * The upstream label tree that should be forked (if any) * - * @var LabelTree + * @var LabelTree|null */ public $upstreamLabelTree; diff --git a/app/Http/Requests/StorePinnedProject.php b/app/Http/Requests/StorePinnedProject.php index 8b59787be..7f7b3f952 100644 --- a/app/Http/Requests/StorePinnedProject.php +++ b/app/Http/Requests/StorePinnedProject.php @@ -48,7 +48,7 @@ public function withValidator($validator) $validator->after(function ($validator) { $pinnedCount = $this->user()->projects()->where('pinned', true)->count(); - if ($pinnedCount === 3 && !$this->project->pivot->pinned) { + if ($pinnedCount === 3 && !$this->project->getRelationValue('pivot')->pinned) { $validator->errors()->add('id', 'You cannot pin more than three projects.'); } }); diff --git a/app/Http/Requests/UpdateAnnotationSession.php b/app/Http/Requests/UpdateAnnotationSession.php index 646bd21b5..7b2769969 100644 --- a/app/Http/Requests/UpdateAnnotationSession.php +++ b/app/Http/Requests/UpdateAnnotationSession.php @@ -12,7 +12,7 @@ class UpdateAnnotationSession extends FormRequest * * @var AnnotationSession */ - public $session; + public $annotationSession; /** * Determine if the user is authorized to make this request. @@ -21,9 +21,9 @@ class UpdateAnnotationSession extends FormRequest */ public function authorize() { - $this->session = AnnotationSession::findOrFail($this->route('id')); + $this->annotationSession = AnnotationSession::findOrFail($this->route('id')); - return $this->user()->can('update', $this->session->volume); + return $this->user()->can('update', $this->annotationSession->volume); } /** diff --git a/app/Image.php b/app/Image.php index c6eab803b..62841fa36 100644 --- a/app/Image.php +++ b/app/Image.php @@ -28,7 +28,7 @@ class Image extends VolumeFile /** * The attributes hidden in the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'labels', @@ -37,7 +37,7 @@ class Image extends VolumeFile /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'attrs' => 'array', @@ -50,7 +50,7 @@ class Image extends VolumeFile /** * The annotations on this image. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function annotations() { @@ -60,7 +60,7 @@ public function annotations() /** * The labels, this image got attached by the users. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function labels() { @@ -70,7 +70,7 @@ public function labels() /** * Get the original image as download response. * - * @return Response + * @return array|\Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\StreamedResponse */ public function getFile() { diff --git a/app/ImageAnnotation.php b/app/ImageAnnotation.php index b25e16443..080c9f6c6 100644 --- a/app/ImageAnnotation.php +++ b/app/ImageAnnotation.php @@ -11,7 +11,7 @@ class ImageAnnotation extends Annotation /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'image_id' => 'int', @@ -22,7 +22,7 @@ class ImageAnnotation extends Annotation /** * The image, this annotation belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function image() { @@ -30,9 +30,7 @@ public function image() } /** - * The file, this annotation belongs to. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * {@inheritdoc} */ public function file() { @@ -50,9 +48,7 @@ public function getFileIdAttribute() } /** - * The labels, this annotation got assigned by the users. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * {@inheritdoc} */ public function labels() { diff --git a/app/ImageAnnotationLabel.php b/app/ImageAnnotationLabel.php index 3e899fdd6..1554d3c3e 100644 --- a/app/ImageAnnotationLabel.php +++ b/app/ImageAnnotationLabel.php @@ -10,7 +10,7 @@ class ImageAnnotationLabel extends AnnotationLabel /** * The attributes excluded from the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'created_at', @@ -20,7 +20,7 @@ class ImageAnnotationLabel extends AnnotationLabel /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'user_id' => 'int', @@ -31,7 +31,7 @@ class ImageAnnotationLabel extends AnnotationLabel /** * The annotation, this annotation label belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function annotation() { diff --git a/app/ImageLabel.php b/app/ImageLabel.php index 15e1fe209..f54cdffd3 100644 --- a/app/ImageLabel.php +++ b/app/ImageLabel.php @@ -5,9 +5,7 @@ class ImageLabel extends VolumeFileLabel { /** - * The file, this volume file label belongs to. - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * {@inheritdoc} */ public function file() { @@ -17,7 +15,7 @@ public function file() /** * The image, this image label belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function image() { diff --git a/app/Jobs/CloneImagesOrVideos.php b/app/Jobs/CloneImagesOrVideos.php index 776213afe..e4b988943 100644 --- a/app/Jobs/CloneImagesOrVideos.php +++ b/app/Jobs/CloneImagesOrVideos.php @@ -8,8 +8,6 @@ use Biigle\ImageAnnotation; use Biigle\ImageAnnotationLabel; use Biigle\ImageLabel; -use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage; -use Biigle\Modules\Largo\Jobs\ProcessAnnotatedVideo; use Biigle\Project; use Biigle\Traits\ChecksMetadataStrings; use Biigle\Video; @@ -137,7 +135,7 @@ public function handle() } } if ($copy->files()->exists()) { - $this->postProcessCloning($copy); + ProcessNewVolumeFiles::dispatch($copy); } //save ifdo-file if exist @@ -148,43 +146,11 @@ public function handle() $copy->save(); - event('volume.cloned', [$copy->id]); + event('volume.cloned', $copy); }); } - /** - * Initiate file thumbnail creation - * @param Volume $volume for which thumbnail creation should be started - * @return void - **/ - public function postProcessCloning($volume) - { - ProcessNewVolumeFiles::dispatch($volume); - - // Give the ProcessNewVolumeFiles job a head start so the file thumbnails are - // generated (mostly) before the annotation thumbnails. - $delay = now()->addSeconds(30); - - if (class_exists(ProcessAnnotatedImage::class)) { - $volume->images()->whereHas('annotations') - ->eachById(function ($image) use ($delay) { - ProcessAnnotatedImage::dispatch($image) - ->delay($delay) - ->onQueue(config('largo.generate_annotation_patch_queue')); - }); - } - - if (class_exists(ProcessAnnotatedVideo::class)) { - $volume->videos() - ->whereHas('annotations')->eachById(function ($video) use ($delay) { - ProcessAnnotatedVideo::dispatch($video) - ->delay($delay) - ->onQueue(config('largo.generate_annotation_patch_queue')); - }); - } - } - /** * Copies (selected) images from given volume to volume copy. * @@ -247,6 +213,7 @@ private function copyImageAnnotation($volume, $copy, $selectedFileIds, $selected $chunkNewImageIds = []; // Consider all previous image chunks when calculating the start of the index. $baseImageIndex = ($page - 1) * $chunkSize; + /** @var Image $image */ foreach ($chunk as $index => $image) { $newImageId = $newImageIds[$baseImageIndex + $index]; // Collect relevant image IDs for the annotation query below. @@ -271,6 +238,7 @@ private function copyImageAnnotation($volume, $copy, $selectedFileIds, $selected ->orderBy('id') ->pluck('id'); $insertData = []; + /** @var Image $image */ foreach ($chunk as $image) { foreach ($image->annotations as $annotation) { if ($annotation->labels->isEmpty()) { @@ -390,6 +358,7 @@ private function copyVideoAnnotation($volume, $copy, $selectedFileIds, $selected $chunkNewVideoIds = []; // Consider all previous video chunks when calculating the start of the index. $baseVideoIndex = ($page - 1) * $chunkSize; + /** @var Video $video */ foreach ($chunk as $index => $video) { $newVideoId = $newVideoIds[$baseVideoIndex + $index]; // Collect relevant video IDs for the annotation query below. @@ -415,6 +384,7 @@ private function copyVideoAnnotation($volume, $copy, $selectedFileIds, $selected ->orderBy('id') ->pluck('id'); $insertData = []; + /** @var Video $video */ foreach ($chunk as $video) { foreach ($video->annotations as $annotation) { if ($annotation->labels->isEmpty()) { diff --git a/app/Jobs/CreateNewImagesOrVideos.php b/app/Jobs/CreateNewImagesOrVideos.php index c266698b2..7280b7a87 100644 --- a/app/Jobs/CreateNewImagesOrVideos.php +++ b/app/Jobs/CreateNewImagesOrVideos.php @@ -130,7 +130,7 @@ protected function createFiles($filenames, $metadataMap) ]); $metadata = collect($metadataMap->get($filename)); - if ($metadata) { + if ($metadata->isNotEmpty()) { // Remove empty cells. $metadata = $metadata->filter(); $insert = array_merge( diff --git a/app/Jobs/GenerateFederatedSearchIndex.php b/app/Jobs/GenerateFederatedSearchIndex.php index 34a73980d..2f91b7484 100644 --- a/app/Jobs/GenerateFederatedSearchIndex.php +++ b/app/Jobs/GenerateFederatedSearchIndex.php @@ -36,7 +36,7 @@ public function handle() $index['users'] = []; User::whereIn('id', array_unique($userIds)) ->select('id', 'uuid') - ->eachById(function ($user) use (&$index) { + ->eachById(function (User $user) use (&$index) { $index['users'][] = [ 'id' => $user->id, 'uuid' => $user->uuid, @@ -59,7 +59,7 @@ protected function generateLabelTreeIndex() // Versions and global label trees should not be indexed. LabelTree::withoutVersions() ->whereHas('members') - ->eachById(function ($tree) use (&$trees) { + ->eachById(function (LabelTree $tree) use (&$trees) { $trees[] = [ 'id' => $tree->id, 'name' => $tree->name, @@ -82,7 +82,7 @@ protected function generateLabelTreeIndex() protected function generateProjectIndex() { $projects = []; - Project::eachById(function ($project) use (&$projects) { + Project::eachById(function (Project $project) use (&$projects) { $projects[] = [ 'id' => $project->id, 'name' => $project->name, @@ -115,7 +115,7 @@ protected function generateProjectIndex() protected function generateVolumeIndex() { $volumes = []; - Volume::eachById(function ($volume) use (&$volumes) { + Volume::eachById(function (Volume $volume) use (&$volumes) { $volumes[] = [ 'id' => $volume->id, 'name' => $volume->name, @@ -123,7 +123,7 @@ protected function generateVolumeIndex() 'updated_at' => strval($volume->updated_at), 'url' => route('volume', $volume->id, false), 'thumbnail_url' => $volume->thumbnailUrl, - 'thumbnail_urls' => $volume->thumbnailUrls, + 'thumbnail_urls' => $volume->thumbnailsUrl, ]; }); diff --git a/app/Jobs/ProcessNewImage.php b/app/Jobs/ProcessNewImage.php index 10491f3d9..27b39b823 100644 --- a/app/Jobs/ProcessNewImage.php +++ b/app/Jobs/ProcessNewImage.php @@ -13,8 +13,8 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; +use Jcupitt\Vips\Image as VipsImage; use Log; -use VipsImage; class ProcessNewImage extends Job implements ShouldQueue { @@ -153,7 +153,7 @@ protected function collectMetadata(Image $image, $path) $image->mimetype = File::mimeType($path); try { - $i = VipsImage::newFromFile($path); + $i = $this->getVipsImage($path); $image->width = $i->width; $image->height = $i->height; } catch (Exception $e) { @@ -296,18 +296,14 @@ protected function fracToFloat($frac) $parts = explode('/', $frac); $count = count($parts); - if ($count === 0) { - return 0; - } elseif ($count === 1) { - return $parts[0]; + // Don't use !== 0 to catch all incorrect values. + if ($count === 2 && $parts[1] != 0) { + return floatval($parts[0]) / floatval($parts[1]); + } elseif (is_numeric($parts[0])) { + return floatval($parts[0]); } - // Don't use === to catch all incorrect values. - if ($parts[1] == 0) { - return 0; - } - - return floatval($parts[0]) / floatval($parts[1]); + return 0; } /** @@ -346,4 +342,16 @@ protected function submitTileJob(Image $image) $image->save(); TileSingleImage::dispatch($image); } + + /** + * Get a Vips image instance for the file. + * + * @param string $path + * + * @return VipsImage + */ + protected function getVipsImage(string $path) + { + return VipsImage::newFromFile($path); + } } diff --git a/app/Jobs/ProcessNewVideo.php b/app/Jobs/ProcessNewVideo.php index 0c830c4da..09309608d 100644 --- a/app/Jobs/ProcessNewVideo.php +++ b/app/Jobs/ProcessNewVideo.php @@ -16,9 +16,9 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; +use Jcupitt\Vips\Image as VipsImage; use Log; use Throwable; -use VipsImage; class ProcessNewVideo extends Job implements ShouldQueue { @@ -40,11 +40,16 @@ class ProcessNewVideo extends Job implements ShouldQueue /** * The FFMpeg video instance. - * - * @var \FFMpeg\Media\Video */ protected $ffmpegVideo; + /** + * The FFProbe instance. + * + * @var FFProbe|null + */ + protected $ffprobe; + /** * Ignore this job if the video does not exist any more. * @@ -232,8 +237,8 @@ protected function generateVideoThumbnail($path, $time, $width, $height, $format $this->ffmpegVideo = FFMpeg::create()->open($path); } - $buffer = $this->ffmpegVideo->frame(TimeCode::fromSeconds($time)) - ->save(null, false, true); + $buffer = (string) $this->ffmpegVideo->frame(TimeCode::fromSeconds($time)) + ->save('', false, true); return VipsImage::thumbnail_buffer($buffer, $width, ['height' => $height]) ->writeToBuffer(".{$format}", [ diff --git a/app/Jobs/ProcessNewVolumeFiles.php b/app/Jobs/ProcessNewVolumeFiles.php index 4e1b87af1..a79f4ae1c 100644 --- a/app/Jobs/ProcessNewVolumeFiles.php +++ b/app/Jobs/ProcessNewVolumeFiles.php @@ -2,6 +2,7 @@ namespace Biigle\Jobs; +use Biigle\Video; use Biigle\Volume; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -62,7 +63,7 @@ public function handle() $query->eachById([ProcessNewImage::class, 'dispatch']); } else { $queue = config('videos.process_new_video_queue'); - $query->eachById(fn ($v) => ProcessNewVideo::dispatch($v)->onQueue($queue)); + $query->eachById(fn (Video $v) => ProcessNewVideo::dispatch($v)->onQueue($queue)); } } } diff --git a/app/Jobs/TileSingleImage.php b/app/Jobs/TileSingleImage.php index f0f262379..70b16070e 100644 --- a/app/Jobs/TileSingleImage.php +++ b/app/Jobs/TileSingleImage.php @@ -11,9 +11,9 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Storage; +use Jcupitt\Vips\Image as VipsImage; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; -use VipsImage; class TileSingleImage extends Job implements ShouldQueue { diff --git a/app/Label.php b/app/Label.php index 2090550fe..610c399a9 100644 --- a/app/Label.php +++ b/app/Label.php @@ -13,6 +13,9 @@ * with `rock`. * * Labels can be ordered in a tree-like structure. + * + * @property int $id + * @property string $uuid */ class Label extends Model { @@ -21,7 +24,7 @@ class Label extends Model /** * The attributes hidden from the model's JSON form. * - * @var array + * @var array */ protected $hidden = [ 'uuid', @@ -30,7 +33,7 @@ class Label extends Model /** * The attributes that should be casted to native types. * - * @var array + * @var array */ protected $casts = [ 'parent_id' => 'int', @@ -82,7 +85,7 @@ public function scopeUsed($query) /** * The parent label if the labels are ordered in a tree-like structure. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function parent() { @@ -92,7 +95,7 @@ public function parent() /** * The label tree this label belongs to. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function tree() { @@ -103,7 +106,7 @@ public function tree() * The child labels of this label if they are ordered in a tree-like * structue. * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * @return \Illuminate\Database\Eloquent\Relations\HasMany