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 SubjectVerifierTest 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 subject value. |
||
29 | */ |
||
30 | public function testInvalidSubject() |
||
31 | { |
||
32 | new SubjectVerifier(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 testNoSubject() |
||
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\Subject::NAME) |
||
44 | ->will($this->returnValue(null)); |
||
45 | |||
46 | $verifier = new SubjectVerifier(); |
||
47 | $verifier->verify($this->token); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @expectedException \Emarref\Jwt\Exception\InvalidSubjectException |
||
52 | * @expectedExceptionMessage Subject is invalid. |
||
53 | */ |
||
54 | public function testSubjectInPayloadOnly() |
||
55 | { |
||
56 | $subjectClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Subject') |
||
57 | ->getMock(); |
||
58 | |||
59 | $subjectClaim->expects($this->once()) |
||
60 | ->method('getValue') |
||
61 | ->will($this->returnValue('a_subject')); |
||
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\Subject::NAME) |
||
70 | ->will($this->returnValue($subjectClaim)); |
||
71 | |||
72 | $verifier = new SubjectVerifier(); |
||
73 | $verifier->verify($this->token); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @expectedException \Emarref\Jwt\Exception\InvalidSubjectException |
||
78 | * @expectedExceptionMessage Subject is invalid. |
||
79 | */ |
||
80 | public function testSubjectInContextOnly() |
||
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\Subject::NAME) |
||
89 | ->will($this->returnValue(null)); |
||
90 | |||
91 | $verifier = new SubjectVerifier('a_subject'); |
||
92 | $verifier->verify($this->token); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @expectedException \Emarref\Jwt\Exception\InvalidSubjectException |
||
97 | * @expectedExceptionMessage Subject is invalid. |
||
98 | */ |
||
99 | public function testSubjectMismatch() |
||
100 | { |
||
101 | $subjectClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Subject') |
||
102 | ->getMock(); |
||
103 | |||
104 | $subjectClaim->expects($this->once()) |
||
105 | ->method('getValue') |
||
106 | ->will($this->returnValue('a_subject')); |
||
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\Subject::NAME) |
||
115 | ->will($this->returnValue($subjectClaim)); |
||
116 | |||
117 | $verifier = new SubjectVerifier('some_other_subject'); |
||
118 | $verifier->verify($this->token); |
||
119 | } |
||
120 | |||
121 | public function testSuccess() |
||
122 | { |
||
123 | $subjectClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Subject') |
||
124 | ->getMock(); |
||
125 | |||
126 | $subjectClaim->expects($this->once()) |
||
127 | ->method('getValue') |
||
128 | ->will($this->returnValue('a_subject')); |
||
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\Subject::NAME) |
||
137 | ->will($this->returnValue($subjectClaim)); |
||
138 | |||
139 | $verifier = new SubjectVerifier('a_subject'); |
||
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.