@@ -226,6 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | /** |
228 | 228 | * Send a GET request |
229 | + * @param string $url |
|
229 | 230 | */ |
230 | 231 | public static function get($url, $headers = array(), $options = array()) { |
231 | 232 | return self::request($url, $headers, null, self::GET, $options); |
@@ -263,12 +264,14 @@ discard block |
||
263 | 264 | */ |
264 | 265 | /** |
265 | 266 | * Send a POST request |
267 | + * @param string $url |
|
266 | 268 | */ |
267 | 269 | public static function post($url, $headers = array(), $data = array(), $options = array()) { |
268 | 270 | return self::request($url, $headers, $data, self::POST, $options); |
269 | 271 | } |
270 | 272 | /** |
271 | 273 | * Send a PUT request |
274 | + * @param string $url |
|
272 | 275 | */ |
273 | 276 | public static function put($url, $headers = array(), $data = array(), $options = array()) { |
274 | 277 | return self::request($url, $headers, $data, self::PUT, $options); |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | */ |
138 | 138 | public static function autoloader($class) { |
139 | 139 | // Check that the class starts with "Requests" |
140 | - if (strpos($class, 'Requests') !== 0) { |
|
140 | + if(strpos($class, 'Requests') !== 0) { |
|
141 | 141 | return; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $file = str_replace('_', '/', $class); |
145 | - if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) { |
|
145 | + if(file_exists(dirname(__FILE__) . '/' . $file . '.php')) { |
|
146 | 146 | require_once(dirname(__FILE__) . '/' . $file . '.php'); |
147 | 147 | } |
148 | 148 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param string $transport Transport class to add, must support the Requests_Transport interface |
163 | 163 | */ |
164 | 164 | public static function add_transport($transport) { |
165 | - if (empty(self::$transports)) { |
|
165 | + if(empty(self::$transports)) { |
|
166 | 166 | self::$transports = array( |
167 | 167 | 'Requests_Transport_cURL', |
168 | 168 | 'Requests_Transport_fsockopen', |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | $cap_string = serialize($capabilities); |
187 | 187 | |
188 | 188 | // Don't search for a transport if it's already been done for these $capabilities |
189 | - if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { |
|
189 | + if(isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) { |
|
190 | 190 | return new self::$transport[$cap_string](); |
191 | 191 | } |
192 | 192 | // @codeCoverageIgnoreEnd |
193 | 193 | |
194 | - if (empty(self::$transports)) { |
|
194 | + if(empty(self::$transports)) { |
|
195 | 195 | self::$transports = array( |
196 | 196 | 'Requests_Transport_cURL', |
197 | 197 | 'Requests_Transport_fsockopen', |
@@ -199,18 +199,18 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | // Find us a working transport |
202 | - foreach (self::$transports as $class) { |
|
203 | - if (!class_exists($class)) { |
|
202 | + foreach(self::$transports as $class) { |
|
203 | + if(!class_exists($class)) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $result = call_user_func(array($class, 'test'), $capabilities); |
208 | - if ($result) { |
|
208 | + if($result) { |
|
209 | 209 | self::$transport[$cap_string] = $class; |
210 | 210 | break; |
211 | 211 | } |
212 | 212 | } |
213 | - if (self::$transport[$cap_string] === null) { |
|
213 | + if(self::$transport[$cap_string] === null) { |
|
214 | 214 | throw new Requests_Exception('No working transports found', 'notransport', self::$transports); |
215 | 215 | } |
216 | 216 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @return Requests_Response |
356 | 356 | */ |
357 | 357 | public static function request($url, $headers = array(), $data = array(), $type = self::GET, $options = array()) { |
358 | - if (empty($options['type'])) { |
|
358 | + if(empty($options['type'])) { |
|
359 | 359 | $options['type'] = $type; |
360 | 360 | } |
361 | 361 | $options = array_merge(self::get_default_options(), $options); |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | |
365 | 365 | $options['hooks']->dispatch('requests.before_request', array(&$url, &$headers, &$data, &$type, &$options)); |
366 | 366 | |
367 | - if (!empty($options['transport'])) { |
|
367 | + if(!empty($options['transport'])) { |
|
368 | 368 | $transport = $options['transport']; |
369 | 369 | |
370 | - if (is_string($options['transport'])) { |
|
370 | + if(is_string($options['transport'])) { |
|
371 | 371 | $transport = new $transport(); |
372 | 372 | } |
373 | 373 | } |
@@ -427,29 +427,29 @@ discard block |
||
427 | 427 | public static function request_multiple($requests, $options = array()) { |
428 | 428 | $options = array_merge(self::get_default_options(true), $options); |
429 | 429 | |
430 | - if (!empty($options['hooks'])) { |
|
430 | + if(!empty($options['hooks'])) { |
|
431 | 431 | $options['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); |
432 | - if (!empty($options['complete'])) { |
|
432 | + if(!empty($options['complete'])) { |
|
433 | 433 | $options['hooks']->register('multiple.request.complete', $options['complete']); |
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
437 | - foreach ($requests as $id => &$request) { |
|
438 | - if (!isset($request['headers'])) { |
|
437 | + foreach($requests as $id => &$request) { |
|
438 | + if(!isset($request['headers'])) { |
|
439 | 439 | $request['headers'] = array(); |
440 | 440 | } |
441 | - if (!isset($request['data'])) { |
|
441 | + if(!isset($request['data'])) { |
|
442 | 442 | $request['data'] = array(); |
443 | 443 | } |
444 | - if (!isset($request['type'])) { |
|
444 | + if(!isset($request['type'])) { |
|
445 | 445 | $request['type'] = self::GET; |
446 | 446 | } |
447 | - if (!isset($request['options'])) { |
|
447 | + if(!isset($request['options'])) { |
|
448 | 448 | $request['options'] = $options; |
449 | 449 | $request['options']['type'] = $request['type']; |
450 | 450 | } |
451 | 451 | else { |
452 | - if (empty($request['options']['type'])) { |
|
452 | + if(empty($request['options']['type'])) { |
|
453 | 453 | $request['options']['type'] = $request['type']; |
454 | 454 | } |
455 | 455 | $request['options'] = array_merge($options, $request['options']); |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | self::set_defaults($request['url'], $request['headers'], $request['data'], $request['type'], $request['options']); |
459 | 459 | |
460 | 460 | // Ensure we only hook in once |
461 | - if ($request['options']['hooks'] !== $options['hooks']) { |
|
461 | + if($request['options']['hooks'] !== $options['hooks']) { |
|
462 | 462 | $request['options']['hooks']->register('transport.internal.parse_response', array('Requests', 'parse_multiple')); |
463 | - if (!empty($request['options']['complete'])) { |
|
463 | + if(!empty($request['options']['complete'])) { |
|
464 | 464 | $request['options']['hooks']->register('multiple.request.complete', $request['options']['complete']); |
465 | 465 | } |
466 | 466 | } |
467 | 467 | } |
468 | 468 | unset($request); |
469 | 469 | |
470 | - if (!empty($options['transport'])) { |
|
470 | + if(!empty($options['transport'])) { |
|
471 | 471 | $transport = $options['transport']; |
472 | 472 | |
473 | - if (is_string($options['transport'])) { |
|
473 | + if(is_string($options['transport'])) { |
|
474 | 474 | $transport = new $transport(); |
475 | 475 | } |
476 | 476 | } |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | } |
480 | 480 | $responses = $transport->request_multiple($requests, $options); |
481 | 481 | |
482 | - foreach ($responses as $id => &$response) { |
|
482 | + foreach($responses as $id => &$response) { |
|
483 | 483 | // If our hook got messed with somehow, ensure we end up with the |
484 | 484 | // correct response |
485 | - if (is_string($response)) { |
|
485 | + if(is_string($response)) { |
|
486 | 486 | $request = $requests[$id]; |
487 | 487 | self::parse_multiple($response, $request); |
488 | 488 | $request['options']['hooks']->dispatch('multiple.request.complete', array(&$response, $id)); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | 'verify' => Requests::get_certificate_path(), |
522 | 522 | 'verifyname' => true, |
523 | 523 | ); |
524 | - if ($multirequest !== false) { |
|
524 | + if($multirequest !== false) { |
|
525 | 525 | $defaults['complete'] = null; |
526 | 526 | } |
527 | 527 | return $defaults; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @return string Default certificate path. |
534 | 534 | */ |
535 | 535 | public static function get_certificate_path() { |
536 | - if ( ! empty( Requests::$certificate_path ) ) { |
|
536 | + if(!empty(Requests::$certificate_path)) { |
|
537 | 537 | return Requests::$certificate_path; |
538 | 538 | } |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @param string $path Certificate path, pointing to a PEM file. |
547 | 547 | */ |
548 | - public static function set_certificate_path( $path ) { |
|
548 | + public static function set_certificate_path($path) { |
|
549 | 549 | Requests::$certificate_path = $path; |
550 | 550 | } |
551 | 551 | |
@@ -560,39 +560,39 @@ discard block |
||
560 | 560 | * @return array $options |
561 | 561 | */ |
562 | 562 | protected static function set_defaults(&$url, &$headers, &$data, &$type, &$options) { |
563 | - if (!preg_match('/^http(s)?:\/\//i', $url, $matches)) { |
|
563 | + if(!preg_match('/^http(s)?:\/\//i', $url, $matches)) { |
|
564 | 564 | throw new Requests_Exception('Only HTTP(S) requests are handled.', 'nonhttp', $url); |
565 | 565 | } |
566 | 566 | |
567 | - if (empty($options['hooks'])) { |
|
567 | + if(empty($options['hooks'])) { |
|
568 | 568 | $options['hooks'] = new Requests_Hooks(); |
569 | 569 | } |
570 | 570 | |
571 | - if (is_array($options['auth'])) { |
|
571 | + if(is_array($options['auth'])) { |
|
572 | 572 | $options['auth'] = new Requests_Auth_Basic($options['auth']); |
573 | 573 | } |
574 | - if ($options['auth'] !== false) { |
|
574 | + if($options['auth'] !== false) { |
|
575 | 575 | $options['auth']->register($options['hooks']); |
576 | 576 | } |
577 | 577 | |
578 | - if (is_string($options['proxy']) || is_array($options['proxy'])) { |
|
578 | + if(is_string($options['proxy']) || is_array($options['proxy'])) { |
|
579 | 579 | $options['proxy'] = new Requests_Proxy_HTTP($options['proxy']); |
580 | 580 | } |
581 | - if ($options['proxy'] !== false) { |
|
581 | + if($options['proxy'] !== false) { |
|
582 | 582 | $options['proxy']->register($options['hooks']); |
583 | 583 | } |
584 | 584 | |
585 | - if (is_array($options['cookies'])) { |
|
585 | + if(is_array($options['cookies'])) { |
|
586 | 586 | $options['cookies'] = new Requests_Cookie_Jar($options['cookies']); |
587 | 587 | } |
588 | - elseif (empty($options['cookies'])) { |
|
588 | + elseif(empty($options['cookies'])) { |
|
589 | 589 | $options['cookies'] = new Requests_Cookie_Jar(); |
590 | 590 | } |
591 | - if ($options['cookies'] !== false) { |
|
591 | + if($options['cookies'] !== false) { |
|
592 | 592 | $options['cookies']->register($options['hooks']); |
593 | 593 | } |
594 | 594 | |
595 | - if ($options['idn'] !== false) { |
|
595 | + if($options['idn'] !== false) { |
|
596 | 596 | $iri = new Requests_IRI($url); |
597 | 597 | $iri->host = Requests_IDNAEncoder::encode($iri->ihost); |
598 | 598 | $url = $iri->uri; |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | // Massage the type to ensure we support it. |
602 | 602 | $type = strtoupper($type); |
603 | 603 | |
604 | - if (!isset($options['data_format'])) { |
|
605 | - if (in_array($type, array(self::HEAD, self::GET, self::DELETE))) { |
|
604 | + if(!isset($options['data_format'])) { |
|
605 | + if(in_array($type, array(self::HEAD, self::GET, self::DELETE))) { |
|
606 | 606 | $options['data_format'] = 'query'; |
607 | 607 | } |
608 | 608 | else { |
@@ -627,15 +627,15 @@ discard block |
||
627 | 627 | */ |
628 | 628 | protected static function parse_response($headers, $url, $req_headers, $req_data, $options) { |
629 | 629 | $return = new Requests_Response(); |
630 | - if (!$options['blocking']) { |
|
630 | + if(!$options['blocking']) { |
|
631 | 631 | return $return; |
632 | 632 | } |
633 | 633 | |
634 | 634 | $return->raw = $headers; |
635 | 635 | $return->url = $url; |
636 | 636 | |
637 | - if (!$options['filename']) { |
|
638 | - if (($pos = strpos($headers, "\r\n\r\n")) === false) { |
|
637 | + if(!$options['filename']) { |
|
638 | + if(($pos = strpos($headers, "\r\n\r\n")) === false) { |
|
639 | 639 | // Crap! |
640 | 640 | throw new Requests_Exception('Missing header/body separator', 'requests.no_crlf_separator'); |
641 | 641 | } |
@@ -652,44 +652,44 @@ discard block |
||
652 | 652 | $headers = preg_replace('/\n[ \t]/', ' ', $headers); |
653 | 653 | $headers = explode("\n", $headers); |
654 | 654 | preg_match('#^HTTP/(1\.\d)[ \t]+(\d+)#i', array_shift($headers), $matches); |
655 | - if (empty($matches)) { |
|
655 | + if(empty($matches)) { |
|
656 | 656 | throw new Requests_Exception('Response could not be parsed', 'noversion', $headers); |
657 | 657 | } |
658 | - $return->protocol_version = (float) $matches[1]; |
|
659 | - $return->status_code = (int) $matches[2]; |
|
660 | - if ($return->status_code >= 200 && $return->status_code < 300) { |
|
658 | + $return->protocol_version = (float)$matches[1]; |
|
659 | + $return->status_code = (int)$matches[2]; |
|
660 | + if($return->status_code >= 200 && $return->status_code < 300) { |
|
661 | 661 | $return->success = true; |
662 | 662 | } |
663 | 663 | |
664 | - foreach ($headers as $header) { |
|
664 | + foreach($headers as $header) { |
|
665 | 665 | list($key, $value) = explode(':', $header, 2); |
666 | 666 | $value = trim($value); |
667 | 667 | preg_replace('#(\s+)#i', ' ', $value); |
668 | 668 | $return->headers[$key] = $value; |
669 | 669 | } |
670 | - if (isset($return->headers['transfer-encoding'])) { |
|
670 | + if(isset($return->headers['transfer-encoding'])) { |
|
671 | 671 | $return->body = self::decode_chunked($return->body); |
672 | 672 | unset($return->headers['transfer-encoding']); |
673 | 673 | } |
674 | - if (isset($return->headers['content-encoding'])) { |
|
674 | + if(isset($return->headers['content-encoding'])) { |
|
675 | 675 | $return->body = self::decompress($return->body); |
676 | 676 | } |
677 | 677 | |
678 | 678 | //fsockopen and cURL compatibility |
679 | - if (isset($return->headers['connection'])) { |
|
679 | + if(isset($return->headers['connection'])) { |
|
680 | 680 | unset($return->headers['connection']); |
681 | 681 | } |
682 | 682 | |
683 | 683 | $options['hooks']->dispatch('requests.before_redirect_check', array(&$return, $req_headers, $req_data, $options)); |
684 | 684 | |
685 | - if ($return->is_redirect() && $options['follow_redirects'] === true) { |
|
686 | - if (isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { |
|
687 | - if ($return->status_code === 303) { |
|
685 | + if($return->is_redirect() && $options['follow_redirects'] === true) { |
|
686 | + if(isset($return->headers['location']) && $options['redirected'] < $options['redirects']) { |
|
687 | + if($return->status_code === 303) { |
|
688 | 688 | $options['type'] = self::GET; |
689 | 689 | } |
690 | 690 | $options['redirected']++; |
691 | 691 | $location = $return->headers['location']; |
692 | - if (strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { |
|
692 | + if(strpos($location, 'http://') !== 0 && strpos($location, 'https://') !== 0) { |
|
693 | 693 | // relative redirect, for compatibility make it absolute |
694 | 694 | $location = Requests_IRI::absolutize($url, $location); |
695 | 695 | $location = $location->uri; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | $redirected->history[] = $return; |
708 | 708 | return $redirected; |
709 | 709 | } |
710 | - elseif ($options['redirected'] >= $options['redirects']) { |
|
710 | + elseif($options['redirected'] >= $options['redirects']) { |
|
711 | 711 | throw new Requests_Exception('Too many redirects', 'toomanyredirects', $return); |
712 | 712 | } |
713 | 713 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $options = $request['options']; |
737 | 737 | $response = self::parse_response($response, $url, $headers, $data, $options); |
738 | 738 | } |
739 | - catch (Requests_Exception $e) { |
|
739 | + catch(Requests_Exception $e) { |
|
740 | 740 | $response = $e; |
741 | 741 | } |
742 | 742 | } |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @return string Decoded body |
750 | 750 | */ |
751 | 751 | protected static function decode_chunked($data) { |
752 | - if (!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { |
|
752 | + if(!preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', trim($data))) { |
|
753 | 753 | return $data; |
754 | 754 | } |
755 | 755 | |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | $decoded = ''; |
759 | 759 | $encoded = $data; |
760 | 760 | |
761 | - while (true) { |
|
762 | - $is_chunked = (bool) preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); |
|
763 | - if (!$is_chunked) { |
|
761 | + while(true) { |
|
762 | + $is_chunked = (bool)preg_match('/^([0-9a-f]+)(?:;(?:[\w-]*)(?:=(?:(?:[\w-]*)*|"(?:[^\r\n])*"))?)*\r\n/i', $encoded, $matches); |
|
763 | + if(!$is_chunked) { |
|
764 | 764 | // Looks like it's not chunked after all |
765 | 765 | return $data; |
766 | 766 | } |
767 | 767 | |
768 | 768 | $length = hexdec(trim($matches[1])); |
769 | - if ($length === 0) { |
|
769 | + if($length === 0) { |
|
770 | 770 | // Ignore trailer headers |
771 | 771 | return $decoded; |
772 | 772 | } |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $decoded .= substr($encoded, $chunk_length, $length); |
776 | 776 | $encoded = substr($encoded, $chunk_length + $length + 2); |
777 | 777 | |
778 | - if (trim($encoded) === '0' || empty($encoded)) { |
|
778 | + if(trim($encoded) === '0' || empty($encoded)) { |
|
779 | 779 | return $decoded; |
780 | 780 | } |
781 | 781 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | */ |
794 | 794 | public static function flatten($array) { |
795 | 795 | $return = array(); |
796 | - foreach ($array as $key => $value) { |
|
796 | + foreach($array as $key => $value) { |
|
797 | 797 | $return[] = sprintf('%s: %s', $key, $value); |
798 | 798 | } |
799 | 799 | return $return; |
@@ -821,21 +821,21 @@ discard block |
||
821 | 821 | * @return string Decompressed string |
822 | 822 | */ |
823 | 823 | public static function decompress($data) { |
824 | - if (substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { |
|
824 | + if(substr($data, 0, 2) !== "\x1f\x8b" && substr($data, 0, 2) !== "\x78\x9c") { |
|
825 | 825 | // Not actually compressed. Probably cURL ruining this for us. |
826 | 826 | return $data; |
827 | 827 | } |
828 | 828 | |
829 | - if (function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) { |
|
829 | + if(function_exists('gzdecode') && ($decoded = @gzdecode($data)) !== false) { |
|
830 | 830 | return $decoded; |
831 | 831 | } |
832 | - elseif (function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) { |
|
832 | + elseif(function_exists('gzinflate') && ($decoded = @gzinflate($data)) !== false) { |
|
833 | 833 | return $decoded; |
834 | 834 | } |
835 | - elseif (($decoded = self::compatible_gzinflate($data)) !== false) { |
|
835 | + elseif(($decoded = self::compatible_gzinflate($data)) !== false) { |
|
836 | 836 | return $decoded; |
837 | 837 | } |
838 | - elseif (function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) { |
|
838 | + elseif(function_exists('gzuncompress') && ($decoded = @gzuncompress($data)) !== false) { |
|
839 | 839 | return $decoded; |
840 | 840 | } |
841 | 841 | |
@@ -865,26 +865,26 @@ discard block |
||
865 | 865 | public static function compatible_gzinflate($gzData) { |
866 | 866 | // Compressed data might contain a full zlib header, if so strip it for |
867 | 867 | // gzinflate() |
868 | - if (substr($gzData, 0, 3) == "\x1f\x8b\x08") { |
|
868 | + if(substr($gzData, 0, 3) == "\x1f\x8b\x08") { |
|
869 | 869 | $i = 10; |
870 | 870 | $flg = ord(substr($gzData, 3, 1)); |
871 | - if ($flg > 0) { |
|
872 | - if ($flg & 4) { |
|
871 | + if($flg > 0) { |
|
872 | + if($flg&4) { |
|
873 | 873 | list($xlen) = unpack('v', substr($gzData, $i, 2)); |
874 | 874 | $i = $i + 2 + $xlen; |
875 | 875 | } |
876 | - if ($flg & 8) { |
|
876 | + if($flg&8) { |
|
877 | 877 | $i = strpos($gzData, "\0", $i) + 1; |
878 | 878 | } |
879 | - if ($flg & 16) { |
|
879 | + if($flg&16) { |
|
880 | 880 | $i = strpos($gzData, "\0", $i) + 1; |
881 | 881 | } |
882 | - if ($flg & 2) { |
|
882 | + if($flg&2) { |
|
883 | 883 | $i = $i + 2; |
884 | 884 | } |
885 | 885 | } |
886 | 886 | $decompressed = self::compatible_gzinflate(substr($gzData, $i)); |
887 | - if (false !== $decompressed) { |
|
887 | + if(false !== $decompressed) { |
|
888 | 888 | return $decompressed; |
889 | 889 | } |
890 | 890 | } |
@@ -905,17 +905,17 @@ discard block |
||
905 | 905 | // First 2 bytes should be divisible by 0x1F |
906 | 906 | list(, $first_two_bytes) = unpack('n', $gzData); |
907 | 907 | |
908 | - if (0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { |
|
908 | + if(0x08 == $first_nibble && 0 == ($first_two_bytes % 0x1F)) { |
|
909 | 909 | $huffman_encoded = true; |
910 | 910 | } |
911 | 911 | |
912 | - if ($huffman_encoded) { |
|
913 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
912 | + if($huffman_encoded) { |
|
913 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
914 | 914 | return $decompressed; |
915 | 915 | } |
916 | 916 | } |
917 | 917 | |
918 | - if ("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { |
|
918 | + if("\x50\x4b\x03\x04" == substr($gzData, 0, 4)) { |
|
919 | 919 | // ZIP file format header |
920 | 920 | // Offset 6: 2 bytes, General-purpose field |
921 | 921 | // Offset 26: 2 bytes, filename length |
@@ -927,9 +927,9 @@ discard block |
||
927 | 927 | // If the file has been compressed on the fly, 0x08 bit is set of |
928 | 928 | // the general purpose field. We can use this to differentiate |
929 | 929 | // between a compressed document, and a ZIP file |
930 | - $zip_compressed_on_the_fly = (0x08 == (0x08 & $general_purpose_flag)); |
|
930 | + $zip_compressed_on_the_fly = (0x08 == (0x08&$general_purpose_flag)); |
|
931 | 931 | |
932 | - if (!$zip_compressed_on_the_fly) { |
|
932 | + if(!$zip_compressed_on_the_fly) { |
|
933 | 933 | // Don't attempt to decode a compressed zip file |
934 | 934 | return $gzData; |
935 | 935 | } |
@@ -937,20 +937,20 @@ discard block |
||
937 | 937 | // Determine the first byte of data, based on the above ZIP header |
938 | 938 | // offsets: |
939 | 939 | $first_file_start = array_sum(unpack('v2', substr($gzData, 26, 4))); |
940 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { |
|
940 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 30 + $first_file_start)))) { |
|
941 | 941 | return $decompressed; |
942 | 942 | } |
943 | 943 | return false; |
944 | 944 | } |
945 | 945 | |
946 | 946 | // Finally fall back to straight gzinflate |
947 | - if (false !== ($decompressed = @gzinflate($gzData))) { |
|
947 | + if(false !== ($decompressed = @gzinflate($gzData))) { |
|
948 | 948 | return $decompressed; |
949 | 949 | } |
950 | 950 | |
951 | 951 | // Fallback for all above failing, not expected, but included for |
952 | 952 | // debugging and preventing regressions and to track stats |
953 | - if (false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
953 | + if(false !== ($decompressed = @gzinflate(substr($gzData, 2)))) { |
|
954 | 954 | return $decompressed; |
955 | 955 | } |
956 | 956 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | |
960 | 960 | public static function match_domain($host, $reference) { |
961 | 961 | // Check for a direct match |
962 | - if ($host === $reference) { |
|
962 | + if($host === $reference) { |
|
963 | 963 | return true; |
964 | 964 | } |
965 | 965 | |
@@ -967,10 +967,10 @@ discard block |
||
967 | 967 | // Also validates that the host has 3 parts or more, as per Firefox's |
968 | 968 | // ruleset. |
969 | 969 | $parts = explode('.', $host); |
970 | - if (ip2long($host) === false && count($parts) >= 3) { |
|
970 | + if(ip2long($host) === false && count($parts) >= 3) { |
|
971 | 971 | $parts[0] = '*'; |
972 | 972 | $wildcard = implode('.', $parts); |
973 | - if ($wildcard === $reference) { |
|
973 | + if($wildcard === $reference) { |
|
974 | 974 | return true; |
975 | 975 | } |
976 | 976 | } |
@@ -357,7 +357,7 @@ |
||
357 | 357 | * @param int $delta |
358 | 358 | * @param int $numpoints |
359 | 359 | * @param bool $firsttime |
360 | - * @return int New bias |
|
360 | + * @return double New bias |
|
361 | 361 | */ |
362 | 362 | protected static function adapt($delta, $numpoints, $firsttime) { |
363 | 363 | # function adapt(delta,numpoints,firsttime): |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function encode($string) { |
44 | 44 | $parts = explode('.', $string); |
45 | - foreach ($parts as &$part) { |
|
45 | + foreach($parts as &$part) { |
|
46 | 46 | $part = self::to_ascii($part); |
47 | 47 | } |
48 | 48 | return implode('.', $parts); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public static function to_ascii($string) { |
63 | 63 | // Step 1: Check if the string is already ASCII |
64 | - if (self::is_ascii($string)) { |
|
64 | + if(self::is_ascii($string)) { |
|
65 | 65 | // Skip to step 7 |
66 | - if (strlen($string) < 64) { |
|
66 | + if(strlen($string) < 64) { |
|
67 | 67 | return $string; |
68 | 68 | } |
69 | 69 | |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | // Step 3: UseSTD3ASCIIRules is false, continue |
77 | 77 | // Step 4: Check if it's ASCII now |
78 | - if (self::is_ascii($string)) { |
|
78 | + if(self::is_ascii($string)) { |
|
79 | 79 | // Skip to step 7 |
80 | - if (strlen($string) < 64) { |
|
80 | + if(strlen($string) < 64) { |
|
81 | 81 | return $string; |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | // Step 5: Check ACE prefix |
88 | - if (strpos($string, self::ACE_PREFIX) === 0) { |
|
88 | + if(strpos($string, self::ACE_PREFIX) === 0) { |
|
89 | 89 | throw new Requests_Exception('Provided string begins with ACE prefix', 'idna.provided_is_prefixed', $string); |
90 | 90 | } |
91 | 91 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $string = self::ACE_PREFIX . $string; |
97 | 97 | |
98 | 98 | // Step 8: Check size |
99 | - if (strlen($string) < 64) { |
|
99 | + if(strlen($string) < 64) { |
|
100 | 100 | return $string; |
101 | 101 | } |
102 | 102 | |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | // Get number of bytes |
142 | 142 | $strlen = strlen($input); |
143 | 143 | |
144 | - for ($position = 0; $position < $strlen; $position++) { |
|
144 | + for($position = 0; $position < $strlen; $position++) { |
|
145 | 145 | $value = ord($input[$position]); |
146 | 146 | |
147 | 147 | // One byte sequence: |
148 | - if ((~$value & 0x80) === 0x80) { |
|
148 | + if((~$value&0x80) === 0x80) { |
|
149 | 149 | $character = $value; |
150 | 150 | $length = 1; |
151 | 151 | $remaining = 0; |
152 | 152 | } |
153 | 153 | // Two byte sequence: |
154 | - elseif (($value & 0xE0) === 0xC0) { |
|
155 | - $character = ($value & 0x1F) << 6; |
|
154 | + elseif(($value&0xE0) === 0xC0) { |
|
155 | + $character = ($value&0x1F) << 6; |
|
156 | 156 | $length = 2; |
157 | 157 | $remaining = 1; |
158 | 158 | } |
159 | 159 | // Three byte sequence: |
160 | - elseif (($value & 0xF0) === 0xE0) { |
|
161 | - $character = ($value & 0x0F) << 12; |
|
160 | + elseif(($value&0xF0) === 0xE0) { |
|
161 | + $character = ($value&0x0F) << 12; |
|
162 | 162 | $length = 3; |
163 | 163 | $remaining = 2; |
164 | 164 | } |
165 | 165 | // Four byte sequence: |
166 | - elseif (($value & 0xF8) === 0xF0) { |
|
167 | - $character = ($value & 0x07) << 18; |
|
166 | + elseif(($value&0xF8) === 0xF0) { |
|
167 | + $character = ($value&0x07) << 18; |
|
168 | 168 | $length = 4; |
169 | 169 | $remaining = 3; |
170 | 170 | } |
@@ -173,31 +173,31 @@ discard block |
||
173 | 173 | throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $value); |
174 | 174 | } |
175 | 175 | |
176 | - if ($remaining > 0) { |
|
177 | - if ($position + $length > $strlen) { |
|
176 | + if($remaining > 0) { |
|
177 | + if($position + $length > $strlen) { |
|
178 | 178 | throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character); |
179 | 179 | } |
180 | - for ($position++; $remaining > 0; $position++) { |
|
180 | + for($position++; $remaining > 0; $position++) { |
|
181 | 181 | $value = ord($input[$position]); |
182 | 182 | |
183 | 183 | // If it is invalid, count the sequence as invalid and reprocess the current byte: |
184 | - if (($value & 0xC0) !== 0x80) { |
|
184 | + if(($value&0xC0) !== 0x80) { |
|
185 | 185 | throw new Requests_Exception('Invalid Unicode codepoint', 'idna.invalidcodepoint', $character); |
186 | 186 | } |
187 | 187 | |
188 | - $character |= ($value & 0x3F) << (--$remaining * 6); |
|
188 | + $character |= ($value&0x3F) << (--$remaining * 6); |
|
189 | 189 | } |
190 | 190 | $position--; |
191 | 191 | } |
192 | 192 | |
193 | - if ( |
|
193 | + if( |
|
194 | 194 | // Non-shortest form sequences are invalid |
195 | 195 | $length > 1 && $character <= 0x7F |
196 | 196 | || $length > 2 && $character <= 0x7FF |
197 | 197 | || $length > 3 && $character <= 0xFFFF |
198 | 198 | // Outside of range of ucschar codepoints |
199 | 199 | // Noncharacters |
200 | - || ($character & 0xFFFE) === 0xFFFE |
|
200 | + || ($character&0xFFFE) === 0xFFFE |
|
201 | 201 | || $character >= 0xFDD0 && $character <= 0xFDEF |
202 | 202 | || ( |
203 | 203 | // Everything else not in ucschar |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | $codepoints = self::utf8_to_codepoints($input); |
240 | 240 | $extended = array(); |
241 | 241 | |
242 | - foreach ($codepoints as $char) { |
|
243 | - if ($char < 128) { |
|
242 | + foreach($codepoints as $char) { |
|
243 | + if($char < 128) { |
|
244 | 244 | // Character is valid ASCII |
245 | 245 | // TODO: this should also check if it's valid for a URL |
246 | 246 | $output .= chr($char); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | // Check if the character is non-ASCII, but below initial n |
250 | 250 | // This never occurs for Punycode, so ignore in coverage |
251 | 251 | // @codeCoverageIgnoreStart |
252 | - elseif ($char < $n) { |
|
252 | + elseif($char < $n) { |
|
253 | 253 | throw new Requests_Exception('Invalid character', 'idna.character_outside_domain', $char); |
254 | 254 | } |
255 | 255 | // @codeCoverageIgnoreEnd |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | sort($extended); |
262 | 262 | $b = $h; |
263 | 263 | # [copy them] followed by a delimiter if b > 0 |
264 | - if (strlen($output) > 0) { |
|
264 | + if(strlen($output) > 0) { |
|
265 | 265 | $output .= '-'; |
266 | 266 | } |
267 | 267 | # {if the input contains a non-basic code point < n then fail} |
268 | 268 | # while h < length(input) do begin |
269 | - while ($h < count($codepoints)) { |
|
269 | + while($h < count($codepoints)) { |
|
270 | 270 | # let m = the minimum code point >= n in the input |
271 | 271 | $m = array_shift($extended); |
272 | 272 | //printf('next code point to insert is %s' . PHP_EOL, dechex($m)); |
@@ -275,31 +275,31 @@ discard block |
||
275 | 275 | # let n = m |
276 | 276 | $n = $m; |
277 | 277 | # for each code point c in the input (in order) do begin |
278 | - for ($num = 0; $num < count($codepoints); $num++) { |
|
278 | + for($num = 0; $num < count($codepoints); $num++) { |
|
279 | 279 | $c = $codepoints[$num]; |
280 | 280 | # if c < n then increment delta, fail on overflow |
281 | - if ($c < $n) { |
|
281 | + if($c < $n) { |
|
282 | 282 | $delta++; |
283 | 283 | } |
284 | 284 | # if c == n then begin |
285 | - elseif ($c === $n) { |
|
285 | + elseif($c === $n) { |
|
286 | 286 | # let q = delta |
287 | 287 | $q = $delta; |
288 | 288 | # for k = base to infinity in steps of base do begin |
289 | - for ($k = self::BOOTSTRAP_BASE; ; $k += self::BOOTSTRAP_BASE) { |
|
289 | + for($k = self::BOOTSTRAP_BASE; ; $k += self::BOOTSTRAP_BASE) { |
|
290 | 290 | # let t = tmin if k <= bias {+ tmin}, or |
291 | 291 | # tmax if k >= bias + tmax, or k - bias otherwise |
292 | - if ($k <= ($bias + self::BOOTSTRAP_TMIN)) { |
|
292 | + if($k <= ($bias + self::BOOTSTRAP_TMIN)) { |
|
293 | 293 | $t = self::BOOTSTRAP_TMIN; |
294 | 294 | } |
295 | - elseif ($k >= ($bias + self::BOOTSTRAP_TMAX)) { |
|
295 | + elseif($k >= ($bias + self::BOOTSTRAP_TMAX)) { |
|
296 | 296 | $t = self::BOOTSTRAP_TMAX; |
297 | 297 | } |
298 | 298 | else { |
299 | 299 | $t = $k - $bias; |
300 | 300 | } |
301 | 301 | # if q < t then break |
302 | - if ($q < $t) { |
|
302 | + if($q < $t) { |
|
303 | 303 | break; |
304 | 304 | } |
305 | 305 | # output the code point for digit t + ((q - t) mod (base - t)) |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | protected static function digit_to_char($digit) { |
343 | 343 | // @codeCoverageIgnoreStart |
344 | 344 | // As far as I know, this never happens, but still good to be sure. |
345 | - if ($digit < 0 || $digit > 35) { |
|
345 | + if($digit < 0 || $digit > 35) { |
|
346 | 346 | throw new Requests_Exception(sprintf('Invalid digit %d', $digit), 'idna.invalid_digit', $digit); |
347 | 347 | } |
348 | 348 | // @codeCoverageIgnoreEnd |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | protected static function adapt($delta, $numpoints, $firsttime) { |
363 | 363 | # function adapt(delta,numpoints,firsttime): |
364 | 364 | # if firsttime then let delta = delta div damp |
365 | - if ($firsttime) { |
|
365 | + if($firsttime) { |
|
366 | 366 | $delta = floor($delta / self::BOOTSTRAP_DAMP); |
367 | 367 | } |
368 | 368 | # else let delta = delta div 2 |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $k = 0; |
376 | 376 | # while delta > ((base - tmin) * tmax) div 2 do begin |
377 | 377 | $max = floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN) * self::BOOTSTRAP_TMAX) / 2); |
378 | - while ($delta > $max) { |
|
378 | + while($delta > $max) { |
|
379 | 379 | # let delta = delta div (base - tmin) |
380 | 380 | $delta = floor($delta / (self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN)); |
381 | 381 | # let k = k + base |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * Returns false if $base is not absolute, otherwise an IRI. |
251 | 251 | * |
252 | - * @param IRI|string $base (Absolute) Base IRI |
|
252 | + * @param string $base (Absolute) Base IRI |
|
253 | 253 | * @param IRI|string $relative Relative IRI |
254 | 254 | * @return IRI|false |
255 | 255 | */ |
@@ -984,6 +984,7 @@ discard block |
||
984 | 984 | * Convert an IRI to a URI (or parts thereof) |
985 | 985 | * |
986 | 986 | * @param string|bool IRI to convert (or false from {@see get_iri}) |
987 | + * @param false|string $string |
|
987 | 988 | * @return string|false URI if IRI is valid, false otherwise. |
988 | 989 | */ |
989 | 990 | protected function to_uri($string) { |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | * @param mixed $value Property value |
154 | 154 | */ |
155 | 155 | public function __set($name, $value) { |
156 | - if (method_exists($this, 'set_' . $name)) { |
|
156 | + if(method_exists($this, 'set_' . $name)) { |
|
157 | 157 | call_user_func(array($this, 'set_' . $name), $value); |
158 | 158 | } |
159 | - elseif ( |
|
159 | + elseif( |
|
160 | 160 | $name === 'iauthority' |
161 | 161 | || $name === 'iuserinfo' |
162 | 162 | || $name === 'ihost' |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | // Also why we use array_key_exists below instead of isset() |
180 | 180 | $props = get_object_vars($this); |
181 | 181 | |
182 | - if ( |
|
182 | + if( |
|
183 | 183 | $name === 'iri' || |
184 | 184 | $name === 'uri' || |
185 | 185 | $name === 'iauthority' || |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $method = 'get_' . $name; |
189 | 189 | $return = $this->$method(); |
190 | 190 | } |
191 | - elseif (array_key_exists($name, $props)) { |
|
191 | + elseif(array_key_exists($name, $props)) { |
|
192 | 192 | $return = $this->$name; |
193 | 193 | } |
194 | 194 | // host -> ihost |
195 | - elseif (($prop = 'i' . $name) && array_key_exists($prop, $props)) { |
|
195 | + elseif(($prop = 'i' . $name) && array_key_exists($prop, $props)) { |
|
196 | 196 | $name = $prop; |
197 | 197 | $return = $this->$prop; |
198 | 198 | } |
199 | 199 | // ischeme -> scheme |
200 | - elseif (($prop = substr($name, 1)) && array_key_exists($prop, $props)) { |
|
200 | + elseif(($prop = substr($name, 1)) && array_key_exists($prop, $props)) { |
|
201 | 201 | $name = $prop; |
202 | 202 | $return = $this->$prop; |
203 | 203 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $return = null; |
207 | 207 | } |
208 | 208 | |
209 | - if ($return === null && isset($this->normalization[$this->scheme][$name])) { |
|
209 | + if($return === null && isset($this->normalization[$this->scheme][$name])) { |
|
210 | 210 | return $this->normalization[$this->scheme][$name]; |
211 | 211 | } |
212 | 212 | else { |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @param string $name Property name |
231 | 231 | */ |
232 | 232 | public function __unset($name) { |
233 | - if (method_exists($this, 'set_' . $name)) { |
|
233 | + if(method_exists($this, 'set_' . $name)) { |
|
234 | 234 | call_user_func(array($this, 'set_' . $name), ''); |
235 | 235 | } |
236 | 236 | } |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | * @return IRI|false |
255 | 255 | */ |
256 | 256 | public static function absolutize($base, $relative) { |
257 | - if (!($relative instanceof Requests_IRI)) { |
|
257 | + if(!($relative instanceof Requests_IRI)) { |
|
258 | 258 | $relative = new Requests_IRI($relative); |
259 | 259 | } |
260 | - if (!$relative->is_valid()) { |
|
260 | + if(!$relative->is_valid()) { |
|
261 | 261 | return false; |
262 | 262 | } |
263 | - elseif ($relative->scheme !== null) { |
|
263 | + elseif($relative->scheme !== null) { |
|
264 | 264 | return clone $relative; |
265 | 265 | } |
266 | 266 | |
267 | - if (!($base instanceof Requests_IRI)) { |
|
267 | + if(!($base instanceof Requests_IRI)) { |
|
268 | 268 | $base = new Requests_IRI($base); |
269 | 269 | } |
270 | - if ($base->scheme === null || !$base->is_valid()) { |
|
270 | + if($base->scheme === null || !$base->is_valid()) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 | |
274 | - if ($relative->get_iri() !== '') { |
|
275 | - if ($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) { |
|
274 | + if($relative->get_iri() !== '') { |
|
275 | + if($relative->iuserinfo !== null || $relative->ihost !== null || $relative->port !== null) { |
|
276 | 276 | $target = clone $relative; |
277 | 277 | $target->scheme = $base->scheme; |
278 | 278 | } |
@@ -282,14 +282,14 @@ discard block |
||
282 | 282 | $target->iuserinfo = $base->iuserinfo; |
283 | 283 | $target->ihost = $base->ihost; |
284 | 284 | $target->port = $base->port; |
285 | - if ($relative->ipath !== '') { |
|
286 | - if ($relative->ipath[0] === '/') { |
|
285 | + if($relative->ipath !== '') { |
|
286 | + if($relative->ipath[0] === '/') { |
|
287 | 287 | $target->ipath = $relative->ipath; |
288 | 288 | } |
289 | - elseif (($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') { |
|
289 | + elseif(($base->iuserinfo !== null || $base->ihost !== null || $base->port !== null) && $base->ipath === '') { |
|
290 | 290 | $target->ipath = '/' . $relative->ipath; |
291 | 291 | } |
292 | - elseif (($last_segment = strrpos($base->ipath, '/')) !== false) { |
|
292 | + elseif(($last_segment = strrpos($base->ipath, '/')) !== false) { |
|
293 | 293 | $target->ipath = substr($base->ipath, 0, $last_segment + 1) . $relative->ipath; |
294 | 294 | } |
295 | 295 | else { |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | } |
301 | 301 | else { |
302 | 302 | $target->ipath = $base->ipath; |
303 | - if ($relative->iquery !== null) { |
|
303 | + if($relative->iquery !== null) { |
|
304 | 304 | $target->iquery = $relative->iquery; |
305 | 305 | } |
306 | - elseif ($base->iquery !== null) { |
|
306 | + elseif($base->iquery !== null) { |
|
307 | 307 | $target->iquery = $base->iquery; |
308 | 308 | } |
309 | 309 | } |
@@ -327,23 +327,23 @@ discard block |
||
327 | 327 | protected function parse_iri($iri) { |
328 | 328 | $iri = trim($iri, "\x20\x09\x0A\x0C\x0D"); |
329 | 329 | $has_match = preg_match('/^((?P<scheme>[^:\/?#]+):)?(\/\/(?P<authority>[^\/?#]*))?(?P<path>[^?#]*)(\?(?P<query>[^#]*))?(#(?P<fragment>.*))?$/', $iri, $match); |
330 | - if (!$has_match) { |
|
330 | + if(!$has_match) { |
|
331 | 331 | throw new Requests_Exception('Cannot parse supplied IRI', 'iri.cannot_parse', $iri); |
332 | 332 | } |
333 | 333 | |
334 | - if ($match[1] === '') { |
|
334 | + if($match[1] === '') { |
|
335 | 335 | $match['scheme'] = null; |
336 | 336 | } |
337 | - if (!isset($match[3]) || $match[3] === '') { |
|
337 | + if(!isset($match[3]) || $match[3] === '') { |
|
338 | 338 | $match['authority'] = null; |
339 | 339 | } |
340 | - if (!isset($match[5])) { |
|
340 | + if(!isset($match[5])) { |
|
341 | 341 | $match['path'] = ''; |
342 | 342 | } |
343 | - if (!isset($match[6]) || $match[6] === '') { |
|
343 | + if(!isset($match[6]) || $match[6] === '') { |
|
344 | 344 | $match['query'] = null; |
345 | 345 | } |
346 | - if (!isset($match[8]) || $match[8] === '') { |
|
346 | + if(!isset($match[8]) || $match[8] === '') { |
|
347 | 347 | $match['fragment'] = null; |
348 | 348 | } |
349 | 349 | return $match; |
@@ -357,46 +357,46 @@ discard block |
||
357 | 357 | */ |
358 | 358 | protected function remove_dot_segments($input) { |
359 | 359 | $output = ''; |
360 | - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { |
|
360 | + while(strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { |
|
361 | 361 | // A: If the input buffer begins with a prefix of "../" or "./", |
362 | 362 | // then remove that prefix from the input buffer; otherwise, |
363 | - if (strpos($input, '../') === 0) { |
|
363 | + if(strpos($input, '../') === 0) { |
|
364 | 364 | $input = substr($input, 3); |
365 | 365 | } |
366 | - elseif (strpos($input, './') === 0) { |
|
366 | + elseif(strpos($input, './') === 0) { |
|
367 | 367 | $input = substr($input, 2); |
368 | 368 | } |
369 | 369 | // B: if the input buffer begins with a prefix of "/./" or "/.", |
370 | 370 | // where "." is a complete path segment, then replace that prefix |
371 | 371 | // with "/" in the input buffer; otherwise, |
372 | - elseif (strpos($input, '/./') === 0) { |
|
372 | + elseif(strpos($input, '/./') === 0) { |
|
373 | 373 | $input = substr($input, 2); |
374 | 374 | } |
375 | - elseif ($input === '/.') { |
|
375 | + elseif($input === '/.') { |
|
376 | 376 | $input = '/'; |
377 | 377 | } |
378 | 378 | // C: if the input buffer begins with a prefix of "/../" or "/..", |
379 | 379 | // where ".." is a complete path segment, then replace that prefix |
380 | 380 | // with "/" in the input buffer and remove the last segment and its |
381 | 381 | // preceding "/" (if any) from the output buffer; otherwise, |
382 | - elseif (strpos($input, '/../') === 0) { |
|
382 | + elseif(strpos($input, '/../') === 0) { |
|
383 | 383 | $input = substr($input, 3); |
384 | 384 | $output = substr_replace($output, '', strrpos($output, '/')); |
385 | 385 | } |
386 | - elseif ($input === '/..') { |
|
386 | + elseif($input === '/..') { |
|
387 | 387 | $input = '/'; |
388 | 388 | $output = substr_replace($output, '', strrpos($output, '/')); |
389 | 389 | } |
390 | 390 | // D: if the input buffer consists only of "." or "..", then remove |
391 | 391 | // that from the input buffer; otherwise, |
392 | - elseif ($input === '.' || $input === '..') { |
|
392 | + elseif($input === '.' || $input === '..') { |
|
393 | 393 | $input = ''; |
394 | 394 | } |
395 | 395 | // E: move the first path segment in the input buffer to the end of |
396 | 396 | // the output buffer, including the initial "/" character (if any) |
397 | 397 | // and any subsequent characters up to, but not including, the next |
398 | 398 | // "/" character or the end of the input buffer |
399 | - elseif (($pos = strpos($input, '/', 1)) !== false) { |
|
399 | + elseif(($pos = strpos($input, '/', 1)) !== false) { |
|
400 | 400 | $output .= substr($input, 0, $pos); |
401 | 401 | $input = substr_replace($input, '', 0, $pos); |
402 | 402 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | // Now replace any bytes that aren't allowed with their pct-encoded versions |
432 | 432 | $position = 0; |
433 | 433 | $strlen = strlen($string); |
434 | - while (($position += strspn($string, $extra_chars, $position)) < $strlen) { |
|
434 | + while(($position += strspn($string, $extra_chars, $position)) < $strlen) { |
|
435 | 435 | $value = ord($string[$position]); |
436 | 436 | |
437 | 437 | // Start position |
@@ -442,20 +442,20 @@ discard block |
||
442 | 442 | |
443 | 443 | // No one byte sequences are valid due to the while. |
444 | 444 | // Two byte sequence: |
445 | - if (($value & 0xE0) === 0xC0) { |
|
446 | - $character = ($value & 0x1F) << 6; |
|
445 | + if(($value&0xE0) === 0xC0) { |
|
446 | + $character = ($value&0x1F) << 6; |
|
447 | 447 | $length = 2; |
448 | 448 | $remaining = 1; |
449 | 449 | } |
450 | 450 | // Three byte sequence: |
451 | - elseif (($value & 0xF0) === 0xE0) { |
|
452 | - $character = ($value & 0x0F) << 12; |
|
451 | + elseif(($value&0xF0) === 0xE0) { |
|
452 | + $character = ($value&0x0F) << 12; |
|
453 | 453 | $length = 3; |
454 | 454 | $remaining = 2; |
455 | 455 | } |
456 | 456 | // Four byte sequence: |
457 | - elseif (($value & 0xF8) === 0xF0) { |
|
458 | - $character = ($value & 0x07) << 18; |
|
457 | + elseif(($value&0xF8) === 0xF0) { |
|
458 | + $character = ($value&0x07) << 18; |
|
459 | 459 | $length = 4; |
460 | 460 | $remaining = 3; |
461 | 461 | } |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | $remaining = 0; |
467 | 467 | } |
468 | 468 | |
469 | - if ($remaining) { |
|
470 | - if ($position + $length <= $strlen) { |
|
471 | - for ($position++; $remaining; $position++) { |
|
469 | + if($remaining) { |
|
470 | + if($position + $length <= $strlen) { |
|
471 | + for($position++; $remaining; $position++) { |
|
472 | 472 | $value = ord($string[$position]); |
473 | 473 | |
474 | 474 | // Check that the byte is valid, then add it to the character: |
475 | - if (($value & 0xC0) === 0x80) { |
|
476 | - $character |= ($value & 0x3F) << (--$remaining * 6); |
|
475 | + if(($value&0xC0) === 0x80) { |
|
476 | + $character |= ($value&0x3F) << (--$remaining * 6); |
|
477 | 477 | } |
478 | 478 | // If it is invalid, count the sequence as invalid and reprocess the current byte: |
479 | 479 | else { |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | // Percent encode anything invalid or not in ucschar |
493 | - if ( |
|
493 | + if( |
|
494 | 494 | // Invalid sequences |
495 | 495 | !$valid |
496 | 496 | // Non-shortest form sequences are invalid |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | || $length > 3 && $character <= 0xFFFF |
500 | 500 | // Outside of range of ucschar codepoints |
501 | 501 | // Noncharacters |
502 | - || ($character & 0xFFFE) === 0xFFFE |
|
502 | + || ($character&0xFFFE) === 0xFFFE |
|
503 | 503 | || $character >= 0xFDD0 && $character <= 0xFDEF |
504 | 504 | || ( |
505 | 505 | // Everything else not in ucschar |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | ) |
516 | 516 | ) { |
517 | 517 | // If we were a character, pretend we weren't, but rather an error. |
518 | - if ($valid) { |
|
518 | + if($valid) { |
|
519 | 519 | $position--; |
520 | 520 | } |
521 | 521 | |
522 | - for ($j = $start; $j <= $position; $j++) { |
|
522 | + for($j = $start; $j <= $position; $j++) { |
|
523 | 523 | $string = substr_replace($string, sprintf('%%%02X', ord($string[$j])), $j, 1); |
524 | 524 | $j += 2; |
525 | 525 | $position += 2; |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | $remaining = 0; |
553 | 553 | |
554 | 554 | // Loop over each and every byte, and set $value to its value |
555 | - for ($i = 1, $len = count($bytes); $i < $len; $i++) { |
|
555 | + for($i = 1, $len = count($bytes); $i < $len; $i++) { |
|
556 | 556 | $value = hexdec($bytes[$i]); |
557 | 557 | |
558 | 558 | // If we're the first byte of sequence: |
559 | - if (!$remaining) { |
|
559 | + if(!$remaining) { |
|
560 | 560 | // Start position |
561 | 561 | $start = $i; |
562 | 562 | |
@@ -564,25 +564,25 @@ discard block |
||
564 | 564 | $valid = true; |
565 | 565 | |
566 | 566 | // One byte sequence: |
567 | - if ($value <= 0x7F) { |
|
567 | + if($value <= 0x7F) { |
|
568 | 568 | $character = $value; |
569 | 569 | $length = 1; |
570 | 570 | } |
571 | 571 | // Two byte sequence: |
572 | - elseif (($value & 0xE0) === 0xC0) { |
|
573 | - $character = ($value & 0x1F) << 6; |
|
572 | + elseif(($value&0xE0) === 0xC0) { |
|
573 | + $character = ($value&0x1F) << 6; |
|
574 | 574 | $length = 2; |
575 | 575 | $remaining = 1; |
576 | 576 | } |
577 | 577 | // Three byte sequence: |
578 | - elseif (($value & 0xF0) === 0xE0) { |
|
579 | - $character = ($value & 0x0F) << 12; |
|
578 | + elseif(($value&0xF0) === 0xE0) { |
|
579 | + $character = ($value&0x0F) << 12; |
|
580 | 580 | $length = 3; |
581 | 581 | $remaining = 2; |
582 | 582 | } |
583 | 583 | // Four byte sequence: |
584 | - elseif (($value & 0xF8) === 0xF0) { |
|
585 | - $character = ($value & 0x07) << 18; |
|
584 | + elseif(($value&0xF8) === 0xF0) { |
|
585 | + $character = ($value&0x07) << 18; |
|
586 | 586 | $length = 4; |
587 | 587 | $remaining = 3; |
588 | 588 | } |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | // Continuation byte: |
596 | 596 | else { |
597 | 597 | // Check that the byte is valid, then add it to the character: |
598 | - if (($value & 0xC0) === 0x80) { |
|
598 | + if(($value&0xC0) === 0x80) { |
|
599 | 599 | $remaining--; |
600 | - $character |= ($value & 0x3F) << ($remaining * 6); |
|
600 | + $character |= ($value&0x3F) << ($remaining * 6); |
|
601 | 601 | } |
602 | 602 | // If it is invalid, count the sequence as invalid and reprocess the current byte as the start of a sequence: |
603 | 603 | else { |
@@ -608,9 +608,9 @@ discard block |
||
608 | 608 | } |
609 | 609 | |
610 | 610 | // If we've reached the end of the current byte sequence, append it to Unicode::$data |
611 | - if (!$remaining) { |
|
611 | + if(!$remaining) { |
|
612 | 612 | // Percent encode anything invalid or not in iunreserved |
613 | - if ( |
|
613 | + if( |
|
614 | 614 | // Invalid sequences |
615 | 615 | !$valid |
616 | 616 | // Non-shortest form sequences are invalid |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | || $character < 0x2D |
622 | 622 | || $character > 0xEFFFD |
623 | 623 | // Noncharacters |
624 | - || ($character & 0xFFFE) === 0xFFFE |
|
624 | + || ($character&0xFFFE) === 0xFFFE |
|
625 | 625 | || $character >= 0xFDD0 && $character <= 0xFDEF |
626 | 626 | // Everything else not in iunreserved (this is all BMP) |
627 | 627 | || $character === 0x2F |
@@ -631,12 +631,12 @@ discard block |
||
631 | 631 | || $character > 0x7E && $character < 0xA0 |
632 | 632 | || $character > 0xD7FF && $character < 0xF900 |
633 | 633 | ) { |
634 | - for ($j = $start; $j <= $i; $j++) { |
|
634 | + for($j = $start; $j <= $i; $j++) { |
|
635 | 635 | $string .= '%' . strtoupper($bytes[$j]); |
636 | 636 | } |
637 | 637 | } |
638 | 638 | else { |
639 | - for ($j = $start; $j <= $i; $j++) { |
|
639 | + for($j = $start; $j <= $i; $j++) { |
|
640 | 640 | $string .= chr(hexdec($bytes[$j])); |
641 | 641 | } |
642 | 642 | } |
@@ -645,8 +645,8 @@ discard block |
||
645 | 645 | |
646 | 646 | // If we have any bytes left over they are invalid (i.e., we are |
647 | 647 | // mid-way through a multi-byte sequence) |
648 | - if ($remaining) { |
|
649 | - for ($j = $start; $j < $len; $j++) { |
|
648 | + if($remaining) { |
|
649 | + for($j = $start; $j < $len; $j++) { |
|
650 | 650 | $string .= '%' . strtoupper($bytes[$j]); |
651 | 651 | } |
652 | 652 | } |
@@ -655,25 +655,25 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | protected function scheme_normalization() { |
658 | - if (isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { |
|
658 | + if(isset($this->normalization[$this->scheme]['iuserinfo']) && $this->iuserinfo === $this->normalization[$this->scheme]['iuserinfo']) { |
|
659 | 659 | $this->iuserinfo = null; |
660 | 660 | } |
661 | - if (isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { |
|
661 | + if(isset($this->normalization[$this->scheme]['ihost']) && $this->ihost === $this->normalization[$this->scheme]['ihost']) { |
|
662 | 662 | $this->ihost = null; |
663 | 663 | } |
664 | - if (isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { |
|
664 | + if(isset($this->normalization[$this->scheme]['port']) && $this->port === $this->normalization[$this->scheme]['port']) { |
|
665 | 665 | $this->port = null; |
666 | 666 | } |
667 | - if (isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { |
|
667 | + if(isset($this->normalization[$this->scheme]['ipath']) && $this->ipath === $this->normalization[$this->scheme]['ipath']) { |
|
668 | 668 | $this->ipath = ''; |
669 | 669 | } |
670 | - if (isset($this->ihost) && empty($this->ipath)) { |
|
670 | + if(isset($this->ihost) && empty($this->ipath)) { |
|
671 | 671 | $this->ipath = '/'; |
672 | 672 | } |
673 | - if (isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { |
|
673 | + if(isset($this->normalization[$this->scheme]['iquery']) && $this->iquery === $this->normalization[$this->scheme]['iquery']) { |
|
674 | 674 | $this->iquery = null; |
675 | 675 | } |
676 | - if (isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { |
|
676 | + if(isset($this->normalization[$this->scheme]['ifragment']) && $this->ifragment === $this->normalization[$this->scheme]['ifragment']) { |
|
677 | 677 | $this->ifragment = null; |
678 | 678 | } |
679 | 679 | } |
@@ -686,14 +686,14 @@ discard block |
||
686 | 686 | */ |
687 | 687 | public function is_valid() { |
688 | 688 | $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; |
689 | - if ($this->ipath !== '' && |
|
689 | + if($this->ipath !== '' && |
|
690 | 690 | ( |
691 | 691 | $isauthority && $this->ipath[0] !== '/' || |
692 | 692 | ( |
693 | 693 | $this->scheme === null && |
694 | 694 | !$isauthority && |
695 | 695 | strpos($this->ipath, ':') !== false && |
696 | - (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) |
|
696 | + (strpos($this->ipath, '/') === false?true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) |
|
697 | 697 | ) |
698 | 698 | ) |
699 | 699 | ) { |
@@ -712,14 +712,14 @@ discard block |
||
712 | 712 | */ |
713 | 713 | protected function set_iri($iri) { |
714 | 714 | static $cache; |
715 | - if (!$cache) { |
|
715 | + if(!$cache) { |
|
716 | 716 | $cache = array(); |
717 | 717 | } |
718 | 718 | |
719 | - if ($iri === null) { |
|
719 | + if($iri === null) { |
|
720 | 720 | return true; |
721 | 721 | } |
722 | - if (isset($cache[$iri])) { |
|
722 | + if(isset($cache[$iri])) { |
|
723 | 723 | list($this->scheme, |
724 | 724 | $this->iuserinfo, |
725 | 725 | $this->ihost, |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | return $return; |
732 | 732 | } |
733 | 733 | |
734 | - $parsed = $this->parse_iri((string) $iri); |
|
734 | + $parsed = $this->parse_iri((string)$iri); |
|
735 | 735 | |
736 | 736 | $return = $this->set_scheme($parsed['scheme']) |
737 | 737 | && $this->set_authority($parsed['authority']) |
@@ -758,10 +758,10 @@ discard block |
||
758 | 758 | * @return bool |
759 | 759 | */ |
760 | 760 | protected function set_scheme($scheme) { |
761 | - if ($scheme === null) { |
|
761 | + if($scheme === null) { |
|
762 | 762 | $this->scheme = null; |
763 | 763 | } |
764 | - elseif (!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) { |
|
764 | + elseif(!preg_match('/^[A-Za-z][0-9A-Za-z+\-.]*$/', $scheme)) { |
|
765 | 765 | $this->scheme = null; |
766 | 766 | return false; |
767 | 767 | } |
@@ -780,17 +780,17 @@ discard block |
||
780 | 780 | */ |
781 | 781 | protected function set_authority($authority) { |
782 | 782 | static $cache; |
783 | - if (!$cache) { |
|
783 | + if(!$cache) { |
|
784 | 784 | $cache = array(); |
785 | 785 | } |
786 | 786 | |
787 | - if ($authority === null) { |
|
787 | + if($authority === null) { |
|
788 | 788 | $this->iuserinfo = null; |
789 | 789 | $this->ihost = null; |
790 | 790 | $this->port = null; |
791 | 791 | return true; |
792 | 792 | } |
793 | - if (isset($cache[$authority])) { |
|
793 | + if(isset($cache[$authority])) { |
|
794 | 794 | list($this->iuserinfo, |
795 | 795 | $this->ihost, |
796 | 796 | $this->port, |
@@ -800,16 +800,16 @@ discard block |
||
800 | 800 | } |
801 | 801 | |
802 | 802 | $remaining = $authority; |
803 | - if (($iuserinfo_end = strrpos($remaining, '@')) !== false) { |
|
803 | + if(($iuserinfo_end = strrpos($remaining, '@')) !== false) { |
|
804 | 804 | $iuserinfo = substr($remaining, 0, $iuserinfo_end); |
805 | 805 | $remaining = substr($remaining, $iuserinfo_end + 1); |
806 | 806 | } |
807 | 807 | else { |
808 | 808 | $iuserinfo = null; |
809 | 809 | } |
810 | - if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) { |
|
810 | + if(($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) { |
|
811 | 811 | $port = substr($remaining, $port_start + 1); |
812 | - if ($port === false || $port === '') { |
|
812 | + if($port === false || $port === '') { |
|
813 | 813 | $port = null; |
814 | 814 | } |
815 | 815 | $remaining = substr($remaining, 0, $port_start); |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * @return bool |
838 | 838 | */ |
839 | 839 | protected function set_userinfo($iuserinfo) { |
840 | - if ($iuserinfo === null) { |
|
840 | + if($iuserinfo === null) { |
|
841 | 841 | $this->iuserinfo = null; |
842 | 842 | } |
843 | 843 | else { |
@@ -856,12 +856,12 @@ discard block |
||
856 | 856 | * @return bool |
857 | 857 | */ |
858 | 858 | protected function set_host($ihost) { |
859 | - if ($ihost === null) { |
|
859 | + if($ihost === null) { |
|
860 | 860 | $this->ihost = null; |
861 | 861 | return true; |
862 | 862 | } |
863 | - if (substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') { |
|
864 | - if (Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) { |
|
863 | + if(substr($ihost, 0, 1) === '[' && substr($ihost, -1) === ']') { |
|
864 | + if(Requests_IPv6::check_ipv6(substr($ihost, 1, -1))) { |
|
865 | 865 | $this->ihost = '[' . Requests_IPv6::compress(substr($ihost, 1, -1)) . ']'; |
866 | 866 | } |
867 | 867 | else { |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | // as that can add unescaped characters. |
878 | 878 | $position = 0; |
879 | 879 | $strlen = strlen($ihost); |
880 | - while (($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) { |
|
881 | - if ($ihost[$position] === '%') { |
|
880 | + while(($position += strcspn($ihost, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ%', $position)) < $strlen) { |
|
881 | + if($ihost[$position] === '%') { |
|
882 | 882 | $position += 3; |
883 | 883 | } |
884 | 884 | else { |
@@ -903,13 +903,13 @@ discard block |
||
903 | 903 | * @return bool |
904 | 904 | */ |
905 | 905 | protected function set_port($port) { |
906 | - if ($port === null) { |
|
906 | + if($port === null) { |
|
907 | 907 | $this->port = null; |
908 | 908 | return true; |
909 | 909 | } |
910 | 910 | |
911 | - if (strspn($port, '0123456789') === strlen($port)) { |
|
912 | - $this->port = (int) $port; |
|
911 | + if(strspn($port, '0123456789') === strlen($port)) { |
|
912 | + $this->port = (int)$port; |
|
913 | 913 | $this->scheme_normalization(); |
914 | 914 | return true; |
915 | 915 | } |
@@ -926,21 +926,21 @@ discard block |
||
926 | 926 | */ |
927 | 927 | protected function set_path($ipath) { |
928 | 928 | static $cache; |
929 | - if (!$cache) { |
|
929 | + if(!$cache) { |
|
930 | 930 | $cache = array(); |
931 | 931 | } |
932 | 932 | |
933 | - $ipath = (string) $ipath; |
|
933 | + $ipath = (string)$ipath; |
|
934 | 934 | |
935 | - if (isset($cache[$ipath])) { |
|
936 | - $this->ipath = $cache[$ipath][(int) ($this->scheme !== null)]; |
|
935 | + if(isset($cache[$ipath])) { |
|
936 | + $this->ipath = $cache[$ipath][(int)($this->scheme !== null)]; |
|
937 | 937 | } |
938 | 938 | else { |
939 | 939 | $valid = $this->replace_invalid_with_pct_encoding($ipath, '!$&\'()*+,;=@:/'); |
940 | 940 | $removed = $this->remove_dot_segments($valid); |
941 | 941 | |
942 | 942 | $cache[$ipath] = array($valid, $removed); |
943 | - $this->ipath = ($this->scheme !== null) ? $removed : $valid; |
|
943 | + $this->ipath = ($this->scheme !== null)?$removed : $valid; |
|
944 | 944 | } |
945 | 945 | $this->scheme_normalization(); |
946 | 946 | return true; |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | * @return bool |
954 | 954 | */ |
955 | 955 | protected function set_query($iquery) { |
956 | - if ($iquery === null) { |
|
956 | + if($iquery === null) { |
|
957 | 957 | $this->iquery = null; |
958 | 958 | } |
959 | 959 | else { |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | * @return bool |
971 | 971 | */ |
972 | 972 | protected function set_fragment($ifragment) { |
973 | - if ($ifragment === null) { |
|
973 | + if($ifragment === null) { |
|
974 | 974 | $this->ifragment = null; |
975 | 975 | } |
976 | 976 | else { |
@@ -987,18 +987,18 @@ discard block |
||
987 | 987 | * @return string|false URI if IRI is valid, false otherwise. |
988 | 988 | */ |
989 | 989 | protected function to_uri($string) { |
990 | - if (!is_string($string)) { |
|
990 | + if(!is_string($string)) { |
|
991 | 991 | return false; |
992 | 992 | } |
993 | 993 | |
994 | 994 | static $non_ascii; |
995 | - if (!$non_ascii) { |
|
995 | + if(!$non_ascii) { |
|
996 | 996 | $non_ascii = implode('', range("\x80", "\xFF")); |
997 | 997 | } |
998 | 998 | |
999 | 999 | $position = 0; |
1000 | 1000 | $strlen = strlen($string); |
1001 | - while (($position += strcspn($string, $non_ascii, $position)) < $strlen) { |
|
1001 | + while(($position += strcspn($string, $non_ascii, $position)) < $strlen) { |
|
1002 | 1002 | $string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1); |
1003 | 1003 | $position += 3; |
1004 | 1004 | $strlen += 2; |
@@ -1013,22 +1013,22 @@ discard block |
||
1013 | 1013 | * @return string |
1014 | 1014 | */ |
1015 | 1015 | protected function get_iri() { |
1016 | - if (!$this->is_valid()) { |
|
1016 | + if(!$this->is_valid()) { |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | $iri = ''; |
1021 | - if ($this->scheme !== null) { |
|
1021 | + if($this->scheme !== null) { |
|
1022 | 1022 | $iri .= $this->scheme . ':'; |
1023 | 1023 | } |
1024 | - if (($iauthority = $this->get_iauthority()) !== null) { |
|
1024 | + if(($iauthority = $this->get_iauthority()) !== null) { |
|
1025 | 1025 | $iri .= '//' . $iauthority; |
1026 | 1026 | } |
1027 | 1027 | $iri .= $this->ipath; |
1028 | - if ($this->iquery !== null) { |
|
1028 | + if($this->iquery !== null) { |
|
1029 | 1029 | $iri .= '?' . $this->iquery; |
1030 | 1030 | } |
1031 | - if ($this->ifragment !== null) { |
|
1031 | + if($this->ifragment !== null) { |
|
1032 | 1032 | $iri .= '#' . $this->ifragment; |
1033 | 1033 | } |
1034 | 1034 | |
@@ -1050,18 +1050,18 @@ discard block |
||
1050 | 1050 | * @return string |
1051 | 1051 | */ |
1052 | 1052 | protected function get_iauthority() { |
1053 | - if ($this->iuserinfo === null && $this->ihost === null && $this->port === null) { |
|
1053 | + if($this->iuserinfo === null && $this->ihost === null && $this->port === null) { |
|
1054 | 1054 | return null; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $iauthority = ''; |
1058 | - if ($this->iuserinfo !== null) { |
|
1058 | + if($this->iuserinfo !== null) { |
|
1059 | 1059 | $iauthority .= $this->iuserinfo . '@'; |
1060 | 1060 | } |
1061 | - if ($this->ihost !== null) { |
|
1061 | + if($this->ihost !== null) { |
|
1062 | 1062 | $iauthority .= $this->ihost; |
1063 | 1063 | } |
1064 | - if ($this->port !== null) { |
|
1064 | + if($this->port !== null) { |
|
1065 | 1065 | $iauthority .= ':' . $this->port; |
1066 | 1066 | } |
1067 | 1067 | return $iauthority; |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | */ |
1075 | 1075 | protected function get_authority() { |
1076 | 1076 | $iauthority = $this->get_iauthority(); |
1077 | - if (is_string($iauthority)) { |
|
1077 | + if(is_string($iauthority)) { |
|
1078 | 1078 | return $this->to_uri($iauthority); |
1079 | 1079 | } |
1080 | 1080 | else { |
@@ -232,7 +232,7 @@ |
||
232 | 232 | * |
233 | 233 | * @param array $request Request data (same form as {@see request_multiple}) |
234 | 234 | * @param boolean $merge_options Should we merge options as well? |
235 | - * @return array Request data |
|
235 | + * @return string Request data |
|
236 | 236 | */ |
237 | 237 | protected function merge_request($request, $merge_options = true) { |
238 | 238 | if ($this->url !== null) { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->data = $data; |
70 | 70 | $this->options = $options; |
71 | 71 | |
72 | - if (empty($this->options['cookies'])) { |
|
72 | + if(empty($this->options['cookies'])) { |
|
73 | 73 | $this->options['cookies'] = new Requests_Cookie_Jar(); |
74 | 74 | } |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return mixed|null Property value, null if none found |
82 | 82 | */ |
83 | 83 | public function __get($key) { |
84 | - if (isset($this->options[$key])) { |
|
84 | + if(isset($this->options[$key])) { |
|
85 | 85 | return $this->options[$key]; |
86 | 86 | } |
87 | 87 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string $key Property key |
114 | 114 | */ |
115 | 115 | public function __unset($key) { |
116 | - if (isset($this->options[$key])) { |
|
116 | + if(isset($this->options[$key])) { |
|
117 | 117 | unset($this->options[$key]); |
118 | 118 | } |
119 | 119 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return array Responses (either Requests_Response or a Requests_Exception object) |
216 | 216 | */ |
217 | 217 | public function request_multiple($requests, $options = array()) { |
218 | - foreach ($requests as $key => $request) { |
|
218 | + foreach($requests as $key => $request) { |
|
219 | 219 | $requests[$key] = $this->merge_request($request, false); |
220 | 220 | } |
221 | 221 | |
@@ -235,26 +235,26 @@ discard block |
||
235 | 235 | * @return array Request data |
236 | 236 | */ |
237 | 237 | protected function merge_request($request, $merge_options = true) { |
238 | - if ($this->url !== null) { |
|
238 | + if($this->url !== null) { |
|
239 | 239 | $request['url'] = Requests_IRI::absolutize($this->url, $request['url']); |
240 | 240 | $request['url'] = $request['url']->uri; |
241 | 241 | } |
242 | 242 | |
243 | - if (empty($request['headers'])) { |
|
243 | + if(empty($request['headers'])) { |
|
244 | 244 | $request['headers'] = array(); |
245 | 245 | } |
246 | 246 | $request['headers'] = array_merge($this->headers, $request['headers']); |
247 | 247 | |
248 | - if (empty($request['data'])) { |
|
249 | - if (is_array($this->data)) { |
|
248 | + if(empty($request['data'])) { |
|
249 | + if(is_array($this->data)) { |
|
250 | 250 | $request['data'] = $this->data; |
251 | 251 | } |
252 | 252 | } |
253 | - elseif (is_array($request['data']) && is_array($this->data)) { |
|
253 | + elseif(is_array($request['data']) && is_array($this->data)) { |
|
254 | 254 | $request['data'] = array_merge($this->data, $request['data']); |
255 | 255 | } |
256 | 256 | |
257 | - if ($merge_options !== false) { |
|
257 | + if($merge_options !== false) { |
|
258 | 258 | $request['options'] = array_merge($this->options, $request['options']); |
259 | 259 | |
260 | 260 | // Disallow forcing the type, as that's a per request setting |
@@ -29,5 +29,5 @@ |
||
29 | 29 | * @see Requests_Hooks::register |
30 | 30 | * @param Requests_Hooks $hooks Hook system |
31 | 31 | */ |
32 | - public function register(Requests_Hooks &$hooks); |
|
32 | + public function register(Requests_Hooks&$hooks); |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -28,6 +28,7 @@ |
||
28 | 28 | * |
29 | 29 | * @see Requests_Hooks::register |
30 | 30 | * @param Requests_Hooks $hooks Hook system |
31 | + * @return void |
|
31 | 32 | */ |
32 | 33 | public function register(Requests_Hooks &$hooks); |
33 | 34 | } |
34 | 35 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class Location{ |
|
3 | +class Location { |
|
4 | 4 | |
5 | 5 | public $cityName; |
6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $this->lng = $lng; |
39 | 39 | } |
40 | - public function toArray(){ |
|
40 | + public function toArray() { |
|
41 | 41 | return array( |
42 | 42 | "city" => $this->getCityName(), |
43 | 43 | "country" => 'DE', |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param string $name |
64 | 64 | * @param string $value |
65 | - * @param array|Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
|
65 | + * @param Requests_Utility_CaseInsensitiveDictionary $attributes Associative array of attribute data |
|
66 | 66 | */ |
67 | 67 | public function __construct($name, $value, $attributes = array(), $flags = array(), $reference_time = null) { |
68 | 68 | $this->name = $name; |
@@ -377,6 +377,7 @@ discard block |
||
377 | 377 | * specifies some of this handling, but not in a thorough manner. |
378 | 378 | * |
379 | 379 | * @param string Cookie header value (from a Set-Cookie header) |
380 | + * @param integer $reference_time |
|
380 | 381 | * @return Requests_Cookie Parsed cookie object |
381 | 382 | */ |
382 | 383 | public static function parse($string, $name = '', $reference_time = null) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->flags = array_merge($default_flags, $flags); |
78 | 78 | |
79 | 79 | $this->reference_time = time(); |
80 | - if ($reference_time !== null) { |
|
80 | + if($reference_time !== null) { |
|
81 | 81 | $this->reference_time = $reference_time; |
82 | 82 | } |
83 | 83 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | // If a cookie has both the Max-Age and the Expires attribute, the Max- |
98 | 98 | // Age attribute has precedence and controls the expiration date of the |
99 | 99 | // cookie. |
100 | - if (isset($this->attributes['max-age'])) { |
|
100 | + if(isset($this->attributes['max-age'])) { |
|
101 | 101 | $max_age = $this->attributes['max-age']; |
102 | 102 | return $max_age < $this->reference_time; |
103 | 103 | } |
104 | 104 | |
105 | - if (isset($this->attributes['expires'])) { |
|
105 | + if(isset($this->attributes['expires'])) { |
|
106 | 106 | $expires = $this->attributes['expires']; |
107 | 107 | return $expires < $this->reference_time; |
108 | 108 | } |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | * @return boolean Whether the cookie is valid for the given URI |
118 | 118 | */ |
119 | 119 | public function uri_matches(Requests_IRI $uri) { |
120 | - if (!$this->domain_matches($uri->host)) { |
|
120 | + if(!$this->domain_matches($uri->host)) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
124 | - if (!$this->path_matches($uri->path)) { |
|
124 | + if(!$this->path_matches($uri->path)) { |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
@@ -135,37 +135,37 @@ discard block |
||
135 | 135 | * @return boolean Whether the cookie is valid for the given domain |
136 | 136 | */ |
137 | 137 | public function domain_matches($string) { |
138 | - if (!isset($this->attributes['domain'])) { |
|
138 | + if(!isset($this->attributes['domain'])) { |
|
139 | 139 | // Cookies created manually; cookies created by Requests will set |
140 | 140 | // the domain to the requested domain |
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $domain_string = $this->attributes['domain']; |
145 | - if ($domain_string === $string) { |
|
145 | + if($domain_string === $string) { |
|
146 | 146 | // The domain string and the string are identical. |
147 | 147 | return true; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // If the cookie is marked as host-only and we don't have an exact |
151 | 151 | // match, reject the cookie |
152 | - if ($this->flags['host-only'] === true) { |
|
152 | + if($this->flags['host-only'] === true) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - if (strlen($string) <= strlen($domain_string)) { |
|
156 | + if(strlen($string) <= strlen($domain_string)) { |
|
157 | 157 | // For obvious reasons, the string cannot be a suffix if the domain |
158 | 158 | // is shorter than the domain string |
159 | 159 | return false; |
160 | 160 | } |
161 | 161 | |
162 | - if (substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
|
162 | + if(substr($string, -1 * strlen($domain_string)) !== $domain_string) { |
|
163 | 163 | // The domain string should be a suffix of the string. |
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $prefix = substr($string, 0, strlen($string) - strlen($domain_string)); |
168 | - if (substr($prefix, -1) !== '.') { |
|
168 | + if(substr($prefix, -1) !== '.') { |
|
169 | 169 | // The last character of the string that is not included in the |
170 | 170 | // domain string should be a %x2E (".") character. |
171 | 171 | return false; |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | * @return boolean Whether the cookie is valid for the given path |
185 | 185 | */ |
186 | 186 | public function path_matches($request_path) { |
187 | - if (empty($request_path)) { |
|
187 | + if(empty($request_path)) { |
|
188 | 188 | // Normalize empty path to root |
189 | 189 | $request_path = '/'; |
190 | 190 | } |
191 | 191 | |
192 | - if (!isset($this->attributes['path'])) { |
|
192 | + if(!isset($this->attributes['path'])) { |
|
193 | 193 | // Cookies created manually; cookies created by Requests will set |
194 | 194 | // the path to the requested path |
195 | 195 | return true; |
@@ -197,19 +197,19 @@ discard block |
||
197 | 197 | |
198 | 198 | $cookie_path = $this->attributes['path']; |
199 | 199 | |
200 | - if ($cookie_path === $request_path) { |
|
200 | + if($cookie_path === $request_path) { |
|
201 | 201 | // The cookie-path and the request-path are identical. |
202 | 202 | return true; |
203 | 203 | } |
204 | 204 | |
205 | - if (strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
|
206 | - if (substr($cookie_path, -1) === '/') { |
|
205 | + if(strlen($request_path) > strlen($cookie_path) && substr($request_path, 0, strlen($cookie_path)) === $cookie_path) { |
|
206 | + if(substr($cookie_path, -1) === '/') { |
|
207 | 207 | // The cookie-path is a prefix of the request-path, and the last |
208 | 208 | // character of the cookie-path is %x2F ("/"). |
209 | 209 | return true; |
210 | 210 | } |
211 | 211 | |
212 | - if (substr($request_path, strlen($cookie_path), 1) === '/') { |
|
212 | + if(substr($request_path, strlen($cookie_path), 1) === '/') { |
|
213 | 213 | // The cookie-path is a prefix of the request-path, and the |
214 | 214 | // first character of the request-path that is not included in |
215 | 215 | // the cookie-path is a %x2F ("/") character. |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | * @return boolean Whether the cookie was successfully normalized |
227 | 227 | */ |
228 | 228 | public function normalize() { |
229 | - foreach ($this->attributes as $key => $value) { |
|
229 | + foreach($this->attributes as $key => $value) { |
|
230 | 230 | $orig_value = $value; |
231 | 231 | $value = $this->normalize_attribute($key, $value); |
232 | - if ($value === null) { |
|
232 | + if($value === null) { |
|
233 | 233 | unset($this->attributes[$key]); |
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | - if ($value !== $orig_value) { |
|
237 | + if($value !== $orig_value) { |
|
238 | 238 | $this->attributes[$key] = $value; |
239 | 239 | } |
240 | 240 | } |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | * @return mixed Value if available, or null if the attribute value is invalid (and should be skipped) |
253 | 253 | */ |
254 | 254 | protected function normalize_attribute($name, $value) { |
255 | - switch (strtolower($name)) { |
|
255 | + switch(strtolower($name)) { |
|
256 | 256 | case 'expires': |
257 | 257 | // Expiration parsing, as per RFC 6265 section 5.2.1 |
258 | - if (is_int($value)) { |
|
258 | + if(is_int($value)) { |
|
259 | 259 | return $value; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $expiry_time = strtotime($value); |
263 | - if ($expiry_time === false) { |
|
263 | + if($expiry_time === false) { |
|
264 | 264 | return null; |
265 | 265 | } |
266 | 266 | |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | |
269 | 269 | case 'max-age': |
270 | 270 | // Expiration parsing, as per RFC 6265 section 5.2.2 |
271 | - if (is_int($value)) { |
|
271 | + if(is_int($value)) { |
|
272 | 272 | return $value; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Check that we have a valid age |
276 | - if (!preg_match('/^-?\d+$/', $value)) { |
|
276 | + if(!preg_match('/^-?\d+$/', $value)) { |
|
277 | 277 | return null; |
278 | 278 | } |
279 | 279 | |
280 | - $delta_seconds = (int) $value; |
|
281 | - if ($delta_seconds <= 0) { |
|
280 | + $delta_seconds = (int)$value; |
|
281 | + if($delta_seconds <= 0) { |
|
282 | 282 | $expiry_time = 0; |
283 | 283 | } |
284 | 284 | else { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | case 'domain': |
291 | 291 | // Domain normalization, as per RFC 6265 section 5.2.3 |
292 | - if ($value[0] === '.') { |
|
292 | + if($value[0] === '.') { |
|
293 | 293 | $value = substr($value, 1); |
294 | 294 | } |
295 | 295 | |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function format_for_set_cookie() { |
334 | 334 | $header_value = $this->format_for_header(); |
335 | - if (!empty($this->attributes)) { |
|
335 | + if(!empty($this->attributes)) { |
|
336 | 336 | $parts = array(); |
337 | - foreach ($this->attributes as $key => $value) { |
|
337 | + foreach($this->attributes as $key => $value) { |
|
338 | 338 | // Ignore non-associative attributes |
339 | - if (is_numeric($key)) { |
|
339 | + if(is_numeric($key)) { |
|
340 | 340 | $parts[] = $value; |
341 | 341 | } |
342 | 342 | else { |
@@ -383,10 +383,10 @@ discard block |
||
383 | 383 | $parts = explode(';', $string); |
384 | 384 | $kvparts = array_shift($parts); |
385 | 385 | |
386 | - if (!empty($name)) { |
|
386 | + if(!empty($name)) { |
|
387 | 387 | $value = $string; |
388 | 388 | } |
389 | - elseif (strpos($kvparts, '=') === false) { |
|
389 | + elseif(strpos($kvparts, '=') === false) { |
|
390 | 390 | // Some sites might only have a value without the equals separator. |
391 | 391 | // Deviate from RFC 6265 and pretend it was actually a blank name |
392 | 392 | // (`=foo`) |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | // Attribute key are handled case-insensitively |
405 | 405 | $attributes = new Requests_Utility_CaseInsensitiveDictionary(); |
406 | 406 | |
407 | - if (!empty($parts)) { |
|
408 | - foreach ($parts as $part) { |
|
409 | - if (strpos($part, '=') === false) { |
|
407 | + if(!empty($parts)) { |
|
408 | + foreach($parts as $part) { |
|
409 | + if(strpos($part, '=') === false) { |
|
410 | 410 | $part_key = $part; |
411 | 411 | $part_value = true; |
412 | 412 | } |
@@ -433,16 +433,16 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public static function parse_from_headers(Requests_Response_Headers $headers, Requests_IRI $origin = null, $time = null) { |
435 | 435 | $cookie_headers = $headers->getValues('Set-Cookie'); |
436 | - if (empty($cookie_headers)) { |
|
436 | + if(empty($cookie_headers)) { |
|
437 | 437 | return array(); |
438 | 438 | } |
439 | 439 | |
440 | 440 | $cookies = array(); |
441 | - foreach ($cookie_headers as $header) { |
|
441 | + foreach($cookie_headers as $header) { |
|
442 | 442 | $parsed = self::parse($header, '', $time); |
443 | 443 | |
444 | 444 | // Default domain/path attributes |
445 | - if (empty($parsed->attributes['domain']) && !empty($origin)) { |
|
445 | + if(empty($parsed->attributes['domain']) && !empty($origin)) { |
|
446 | 446 | $parsed->attributes['domain'] = $origin->host; |
447 | 447 | $parsed->flags['host-only'] = true; |
448 | 448 | } |
@@ -451,17 +451,17 @@ discard block |
||
451 | 451 | } |
452 | 452 | |
453 | 453 | $path_is_valid = (!empty($parsed->attributes['path']) && $parsed->attributes['path'][0] === '/'); |
454 | - if (!$path_is_valid && !empty($origin)) { |
|
454 | + if(!$path_is_valid && !empty($origin)) { |
|
455 | 455 | $path = $origin->path; |
456 | 456 | |
457 | 457 | // Default path normalization as per RFC 6265 section 5.1.4 |
458 | - if (substr($path, 0, 1) !== '/') { |
|
458 | + if(substr($path, 0, 1) !== '/') { |
|
459 | 459 | // If the uri-path is empty or if the first character of |
460 | 460 | // the uri-path is not a %x2F ("/") character, output |
461 | 461 | // %x2F ("/") and skip the remaining steps. |
462 | 462 | $path = '/'; |
463 | 463 | } |
464 | - elseif (substr_count($path, '/') === 1) { |
|
464 | + elseif(substr_count($path, '/') === 1) { |
|
465 | 465 | // If the uri-path contains no more than one %x2F ("/") |
466 | 466 | // character, output %x2F ("/") and skip the remaining |
467 | 467 | // step. |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | |
479 | 479 | // Reject invalid cookie domains |
480 | - if (!empty($origin) && !$parsed->domain_matches($origin->host)) { |
|
480 | + if(!empty($origin) && !$parsed->domain_matches($origin->host)) { |
|
481 | 481 | continue; |
482 | 482 | } |
483 | 483 |
@@ -29,6 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | + /** |
|
33 | + * @param string $message |
|
34 | + */ |
|
32 | 35 | public function __construct($message, $type, $data = null, $code = 0) { |
33 | 36 | if ($type !== null) { |
34 | 37 | $this->type = $type; |
@@ -30,15 +30,15 @@ |
||
30 | 30 | protected $reason = 'Unknown'; |
31 | 31 | |
32 | 32 | public function __construct($message, $type, $data = null, $code = 0) { |
33 | - if ($type !== null) { |
|
33 | + if($type !== null) { |
|
34 | 34 | $this->type = $type; |
35 | 35 | } |
36 | 36 | |
37 | - if ($code !== null) { |
|
37 | + if($code !== null) { |
|
38 | 38 | $this->code = $code; |
39 | 39 | } |
40 | 40 | |
41 | - if ($message !== null) { |
|
41 | + if($message !== null) { |
|
42 | 42 | $this->reason = $message; |
43 | 43 | } |
44 | 44 |
@@ -19,6 +19,7 @@ |
||
19 | 19 | * @param string $hook Hook name |
20 | 20 | * @param callback $callback Function/method to call on event |
21 | 21 | * @param int $priority Priority number. <0 is executed earlier, >0 is executed later |
22 | + * @return void |
|
22 | 23 | */ |
23 | 24 | public function register($hook, $callback, $priority = 0); |
24 | 25 |