1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\ApiBundle\Entity\oAuth2; |
||
13 | |||
14 | use Doctrine\ORM\Mapping as ORM; |
||
15 | use FOS\OAuthServerBundle\Model\AccessToken as BaseAccessToken; |
||
16 | use FOS\OAuthServerBundle\Model\ClientInterface; |
||
17 | use Mautic\CoreBundle\Doctrine\Mapping\ClassMetadataBuilder; |
||
18 | use Symfony\Component\Security\Core\User\UserInterface; |
||
19 | |||
20 | /** |
||
21 | * Class AccessToken. |
||
22 | */ |
||
23 | class AccessToken extends BaseAccessToken |
||
24 | { |
||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * @var Client |
||
32 | */ |
||
33 | protected $client; |
||
34 | |||
35 | /** |
||
36 | * @var \Mautic\UserBundle\Entity\User |
||
37 | */ |
||
38 | protected $user; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $token; |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $expiresAt; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $scope; |
||
54 | |||
55 | public static function loadMetadata(ORM\ClassMetadata $metadata) |
||
56 | { |
||
57 | $builder = new ClassMetadataBuilder($metadata); |
||
58 | |||
59 | $builder->setTable('oauth2_accesstokens') |
||
60 | ->addIndex(['token'], 'oauth2_access_token_search'); |
||
61 | |||
62 | $builder->createField('id', 'integer') |
||
63 | ->isPrimaryKey() |
||
64 | ->generatedValue() |
||
65 | ->build(); |
||
66 | |||
67 | $builder->createManyToOne('client', 'Client') |
||
68 | ->addJoinColumn('client_id', 'id', false, false, 'CASCADE') |
||
69 | ->build(); |
||
70 | |||
71 | $builder->createManyToOne('user', 'Mautic\UserBundle\Entity\User') |
||
72 | ->addJoinColumn('user_id', 'id', false, false, 'CASCADE') |
||
73 | ->build(); |
||
74 | |||
75 | $builder->createField('token', 'string') |
||
76 | ->unique() |
||
77 | ->build(); |
||
78 | |||
79 | $builder->createField('expiresAt', 'bigint') |
||
80 | ->columnName('expires_at') |
||
81 | ->nullable() |
||
82 | ->build(); |
||
83 | |||
84 | $builder->createField('scope', 'string') |
||
85 | ->nullable() |
||
86 | ->build(); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Get id. |
||
91 | * |
||
92 | * @return int |
||
93 | */ |
||
94 | public function getId() |
||
95 | { |
||
96 | return $this->id; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Set client. |
||
101 | * |
||
102 | * @return AccessToken |
||
103 | */ |
||
104 | public function setClient(ClientInterface $client) |
||
105 | { |
||
106 | $this->client = $client; |
||
0 ignored issues
–
show
|
|||
107 | |||
108 | return $this; |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Get client. |
||
113 | * |
||
114 | * @return ClientInterface |
||
115 | */ |
||
116 | public function getClient() |
||
117 | { |
||
118 | return $this->client; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Set user. |
||
123 | * |
||
124 | * @param UserInterface $user |
||
125 | * |
||
126 | * @return AccessToken |
||
127 | */ |
||
128 | public function setUser(UserInterface $user = null) |
||
129 | { |
||
130 | $this->user = $user; |
||
131 | |||
132 | return $this; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Get user. |
||
137 | * |
||
138 | * @return UserInterface |
||
139 | */ |
||
140 | public function getUser() |
||
141 | { |
||
142 | return $this->user; |
||
143 | } |
||
144 | } |
||
145 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.