wp/wp-includes/class-wp-http-cookie.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 19 3d72ae0968f4
--- a/wp/wp-includes/class-wp-http-cookie.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-http-cookie.php	Tue Dec 15 13:49:49 2020 +0100
@@ -37,10 +37,10 @@
 	public $value;
 
 	/**
-	 * When the cookie expires.
+	 * When the cookie expires. Unix timestamp or formatted date.
 	 *
 	 * @since 2.8.0
-	 * @var string
+	 * @var string|int|null
 	 */
 	public $expires;
 
@@ -80,26 +80,26 @@
 	 * @param string|array $data {
 	 *     Raw cookie data as header string or data array.
 	 *
-	 *     @type string     $name      Cookie name.
-	 *     @type mixed      $value     Value. Should NOT already be urlencoded.
-	 *     @type string|int $expires   Optional. Unix timestamp or formatted date. Default null.
-	 *     @type string     $path      Optional. Path. Default '/'.
-	 *     @type string     $domain    Optional. Domain. Default host of parsed $requested_url.
-	 *     @type int        $port      Optional. Port. Default null.
-	 *     @type bool       $host_only Optional. host-only storage flag. Default true.
+	 *     @type string          $name      Cookie name.
+	 *     @type mixed           $value     Value. Should NOT already be urlencoded.
+	 *     @type string|int|null $expires   Optional. Unix timestamp or formatted date. Default null.
+	 *     @type string          $path      Optional. Path. Default '/'.
+	 *     @type string          $domain    Optional. Domain. Default host of parsed $requested_url.
+	 *     @type int             $port      Optional. Port. Default null.
+	 *     @type bool            $host_only Optional. host-only storage flag. Default true.
 	 * }
 	 * @param string       $requested_url The URL which the cookie was set on, used for default $domain
 	 *                                    and $port values.
 	 */
 	public function __construct( $data, $requested_url = '' ) {
 		if ( $requested_url ) {
-			$arrURL = @parse_url( $requested_url );
+			$arrURL = parse_url( $requested_url );
 		}
 		if ( isset( $arrURL['host'] ) ) {
 			$this->domain = $arrURL['host'];
 		}
 		$this->path = isset( $arrURL['path'] ) ? $arrURL['path'] : '/';
-		if ( '/' != substr( $this->path, -1 ) ) {
+		if ( '/' !== substr( $this->path, -1 ) ) {
 			$this->path = dirname( $this->path ) . '/';
 		}
 
@@ -127,7 +127,7 @@
 
 				list( $key, $val ) = strpos( $pair, '=' ) ? explode( '=', $pair ) : array( $pair, '' );
 				$key               = strtolower( trim( $key ) );
-				if ( 'expires' == $key ) {
+				if ( 'expires' === $key ) {
 					$val = strtotime( $val );
 				}
 				$this->$key = $val;
@@ -174,7 +174,7 @@
 
 		// Get details on the URL we're thinking about sending to.
 		$url         = parse_url( $url );
-		$url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' == $url['scheme'] ? 443 : 80 );
+		$url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' === $url['scheme'] ? 443 : 80 );
 		$url['path'] = isset( $url['path'] ) ? $url['path'] : '/';
 
 		// Values to use for comparison against the URL.
@@ -186,13 +186,13 @@
 		}
 
 		// Host - very basic check that the request URL ends with the domain restriction (minus leading dot).
-		$domain = substr( $domain, 0, 1 ) == '.' ? substr( $domain, 1 ) : $domain;
+		$domain = ( '.' === substr( $domain, 0, 1 ) ) ? substr( $domain, 1 ) : $domain;
 		if ( substr( $url['host'], -strlen( $domain ) ) != $domain ) {
 			return false;
 		}
 
 		// Port - supports "port-lists" in the format: "80,8000,8080".
-		if ( ! empty( $port ) && ! in_array( $url['port'], explode( ',', $port ) ) ) {
+		if ( ! empty( $port ) && ! in_array( $url['port'], array_map( 'intval', explode( ',', $port ) ), true ) ) {
 			return false;
 		}
 
@@ -211,7 +211,7 @@
 	 *
 	 * @return string Header encoded cookie name and value.
 	 */
-	public function getHeaderValue() {
+	public function getHeaderValue() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
 		if ( ! isset( $this->name ) || ! isset( $this->value ) ) {
 			return '';
 		}
@@ -234,7 +234,7 @@
 	 *
 	 * @return string
 	 */
-	public function getFullHeader() {
+	public function getFullHeader() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
 		return 'Cookie: ' . $this->getHeaderValue();
 	}
 
@@ -244,11 +244,11 @@
 	 * @since 4.6.0
 	 *
 	 * @return array {
-	 *    List of attributes.
+	 *     List of attributes.
 	 *
-	 *    @type string $expires When the cookie expires.
-	 *    @type string $path    Cookie URL path.
-	 *    @type string $domain  Cookie domain.
+	 *     @type string|int|null $expires When the cookie expires. Unix timestamp or formatted date.
+	 *     @type string          $path    Cookie URL path.
+	 *     @type string          $domain  Cookie domain.
 	 * }
 	 */
 	public function get_attributes() {