PasswordCallback::getPassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * AppserverIo\Psr\Security\Auth\Callback\PasswordCallback
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io-psr/security
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Psr\Security\Auth\Callback;
22
23
use AppserverIo\Lang\String;
24
25
/**
26
 * A password callback implementation.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2015 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/appserver-io-psr/security
32
 * @link      http://www.appserver.io
33
 */
34
class PasswordCallback implements CallbackInterface
35
{
36
37
    /**
38
     * The user's password.
39
     *
40
     * @var \AppserverIo\Lang\String
41
     */
42
    protected $password;
43
44
    /**
45
     * Set's the passed password.
46
     *
47
     * @param \AppserverIo\Lang\String $password The password to set
48
     *
49
     * @return void
50
     */
51 1
    public function setPassword(String $password)
52
    {
53 1
        $this->password = $password;
0 ignored issues
show
Documentation Bug introduced by
It seems like $password can also be of type string. However, the property $password is declared as type object<AppserverIo\Lang\String>. Maybe add an additional type check?

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 mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
54 1
    }
55
56
    /**
57
     * Return's the user's password.
58
     *
59
     * @return \AppserverIo\Lang\String The user's password
60
     */
61 2
    public function getPassword()
62
    {
63 2
        return $this->password;
64
    }
65
}
66