Skip to content

Commit 144249b

Browse files
Add phpdocs in class generated by make:user
1 parent f63b0c0 commit 144249b

8 files changed

+65
-9
lines changed

src/Security/UserClassBuilder.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,41 @@ private function addGetRoles(ClassSourceManipulator $manipulator, UserClassConfi
102102
'roles',
103103
[
104104
'type' => 'json',
105+
],
106+
[
107+
'@var list<string> The user roles',
105108
]
106109
);
107110
} else {
108111
// add normal property
109112
$manipulator->addProperty(
110113
name: 'roles',
111-
defaultValue: new Node\Expr\Array_([], ['kind' => Node\Expr\Array_::KIND_SHORT])
114+
defaultValue: new Node\Expr\Array_([], ['kind' => Node\Expr\Array_::KIND_SHORT]),
115+
comments: [
116+
'@var list<string> The user roles',
117+
]
112118
);
113119

114120
$manipulator->addGetter(
115121
'roles',
116122
'array',
117-
false
118-
);
119-
120-
$manipulator->addSetter(
121-
'roles',
122-
'array',
123-
false
123+
false,
124124
);
125125
}
126126

127+
$manipulator->addSetter(
128+
'roles',
129+
'array',
130+
false,
131+
['@param list<string> $roles']
132+
);
133+
127134
// define getRoles (if it was defined above, this will override)
128135
$builder = $manipulator->createMethodBuilder(
129136
'getRoles',
130137
'array',
131138
false,
132-
['@see UserInterface']
139+
['@see UserInterface', '@return list<string>']
133140
);
134141

135142
// $roles = $this->roles

tests/Security/fixtures/expected/UserEntityWithEmailAsIdentifier.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
1717
#[ORM\Column(length: 180, unique: true)]
1818
private ?string $email = null;
1919

20+
/**
21+
* @var list<string> The user roles
22+
*/
2023
#[ORM\Column]
2124
private array $roles = [];
2225

@@ -55,6 +58,7 @@ public function getUserIdentifier(): string
5558

5659
/**
5760
* @see UserInterface
61+
* @return list<string>
5862
*/
5963
public function getRoles(): array
6064
{
@@ -65,6 +69,9 @@ public function getRoles(): array
6569
return array_unique($roles);
6670
}
6771

72+
/**
73+
* @param list<string> $roles
74+
*/
6875
public function setRoles(array $roles): static
6976
{
7077
$this->roles = $roles;

tests/Security/fixtures/expected/UserEntityWithPassword.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
1717
#[ORM\Column(length: 180, unique: true)]
1818
private ?string $userIdentifier = null;
1919

20+
/**
21+
* @var list<string> The user roles
22+
*/
2023
#[ORM\Column]
2124
private array $roles = [];
2225

@@ -50,6 +53,7 @@ public function setUserIdentifier(string $userIdentifier): static
5053

5154
/**
5255
* @see UserInterface
56+
* @return list<string>
5357
*/
5458
public function getRoles(): array
5559
{
@@ -60,6 +64,9 @@ public function getRoles(): array
6064
return array_unique($roles);
6165
}
6266

67+
/**
68+
* @param list<string> $roles
69+
*/
6370
public function setRoles(array $roles): static
6471
{
6572
$this->roles = $roles;

tests/Security/fixtures/expected/UserEntityWithUser_IdentifierAsIdentifier.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
1717
#[ORM\Column(length: 180, unique: true)]
1818
private ?string $user_identifier = null;
1919

20+
/**
21+
* @var list<string> The user roles
22+
*/
2023
#[ORM\Column]
2124
private array $roles = [];
2225

@@ -50,6 +53,7 @@ public function setUserIdentifier(string $user_identifier): static
5053

5154
/**
5255
* @see UserInterface
56+
* @return list<string>
5357
*/
5458
public function getRoles(): array
5559
{
@@ -60,6 +64,9 @@ public function getRoles(): array
6064
return array_unique($roles);
6165
}
6266

67+
/**
68+
* @param list<string> $roles
69+
*/
6370
public function setRoles(array $roles): static
6471
{
6572
$this->roles = $roles;

tests/Security/fixtures/expected/UserEntityWithoutPassword.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class User implements UserInterface
1616
#[ORM\Column(length: 180, unique: true)]
1717
private ?string $userIdentifier = null;
1818

19+
/**
20+
* @var list<string> The user roles
21+
*/
1922
#[ORM\Column]
2023
private array $roles = [];
2124

@@ -43,6 +46,7 @@ public function setUserIdentifier(string $userIdentifier): static
4346

4447
/**
4548
* @see UserInterface
49+
* @return list<string>
4650
*/
4751
public function getRoles(): array
4852
{
@@ -53,6 +57,9 @@ public function getRoles(): array
5357
return array_unique($roles);
5458
}
5559

60+
/**
61+
* @param list<string> $roles
62+
*/
5663
public function setRoles(array $roles): static
5764
{
5865
$this->roles = $roles;

tests/Security/fixtures/expected/UserModelWithEmailAsIdentifier.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
99
{
1010
private $email;
1111

12+
/**
13+
* @var list<string> The user roles
14+
*/
1215
private $roles = [];
1316

1417
/**
@@ -40,6 +43,7 @@ public function getUserIdentifier(): string
4043

4144
/**
4245
* @see UserInterface
46+
* @return list<string>
4347
*/
4448
public function getRoles(): array
4549
{
@@ -50,6 +54,9 @@ public function getRoles(): array
5054
return array_unique($roles);
5155
}
5256

57+
/**
58+
* @param list<string> $roles
59+
*/
5360
public function setRoles(array $roles): static
5461
{
5562
$this->roles = $roles;

tests/Security/fixtures/expected/UserModelWithPassword.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
99
{
1010
private $userIdentifier;
1111

12+
/**
13+
* @var list<string> The user roles
14+
*/
1215
private $roles = [];
1316

1417
/**
@@ -35,6 +38,7 @@ public function setUserIdentifier(string $userIdentifier): static
3538

3639
/**
3740
* @see UserInterface
41+
* @return list<string>
3842
*/
3943
public function getRoles(): array
4044
{
@@ -45,6 +49,9 @@ public function getRoles(): array
4549
return array_unique($roles);
4650
}
4751

52+
/**
53+
* @param list<string> $roles
54+
*/
4855
public function setRoles(array $roles): static
4956
{
5057
$this->roles = $roles;

tests/Security/fixtures/expected/UserModelWithoutPassword.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class User implements UserInterface
88
{
99
private $userIdentifier;
1010

11+
/**
12+
* @var list<string> The user roles
13+
*/
1114
private $roles = [];
1215

1316
/**
@@ -29,6 +32,7 @@ public function setUserIdentifier(string $userIdentifier): static
2932

3033
/**
3134
* @see UserInterface
35+
* @return list<string>
3236
*/
3337
public function getRoles(): array
3438
{
@@ -39,6 +43,9 @@ public function getRoles(): array
3943
return array_unique($roles);
4044
}
4145

46+
/**
47+
* @param list<string> $roles
48+
*/
4249
public function setRoles(array $roles): static
4350
{
4451
$this->roles = $roles;

0 commit comments

Comments
 (0)