This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Emarref\Jwt\Verification; |
||
4 | |||
5 | use Emarref\Jwt\Claim; |
||
6 | |||
7 | View Code Duplication | class IssuerVerifierTest extends \PHPUnit_Framework_TestCase |
|
0 ignored issues
–
show
|
|||
8 | { |
||
9 | /** |
||
10 | * @var \PHPUnit_Framework_MockObject_MockObject|\Emarref\Jwt\Token\Payload |
||
11 | */ |
||
12 | private $payload; |
||
13 | |||
14 | /** |
||
15 | * @var \PHPUnit_Framework_MockObject_MockObject|\Emarref\Jwt\Token |
||
16 | */ |
||
17 | private $token; |
||
18 | |||
19 | public function setUp() |
||
20 | { |
||
21 | $this->payload = $this->getMockBuilder('Emarref\Jwt\Token\Payload')->getMock(); |
||
22 | |||
23 | $this->token = $this->getMockBuilder('Emarref\Jwt\Token')->getMock(); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @expectedException \InvalidArgumentException |
||
28 | * @expectedExceptionMessage Cannot verify invalid issuer value. |
||
29 | */ |
||
30 | public function testInvalidIssuer() |
||
31 | { |
||
32 | new IssuerVerifier(new \stdClass()); |
||
0 ignored issues
–
show
new \stdClass() is of type object<stdClass> , but the function expects a string|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
33 | } |
||
34 | |||
35 | public function testNoIssuer() |
||
36 | { |
||
37 | $this->token->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
38 | ->method('getPayload') |
||
39 | ->will($this->returnValue($this->payload)); |
||
40 | |||
41 | $this->payload->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token\Payload .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
42 | ->method('findClaimByName') |
||
43 | ->with(Claim\Issuer::NAME) |
||
44 | ->will($this->returnValue(null)); |
||
45 | |||
46 | $verifier = new IssuerVerifier(); |
||
47 | $verifier->verify($this->token); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @expectedException \Emarref\Jwt\Exception\InvalidIssuerException |
||
52 | * @expectedExceptionMessage Issuer is invalid. |
||
53 | */ |
||
54 | public function testIssuerInPayloadOnly() |
||
55 | { |
||
56 | $issuerClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Issuer') |
||
57 | ->getMock(); |
||
58 | |||
59 | $issuerClaim->expects($this->once()) |
||
60 | ->method('getValue') |
||
61 | ->will($this->returnValue('an_issuer')); |
||
62 | |||
63 | $this->token->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
64 | ->method('getPayload') |
||
65 | ->will($this->returnValue($this->payload)); |
||
66 | |||
67 | $this->payload->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token\Payload .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
68 | ->method('findClaimByName') |
||
69 | ->with(Claim\Issuer::NAME) |
||
70 | ->will($this->returnValue($issuerClaim)); |
||
71 | |||
72 | $verifier = new IssuerVerifier(); |
||
73 | $verifier->verify($this->token); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @expectedException \Emarref\Jwt\Exception\InvalidIssuerException |
||
78 | * @expectedExceptionMessage Issuer is invalid. |
||
79 | */ |
||
80 | public function testIssuerInContextOnly() |
||
81 | { |
||
82 | $this->token->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
83 | ->method('getPayload') |
||
84 | ->will($this->returnValue($this->payload)); |
||
85 | |||
86 | $this->payload->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token\Payload .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
87 | ->method('findClaimByName') |
||
88 | ->with(Claim\Issuer::NAME) |
||
89 | ->will($this->returnValue(null)); |
||
90 | |||
91 | $verifier = new IssuerVerifier('an_issuer'); |
||
92 | $verifier->verify($this->token); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @expectedException \Emarref\Jwt\Exception\InvalidIssuerException |
||
97 | * @expectedExceptionMessage Issuer is invalid. |
||
98 | */ |
||
99 | public function testIssuerMismatch() |
||
100 | { |
||
101 | $issuerClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Issuer') |
||
102 | ->getMock(); |
||
103 | |||
104 | $issuerClaim->expects($this->once()) |
||
105 | ->method('getValue') |
||
106 | ->will($this->returnValue('an_issuer')); |
||
107 | |||
108 | $this->token->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
109 | ->method('getPayload') |
||
110 | ->will($this->returnValue($this->payload)); |
||
111 | |||
112 | $this->payload->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token\Payload .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
113 | ->method('findClaimByName') |
||
114 | ->with(Claim\Issuer::NAME) |
||
115 | ->will($this->returnValue($issuerClaim)); |
||
116 | |||
117 | $verifier = new IssuerVerifier('some_other_issuer'); |
||
118 | $verifier->verify($this->token); |
||
119 | } |
||
120 | |||
121 | public function testSuccess() |
||
122 | { |
||
123 | $issuerClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Issuer') |
||
124 | ->getMock(); |
||
125 | |||
126 | $issuerClaim->expects($this->once()) |
||
127 | ->method('getValue') |
||
128 | ->will($this->returnValue('an_issuer')); |
||
129 | |||
130 | $this->token->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
131 | ->method('getPayload') |
||
132 | ->will($this->returnValue($this->payload)); |
||
133 | |||
134 | $this->payload->expects($this->once()) |
||
0 ignored issues
–
show
The method
expects does only exist in PHPUnit_Framework_MockObject_MockObject , but not in Emarref\Jwt\Token\Payload .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
135 | ->method('findClaimByName') |
||
136 | ->with(Claim\Issuer::NAME) |
||
137 | ->will($this->returnValue($issuerClaim)); |
||
138 | |||
139 | $verifier = new IssuerVerifier('an_issuer'); |
||
140 | $verifier->verify($this->token); |
||
141 | } |
||
142 | } |
||
143 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.