Changeset 52244 for trunk/src/wp-includes/Requests/Auth/Basic.php
- Timestamp:
- 11/25/2021 01:10:30 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/Requests/Auth/Basic.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/Requests/Auth/Basic.php
r50842 r52244 3 3 * Basic Authentication provider 4 4 * 5 * @package Requests 6 * @subpackage Authentication 5 * @package Requests\Authentication 7 6 */ 7 8 namespace WpOrg\Requests\Auth; 9 10 use WpOrg\Requests\Auth; 11 use WpOrg\Requests\Exception\ArgumentCount; 12 use WpOrg\Requests\Exception\InvalidArgument; 13 use WpOrg\Requests\Hooks; 8 14 9 15 /** … … 13 19 * header. 14 20 * 15 * @package Requests 16 * @subpackage Authentication 21 * @package Requests\Authentication 17 22 */ 18 class Requests_Auth_Basic implements Requests_Auth {23 class Basic implements Auth { 19 24 /** 20 25 * Username … … 34 39 * Constructor 35 40 * 36 * @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`) 41 * @since 2.0 Throws an `InvalidArgument` exception. 42 * @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception. 43 * 37 44 * @param array|null $args Array of user and password. Must have exactly two elements 45 * 46 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null. 47 * @throws \WpOrg\Requests\Exception\ArgumentCount On incorrect number of array elements (`authbasicbadargs`). 38 48 */ 39 49 public function __construct($args = null) { 40 50 if (is_array($args)) { 41 51 if (count($args) !== 2) { 42 throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs');52 throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs'); 43 53 } 44 54 45 55 list($this->user, $this->pass) = $args; 56 return; 57 } 58 59 if ($args !== null) { 60 throw InvalidArgument::create(1, '$args', 'array|null', gettype($args)); 46 61 } 47 62 } … … 50 65 * Register the necessary callbacks 51 66 * 52 * @see curl_before_send53 * @see fsockopen_header54 * @param Requests_Hooks $hooks Hook system67 * @see \WpOrg\Requests\Auth\Basic::curl_before_send() 68 * @see \WpOrg\Requests\Auth\Basic::fsockopen_header() 69 * @param \WpOrg\Requests\Hooks $hooks Hook system 55 70 */ 56 public function register( Requests_Hooks $hooks) {57 $hooks->register('curl.before_send', array($this, 'curl_before_send'));58 $hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header'));71 public function register(Hooks $hooks) { 72 $hooks->register('curl.before_send', [$this, 'curl_before_send']); 73 $hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']); 59 74 } 60 75 … … 62 77 * Set cURL parameters before the data is sent 63 78 * 64 * @param resource $handle cURL resource79 * @param resource|\CurlHandle $handle cURL handle 65 80 */ 66 81 public function curl_before_send(&$handle) {
Note: See TracChangeset
for help on using the changeset viewer.