19
19
class RequestMatcher implements RequestMatcherInterface
20
20
{
21
21
/**
22
- * @var string
22
+ * @var string|null
23
23
*/
24
24
private $ path ;
25
25
26
26
/**
27
- * @var string
27
+ * @var string|null
28
28
*/
29
29
private $ host ;
30
30
31
31
/**
32
- * @var array
32
+ * @var string[]
33
33
*/
34
34
private $ methods = array ();
35
35
36
36
/**
37
- * @var string
37
+ * @var string[]
38
38
*/
39
39
private $ ips = array ();
40
40
@@ -76,13 +76,13 @@ public function __construct($path = null, $host = null, $methods = null, $ips =
76
76
*/
77
77
public function matchScheme ($ scheme )
78
78
{
79
- $ this ->schemes = array_map ('strtolower ' , (array ) $ scheme );
79
+ $ this ->schemes = null !== $ scheme ? array_map ('strtolower ' , (array ) $ scheme) : array ( );
80
80
}
81
81
82
82
/**
83
83
* Adds a check for the URL host name.
84
84
*
85
- * @param string $regexp A Regexp
85
+ * @param string|null $regexp A Regexp
86
86
*/
87
87
public function matchHost ($ regexp )
88
88
{
@@ -92,7 +92,7 @@ public function matchHost($regexp)
92
92
/**
93
93
* Adds a check for the URL path info.
94
94
*
95
- * @param string $regexp A Regexp
95
+ * @param string|null $regexp A Regexp
96
96
*/
97
97
public function matchPath ($ regexp )
98
98
{
@@ -112,21 +112,21 @@ public function matchIp($ip)
112
112
/**
113
113
* Adds a check for the client IP.
114
114
*
115
- * @param string|string[] $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
115
+ * @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
116
116
*/
117
117
public function matchIps ($ ips )
118
118
{
119
- $ this ->ips = (array ) $ ips ;
119
+ $ this ->ips = null !== $ ips ? (array ) $ ips : array () ;
120
120
}
121
121
122
122
/**
123
123
* Adds a check for the HTTP method.
124
124
*
125
- * @param string|string[] $method An HTTP method or an array of HTTP methods
125
+ * @param string|string[]|null $method An HTTP method or an array of HTTP methods
126
126
*/
127
127
public function matchMethod ($ method )
128
128
{
129
- $ this ->methods = array_map ('strtoupper ' , (array ) $ method );
129
+ $ this ->methods = null !== $ method ? array_map ('strtoupper ' , (array ) $ method) : array ( );
130
130
}
131
131
132
132
/**
@@ -145,11 +145,11 @@ public function matchAttribute($key, $regexp)
145
145
*/
146
146
public function matches (Request $ request )
147
147
{
148
- if ($ this ->schemes && !in_array ($ request ->getScheme (), $ this ->schemes )) {
148
+ if ($ this ->schemes && !in_array ($ request ->getScheme (), $ this ->schemes , true )) {
149
149
return false ;
150
150
}
151
151
152
- if ($ this ->methods && !in_array ($ request ->getMethod (), $ this ->methods )) {
152
+ if ($ this ->methods && !in_array ($ request ->getMethod (), $ this ->methods , true )) {
153
153
return false ;
154
154
}
155
155
0 commit comments