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 | declare(strict_types=1); |
||
3 | |||
4 | namespace Northwoods\Broker; |
||
5 | |||
6 | use Eloquent\Phony\Mock\Handle\InstanceHandle; |
||
7 | use Eloquent\Phony\Phpunit\Phony; |
||
8 | use OutOfBoundsException; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | use Psr\Http\Message\ResponseInterface; |
||
11 | use Psr\Http\Message\ServerRequestInterface; |
||
12 | use Psr\Http\Server\MiddlewareInterface; |
||
13 | use Psr\Http\Server\RequestHandlerInterface; |
||
14 | |||
15 | class BrokerTest extends TestCase |
||
16 | { |
||
17 | /** @var Broker */ |
||
18 | private $broker; |
||
19 | |||
20 | public function setUp(): void |
||
21 | { |
||
22 | $this->broker = new Broker(); |
||
23 | } |
||
24 | |||
25 | View Code Duplication | public function testCanAppendMiddleware(): void |
|
0 ignored issues
–
show
|
|||
26 | { |
||
27 | // Mock |
||
28 | $mw1 = $this->mockMiddleware(); |
||
29 | $mw2 = $this->mockMiddleware(); |
||
30 | |||
31 | $this->broker->append($mw1->get(), $mw2->get()); |
||
32 | |||
33 | // Execute |
||
34 | $response = $this->broker->process( |
||
0 ignored issues
–
show
$response is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
35 | $this->mockRequest()->get(), |
||
0 ignored issues
–
show
$this->mockRequest()->get() is of type object<Eloquent\Phony\Mock\Mock> , but the function expects a object<Psr\Http\Message\ServerRequestInterface> .
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);
![]() |
|||
36 | $this->mockHandler()->get() |
||
0 ignored issues
–
show
$this->mockHandler()->get() is of type object<Eloquent\Phony\Mock\Mock> , but the function expects a object<Psr\Http\Server\RequestHandlerInterface> .
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);
![]() |
|||
37 | ); |
||
38 | |||
39 | // Verify |
||
40 | Phony::inOrder( |
||
41 | $mw1->process->once()->called(), |
||
42 | $mw2->process->once()->called() |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | View Code Duplication | public function testCanPrependMiddleware(): void |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
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. ![]() |
|||
47 | { |
||
48 | // Mock |
||
49 | $mw1 = $this->mockMiddleware(); |
||
50 | $mw2 = $this->mockMiddleware(); |
||
51 | |||
52 | $this->broker->append($mw1->get()); |
||
53 | $this->broker->prepend($mw2->get()); |
||
54 | |||
55 | // Execute |
||
56 | $response = $this->broker->process( |
||
0 ignored issues
–
show
$response is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
57 | $this->mockRequest()->get(), |
||
0 ignored issues
–
show
$this->mockRequest()->get() is of type object<Eloquent\Phony\Mock\Mock> , but the function expects a object<Psr\Http\Message\ServerRequestInterface> .
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);
![]() |
|||
58 | $this->mockHandler()->get() |
||
0 ignored issues
–
show
$this->mockHandler()->get() is of type object<Eloquent\Phony\Mock\Mock> , but the function expects a object<Psr\Http\Server\RequestHandlerInterface> .
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);
![]() |
|||
59 | ); |
||
60 | |||
61 | // Verify |
||
62 | Phony::inOrder( |
||
63 | $mw2->process->once()->called(), |
||
64 | $mw1->process->once()->called() |
||
65 | ); |
||
66 | } |
||
67 | |||
68 | public function testCannotHandleWithoutMiddleware(): void |
||
69 | { |
||
70 | // Expect |
||
71 | $this->expectException(OutOfBoundsException::class); |
||
72 | |||
73 | // Execute |
||
74 | $this->broker->handle( |
||
75 | $this->mockRequest()->get() |
||
0 ignored issues
–
show
$this->mockRequest()->get() is of type object<Eloquent\Phony\Mock\Mock> , but the function expects a object<Psr\Http\Message\ServerRequestInterface> .
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);
![]() |
|||
76 | ); |
||
77 | } |
||
78 | |||
79 | private function mockHandler(): InstanceHandle |
||
80 | { |
||
81 | $handler = Phony::mock(RequestHandlerInterface::class); |
||
82 | $handler->handle->returns($this->mockResponse()); |
||
83 | |||
84 | return $handler; |
||
85 | } |
||
86 | |||
87 | private function mockMiddleware(): InstanceHandle |
||
88 | { |
||
89 | $middleware = Phony::mock(MiddlewareInterface::class); |
||
90 | |||
91 | $middleware->process->does(function ($request, $handler) { |
||
92 | return $handler->handle($request); |
||
93 | }); |
||
94 | |||
95 | return $middleware; |
||
96 | } |
||
97 | |||
98 | private function mockRequest(): InstanceHandle |
||
99 | { |
||
100 | return Phony::mock(ServerRequestInterface::class); |
||
101 | } |
||
102 | |||
103 | private function mockResponse(): InstanceHandle |
||
104 | { |
||
105 | return Phony::mock(ResponseInterface::class); |
||
106 | } |
||
107 | } |
||
108 |
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.