Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
27 | public function post($params) |
||
28 | { |
||
29 | // Get the token |
||
30 | $token = AuthenticationAction::getAccessTokenFromHeader(); |
||
31 | |||
32 | $refreshToken = Yii::$app->request->post('refresh_token', false); |
||
33 | if ($refreshToken !== $token->refresh_token) { |
||
34 | return false; |
||
35 | } |
||
36 | |||
37 | // If we can delete the token, send a newly generated token out |
||
38 | if ($token->delete()) { |
||
39 | // Merge any extra attributes with the generated tokens |
||
40 | $tokens = ArrayHelper::merge($this->extraAttributes, Token::generate(Yii::$app->user->id)->getAuthResponse()); |
||
41 | // Merge the identity attributes |
||
42 | foreach ($this->identityAttributes as $attr) { |
||
43 | $tokens[$attr] = Yii::$app->user->getIdentity()->$attr; |
||
44 | } |
||
45 | return $tokens; |
||
46 | } |
||
47 | // Return false for any other reasons |
||
48 | return false; |
||
49 | } |
||
50 | } |
||
51 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: