diff --git a/bin/_lib.sh b/bin/_lib.sh index 5a3cac62..dd7cc3af 100755 --- a/bin/_lib.sh +++ b/bin/_lib.sh @@ -35,7 +35,6 @@ install_wordpress() { composer require --dev --no-interaction -W \ johnpbloch/wordpress:* \ wp-graphql/wp-graphql-jwt-authentication \ - axepress/wp-graphql-headless-login \ wpackagist-plugin/woocommerce \ wpackagist-plugin/woocommerce-gateway-stripe \ wpackagist-plugin/wp-graphql \ @@ -51,7 +50,6 @@ remove_wordpress() { # Remove WordPress dependencies composer remove --dev wp-graphql/wp-graphql-jwt-authentication \ - axepress/wp-graphql-headless-login \ wpackagist-plugin/woocommerce-gateway-stripe \ wpackagist-plugin/wp-graphql \ wpackagist-theme/twentytwentyone \ diff --git a/composer.lock b/composer.lock index 99603626..6b958ce6 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "firebase/php-jwt", - "version": "v6.10.1", + "version": "v6.11.0", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "500501c2ce893c824c801da135d02661199f60c5" + "reference": "8f718f4dfc9c5d5f0c994cdfd103921b43592712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/500501c2ce893c824c801da135d02661199f60c5", - "reference": "500501c2ce893c824c801da135d02661199f60c5", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/8f718f4dfc9c5d5f0c994cdfd103921b43592712", + "reference": "8f718f4dfc9c5d5f0c994cdfd103921b43592712", "shasum": "" }, "require": { @@ -65,9 +65,9 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.10.1" + "source": "https://github.com/firebase/php-jwt/tree/v6.11.0" }, - "time": "2024-05-18T18:05:11+00:00" + "time": "2025-01-23T05:11:06+00:00" } ], "packages-dev": [ @@ -1259,16 +1259,16 @@ }, { "name": "symfony/console", - "version": "v5.4.46", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "fb0d4760e7147d81ab4d9e2d57d56268261b4e4e" + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/fb0d4760e7147d81ab4d9e2d57d56268261b4e4e", - "reference": "fb0d4760e7147d81ab4d9e2d57d56268261b4e4e", + "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", "shasum": "" }, "require": { @@ -1338,7 +1338,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.46" + "source": "https://github.com/symfony/console/tree/v5.4.47" }, "funding": [ { @@ -1354,20 +1354,20 @@ "type": "tidelift" } ], - "time": "2024-11-05T14:17:06+00:00" + "time": "2024-11-06T11:30:55+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -1375,12 +1375,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -1405,7 +1405,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -1421,7 +1421,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1449,8 +1449,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1525,8 +1525,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1603,8 +1603,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1687,8 +1687,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1761,8 +1761,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1837,8 +1837,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -1899,16 +1899,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { @@ -1921,12 +1921,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -1962,7 +1962,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -1978,20 +1978,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/string", - "version": "v6.4.13", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627" + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", + "url": "https://api.github.com/repos/symfony/string/zipball/73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", "shasum": "" }, "require": { @@ -2048,7 +2048,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.13" + "source": "https://github.com/symfony/string/tree/v6.4.15" }, "funding": [ { @@ -2064,7 +2064,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:18:03+00:00" + "time": "2024-11-13T13:31:12+00:00" }, { "name": "szepeviktor/phpstan-wordpress", diff --git a/includes/data/connection/class-product-connection-resolver.php b/includes/data/connection/class-product-connection-resolver.php index 8c892897..8a7c4446 100644 --- a/includes/data/connection/class-product-connection-resolver.php +++ b/includes/data/connection/class-product-connection-resolver.php @@ -196,23 +196,23 @@ public function get_query_args() { $query_args['graphql_cursor_compare_by_price_key'] = 'wc_product_meta_lookup.max_price'; $query_args['graphql_cursor_compare_by_price_value'] = $price; } - } - - if ( $offset_product && 'popularity' === $query_args['orderby'] ) { + } elseif ( $offset_product && 'popularity' === $query_args['orderby'] ) { $query_args['graphql_cursor_compare_by_popularity_value'] = $offset_product->get_total_sales(); $query_args['graphql_cursor_compare_by_popularity_key'] = 'wc_product_meta_lookup.total_sales'; - } - - if ( $offset_product && 'rating' === $query_args['orderby'] ) { + } elseif ( $offset_product && 'rating' === $query_args['orderby'] ) { $query_args['graphql_cursor_compare_by_rating_value'] = $offset_product->get_average_rating(); $query_args['graphql_cursor_compare_by_rating_key'] = 'wc_product_meta_lookup.average_rating'; - } - - if ( $offset_product && 'comment_count' === $query_args['orderby'] ) { + } elseif ( $offset_product && 'comment_count' === $query_args['orderby'] ) { $query_args['graphql_cursor_compare_by_comment_count_value'] = $offset_product->get_rating_count(); $query_args['graphql_cursor_compare_by_comment_count_key'] = 'wc_product_meta_lookup.rating_count'; $query_args['graphql_cursor_compare_by_rating_value'] = $offset_product->get_average_rating(); $query_args['graphql_cursor_compare_by_rating_key'] = 'wc_product_meta_lookup.average_rating'; + } elseif ( $offset_product && 'menu_order title' === $query_args['orderby'] ) { + $query_args['orderby'] = [ + 'menu_order' => $query_args['order'], + 'post_title' => isset( $this->args['last'] ) ? 'ASC' : 'DESC', + ]; + unset( $query_args['order'] ); } /** diff --git a/tests/wpunit/ConnectionPaginationTest.php b/tests/wpunit/ConnectionPaginationTest.php index 2a41d51c..687cd34c 100644 --- a/tests/wpunit/ConnectionPaginationTest.php +++ b/tests/wpunit/ConnectionPaginationTest.php @@ -246,6 +246,211 @@ static function ( $key_a, $key_b ) { $this->assertQuerySuccessful( $response, $expected ); } + public function testProductsPaginationWithOrderby() { + $products = [ + $this->factory->product->createSimple( [ 'menu_order' => 0, 'regular_price' => 5 ] ), + $this->factory->product->createSimple( [ 'menu_order' => 1, 'regular_price' => 4 ] ), + $this->factory->product->createSimple( [ 'menu_order' => 2, 'regular_price' => 3, 'sale_price' => 0.50 ] ), + $this->factory->product->createSimple( [ 'menu_order' => 3, 'regular_price' => 2 ] ), + $this->factory->product->createSimple( [ 'menu_order' => 4, 'regular_price' => 1 ] ), + ]; + + usort( + $products, + static function ( $key_a, $key_b ) { + return $key_a < $key_b; + } + ); + + $query = ' + query ($first: Int, $last: Int, $after: String, $before: String, $where: RootQueryToProductUnionConnectionWhereArgs) { + products(first: $first, last: $last, after: $after, before: $before, where: $where) { + found + nodes { + databaseId + menuOrder + } + pageInfo { + hasPreviousPage + hasNextPage + startCursor + endCursor + } + } + } + '; + + /** + * Assertion One + * + * Test "first" parameter with the "orderby.MENU_ORDER". + */ + $variables = [ 'first' => 2, 'where' => [ 'orderby' => [ [ 'field' => 'MENU_ORDER', 'order' => 'DESC' ] ] ] ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', 5 ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', false ), + $this->expectedField( 'products.pageInfo.hasNextPage', true ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[0] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[1] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[0] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[1] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Two + * + * Test "after" parameter with the "orderby.MENU_ORDER". + */ + $variables = [ + 'first' => 3, + 'after' => $this->toCursor( $products[1] ), + 'where' => [ 'orderby' => [ [ 'field' => 'MENU_ORDER', 'order' => 'DESC' ] ] ], + ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', static::IS_NULL ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', false ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[2] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[4] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[2] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[3] ), + $this->expectedField( 'products.nodes.2.databaseId', $products[4] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Three + * + * Test "last" parameter with the "orderby.MENU_ORDER". + */ + $variables = [ 'last' => 2, 'where' => [ 'orderby' => [ [ 'field' => 'MENU_ORDER', 'order' => 'DESC' ] ] ] ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', 5 ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', false ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[1] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[0] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[1] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[0] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Four + * + * Test "before" parameter with the "orderby.MENU_ORDER". + */ + $variables = [ + 'last' => 2, + 'before' => $this->toCursor( $products[1] ), + 'where' => [ 'orderby' => [ [ 'field' => 'MENU_ORDER', 'order' => 'DESC' ] ] ] + ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', static::IS_NULL ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', true ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[3] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[2] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[3] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[2] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Five + * + * Test "first" parameter with the "orderby.PRICE". + */ + $variables = [ 'first' => 2, 'where' => [ 'orderby' => [ [ 'field' => 'PRICE', 'order' => 'DESC' ] ] ] ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', 5 ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', false ), + $this->expectedField( 'products.pageInfo.hasNextPage', true ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[4] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[3] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[4] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[3] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Six + * + * Test "after" parameter with the "orderby.PRICE". + */ + $variables = [ + 'first' => 3, + 'after' => $this->toCursor( $products[3] ), + 'where' => [ 'orderby' => [ [ 'field' => 'PRICE', 'order' => 'DESC' ] ] ], + ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', static::IS_NULL ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', false ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[1] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[2] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[1] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[0] ), + $this->expectedField( 'products.nodes.2.databaseId', $products[2] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Seven + * + * Test "last" parameter with the "orderby.PRICE". + */ + $variables = [ 'last' => 2, 'where' => [ 'orderby' => [ [ 'field' => 'PRICE', 'order' => 'ASC' ] ] ] ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', 5 ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', false ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[0] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[2] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[0] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[2] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + + /** + * Assertion Eight + * + * Test "before" parameter with the "orderby.PRICE". + */ + $variables = [ + 'last' => 2, + 'before' => $this->toCursor( $products[0] ), + 'where' => [ 'orderby' => [ [ 'field' => 'PRICE', 'order' => 'ASC' ] ] ] + ]; + $response = $this->graphql( compact( 'query', 'variables' ) ); + $expected = [ + $this->expectedField( 'products.found', static::IS_NULL ), + $this->expectedField( 'products.pageInfo.hasPreviousPage', true ), + $this->expectedField( 'products.pageInfo.hasNextPage', true ), + $this->expectedField( 'products.pageInfo.startCursor', $this->toCursor( $products[3] ) ), + $this->expectedField( 'products.pageInfo.endCursor', $this->toCursor( $products[1] ) ), + $this->expectedField( 'products.nodes.0.databaseId', $products[3] ), + $this->expectedField( 'products.nodes.1.databaseId', $products[1] ), + ]; + + $this->assertQuerySuccessful( $response, $expected ); + } + public function testOrdersPagination() { $this->loginAsShopManager(); diff --git a/vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php b/vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php index b99b2af9..c2a2f0e5 100644 --- a/vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php +++ b/vendor-prefixed/firebase/php-jwt/src/CachedKeySet.php @@ -86,9 +86,9 @@ public function __construct( ClientInterface $httpClient, RequestFactoryInterface $httpFactory, CacheItemPoolInterface $cache, - int $expiresAfter = null, + ?int $expiresAfter = null, bool $rateLimit = false, - string $defaultAlg = null + ?string $defaultAlg = null ) { $this->jwksUri = $jwksUri; $this->httpClient = $httpClient; @@ -186,7 +186,7 @@ private function keyIdExists(string $keyId): bool $jwksResponse = $this->httpClient->sendRequest($request); if ($jwksResponse->getStatusCode() !== 200) { throw new UnexpectedValueException( - sprintf('HTTP Error: %d %s for URI "%s"', + \sprintf('HTTP Error: %d %s for URI "%s"', $jwksResponse->getStatusCode(), $jwksResponse->getReasonPhrase(), $this->jwksUri, diff --git a/vendor-prefixed/firebase/php-jwt/src/JWK.php b/vendor-prefixed/firebase/php-jwt/src/JWK.php index dff2cb92..c6674c42 100644 --- a/vendor-prefixed/firebase/php-jwt/src/JWK.php +++ b/vendor-prefixed/firebase/php-jwt/src/JWK.php @@ -58,7 +58,7 @@ class JWK * * @uses parseKey */ - public static function parseKeySet(array $jwks, string $defaultAlg = null): array + public static function parseKeySet(array $jwks, ?string $defaultAlg = null): array { $keys = []; @@ -99,7 +99,7 @@ public static function parseKeySet(array $jwks, string $defaultAlg = null): arra * * @uses createPemFromModulusAndExponent */ - public static function parseKey(array $jwk, string $defaultAlg = null): ?Key + public static function parseKey(array $jwk, ?string $defaultAlg = null): ?Key { if (empty($jwk)) { throw new InvalidArgumentException('JWK must not be empty'); @@ -178,6 +178,12 @@ public static function parseKey(array $jwk, string $defaultAlg = null): ?Key // This library works internally with EdDSA keys (Ed25519) encoded in standard base64. $publicKey = JWT::convertBase64urlToBase64($jwk['x']); return new Key($publicKey, $jwk['alg']); + case 'oct': + if (!isset($jwk['k'])) { + throw new UnexpectedValueException('k not set'); + } + + return new Key(JWT::urlsafeB64Decode($jwk['k']), $jwk['alg']); default: break; } @@ -218,7 +224,7 @@ private static function createPemFromCrvAndXYCoordinates(string $crv, string $x, ) ); - return sprintf( + return \sprintf( "-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----\n", wordwrap(base64_encode($pem), 64, "\n", true) ); diff --git a/vendor-prefixed/firebase/php-jwt/src/JWT.php b/vendor-prefixed/firebase/php-jwt/src/JWT.php index e2eb7091..fd868c0c 100644 --- a/vendor-prefixed/firebase/php-jwt/src/JWT.php +++ b/vendor-prefixed/firebase/php-jwt/src/JWT.php @@ -102,7 +102,7 @@ class JWT public static function decode( string $jwt, $keyOrKeyArray, - stdClass &$headers = null + ?stdClass &$headers = null ): stdClass { // Validate JWT $timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp; @@ -206,11 +206,11 @@ public static function encode( array $payload, $key, string $alg, - string $keyId = null, - array $head = null + ?string $keyId = null, + ?array $head = null ): string { $header = ['typ' => 'JWT']; - if (isset($head) && \is_array($head)) { + if (isset($head)) { $header = \array_merge($header, $head); } $header['alg'] = $alg; @@ -393,12 +393,7 @@ public static function jsonDecode(string $input) */ public static function jsonEncode(array $input): string { - if (PHP_VERSION_ID >= 50400) { - $json = \json_encode($input, \JSON_UNESCAPED_SLASHES); - } else { - // PHP 5.3 only - $json = \json_encode($input); - } + $json = \json_encode($input, \JSON_UNESCAPED_SLASHES); if ($errno = \json_last_error()) { self::handleJsonError($errno); } elseif ($json === 'null') { diff --git a/vendor-prefixed/firebase/php-jwt/src/Key.php b/vendor-prefixed/firebase/php-jwt/src/Key.php index 002db5e7..366f16cc 100644 --- a/vendor-prefixed/firebase/php-jwt/src/Key.php +++ b/vendor-prefixed/firebase/php-jwt/src/Key.php @@ -15,18 +15,13 @@ class Key { - /** @var string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate */ - private $keyMaterial; - /** @var string */ - private $algorithm; - /** * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial * @param string $algorithm */ public function __construct( - $keyMaterial, - string $algorithm + private $keyMaterial, + private string $algorithm ) { if ( !\is_string($keyMaterial) @@ -44,10 +39,6 @@ public function __construct( if (empty($algorithm)) { throw new InvalidArgumentException('Algorithm must not be empty'); } - - // TODO: Remove in PHP 8.0 in favor of class constructor property promotion - $this->keyMaterial = $keyMaterial; - $this->algorithm = $algorithm; } /**