Skip to content

Commit

Permalink
doc blocks + fix deprecation utf8_encoding (#1789)
Browse files Browse the repository at this point in the history
* doc blocks + fix deprecation utf8_encoding

* fixes
  • Loading branch information
ildyria authored Apr 11, 2023
1 parent 28b395a commit 2f74019
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
31 changes: 18 additions & 13 deletions app/Models/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@
/**
* Class Album.
*
* @property string|null $parent_id
* @property Album|null $parent
* @property Collection<Album> $children
* @property int $num_children The number of children.
* @property Collection<Photo> $all_photos
* @property int $num_photos The number of photos in this album (excluding photos in subalbums).
* @property string $license
* @property string|null $cover_id
* @property Photo|null $cover
* @property string|null $track_short_path
* @property string|null $track_url
* @property int $_lft
* @property int $_rgt
* @property string $id
* @property string|null $parent_id
* @property Album|null $parent
* @property Collection<Album> $children
* @property int $num_children The number of children.
* @property Collection<Photo> $all_photos
* @property int $num_photos The number of photos in this album (excluding photos in subalbums).
* @property string $license
* @property string|null $cover_id
* @property Photo|null $cover
* @property string|null $track_short_path
* @property string|null $track_url
* @property int $_lft
* @property int $_rgt
* @property \App\Models\BaseAlbumImpl $base_class
* @property \App\Models\User|null $owner
* @property Collection<int, \App\Models\User> $shared_with
* @property int|null $shared_with_count
*
* @method static AlbumBuilder query() Begin querying the model.
* @method static AlbumBuilder with(array|string $relations) Begin querying the model with eager loading.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/BaseAlbumImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@
* @property bool $grants_full_photo_access
* @property bool $grants_download
* @property Collection $shared_with
* @property int|null $shared_with_count
* @property string|null $password
* @property bool $is_password_required
* @property PhotoSortingCriterion|null $sorting
* @property AlbumProtectionPolicy $policy
* @property int $is_share_button_visible // NOT USED
* @property string|null $sorting_col
* @property string|null $sorting_order
*/
class BaseAlbumImpl extends Model implements HasRandomID
{
Expand Down
20 changes: 13 additions & 7 deletions app/Models/JobHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

use App\Enum\JobStatus;
use App\Exceptions\ConfigurationKeyMissingException;
use App\Models\Extensions\ThrowsConsistentExceptions;
use App\Models\Extensions\UseFixedQueryBuilder;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\DB;

/**
* App\Models\JobHistory.
*
* @property int $id
* @property int $owner_id
* @property User $owner
Expand All @@ -22,6 +26,10 @@
*/
class JobHistory extends Model
{
use ThrowsConsistentExceptions;
/** @phpstan-use UseFixedQueryBuilder<JobHistory> */
use UseFixedQueryBuilder;

protected $table = 'jobs_history';

protected $hidden = [];
Expand Down Expand Up @@ -64,19 +72,17 @@ public function parent(): BelongsTo
/**
* @return Builder
*
* @throws \RuntimeException
* @throws \InvalidArgumentException
* @throws ConfigurationKeyMissingException
*/
public function scopeWithAlbumTitleOrNull(): Builder
{
$with = JobHistory::query()
->join('base_albums', 'jobs_history.parent_id', '=', 'base_albums.id')
->select(['jobs_history.*', 'base_albums.title']);
->join('base_albums', 'jobs_history.parent_id', '=', 'base_albums.id')
->select(['jobs_history.*', 'base_albums.title']);

return JobHistory::query()
->doesntHave('parent')
->select(['jobs_history.*', DB::raw('NULL as title')])
->union($with);
->doesntHave('parent')
->select(['jobs_history.*', DB::raw('NULL as title')])
->union($with);
}
}
6 changes: 6 additions & 0 deletions app/Models/TagAlbum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
*
* @method static TagAlbumBuilder query() Begin querying the model.
* @method static TagAlbumBuilder with(array|string $relations) Begin querying the model with eager loading.
*
* @property string $id
* @property \App\Models\BaseAlbumImpl $base_class
* @property \App\Models\User $owner
* @property \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $shared_with
* @property int|null $shared_with_count
*/
class TagAlbum extends BaseAlbum
{
Expand Down
11 changes: 10 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable;
use Laragear\WebAuthn\Models\WebAuthnCredential;
use Laragear\WebAuthn\WebAuthnAuthentication;
use function Safe\mb_convert_encoding;

/**
* App\Models\User.
Expand All @@ -34,12 +35,19 @@
* @property bool $may_administrate
* @property bool $may_upload
* @property bool $may_edit_own_settings
* @property string $name
* @property string|null $token
* @property string|null $remember_token
* @property Collection<BaseAlbumImpl> $albums
* @property int|null $albums_count
* @property DatabaseNotificationCollection|DatabaseNotification[] $notifications
* @property int|null $notifications_count
* @property Collection<BaseAlbumImpl> $shared
* @property int|null $shared_count
* @property Collection<Photo> $photos
* @property int|null $photos_count
* @property Collection<int, WebAuthnCredential> $webAuthnCredentials
* @property int|null $web_authn_credentials_count
*/
class User extends Authenticatable implements WebAuthnAuthenticatable
{
Expand Down Expand Up @@ -116,7 +124,8 @@ public function shared(): BelongsToMany
*/
public function username(): string
{
return utf8_encode($this->username);
// @phpstan-ignore-next-line This is temporary and should hopefully be fixed soon by Safe with proper type hinting.
return mb_convert_encoding($this->username, 'UTF-8');
}

/**
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ parameters:
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::without\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::count\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::update\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::join\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Extensions\\FixedQueryBuilder)(<.*>)?::union\(\).#'
- '#Dynamic call to static method App\\Models\\Extensions\\FixedQueryBuilder<.*>::orderByDesc\(\).#'
- '#Call to an undefined method Illuminate\\Database\\Eloquent\\.*::update\(\)#'
Expand Down

0 comments on commit 2f74019

Please sign in to comment.