|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Http\Message\MessageFactory; |
|
4
|
|
|
|
|
5
|
|
|
use Http\Message\MessageFactory; |
|
6
|
|
|
use Http\Message\StreamFactory\DiactorosStreamFactory; |
|
7
|
|
|
use Laminas\Diactoros\Request as LaminasRequest; |
|
8
|
|
|
use Laminas\Diactoros\Response as LaminasResponse; |
|
9
|
|
|
use Zend\Diactoros\Request as ZendRequest; |
|
|
|
|
|
|
10
|
|
|
use Zend\Diactoros\Response as ZendResponse; |
|
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Creates Diactoros messages. |
|
14
|
|
|
* |
|
15
|
|
|
* @author GeLo <[email protected]> |
|
16
|
|
|
* |
|
17
|
|
|
* @deprecated This will be removed in php-http/message2.0. Consider using the official Diactoros PSR-17 factory |
|
18
|
|
|
*/ |
|
19
|
|
|
final class DiactorosMessageFactory implements MessageFactory |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
4 |
|
* @var DiactorosStreamFactory |
|
23
|
|
|
*/ |
|
24
|
4 |
|
private $streamFactory; |
|
25
|
4 |
|
|
|
26
|
|
|
public function __construct() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->streamFactory = new DiactorosStreamFactory(); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
1 |
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* {@inheritdoc} |
|
33
|
|
|
*/ |
|
34
|
|
|
public function createRequest( |
|
35
|
|
|
$method, |
|
36
|
|
|
$uri, |
|
37
|
1 |
|
array $headers = [], |
|
38
|
1 |
|
$body = null, |
|
39
|
1 |
|
$protocolVersion = '1.1' |
|
40
|
1 |
|
) { |
|
41
|
1 |
|
if (class_exists(LaminasRequest::class)) { |
|
42
|
1 |
|
return (new LaminasRequest( |
|
43
|
|
|
$uri, |
|
44
|
|
|
$method, |
|
45
|
|
|
$this->streamFactory->createStream($body), |
|
46
|
|
|
$headers |
|
47
|
|
|
))->withProtocolVersion($protocolVersion); |
|
48
|
1 |
|
} |
|
49
|
|
|
|
|
50
|
|
|
return (new ZendRequest( |
|
51
|
|
|
$uri, |
|
52
|
|
|
$method, |
|
53
|
|
|
$this->streamFactory->createStream($body), |
|
54
|
|
|
$headers |
|
55
|
1 |
|
))->withProtocolVersion($protocolVersion); |
|
56
|
1 |
|
} |
|
57
|
1 |
|
|
|
58
|
1 |
|
/** |
|
59
|
1 |
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function createResponse( |
|
62
|
|
|
$statusCode = 200, |
|
63
|
|
|
$reasonPhrase = null, |
|
64
|
|
|
array $headers = [], |
|
65
|
|
|
$body = null, |
|
66
|
|
|
$protocolVersion = '1.1' |
|
67
|
|
|
) { |
|
68
|
|
|
if (class_exists(LaminasResponse::class)) { |
|
69
|
|
|
return (new LaminasResponse( |
|
70
|
|
|
$this->streamFactory->createStream($body), |
|
71
|
|
|
$statusCode, |
|
72
|
|
|
$headers |
|
73
|
|
|
))->withProtocolVersion($protocolVersion); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return (new ZendResponse( |
|
77
|
|
|
$this->streamFactory->createStream($body), |
|
78
|
|
|
$statusCode, |
|
79
|
|
|
$headers |
|
80
|
|
|
))->withProtocolVersion($protocolVersion); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths