@@ -66,7 +66,7 @@ public function __construct(
6666 ?int $ port ,
6767 ?string $ path ,
6868 ?string $ queryString ,
69- array $ query
69+ array $ query,
7070 ) {
7171 $ this ->scheme = $ scheme ;
7272 $ this ->schemeProtocol = $ schemeProtocol ;
@@ -140,27 +140,27 @@ public function getQuery(): array
140140 return $ this ->queryBag ->toArray ();
141141 }
142142
143- public function getString (string $ name , string $ default = null ): ?string
143+ public function getString (string $ name , ? string $ default = null ): ?string
144144 {
145145 return $ this ->queryBag ->getString ($ name , $ default );
146146 }
147147
148- public function getDecimal (string $ name , int $ default = null ): ?int
148+ public function getDecimal (string $ name , ? int $ default = null ): ?int
149149 {
150150 return $ this ->queryBag ->getDecimal ($ name , $ default );
151151 }
152152
153- public function getOctal (string $ name , int $ default = null ): ?int
153+ public function getOctal (string $ name , ? int $ default = null ): ?int
154154 {
155155 return $ this ->queryBag ->getOctal ($ name , $ default );
156156 }
157157
158- public function getFloat (string $ name , float $ default = null ): ?float
158+ public function getFloat (string $ name , ? float $ default = null ): ?float
159159 {
160160 return $ this ->queryBag ->getFloat ($ name , $ default );
161161 }
162162
163- public function getBool (string $ name , bool $ default = null ): ?bool
163+ public function getBool (string $ name , ? bool $ default = null ): ?bool
164164 {
165165 return $ this ->queryBag ->getBool ($ name , $ default );
166166 }
@@ -192,14 +192,12 @@ public static function parseFirst(string $dsn): ?self
192192 }
193193
194194 /**
195- * @param string $dsn
196- *
197195 * @return Dsn[]
198196 */
199197 public static function parse (string $ dsn ): array
200198 {
201- if (false === strpos ($ dsn , ': ' )) {
202- throw new \LogicException (sprintf ( 'The DSN is invalid. It does not have scheme separator ":". ' ) );
199+ if (! str_contains ($ dsn , ': ' )) {
200+ throw new \LogicException ('The DSN is invalid. It does not have scheme separator ":". ' );
203201 }
204202
205203 list ($ scheme , $ dsnWithoutScheme ) = explode (': ' , $ dsn , 2 );
@@ -215,28 +213,28 @@ public static function parse(string $dsn): array
215213 unset($ schemeParts [0 ]);
216214 $ schemeExtensions = array_values ($ schemeParts );
217215
218- $ user = parse_url ($ dsn , PHP_URL_USER ) ?: null ;
216+ $ user = parse_url ($ dsn , \ PHP_URL_USER ) ?: null ;
219217 if (is_string ($ user )) {
220218 $ user = rawurldecode ($ user );
221219 }
222220
223- $ password = parse_url ($ dsn , PHP_URL_PASS ) ?: null ;
221+ $ password = parse_url ($ dsn , \ PHP_URL_PASS ) ?: null ;
224222 if (is_string ($ password )) {
225223 $ password = rawurldecode ($ password );
226224 }
227225
228- $ path = parse_url ($ dsn , PHP_URL_PATH ) ?: null ;
226+ $ path = parse_url ($ dsn , \ PHP_URL_PATH ) ?: null ;
229227 if ($ path ) {
230228 $ path = rawurldecode ($ path );
231229 }
232230
233231 $ query = [];
234- $ queryString = parse_url ($ dsn , PHP_URL_QUERY ) ?: null ;
232+ $ queryString = parse_url ($ dsn , \ PHP_URL_QUERY ) ?: null ;
235233 if (is_string ($ queryString )) {
236- $ query = self ::httpParseQuery ($ queryString , '& ' , PHP_QUERY_RFC3986 );
234+ $ query = self ::httpParseQuery ($ queryString , '& ' , \ PHP_QUERY_RFC3986 );
237235 }
238236 $ hostsPorts = '' ;
239- if (0 === strpos ($ dsnWithoutScheme , '// ' )) {
237+ if (str_starts_with ($ dsnWithoutScheme , '// ' )) {
240238 $ dsnWithoutScheme = substr ($ dsnWithoutScheme , 2 );
241239 $ dsnWithoutUserPassword = explode ('@ ' , $ dsnWithoutScheme , 2 );
242240 $ dsnWithoutUserPassword = 2 === count ($ dsnWithoutUserPassword ) ?
@@ -299,7 +297,7 @@ public static function parse(string $dsn): array
299297 /**
300298 * based on http://php.net/manual/en/function.parse-str.php#119484 with some slight modifications.
301299 */
302- private static function httpParseQuery (string $ queryString , string $ argSeparator = '& ' , int $ decType = PHP_QUERY_RFC1738 ): array
300+ private static function httpParseQuery (string $ queryString , string $ argSeparator = '& ' , int $ decType = \ PHP_QUERY_RFC1738 ): array
303301 {
304302 $ result = [];
305303 $ parts = explode ($ argSeparator , $ queryString );
@@ -308,11 +306,11 @@ private static function httpParseQuery(string $queryString, string $argSeparator
308306 list ($ paramName , $ paramValue ) = explode ('= ' , $ part , 2 );
309307
310308 switch ($ decType ) {
311- case PHP_QUERY_RFC3986 :
309+ case \ PHP_QUERY_RFC3986 :
312310 $ paramName = rawurldecode ($ paramName );
313311 $ paramValue = rawurldecode ($ paramValue );
314312 break ;
315- case PHP_QUERY_RFC1738 :
313+ case \ PHP_QUERY_RFC1738 :
316314 default :
317315 $ paramName = urldecode ($ paramName );
318316 $ paramValue = urldecode ($ paramValue );
0 commit comments