1919class RequestMatcher implements RequestMatcherInterface
2020{
2121 /**
22- * @var string
22+ * @var string|null
2323 */
2424 private $ path ;
2525
2626 /**
27- * @var string
27+ * @var string|null
2828 */
2929 private $ host ;
3030
3131 /**
32- * @var array
32+ * @var string[]
3333 */
3434 private $ methods = array ();
3535
3636 /**
37- * @var string
37+ * @var string[]
3838 */
3939 private $ ips = array ();
4040
@@ -76,13 +76,13 @@ public function __construct($path = null, $host = null, $methods = null, $ips =
7676 */
7777 public function matchScheme ($ scheme )
7878 {
79- $ this ->schemes = array_map ('strtolower ' , (array ) $ scheme );
79+ $ this ->schemes = null !== $ scheme ? array_map ('strtolower ' , (array ) $ scheme) : array ( );
8080 }
8181
8282 /**
8383 * Adds a check for the URL host name.
8484 *
85- * @param string $regexp A Regexp
85+ * @param string|null $regexp A Regexp
8686 */
8787 public function matchHost ($ regexp )
8888 {
@@ -92,7 +92,7 @@ public function matchHost($regexp)
9292 /**
9393 * Adds a check for the URL path info.
9494 *
95- * @param string $regexp A Regexp
95+ * @param string|null $regexp A Regexp
9696 */
9797 public function matchPath ($ regexp )
9898 {
@@ -112,21 +112,21 @@ public function matchIp($ip)
112112 /**
113113 * Adds a check for the client IP.
114114 *
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
116116 */
117117 public function matchIps ($ ips )
118118 {
119- $ this ->ips = (array ) $ ips ;
119+ $ this ->ips = null !== $ ips ? (array ) $ ips : array () ;
120120 }
121121
122122 /**
123123 * Adds a check for the HTTP method.
124124 *
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
126126 */
127127 public function matchMethod ($ method )
128128 {
129- $ this ->methods = array_map ('strtoupper ' , (array ) $ method );
129+ $ this ->methods = null !== $ method ? array_map ('strtoupper ' , (array ) $ method) : array ( );
130130 }
131131
132132 /**
@@ -145,11 +145,11 @@ public function matchAttribute($key, $regexp)
145145 */
146146 public function matches (Request $ request )
147147 {
148- if ($ this ->schemes && !in_array ($ request ->getScheme (), $ this ->schemes )) {
148+ if ($ this ->schemes && !in_array ($ request ->getScheme (), $ this ->schemes , true )) {
149149 return false ;
150150 }
151151
152- if ($ this ->methods && !in_array ($ request ->getMethod (), $ this ->methods )) {
152+ if ($ this ->methods && !in_array ($ request ->getMethod (), $ this ->methods , true )) {
153153 return false ;
154154 }
155155
0 commit comments