1515use Lcobucci \JWT \Signer \Key \InMemory ;
1616use Lcobucci \JWT \Signer \Rsa \Sha256 ;
1717use Lcobucci \JWT \Token ;
18- use League \OAuth2 \Server \CryptKey ;
18+ use League \OAuth2 \Server \CryptKeyInterface ;
1919use League \OAuth2 \Server \Entities \AccessTokenEntityInterface ;
2020use League \OAuth2 \Server \Entities \ClientEntityInterface ;
2121use League \OAuth2 \Server \Entities \ScopeEntityInterface ;
@@ -33,8 +33,9 @@ class OAuthAccessToken implements AccessTokenEntityInterface
3333 #[ORM \JoinColumn(name: 'client_id ' , referencedColumnName: 'id ' )]
3434 private ClientEntityInterface $ client ;
3535
36- #[ORM \Column(name: 'user_id ' , type: 'string ' , length: 25 , nullable: true )]
37- private ?string $ userId = null ;
36+ /** @var non-empty-string $userId */
37+ #[ORM \Column(name: 'user_id ' , type: 'string ' , length: 25 )]
38+ private string $ userId ;
3839
3940 /** @var non-empty-string $token */
4041 #[ORM \Column(name: 'token ' , type: 'string ' , length: 100 )]
@@ -53,7 +54,7 @@ class OAuthAccessToken implements AccessTokenEntityInterface
5354 #[ORM \Column(name: 'expires_at ' , type: 'datetime_immutable ' )]
5455 private DateTimeImmutable $ expiresAt ;
5556
56- private ?CryptKey $ privateKey = null ;
57+ private ?CryptKeyInterface $ privateKey = null ;
5758
5859 private ?Configuration $ jwtConfiguration = null ;
5960
@@ -62,11 +63,9 @@ public function __construct()
6263 $ this ->scopes = new ArrayCollection ();
6364 }
6465
65- public function setClient (ClientEntityInterface $ client ): self
66+ public function setClient (ClientEntityInterface $ client ): void
6667 {
6768 $ this ->client = $ client ;
68-
69- return $ this ;
7069 }
7170
7271 public function getClient (): ClientEntityInterface
@@ -85,11 +84,9 @@ public function getToken(): string
8584 /**
8685 * @param non-empty-string $token
8786 */
88- public function setToken (string $ token ): self
87+ public function setToken (string $ token ): void
8988 {
9089 $ this ->token = $ token ;
91-
92- return $ this ;
9390 }
9491
9592 public function setIsRevoked (bool $ isRevoked ): self
@@ -122,37 +119,33 @@ public function getIdentifier(): string
122119 /**
123120 * @param mixed $identifier
124121 */
125- public function setIdentifier ($ identifier ): self
122+ public function setIdentifier ($ identifier ): void
126123 {
127- return $ this ->setToken ($ identifier );
124+ $ this ->setToken ($ identifier );
128125 }
129126
130127 /**
131- * @param string|int|null $identifier
128+ * @param non-empty- string|int $identifier
132129 */
133- public function setUserIdentifier ($ identifier ): self
130+ public function setUserIdentifier ($ identifier ): void
134131 {
135132 if (is_int ($ identifier )) {
136133 $ identifier = (string ) $ identifier ;
137134 }
138135
139136 $ this ->userId = $ identifier ;
140-
141- return $ this ;
142137 }
143138
144- public function getUserIdentifier (): ? string
139+ public function getUserIdentifier (): string
145140 {
146141 return $ this ->userId ;
147142 }
148143
149- public function addScope (ScopeEntityInterface $ scope ): self
144+ public function addScope (ScopeEntityInterface $ scope ): void
150145 {
151146 if (! $ this ->scopes ->contains ($ scope )) {
152147 $ this ->scopes ->add ($ scope );
153148 }
154-
155- return $ this ;
156149 }
157150
158151 public function removeScope (OAuthScope $ scope ): self
@@ -178,18 +171,14 @@ public function getExpiryDateTime(): DateTimeImmutable
178171 return $ this ->expiresAt ;
179172 }
180173
181- public function setExpiryDateTime (DateTimeImmutable $ dateTime ): self
174+ public function setExpiryDateTime (DateTimeImmutable $ dateTime ): void
182175 {
183176 $ this ->expiresAt = $ dateTime ;
184-
185- return $ this ;
186177 }
187178
188- public function setPrivateKey (CryptKey $ privateKey ): self
179+ public function setPrivateKey (CryptKeyInterface $ privateKey ): void
189180 {
190181 $ this ->privateKey = $ privateKey ;
191-
192- return $ this ;
193182 }
194183
195184 public function initJwtConfiguration (): self
@@ -238,4 +227,9 @@ public function __toString(): string
238227 {
239228 return $ this ->convertToJWT ()->toString ();
240229 }
230+
231+ public function toString (): string
232+ {
233+ return $ this ->convertToJWT ()->toString ();
234+ }
241235}
0 commit comments