MethodNotFoundException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 47
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getClassname() 0 4 1
A getMethodName() 0 4 1
A getArguments() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Prophecy.
5
 * (c) Konstantin Kudryashov <[email protected]>
6
 *     Marcello Duarte <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Prophecy\Exception\Doubler;
13
14
class MethodNotFoundException extends DoubleException
15
{
16
    /**
17
     * @var string|object
18
     */
19
    private $classname;
20
21
    /**
22
     * @var string
23
     */
24
    private $methodName;
25
26
    /**
27
     * @var array
28
     */
29
    private $arguments;
30
31
    /**
32
     * @param string $message
33
     * @param string|object $classname
34
     * @param string $methodName
35
     * @param null|Argument\ArgumentsWildcard|array $arguments
36
     */
37
    public function __construct($message, $classname, $methodName, $arguments = null)
38
    {
39
        parent::__construct($message);
40
41
        $this->classname  = $classname;
42
        $this->methodName = $methodName;
43
        $this->arguments = $arguments;
0 ignored issues
show
Documentation Bug introduced by
It seems like $arguments can also be of type null or object<Prophecy\Exceptio...ment\ArgumentsWildcard>. However, the property $arguments is declared as type array. 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...
44
    }
45
46
    public function getClassname()
47
    {
48
        return $this->classname;
49
    }
50
51
    public function getMethodName()
52
    {
53
        return $this->methodName;
54
    }
55
56
    public function getArguments()
57
    {
58
        return $this->arguments;
59
    }
60
}
61