Skip to content

Commit f2944c1

Browse files
E4SdJG528X9FsnpaBz6yxwd3v2a
authored andcommitted
test: case for the issue barryvdh#1505;
duplication of properties that have generic types specified and descriptions;
1 parent a147618 commit f2944c1

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
11+
* @property array<int, string> $cast_to_json some-description
12+
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description
13+
*
14+
* @property array|null $cast_to_encrypted_array -- These three are OK (no types)
15+
* @property array $cast_to_encrypted_json some-description
16+
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description
17+
*
18+
* @property string $cast_to_string -- The next three are OK (no description), this not included
19+
*
20+
* @property array<int, string>|null $cast_to_immutable_date
21+
* @property array<int, string> $cast_to_immutable_date_serialization
22+
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime
23+
*/
24+
class ArrayCastsWithComment extends Model
25+
{
26+
protected $table = 'simple_casts';
27+
28+
protected $casts = [
29+
'cast_to_array' => 'array',
30+
'cast_to_json' => 'json',
31+
'cast_to_collection' => 'collection',
32+
33+
'cast_to_encrypted_array' => 'array',
34+
'cast_to_encrypted_json' => 'json',
35+
'cast_to_encrypted_collection' => 'collection',
36+
37+
'cast_to_string' => 'string',
38+
39+
'cast_to_immutable_date' => 'array',
40+
'cast_to_immutable_date_serialization' => 'json',
41+
'cast_to_immutable_custom_datetime' => 'collection',
42+
];
43+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment;
6+
7+
use Barryvdh\LaravelIdeHelper\Console\ModelsCommand;
8+
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AbstractModelsCommand;
9+
10+
class Test extends AbstractModelsCommand
11+
{
12+
public function test(): void
13+
{
14+
$command = $this->app->make(ModelsCommand::class);
15+
16+
$tester = $this->runCommand($command, [
17+
'--write' => true,
18+
]);
19+
20+
$this->assertSame(0, $tester->getStatusCode());
21+
$this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay());
22+
$this->assertMatchesMockedSnapshot();
23+
}
24+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models;
6+
7+
use Illuminate\Database\Eloquent\Model;
8+
9+
/**
10+
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models\ArrayCastsWithComment
11+
*
12+
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
13+
* @property array<int, string> $cast_to_json some-description
14+
* @property \Illuminate\Support\Collection<int, string> $cast_to_collection some-description
15+
* @property array|null $cast_to_encrypted_array -- These three are OK (no types)
16+
* @property array $cast_to_encrypted_json some-description
17+
* @property \Illuminate\Support\Collection $cast_to_encrypted_collection some-description
18+
* @property string $cast_to_string -- The next three are OK (no description), this not included
19+
* @property array<int, string>|null $cast_to_immutable_date
20+
* @property array<int, string> $cast_to_immutable_date_serialization
21+
* @property \Illuminate\Support\Collection<int, string> $cast_to_immutable_custom_datetime
22+
* @property string $cast_to_int
23+
* @property string $cast_to_integer
24+
* @property string $cast_to_real
25+
* @property string $cast_to_float
26+
* @property string $cast_to_double
27+
* @property string $cast_to_decimal
28+
* @property string $cast_to_bool
29+
* @property string $cast_to_boolean
30+
* @property string $cast_to_object
31+
* @property string $cast_to_date
32+
* @property string $cast_to_datetime
33+
* @property string $cast_to_date_serialization
34+
* @property string $cast_to_datetime_serialization
35+
* @property string $cast_to_custom_datetime
36+
* @property string $cast_to_immutable_datetime
37+
* @property string $cast_to_immutable_datetime_serialization
38+
* @property string $cast_to_timestamp
39+
* @property string $cast_to_encrypted
40+
* @property string $cast_to_encrypted_object
41+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newModelQuery()
42+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment newQuery()
43+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment query()
44+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToArray($value)
45+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBool($value)
46+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToBoolean($value)
47+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCollection($value)
48+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToCustomDatetime($value)
49+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDate($value)
50+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDateSerialization($value)
51+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetime($value)
52+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDatetimeSerialization($value)
53+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDecimal($value)
54+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToDouble($value)
55+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncrypted($value)
56+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedArray($value)
57+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedCollection($value)
58+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedJson($value)
59+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToEncryptedObject($value)
60+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToFloat($value)
61+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableCustomDatetime($value)
62+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDate($value)
63+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDateSerialization($value)
64+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetime($value)
65+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToImmutableDatetimeSerialization($value)
66+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInt($value)
67+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToInteger($value)
68+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToJson($value)
69+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToObject($value)
70+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToReal($value)
71+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToString($value)
72+
* @method static \Illuminate\Database\Eloquent\Builder|ArrayCastsWithComment whereCastToTimestamp($value)
73+
* @mixin \Eloquent
74+
*/
75+
class ArrayCastsWithComment extends Model
76+
{
77+
protected $table = 'simple_casts';
78+
79+
protected $casts = [
80+
'cast_to_array' => 'array',
81+
'cast_to_json' => 'json',
82+
'cast_to_collection' => 'collection',
83+
84+
'cast_to_encrypted_array' => 'array',
85+
'cast_to_encrypted_json' => 'json',
86+
'cast_to_encrypted_collection' => 'collection',
87+
88+
'cast_to_string' => 'string',
89+
90+
'cast_to_immutable_date' => 'array',
91+
'cast_to_immutable_date_serialization' => 'json',
92+
'cast_to_immutable_custom_datetime' => 'collection',
93+
];
94+
}

0 commit comments

Comments
 (0)