21
21
*/
22
22
class Message implements MessageInterface
23
23
{
24
- private $ version = '1.1 ' ;
25
- private $ headers = [];
26
- private $ body ;
27
-
28
- public function __construct (string $ version = '1.1 ' , array $ headers = [], StreamInterface $ body = null )
29
- {
30
- $ this ->version = $ version ;
31
- $ this ->headers = $ headers ;
32
- $ this ->body = $ body ?? new Stream ();
24
+ public function __construct (
25
+ private readonly string $ version = '1.1 ' ,
26
+ private array $ headers = [],
27
+ private readonly StreamInterface $ body = new Stream (),
28
+ ) {
33
29
}
34
30
35
31
public function getProtocolVersion (): string
36
32
{
37
33
return $ this ->version ;
38
34
}
39
35
40
- /**
41
- * {@inheritdoc}
42
- *
43
- * @return static
44
- */
45
- public function withProtocolVersion ($ version ): MessageInterface
36
+ public function withProtocolVersion ($ version ): never
46
37
{
47
38
throw new \BadMethodCallException ('Not implemented. ' );
48
39
}
@@ -67,34 +58,19 @@ public function getHeaderLine($name): string
67
58
return $ this ->hasHeader ($ name ) ? implode (', ' , $ this ->headers [$ name ]) : '' ;
68
59
}
69
60
70
- /**
71
- * {@inheritdoc}
72
- *
73
- * @return static
74
- */
75
- public function withHeader ($ name , $ value ): MessageInterface
61
+ public function withHeader ($ name , $ value ): static
76
62
{
77
63
$ this ->headers [$ name ] = (array ) $ value ;
78
64
79
65
return $ this ;
80
66
}
81
67
82
- /**
83
- * {@inheritdoc}
84
- *
85
- * @return static
86
- */
87
- public function withAddedHeader ($ name , $ value ): MessageInterface
68
+ public function withAddedHeader ($ name , $ value ): never
88
69
{
89
70
throw new \BadMethodCallException ('Not implemented. ' );
90
71
}
91
72
92
- /**
93
- * {@inheritdoc}
94
- *
95
- * @return static
96
- */
97
- public function withoutHeader ($ name ): MessageInterface
73
+ public function withoutHeader ($ name ): static
98
74
{
99
75
unset($ this ->headers [$ name ]);
100
76
@@ -108,10 +84,8 @@ public function getBody(): StreamInterface
108
84
109
85
/**
110
86
* {@inheritdoc}
111
- *
112
- * @return static
113
87
*/
114
- public function withBody (StreamInterface $ body ): MessageInterface
88
+ public function withBody (StreamInterface $ body ): never
115
89
{
116
90
throw new \BadMethodCallException ('Not implemented. ' );
117
91
}
0 commit comments