@@ -65,11 +65,11 @@ trait HTTPOptionsTrait{
6565 */
6666 protected function HTTPOptionsTrait ():void {
6767
68- if (!is_array ($ this ->curl_options )){
68+ if (!\ is_array ($ this ->curl_options )){
6969 $ this ->curl_options = [];
7070 }
7171
72- if (!is_string ($ this ->user_agent ) || empty (trim ($ this ->user_agent ))){
72+ if (!\ is_string ($ this ->user_agent ) || empty (\ trim ($ this ->user_agent ))){
7373 throw new ClientException ('invalid user agent ' );
7474 }
7575
@@ -83,69 +83,69 @@ protected function HTTPOptionsTrait():void{
8383 protected function setCA ():void {
8484
8585 // disable verification if wanted so
86- if ($ this ->ssl_verifypeer !== true || (isset ($ this ->curl_options [CURLOPT_SSL_VERIFYPEER ]) && !$ this ->curl_options [CURLOPT_SSL_VERIFYPEER ])){
87- unset($ this ->curl_options [CURLOPT_CAINFO ], $ this ->curl_options [CURLOPT_CAPATH ]);
86+ if ($ this ->ssl_verifypeer !== true || (isset ($ this ->curl_options [\ CURLOPT_SSL_VERIFYPEER ]) && !$ this ->curl_options [\ CURLOPT_SSL_VERIFYPEER ])){
87+ unset($ this ->curl_options [\ CURLOPT_CAINFO ], $ this ->curl_options [\ CURLOPT_CAPATH ]);
8888
89- $ this ->curl_options [CURLOPT_SSL_VERIFYHOST ] = 0 ;
90- $ this ->curl_options [CURLOPT_SSL_VERIFYPEER ] = false ;
89+ $ this ->curl_options [\ CURLOPT_SSL_VERIFYHOST ] = 0 ;
90+ $ this ->curl_options [\ CURLOPT_SSL_VERIFYPEER ] = false ;
9191
9292 return ;
9393 }
9494
95- $ this ->curl_options [CURLOPT_SSL_VERIFYHOST ] = 2 ;
96- $ this ->curl_options [CURLOPT_SSL_VERIFYPEER ] = true ;
95+ $ this ->curl_options [\ CURLOPT_SSL_VERIFYHOST ] = 2 ;
96+ $ this ->curl_options [\ CURLOPT_SSL_VERIFYPEER ] = true ;
9797
9898 // a path/dir/link to a CA bundle is given, let's check that
99- if (is_string ($ this ->ca_info )){
99+ if (\ is_string ($ this ->ca_info )){
100100
101101 // if you - for whatever obscure reason - need to check Windows .lnk links,
102102 // see http://php.net/manual/en/function.is-link.php#91249
103103 switch (true ){
104- case is_dir ($ this ->ca_info ):
105- case is_link ($ this ->ca_info ) && is_dir (readlink ($ this ->ca_info )): // @codeCoverageIgnore
106- $ this ->curl_options [CURLOPT_CAPATH ] = $ this ->ca_info ;
107- unset($ this ->curl_options [CURLOPT_CAINFO ]);
104+ case \ is_dir ($ this ->ca_info ):
105+ case \ is_link ($ this ->ca_info ) && \ is_dir (\ readlink ($ this ->ca_info )): // @codeCoverageIgnore
106+ $ this ->curl_options [\ CURLOPT_CAPATH ] = $ this ->ca_info ;
107+ unset($ this ->curl_options [\ CURLOPT_CAINFO ]);
108108 return ;
109109
110- case is_file ($ this ->ca_info ):
111- case is_link ($ this ->ca_info ) && is_file (readlink ($ this ->ca_info )): // @codeCoverageIgnore
112- $ this ->curl_options [CURLOPT_CAINFO ] = $ this ->ca_info ;
113- unset($ this ->curl_options [CURLOPT_CAPATH ]);
110+ case \ is_file ($ this ->ca_info ):
111+ case \ is_link ($ this ->ca_info ) && \ is_file (\ readlink ($ this ->ca_info )): // @codeCoverageIgnore
112+ $ this ->curl_options [\ CURLOPT_CAINFO ] = $ this ->ca_info ;
113+ unset($ this ->curl_options [\ CURLOPT_CAPATH ]);
114114 return ;
115115 }
116116
117117 throw new ClientException ('invalid path to SSL CA bundle (HTTPOptions::$ca_info): ' .$ this ->ca_info );
118118 }
119119
120120 // we somehow landed here, so let's check if there's a CA bundle given via the cURL options
121- $ ca = $ this ->curl_options [CURLOPT_CAPATH ] ?? $ this ->curl_options [CURLOPT_CAINFO ] ?? false ;
121+ $ ca = $ this ->curl_options [\ CURLOPT_CAPATH ] ?? $ this ->curl_options [\ CURLOPT_CAINFO ] ?? false ;
122122
123123 if ($ ca ){
124124
125125 // just check if the file/path exists
126126 switch (true ){
127- case is_dir ($ ca ):
128- case is_link ($ ca ) && is_dir (readlink ($ ca )): // @codeCoverageIgnore
129- unset($ this ->curl_options [CURLOPT_CAINFO ]);
127+ case \ is_dir ($ ca ):
128+ case \ is_link ($ ca ) && \ is_dir (\ readlink ($ ca )): // @codeCoverageIgnore
129+ unset($ this ->curl_options [\ CURLOPT_CAINFO ]);
130130 return ;
131131
132- case is_file ($ ca ):
133- case is_link ($ ca ) && is_file (readlink ($ ca )): // @codeCoverageIgnore
132+ case \ is_file ($ ca ):
133+ case \ is_link ($ ca ) && \ is_file (\ readlink ($ ca )): // @codeCoverageIgnore
134134 return ;
135135 }
136136
137137 throw new ClientException ('invalid path to SSL CA bundle (CURLOPT_CAPATH/CURLOPT_CAINFO): ' .$ ca );
138138 }
139139
140140 // check php.ini options - PHP should find the file by itself
141- if (file_exists (ini_get ('curl.cainfo ' ))){
141+ if (\ file_exists (\ ini_get ('curl.cainfo ' ))){
142142 return ; // @codeCoverageIgnore
143143 }
144144
145145 // this is getting weird. as a last resort, we're going to check some default paths for a CA bundle file
146146 $ cafiles = [
147147 // check other php.ini settings
148- ini_get ('openssl.cafile ' ),
148+ \ ini_get ('openssl.cafile ' ),
149149 // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
150150 '/etc/pki/tls/certs/ca-bundle.crt ' ,
151151 // Ubuntu, Debian (provided by the ca-certificates package)
@@ -169,8 +169,8 @@ protected function setCA():void{
169169 ];
170170
171171 foreach ($ cafiles as $ file ){
172- if (is_file ($ file ) || (is_link ($ file ) && is_file (readlink ($ file )))){
173- $ this ->curl_options [CURLOPT_CAINFO ] = $ file ;
172+ if (\ is_file ($ file ) || (\ is_link ($ file ) && \ is_file (\ readlink ($ file )))){
173+ $ this ->curl_options [\ CURLOPT_CAINFO ] = $ file ;
174174 return ;
175175 }
176176 }
0 commit comments