Skip to content

Commit 2d38572

Browse files
authored
Merge pull request #220 from johnproblems/session-6-phpstan-property-annotations
fix: Add @Property annotations to models for PHPStan type safety (Session 6)
2 parents 08c4118 + 20f18f4 commit 2d38572

26 files changed

Lines changed: 341 additions & 3 deletions

app/Models/Application.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@
122122
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Server> $additional_servers
123123
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\StandaloneDocker> $additional_networks
124124
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ScheduledTask> $scheduled_tasks
125+
* @property-read array<int, string> $ports_exposes_array Computed attribute from ports_exposes
126+
* @property-read array<int, string> $ports_mappings_array Computed attribute from ports_mappings
127+
* @property-read array<int, string> $fqdns Computed attribute from fqdn
128+
* @property-read array<int, string> $custom_network_aliases_array Computed attribute from custom_network_aliases
129+
* @property-read string|null $git_branch_location Computed Git branch location
130+
* @property-read string|null $git_webhook Computed Git webhook URL
131+
* @property-read string|null $git_commits Git commits URL
132+
* @property-read bool $server_status Server health status
133+
* @property string|null $watch_paths Normalized watch paths (newline-separated)
134+
* @property string $status Application status
135+
* @property string|null $image Docker image (via docker_registry_image_name)
136+
* @property int|null $pull_request_id Pull request ID for preview deployments
137+
* @property bool $is_container_label_readonly_enabled Container label readonly setting
138+
* @property string|null $custom_docker_run_options Custom Docker run options
139+
* @property string|null $custom_labels Custom labels for the container
125140
*/
126141
class Application extends BaseModel
127142
{

app/Models/ApplicationDeploymentQueue.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
use Illuminate\Support\Facades\DB;
99
use OpenApi\Attributes as OA;
1010

11+
/**
12+
* @property-read \App\Models\Server|null $server Computed from server_id
13+
* @property-read \App\Models\Application $application
14+
* @property int|null $server_id Server ID for deployment
15+
* @property int $pull_request_id Pull request ID (0 for main deployment)
16+
*/
1117
#[OA\Schema(
1218
description: 'Project model',
1319
type: 'object',

app/Models/ApplicationPreview.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
use Spatie\Url\Url;
77
use Visus\Cuid2\Cuid2;
88

9+
/**
10+
* @property Application $application
11+
* @property int $pull_request_id
12+
* @property string|null $fqdn
13+
* @property string|null $status
14+
* @property string|null $docker_compose_domains
15+
* @property \Illuminate\Database\Eloquent\Collection<int, LocalPersistentVolume> $persistentStorages
16+
*/
917
class ApplicationPreview extends BaseModel
1018
{
1119
use SoftDeletes;

app/Models/Environment.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
'description' => ['type' => 'string'],
1919
]
2020
)]
21+
/**
22+
* @property int $id
23+
* @property string $uuid
24+
* @property string $name
25+
* @property int $project_id
26+
* @property Project $project
27+
* @property \Illuminate\Database\Eloquent\Collection<int, SharedEnvironmentVariable> $environment_variables
28+
* @property \Illuminate\Database\Eloquent\Collection<int, Application> $applications
29+
* @property \Illuminate\Database\Eloquent\Collection<int, StandalonePostgresql> $postgresqls
30+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneRedis> $redis
31+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneMongodb> $mongodbs
32+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneMysql> $mysqls
33+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneMariadb> $mariadbs
34+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneKeydb> $keydbs
35+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneDragonfly> $dragonflies
36+
* @property \Illuminate\Database\Eloquent\Collection<int, StandaloneClickhouse> $clickhouses
37+
* @property \Illuminate\Database\Eloquent\Collection<int, Service> $services
38+
*/
2139
class Environment extends BaseModel
2240
{
2341
use ClearsGlobalSearchCache;

app/Models/EnvironmentVariable.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@
2929
'updated_at' => ['type' => 'string'],
3030
]
3131
)]
32+
/**
33+
* @property int $id
34+
* @property string $uuid
35+
* @property string $key
36+
* @property string|null $value
37+
* @property string|null $real_value
38+
* @property bool $is_literal
39+
* @property bool $is_multiline
40+
* @property bool $is_preview
41+
* @property bool $is_runtime
42+
* @property bool $is_buildtime
43+
* @property bool $is_shared
44+
* @property bool $is_shown_once
45+
* @property bool $is_required
46+
* @property string|null $version
47+
* @property string $resourceable_type
48+
* @property int $resourceable_id
49+
* @property Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|null $resourceable
50+
* @property Service|null $service
51+
*/
3252
class EnvironmentVariable extends BaseModel
3353
{
3454
protected $guarded = [];

app/Models/LocalFileVolume.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
use Illuminate\Database\Eloquent\Factories\HasFactory;
88
use Symfony\Component\Yaml\Yaml;
99

10+
/**
11+
* @property Application|Service|ServiceApplication|ServiceDatabase $resource
12+
* @property-read Service|null $service
13+
*/
1014
class LocalFileVolume extends BaseModel
1115
{
1216
protected $casts = [

app/Models/LocalPersistentVolume.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
use Illuminate\Database\Eloquent\Model;
77
use Symfony\Component\Yaml\Yaml;
88

9+
/**
10+
* @property int $id
11+
* @property string $name
12+
* @property string $mount_path
13+
* @property string|null $host_path
14+
* @property Application|Service|ServiceApplication|ServiceDatabase|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|null $resource
15+
*/
916
class LocalPersistentVolume extends Model
1017
{
1118
protected $guarded = [];

app/Models/Organization.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,30 @@
77
use Illuminate\Database\Eloquent\Model;
88

99
/**
10-
* @property-read WhiteLabelConfig|null $whiteLabelConfig
10+
* @property int $id
11+
* @property string $uuid
12+
* @property string $name
13+
* @property string|null $slug
14+
* @property bool $whitelabel_public_access
15+
* @property string|null $hierarchy_type
16+
* @property int|null $hierarchy_level
17+
* @property int|null $parent_organization_id
18+
* @property array|null $branding_config
19+
* @property array|null $feature_flags
20+
* @property bool $is_active
21+
* @property \Illuminate\Support\Carbon|null $created_at
22+
* @property \Illuminate\Support\Carbon|null $updated_at
23+
* @property-read \App\Models\Organization|null $parent
24+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Organization> $children
25+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
26+
* @property-read \App\Models\EnterpriseLicense|null $activeLicense
27+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\EnterpriseLicense> $licenses
28+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Server> $servers
29+
* @property-read \App\Models\WhiteLabelConfig|null $whiteLabelConfig
30+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CloudProviderCredential> $cloudProviderCredentials
31+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TerraformDeployment> $terraformDeployments
32+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Application> $applications
33+
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Domain> $domains
1134
*/
1235
class Organization extends Model
1336
{

app/Models/PrivateKey.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@
2727
'updated_at' => ['type' => 'string'],
2828
],
2929
)]
30+
/**
31+
* @property int $id
32+
* @property string $uuid
33+
* @property string $name
34+
* @property string|null $description
35+
* @property string $private_key
36+
* @property string $public_key
37+
* @property string|null $fingerprint
38+
* @property bool $is_git_related
39+
* @property int $team_id
40+
* @property Team $team
41+
* @property \Illuminate\Database\Eloquent\Collection<int, Server> $servers
42+
* @property \Illuminate\Database\Eloquent\Collection<int, GithubApp> $githubApps
43+
* @property \Illuminate\Database\Eloquent\Collection<int, GitlabApp> $gitlabApps
44+
* @property \Illuminate\Database\Eloquent\Collection<int, Application> $applications
45+
*/
3046
class PrivateKey extends BaseModel
3147
{
3248
use HasSafeStringAttribute, WithRateLimiting;

app/Models/Project.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
),
2424
]
2525
)]
26+
/**
27+
* @property int $id
28+
* @property string $uuid
29+
* @property string $name
30+
* @property string|null $description
31+
* @property int $team_id
32+
* @property \Illuminate\Database\Eloquent\Collection<int, Environment> $environments
33+
* @property \Illuminate\Database\Eloquent\Collection<int, SharedEnvironmentVariable> $environment_variables
34+
* @property ProjectSetting|null $settings
35+
* @property Team $team
36+
* @property \Illuminate\Database\Eloquent\Collection<int, Service> $services
37+
* @property \Illuminate\Database\Eloquent\Collection<int, Application> $applications
38+
*/
2639
class Project extends BaseModel
2740
{
2841
use ClearsGlobalSearchCache;

0 commit comments

Comments
 (0)